USB OTG mode for DWC3 (ie imx8mp) host controller with usb_ether USB Ethernet gadget?

Tim Harvey tharvey at gateworks.com
Mon Jun 24 22:03:18 CEST 2024


On Mon, Jun 24, 2024 at 12:54 PM Adam Ford <aford173 at gmail.com> wrote:
>
> On Mon, Jun 24, 2024 at 2:39 PM Tim Harvey <tharvey at gateworks.com> wrote:
> >
> > Greetings,
> >
> > What is missing in U-Boot for the DWC3 host controller to support OTG
> > mode for usb_ether (USB Ethernet gadget)? I'm unable to get the usb
> > ethernet gadget to work for the imx8mp as it errors out with 'No UDC
> > available in the system'.
> >
> > The ums/acm/sdp gadget's all call udc_device_get_by_index to get the
> > UDC controller which for DWC3 is provided by
> > drivers/usb/dwc3/dwc3-generic.c and these gadgets work, however
> > usb_ether is different in that it calls usb_gadget_register_driver to
> > bind the gadget driver to the UDC and for DWC3 this calls
> > usb_gadget_probe_driver which iterates over udc_list which does not
> > contain DWC3 hosts that are in peripheral/otg mode.
> >
> > Before I spend a lot more time on this I wanted to see if anyone else
> > understands why boards with DWC3 host controllers like imx8mp don't
> > seem to register controllers in udc_list that are not in host mode.
> >
> > I'm also unclear how to get a DWC3 controller to switch roles
> > dynamically at runtime based on a gpio state for example. That support
> > appears to be missing and I'm not sure what the right way would be to
> > go about adding it. I notice that some imx8mp boards like the
> > imx8mp-evk have a u-boot.dtsi that just forces its OTG controller to
> > peripheral mode and I force the imx8mp-venice OTG controllers into
> > host mode.
>
> I think there is some interaction between the DWC controller and a
> type-c controller, but I think the mainline code lacks a proper type-c
> controller and/or framework.  Not everyone might use a USB Type-C
> chip, but it seems like if the USB is set to dual-role, it could
> default to peripheral mode until someone starts the USB host stuff
> with 'usb start'

Agreed... if I override the controller to peripheral mode as is done
by Fabio for imx8mp-evk in commit b0eef7326920f ("imx8mp-evk: Add USB0
OTG support") I would expect peripheral mode to work and for imx8mp it
does indeed work for sdp/acm/ums just not for usb_ether.

I'm not clear if usb_ether is doing things the 'right way' or if the
others are doing it the right way and maybe they are both doing things
the right way and the issue I'm facing is that for whatever reason the
dwc3_generic_peripheral driver just doesn't get added to the udc_list.

>
> I am just not sure how to handle situations where a USB cable may be
> connected to a host computer and someone issues a start command and
> brings up VBUS which may cause a voltage contention.

If a USB start command is done the controller should check to make
sure it's in host mode before bringing up VBUS. This is done for the
ci_udc controller used in imx8mm for example. That controller uses the
USB_ID pin routed to the CI block when determining the role. There
does not currently appear to be any support for making role detection
generic such that an extcon driver or something like that could
provide the role functionality.

> I think some people tried to push a Type-C driver if memory serves,
> but I think it was rejected.  I don't recall the details and my memory
> is terrible.  :-)

you're not alone there! I rely heavily on notes but often forget where
my notes are :)

Tim


More information about the U-Boot mailing list