Commit 00af6233 authored by Baolin Wang's avatar Baolin Wang Committed by Felipe Balbi

usb: dwc3: core: Move the mode setting to the right place

When dwc3 core enters into suspend mode, the system (especially for mobile
device) may power off the dwc3 controller for power saving, that will cause
dwc3 controller lost the mode operation when resuming dwc3 core.

Thus we can move the mode setting into dwc3_core_init() function to avoid this
issue.
Signed-off-by: default avatarBaolin Wang <baolin.wang@linaro.org>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent f8ca46ae
...@@ -689,6 +689,21 @@ static int dwc3_core_init(struct dwc3 *dwc) ...@@ -689,6 +689,21 @@ static int dwc3_core_init(struct dwc3 *dwc)
goto err4; 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;
case USB_DR_MODE_OTG:
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
break;
default:
dev_warn(dwc->dev, "Unsupported mode %d\n", dwc->dr_mode);
break;
}
return 0; return 0;
err4: err4:
...@@ -786,7 +801,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) ...@@ -786,7 +801,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
switch (dwc->dr_mode) { switch (dwc->dr_mode) {
case USB_DR_MODE_PERIPHERAL: case USB_DR_MODE_PERIPHERAL:
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
ret = dwc3_gadget_init(dwc); ret = dwc3_gadget_init(dwc);
if (ret) { if (ret) {
if (ret != -EPROBE_DEFER) if (ret != -EPROBE_DEFER)
...@@ -795,7 +809,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) ...@@ -795,7 +809,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
} }
break; break;
case USB_DR_MODE_HOST: case USB_DR_MODE_HOST:
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
ret = dwc3_host_init(dwc); ret = dwc3_host_init(dwc);
if (ret) { if (ret) {
if (ret != -EPROBE_DEFER) if (ret != -EPROBE_DEFER)
...@@ -804,7 +817,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) ...@@ -804,7 +817,6 @@ static int dwc3_core_init_mode(struct dwc3 *dwc)
} }
break; break;
case USB_DR_MODE_OTG: case USB_DR_MODE_OTG:
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG);
ret = dwc3_host_init(dwc); ret = dwc3_host_init(dwc);
if (ret) { if (ret) {
if (ret != -EPROBE_DEFER) if (ret != -EPROBE_DEFER)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment