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

Marek Vasut marex at denx.de
Tue Dec 24 10:42:39 CET 2019


On 12/24/19 9:23 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.
> 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;

[...]

Can't we implement some sort of "reset_wait_clear()" API instead of
open-coding this in the driver ?

Or rather, shouldn't the socfpga_reset_deassert wait until the reset was
actually de-asserted ? This might be even better, I think it should.


More information about the U-Boot mailing list