]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: dwc2: Force port resume on switching to device mode
authorChen Yu <chenyu56@huawei.com>
Mon, 23 Jan 2017 22:59:57 +0000 (14:59 -0800)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 24 Jan 2017 14:19:09 +0000 (16:19 +0200)
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 <xuwei5@hisilicon.com>
Cc: Guodong Xu <guodong.xu@linaro.org>
Cc: Amit Pundir <amit.pundir@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: John Youn <johnyoun@synopsys.com>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Chen Yu <chenyu56@huawei.com>
Cc: Vardan Mikayelyan <mvardan@synopsys.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org
Signed-off-by: Chen Yu <chenyu56@huawei.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc2/hcd.c

index e0d152f2c81bee2931957008ee9ec5f84771a2eb..1f670c3429a66c88ca12cdbb69c113fe843ba07b 100644 (file)
@@ -54,6 +54,8 @@
 #include "core.h"
 #include "hcd.h"
 
+static void dwc2_port_resume(struct dwc2_hsotg *hsotg);
+
 /*
  * =========================================================================
  *  Host Core Layer Functions
@@ -3231,6 +3233,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",