From 432a0d89ddeaffe2ca6a7ffd4d6b629178a5b868 Mon Sep 17 00:00:00 2001 From: William Wu Date: Mon, 13 Jul 2020 20:50:43 +0800 Subject: [PATCH] usb: dwc3: core: reset the whole controller during probe This patch reset the dwc3 controller at the beginning of probe. Without this patch, it may fail in enumeration phase if the dwc3 has been initialized and used before kernel. Typically, we use usb to download image and boot directly on RV1126 board, it will fail to connect to host with the following error log: [2.029506] read descriptors [2.029597] read strings [3.038749] dwc3 ffd00000.dwc3: unexpected direction for Data Phase [3.077445] android_work: did not send uevent (0 0 (null)) [3.282586] vendor storage:20190527 ret = -1 [3.335505] usb0: HOST MAC 16:ba:52:5a:90:28 [3.335566] usb0: MAC 6a:73:d9:da:da:ce [3.335597] configfs-gadget gadget: uvc_function_bind [5.052086] dwc3 ffd00000.dwc3: unexpected direction for Data Phase [5.052431] dwc3 ffd00000.dwc3: unexpected direction for Data Phase Change-Id: I7eede4685a26cff5fc9460233291757edf18e430 Signed-off-by: William Wu --- drivers/usb/dwc3/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index d6a009415168..60f3dc4cefc5 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1567,6 +1567,17 @@ static int dwc3_probe(struct platform_device *pdev) if (IS_ERR(dwc->reset)) return PTR_ERR(dwc->reset); + ret = reset_control_deassert(dwc->reset); + if (ret) + return ret; + + /* Reset the whole dwc3 controller */ + ret = reset_control_assert(dwc->reset); + if (ret) + return ret; + + udelay(1); + ret = reset_control_deassert(dwc->reset); if (ret) return ret;