[PATCH v2 2/2] usb: dwc2: Add polling for reset status

Ley Foon Tan ley.foon.tan at intel.com
Tue Dec 24 09:23:45 CET 2019


In Cyclone 5 SoC platform, the first USB probing is failed but second
probing is success. DWC2 driver read gsnpsid register right after de-assert
reset, but controller is not ready yet and it returns gsnpsid 0.
Polling reset status after de-assert reset to solve the issue.

Retry with this fix more than 10 times without issue.

=> usb reset
resetting USB...
Bus usb at ffb40000: usb probe
SNPSID invalid (not DWC2 OTG device): 00000000
Port not available.
=> usb reset
resetting USB...
Bus usb at ffb40000: usb probe
scanning bus usb at ffb40000 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found

Signed-off-by: Ley Foon Tan <ley.foon.tan at intel.com>

---
v2:
- Change from constant delay to poll for reset status.
---
 drivers/usb/host/dwc2.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index b9c56f763b..1bc41990ee 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -1132,6 +1132,7 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev,
 static int dwc2_reset(struct udevice *dev)
 {
 	int ret;
+	int i = 1000;
 	struct dwc2_priv *priv = dev_get_priv(dev);
 
 	ret = reset_get_bulk(dev, &priv->resets);
@@ -1153,7 +1154,14 @@ static int dwc2_reset(struct udevice *dev)
 		return ret;
 	}
 
-	return 0;
+	/* Poll until reset is completed. */
+	do {
+		ret = reset_status(&priv->resets.resets[0]);
+		if (!ret)
+			return 0;
+	} while (i--);
+
+	return -ETIMEDOUT;
 }
 
 static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv)
-- 
2.19.0



More information about the U-Boot mailing list