This series fixes a few USB issues that show up on the Toradex i.MX95
based modules and finally enables USB support for them.

The i.MX95 has two USB controllers: a host-only DWC3 controller and a
ChipIdea OTG controller. Getting both of them to work together in
U-Boot requires a couple of fixes:

- Combining DWC3 (host only) with CI_UDC as the gadget driver, while
  DM_USB_GADGET is disabled, currently fails to link because DWC3 core
  provides dm_usb_gadget_handle_interrupts() even when the DWC3 gadget
  driver is not built (patch 1).

- The DWC3 reference clock lookup added by commit c6583354b7c1 ("usb:
  dwc3: Look up reference clock DT phandle in both controller DT nodes")
  resolves an index found in the child node's clock-names against the
  clk_bulk of the parent glue node. On the Verdin iMX95 the two lists
  have a different order, so the wrong clock is picked, which shows up
  as intermittent enumeration failures behind a USB hub (patch 2).

- ehci_gadget picks the first USB device it finds, which on the i.MX95
  is the host-only DWC3 controller instead of the ChipIdea OTG
  controller, so "ums" never enters device mode. Skip host-only
  controllers when looking for the gadget controller (patch 3).

The remaining patches enable CI_UDC on the Verdin iMX95 and turn on the
DWC3 host controller support for the Verdin iMX95 and the Toradex SMARC
iMX95.

Testing
-------

USB was tested on a Verdin iMX95, a Toradex SMARC iMX95 and an Apalis
iMX6 (as a regression test for the ehci_gadget change) with:

  usb start

and with:

  ums 0 mmc 0

All three boards were enumerating a USB stick and appeared as USB
devices on a PC connected to the USB device port.

Stefan Eichenberger (6):
  usb: dwc3: core: only provide legacy gadget IRQ handler when
    USB_DWC3_GADGET
  usb: dwc3-generic: fix ref clock lookup indexing wrong clk_bulk array
  usb: skip host-only devices when picking the ehci gadget controller
  configs: verdin-imx95: enable CI_UDC usb gadget driver
  toradex: verdin-imx95: enable DWC3 USB controller support
  toradex: smarc-imx95: enable DWC3 USB controller support

 .../dts/imx95-toradex-smarc-dev-u-boot.dtsi   |  8 -------
 .../arm/dts/imx95-verdin-wifi-dev-u-boot.dtsi |  8 -------
 configs/toradex-smarc-imx95_defconfig         |  4 ++++
 configs/verdin-imx95_defconfig                |  3 ++-
 drivers/usb/dwc3/core.c                       |  2 +-
 drivers/usb/dwc3/dwc3-generic.c               | 24 +++++++++++++++++--
 drivers/usb/host/usb-uclass.c                 | 23 ++++++++++++++++--
 7 files changed, 50 insertions(+), 22 deletions(-)

-- 
2.55.0

Reply via email to