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:

- Add support for the driver model to the ci_udc driver (patch 1). If
  DM_USB_GADGET is not enabled, keep the legacy driver support enabled
  so that boards relying on the legacy driver still work. The ci_udc
  driver does not bind independently, but instead relies on the ehci-mx6
  driver to bind it (patch 2). I'm not sure if this approach is correct,
  but otherwise we would have two drivers binding to the same compatible
  string, which does not work.

- 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 3).

- 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 4).

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 (7):
  usb: ci_udc: add driver model support
  usb: ehci-mx6: bind the ChipIdea gadget driver
  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/dwc3-generic.c               |  47 ++++--
 drivers/usb/gadget/Kconfig                    |   8 +-
 drivers/usb/gadget/ci_udc.c                   | 152 +++++++++++++++++-
 drivers/usb/host/ehci-mx6.c                   |  38 +++++
 drivers/usb/host/usb-uclass.c                 |  23 ++-
 9 files changed, 254 insertions(+), 37 deletions(-)

-- 
2.55.0

Reply via email to