All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: Add small delay after reset
@ 2019-12-23  8:07 Ley Foon Tan
  2019-12-23 11:58 ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Ley Foon Tan @ 2019-12-23  8:07 UTC (permalink / raw)
  To: u-boot

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.
Adding small delay after de-assert reset 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@intel.com>
---
 drivers/usb/host/dwc2.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index b9c56f763b..cbbef19201 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -1153,6 +1153,11 @@ static int dwc2_reset(struct udevice *dev)
 		return ret;
 	}
 
+	/* Certain controller takes some time to complete the reset,
+	 * add small delay before access it.
+	 */
+	udelay(5);
+
 	return 0;
 }
 
-- 
2.19.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] usb: dwc2: Add small delay after reset
  2019-12-23  8:07 [PATCH] usb: dwc2: Add small delay after reset Ley Foon Tan
@ 2019-12-23 11:58 ` Marek Vasut
  2019-12-24  2:00   ` Tan, Ley Foon
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2019-12-23 11:58 UTC (permalink / raw)
  To: u-boot

On 12/23/19 9:07 AM, Ley Foon Tan wrote:
> 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.
> Adding small delay after de-assert reset 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

Can't you poll for the readiness of the IP somehow instead of using
arbitrary delay ?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] usb: dwc2: Add small delay after reset
  2019-12-23 11:58 ` Marek Vasut
@ 2019-12-24  2:00   ` Tan, Ley Foon
  0 siblings, 0 replies; 3+ messages in thread
From: Tan, Ley Foon @ 2019-12-24  2:00 UTC (permalink / raw)
  To: u-boot



> -----Original Message-----
> From: Marek Vasut <marex@denx.de>
> Sent: Monday, December 23, 2019 7:59 PM
> To: Tan, Ley Foon <ley.foon.tan@intel.com>; u-boot at lists.denx.de
> Cc: Ley Foon Tan <lftan.linux@gmail.com>; See, Chin Liang
> <chin.liang.see@intel.com>; Chee, Tien Fong <tien.fong.chee@intel.com>
> Subject: Re: [PATCH] usb: dwc2: Add small delay after reset
> 
> On 12/23/19 9:07 AM, Ley Foon Tan wrote:
> > 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.
> > Adding small delay after de-assert reset 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
> 
> Can't you poll for the readiness of the IP somehow instead of using arbitrary
> delay ?
One way we can do is calling to reset_status() to read back reset status.
Will change that.

Regards
Ley Foon 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-24  2:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-23  8:07 [PATCH] usb: dwc2: Add small delay after reset Ley Foon Tan
2019-12-23 11:58 ` Marek Vasut
2019-12-24  2:00   ` Tan, Ley Foon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.