From: William Wu Date: Thu, 3 Nov 2016 10:03:45 +0000 (+0800) Subject: Revert "UPSTREAM: usb: dwc3: core: Move the mode setting to the right place" X-Git-Tag: firefly_0821_release~1330 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=eca4625c95aee2677a626039f56fa93dcc127cb7;p=firefly-linux-kernel-4.4.55.git Revert "UPSTREAM: usb: dwc3: core: Move the mode setting to the right place" This reverts commit 104756064072e39790eb16c5c987744e81d52a62. This commit 1047560 will reinit dwc3 controller mode when resuming dwc3 core. Generally, this patch can be used for "dr_mode = host", "dr_mode = peripheral" and "dr_mode = otg". However, rockchip dwc3 core don't support otg function, but only support DRD mode. So on rockchip platform, we set dr_mode to otg for DRD mode, then switch host and peripheral dynamically by extcon notifier. Also, we will enable dwc3 to be a wakeup source and enable usb3 power domain in suspend mode if usb device is pluged in. So dwc3 controller will not lost the mode when resuming dwc3 core. Change-Id: I0ee4f5b02d4504e853d8ef81df3df9a8a4ac284f Signed-off-by: William Wu --- diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index d62276d3f555..cc8f5abfac09 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -689,21 +689,6 @@ 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; - 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; err4: @@ -801,6 +786,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) switch (dwc->dr_mode) { case USB_DR_MODE_PERIPHERAL: + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); ret = dwc3_gadget_init(dwc); if (ret) { if (ret != -EPROBE_DEFER) @@ -809,6 +795,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) } break; case USB_DR_MODE_HOST: + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); ret = dwc3_host_init(dwc); if (ret) { if (ret != -EPROBE_DEFER) @@ -817,6 +804,7 @@ static int dwc3_core_init_mode(struct dwc3 *dwc) } break; case USB_DR_MODE_OTG: + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); ret = dwc3_host_init(dwc); if (ret) { if (ret != -EPROBE_DEFER)