From cd60d2b861ccc342c7203984d65e64d250df27e4 Mon Sep 17 00:00:00 2001 From: Jianing Ren Date: Fri, 20 Mar 2020 17:50:30 +0800 Subject: [PATCH] usb: dwc3: fix slow connection in gadget mode This patch fix the bug that if the property maximum-speed of dwc3 is configured to high-speed in DTS, gadget connection will be slow. Before gadget connection, it is necessary to write register DCFG to set maximum speed, if you don't, dwc3 will generate Erratic Error Event many times and results to slow connection. Actually, maximum speed will be set when Android layer call udc_bind_to_driver but it will fail when dwc3 runtime-suspended. For Rockchip SoCs, dwc3 will be suspended as long as USB cable is unplugged, so we add udc_set_speed before dwc3 runtime resume. Change-Id: I261c2cf9a36179a8d600f223fc8fd4757c7f622d Signed-off-by: Jianing Ren --- drivers/usb/dwc3/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index cbf6001c778a..6ad8984d292c 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -252,6 +252,8 @@ runtime: PHY_MODE_USB_DEVICE); phy_set_mode(dwc->usb3_generic_phy, PHY_MODE_USB_DEVICE); + dwc->gadget.ops->udc_set_speed(&dwc->gadget, + dwc->maximum_speed); break; case DWC3_GCTL_PRTCAP_OTG: break;