From: Chen Yu <cheny...@huawei.com>

We've seen failures when switching between host and gadget mode,
which was diagnosed as being caused due to the bus being
auto-suspended when we switched.

So this patch forces a port resume when switching to device
mode if the bus is suspended.

Cc: Wei Xu <xuw...@hisilicon.com>
Cc: Guodong Xu <guodong...@linaro.org>
Cc: Amit Pundir <amit.pun...@linaro.org>
Cc: Rob Herring <robh...@kernel.org>
Cc: Mark Rutland <mark.rutl...@arm.com>
Cc: John Youn <johny...@synopsys.com>
Cc: Douglas Anderson <diand...@chromium.org>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Chen Yu <cheny...@huawei.com>
Signed-off-by: John Stultz <john.stu...@linaro.org>
---
 drivers/usb/dwc2/hcd.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index df5a065..b374e60 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -54,6 +54,9 @@
 #include "core.h"
 #include "hcd.h"
 
+
+static void dwc2_port_resume(struct dwc2_hsotg *hsotg);
+
 /*
  * =========================================================================
  *  Host Core Layer Functions
@@ -3204,6 +3207,11 @@ static void dwc2_conn_id_status_change(struct 
work_struct *work)
        if (gotgctl & GOTGCTL_CONID_B) {
                /* Wait for switch to device mode */
                dev_dbg(hsotg->dev, "connId B\n");
+               if (hsotg->bus_suspended) {
+                       dev_info(hsotg->dev,
+                               "Do port resume before switching to device 
mode\n");
+                       dwc2_port_resume(hsotg);
+               }
                while (!dwc2_is_device_mode(hsotg)) {
                        dev_info(hsotg->dev,
                                 "Waiting for Peripheral Mode, Mode=%s\n",
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to