usb: msm_otg: disallow suspend during charging detection
A cable connection could occur as the device is just about to
enter systemwide suspend. This interrupt will kick off the
charging detection algorithm, but the controller could become
suspended and may lead to ULPI timeouts when the PHY is later
resumed. Note that prior to starting charger detection, the
B-session valid state bit is asserted. We can then fix this in
the general case by preventing the controller from suspending
if B_SESS_VLD is set and the bus is not suspended.
Change-Id: I7aa8dc6880b1b3ec0afe7ea0134677bdba1b9e47
CRs-Fixed: 386262
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>
diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c
index 807a89d..84ee944 100644
--- a/drivers/usb/otg/msm_otg.c
+++ b/drivers/usb/otg/msm_otg.c
@@ -763,6 +763,14 @@
test_bit(A_BUS_SUSPEND, &motg->inputs) &&
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) {
+ enable_irq(motg->irq);
+ return -EBUSY;
+ }
+
/*
* Chipidea 45-nm PHY suspend sequence:
*