USB gadget device (USB_ETHER) with ChipIdea device controller (imx)
Tim Harvey
tharvey at gateworks.com
Sat Jun 22 00:33:11 CEST 2024
Greetings,
Is anyone successfully using USB gadget device (USB_ETHER) on any imx
that has the ChipIdea device controller? (imx6/imx7/imx8mm):
I've never been able to get this to work as when
usb_setup_ehci_gadget() is called from ci_udc's
usb_gadget_register_driver() it first removes the usb controller (and
its children) before reprobing it and this causes a hang.
Here's an example with v2024.07-rc4 on an imx8mm-venice-gw73xx-0x
(imx8mm_venice_defconfig) after enabling CONFIG_USB_ETHER:
u-boot=> net list
eth0 : ethernet at 30be0000 00:d0:12:ba:f8:cc active
u-boot=> bind usb 0 usb_ether # bind usb_ether to first usb controller
u-boot=> net list
eth0 : ethernet at 30be0000 00:d0:12:ba:f8:cc active
eth2 : usb_ether 00:00:00:00:00:00
u-boot => setenv eth2addr 00:d0:12:ba:f8:cd
u-boot=> net list
eth0 : ethernet at 30be0000 00:d0:12:ba:f8:cc active
eth2 : usb_ether 00:d0:12:ba:f8:cd
u-boot=> setenv ethact usb_ether; setenv ipaddr 10.0.0.2; setenv
netmask 255.255.255.0; ping 10.0.0.1
^^^ board hangs, USB host connected to board does not enumerate a CDC
ether device
Unbinding ethernet via 'unbind ethernet 0' first does not appear to
make a difference.
The following patch resolves this however I don't think this is the
right fix as that was apparently added for a reason in commit
fbeceb260232a ("dm: usb: Allow setting up a USB controller as a
device/gadget"):
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index a1cd0ad2d669..38111fda8af9 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -403,6 +403,7 @@ int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
ret = uclass_find_first_device(UCLASS_USB, &dev);
if (ret)
return ret;
+#if 0
ret = device_remove(dev, DM_REMOVE_NORMAL);
if (ret)
return ret;
@@ -412,6 +413,7 @@ int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
ret = device_probe(dev);
if (ret)
return ret;
+#endif
*ctlrp = dev_get_priv(dev);
return 0;
diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
index a1cd0ad2d669..38111fda8af9 100644
--- a/drivers/usb/host/usb-uclass.c
+++ b/drivers/usb/host/usb-uclass.c
@@ -403,6 +403,7 @@ int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
ret = uclass_find_first_device(UCLASS_USB, &dev);
if (ret)
return ret;
+#if 0
ret = device_remove(dev, DM_REMOVE_NORMAL);
if (ret)
return ret;
@@ -412,6 +413,7 @@ int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp)
ret = device_probe(dev);
if (ret)
return ret;
+#endif
*ctlrp = dev_get_priv(dev);
return 0;
Adding debugging to device_remove the hang occurs when removing
'usb_ether.bootdev' and I'm not quite sure where this device even
comes from:
usb_setup_ehci_gadget removing usb at 32e40000
device_remove usb at 32e40000 flags=0x1
device_remove usb_ether flags=0x1
device_remove usb_ether.bootdev flags=0x1
I don't understand why usb_setup_ehci_gadget() is removing the device
in the first place just to go and probe it again.
This is not a regression... I've never seen this work since I first
tried it back in Feb 2022 [1]
Any ideas?
Best Regards,
Tim
[1] https://lore.kernel.org/all/CAJ+vNU1xH-J-0RV09OuM1e+hsRV=HXvh2oS6PfCWY5d+0stRYg@mail.gmail.com/
More information about the U-Boot
mailing list