[PATCH 1/1] usb: gadget: ether: Disable USB pullup in eth probe

Marek Vasut marex at denx.de
Wed Aug 21 23:43:43 CEST 2024


On 8/21/24 11:22 PM, Zixun LI wrote:
> usb_gadget_register_driver() called by probe will initialize the USB
> controller which enters ready to connect state with pull-up resistor
> enabled.
> 
>>From the host's point of view, a device is ready to be enumerated.
> However, since dm_usb_gadget_handle_interrupts() is only called when
> ethernet function is started, at this stage USB events are not managed,
> host's enumeration attempts will fail and resulting error like:
>      usb 1-1: new high-speed USB device number 50 using xhci_hcd
>      usb 1-1: device descriptor read/64, error -110
>      usb 1-1: device descriptor read/64, error -110
>      usb usb1-port1: attempt power cycle
> 
> Disable USB pullup to prevent unwanted enumeration attempt.
> 
> Signed-off-by: Zixun LI <admin at hifiphile.com>
> ---
>   drivers/usb/gadget/ether.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
> index 7973927e8a..c864beeaa7 100644
> --- a/drivers/usb/gadget/ether.c
> +++ b/drivers/usb/gadget/ether.c
> @@ -2459,6 +2459,8 @@ static int usb_eth_probe(struct udevice *dev)
>   {
>   	struct ether_priv *priv = dev_get_priv(dev);
>   	struct eth_pdata *pdata = dev_get_plat(dev);
> +	struct eth_dev *ethdev = &priv->ethdev;
> +	int ret;
> 
>   	priv->netdev = dev;
>   	l_priv = priv;
> @@ -2499,7 +2501,14 @@ static int usb_eth_probe(struct udevice *dev)
>   	priv->eth_driver.disconnect	= eth_disconnect;
>   	priv->eth_driver.suspend	= eth_suspend;
>   	priv->eth_driver.resume		= eth_resume;
> -	return usb_gadget_register_driver(&priv->eth_driver);
> +
> +	ret = usb_gadget_register_driver(&priv->eth_driver);

Wouldn't it be better if usb_gadget_register_driver() started in 
disconnected state right away ?


More information about the U-Boot mailing list