USB: msm_otg: Abort suspend while host mode is activated
ID ground interrupt processing and system suspend can run in parallel.
When Id is grounded, USB is brought out of low power mode(LPM) and state
machine work is run to activate host mode. While waiting for the VBUS
valid event, device suspend callback is executed from system suspend
context. The current code put USB in LPM, without activating host mode
completely. Abort suspend when A_BUS_REQ is asserted which indicate
that host mode is active.
CRs-Fixed: 412841
Change-Id: I4065d7a21087759e8a865543c7ce2b5fe9de37de
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c
index a4c7131..92cbe6f 100644
--- a/drivers/usb/otg/msm_otg.c
+++ b/drivers/usb/otg/msm_otg.c
@@ -844,9 +844,14 @@
motg->caps & ALLOW_LPM_ON_DEV_SUSPEND;
dcp = motg->chg_type == USB_DCP_CHARGER;
- /* charging detection in progress due to cable plug-in */
- if (test_bit(B_SESS_VLD, &motg->inputs) && !device_bus_suspend &&
- !dcp) {
+ /*
+ * Abort suspend when,
+ * 1. charging detection in progress due to cable plug-in
+ * 2. host mode activation in progress due to Micro-A cable insertion
+ */
+
+ if ((test_bit(B_SESS_VLD, &motg->inputs) && !device_bus_suspend &&
+ !dcp) || test_bit(A_BUS_REQ, &motg->inputs)) {
enable_irq(motg->irq);
return -EBUSY;
}