From eca4625c95aee2677a626039f56fa93dcc127cb7 Mon Sep 17 00:00:00 2001 From: William Wu Date: Thu, 3 Nov 2016 18:03:45 +0800 Subject: [PATCH] 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 --- drivers/usb/dwc3/core.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) 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) -- 2.34.1