On Tue, Sep 15, 2026 at 04:24:59PM +0200, Marek Vasut wrote:
> On 9/15/26 9:57 AM, Stefan Eichenberger wrote:
> > On Mon, Sep 14, 2026 at 09:31:25PM +0200, Marek Vasut wrote:
> > > On 9/14/26 9:42 AM, Stefan Eichenberger wrote:
> > > > From: Stefan Eichenberger <[email protected]>
> > > > 
> > > > The i.MX95 SoC has two USB controllers, a DWC3 controller and a ChipIdea
> > > > controller. However, U-Boot might select a controller that is marked as
> > > > host only in the device tree when attempting to set up a USB gadget,
> > > > leading to failures in gadget mode.
> > > > 
> > > > Iterate over usb devices and skipping any that are marked host-only when
> > > > selecting the controller for gadget mode. This ensures that a controller
> > > > that is marked as device or otg is used for USB gadget functionality.
> > > > 
> > > > Verified on Verdin iMX95 hardware: "ums 0 mmc 0" now correctly flips
> > > > the ChipIdea OTG controller into device mode and enumerates on the
> > > > host PC.
> > > 
> > > What was the previous incorrect behavior ?
> > 
> > When I did a ums 0 mmc 0, the host only DWC3 controller was selected. It
> > is not host only by itself, but it is marked as host only for our board
> > in the device tree.
> > 
> > > 
> > > Does your board DT have /aliases { usb0 = &... } entry pointing to the
> > > chipidea controller already ? The controller indexing should match the
> > > aliases ordering.
> > 
> > Yes we use aliases. Interstingly the dwc3 controller is usb1 and the
> > chipidea controller is usb0.
> > 
> > aliases {
> >     ...
> >     usb0 = &usb2;
> >     usb1 = &usb3;
> >     ...
> > };
> > 
> > &usb2 {
> >     dr_mode = "otg";
> >     ...
> > };
> > 
> > &usb3 {
> >     ...
> >     &usb3_dwc3 {
> >             dr_mode = "host";
> >     };
> >     ...
> > };
> > 
> > So it seems this ordering is not respected when selecting the controller
> > for gadget mode. I have to test that again. However, I still think host
> > only devices should never be selected for gadget mode which is what this
> > patch tries to address. Or should e.g. ums 1 mmc 0 just fail for host
> > only controllers?
> 
> Yes
> 
> > In this scenario I assume the ordering is correct so
> > ums 1 would select the dwc3 host only controller.
> The ordering should respect the aliases enumeration, so ums 0 ... is CI HDRC
> and ums 1 is DWC3 . Can you check the U-Boot control DT /aliases node to be
> sure the ordering there is as expected ?
> 
> => fdt addr $fdtcontroladdr
> => fdt print /aliases

aliases {
        can0 = "/soc/bus@44000000/can@443a0000";
        can1 = "/soc/bus@42000000/can@425b0000";
        eeprom0 = "/soc/bus@44000000/i2c@44350000/eeprom@50";
        ethernet0 = 
"/soc/system-controller@4cde0000/pcie@4ca00000/ethernet@0,0";
        ethernet1 = 
"/soc/system-controller@4cde0000/pcie@4ca00000/ethernet@8,0";
        i2c0 = "/soc/bus@44000000/i2c@44350000";
        i2c1 = "/soc/bus@42000000/i2c@42540000";
        i2c2 = "/soc/bus@42000000/i2c@42530000";
        i2c3 = "/soc/bus@42000000/i3c@42520000";
        i2c4 = "/soc/bus@42000000/i2c@426b0000";
        mmc0 = "/soc/bus@42800000/mmc@42850000";
        mmc1 = "/soc/bus@42800000/mmc@42860000";
        mmc2 = "/soc/bus@42800000/mmc@428b0000";
        rtc0 = "/soc/bus@44000000/i2c@44350000/rtc@32";
        rtc1 = "/firmware/scmi/protocol@81";
        serial0 = "/soc/bus@42000000/serial@42690000";
        serial1 = "/soc/bus@42000000/serial@426a0000";
        serial2 = "/soc/bus@44000000/serial@44380000";
        serial3 = "/soc/bus@44000000/serial@44390000";
        serial4 = "/soc/bus@42000000/serial@425a0000";
        usb0 = "/soc/usb@4c200000";
        usb1 = "/soc/usb@4c010010";
        eeprom1 = "/soc/bus@42000000/i2c@42540000/eeprom@57";
};

I think I found what I missed. When I was originally testing it, the
CI_UDC driver was not a driver model driver, therefore the alias for
usb2 (alias usb0) did not work. Now with the driver model driver, it
indeed works:
Verdin iMX95 # ums 0 mmc 0
UMS: LUN 0, dev mmc 0, hwpart 0, sector 0x0, count 0x3b48000
\

Verdin iMX95 # ums 1 mmc 0
UMS: LUN 0, dev mmc 0, hwpart 0, sector 0x0, count 0x3b48000
No USB device found
Couldn't init USB controller.

So I can drop this patch with the next series, thanks a lot!

Regards,
Stefan

Reply via email to