usb: dwc3: redo the mode setting at core init
authorFrank Wang <frank.wang@rock-chips.com>
Fri, 16 Dec 2016 07:14:13 +0000 (15:14 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 21 Dec 2016 03:07:12 +0000 (11:07 +0800)
When dwc3 core enters into suspend mode, the PD may turn off
for power saving, which will cause dwc3 controller lost the
mode operation when resuming time.

This adds redo the mode setting into dwc3_core_init() function
to avoid this issue.

BUG=Redmine: Defect#110481
TEST=rk3399-sapphire-excavator-box(CVTE), check if USB3.0 HUB
can be enumerated after PM resume.

Change-Id: I61c512e9c368afc665cd4d5900367079ed22a34e
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
drivers/usb/dwc3/core.c

index cc8f5abfac09a7e6c84c7aca0a62674d7fea24ed..00eb077e9b51f4e4903608718c767f8e024177b0 100644 (file)
@@ -689,6 +689,18 @@ static int dwc3_core_init(struct dwc3 *dwc)
                goto err4;
        }
 
+       switch (dwc->dr_mode) {
+       case USB_DR_MODE_PERIPHERAL:
+               dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
+               break;
+       case USB_DR_MODE_HOST:
+               dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
+               break;
+       default:
+               dev_dbg(dwc->dev, "Unsupported mode %d\n", dwc->dr_mode);
+               break;
+       }
+
        return 0;
 
 err4: