All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] usb: gadget: ether: Disable USB pullup in eth probe
@ 2024-08-21 21:22 Zixun LI
  2024-08-21 21:43 ` Marek Vasut
  0 siblings, 1 reply; 14+ messages in thread
From: Zixun LI @ 2024-08-21 21:22 UTC (permalink / raw)
  To: Tom Rini, Lukasz Majewski, Mattijs Korpershoek, Marek Vasut
  Cc: Zixun LI, u-boot

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@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);
+	if (ret)
+		return ret;
+
+	/* Keep pullup disabled until interrupt is available */
+	usb_gadget_disconnect(ethdev->gadget);
+	return 0;
 }

 static int usb_eth_remove(struct udevice *dev)
--
2.45.2


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

end of thread, other threads:[~2024-08-29  7:02 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21 21:22 [PATCH 1/1] usb: gadget: ether: Disable USB pullup in eth probe Zixun LI
2024-08-21 21:43 ` Marek Vasut
2024-08-21 21:58   ` Zixun LI
2024-08-21 23:21     ` Marek Vasut
2024-08-22  9:11       ` Zixun LI
2024-08-22 15:19         ` Marek Vasut
2024-08-22 15:53           ` Zixun LI
2024-08-23  1:23             ` Marek Vasut
2024-08-23  9:22               ` Zixun LI
2024-08-24 23:23                 ` Marek Vasut
2024-08-25  0:13                   ` Marek Vasut
2024-08-26  9:12                     ` Zixun LI
2024-08-26 14:40                       ` Marek Vasut
2024-08-29  7:02                         ` Mattijs Korpershoek

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.