[PATCH 1/3] usb: ehci-mx6: move mode set/detect to probe

Tim Harvey tharvey at gateworks.com
Thu Jun 3 17:50:35 CEST 2021


On Tue, Apr 27, 2021 at 6:59 PM Marek Vasut <marex at denx.de> wrote:
>
> On 4/28/21 3:51 AM, Tim Harvey wrote:
> > On Tue, Apr 27, 2021 at 10:45 AM Marek Vasut <marex at denx.de> wrote:
> >>
> >> On 4/27/21 7:08 PM, Tim Harvey wrote:
> >>> There is no need to set and/or detect mode in of_to_plat and
> >>> accessing phy registers at that point before device power domain and
> >>> clock are enabled will cause hangs on platforms such as IMX8M Mini.
> >>>
> >>> Move the mode set/detect from of_to_plat into the probe and remove
> >>> the unnecessary of_to_plat.
> >>>
> >>> Signed-off-by: Tim Harvey <tharvey at gateworks.com>
> >>> ---
> >>>    drivers/usb/host/ehci-mx6.c | 42 ++++++++++++++-----------------------
> >>>    1 file changed, 16 insertions(+), 26 deletions(-)
> >>>
> >>> diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
> >>> index 06be9deaaa..c2dfe49012 100644
> >>> --- a/drivers/usb/host/ehci-mx6.c
> >>> +++ b/drivers/usb/host/ehci-mx6.c
> >>> @@ -539,28 +539,6 @@ static int ehci_usb_phy_mode(struct udevice *dev)
> >>>        return 0;
> >>>    }
> >>>
> >>> -static int ehci_usb_of_to_plat(struct udevice *dev)
> >>> -{
> >>> -     struct usb_plat *plat = dev_get_plat(dev);
> >>> -     enum usb_dr_mode dr_mode;
> >>> -
> >>> -     dr_mode = usb_get_dr_mode(dev_ofnode(dev));
> >>> -
> >>> -     switch (dr_mode) {
> >>> -     case USB_DR_MODE_HOST:
> >>> -             plat->init_type = USB_INIT_HOST;
> >>> -             break;
> >>> -     case USB_DR_MODE_PERIPHERAL:
> >>> -             plat->init_type = USB_INIT_DEVICE;
> >>> -             break;
> >>> -     case USB_DR_MODE_OTG:
> >>> -     case USB_DR_MODE_UNKNOWN:
> >>> -             return ehci_usb_phy_mode(dev);
> >>> -     };
> >>> -
> >>> -     return 0;
> >>> -}
> >>> -
> >>
> >> [...]
> >>
> >>> @@ -764,7 +755,6 @@ U_BOOT_DRIVER(usb_mx6) = {
> >>>        .name   = "ehci_mx6",
> >>>        .id     = UCLASS_USB,
> >>>        .of_match = mx6_usb_ids,
> >>> -     .of_to_plat = ehci_usb_of_to_plat,
> >>
> >> I wonder why it was implemented in of_to_plat originally , maybe there
> >> is some reason for that ?
> >
> > Marek,
> >
> > Looking back the commit that added the ehci_usb_ofdata_to_platdata was:
> > cccbddc38c43 ("usb: ehci-mx6: implement ofdata_to_platdata")
> >
> > Before that there was a board-specific function that would set the
> > usb_plat->init_type.
> >
> > The only reason to set usb_plat->init_type in of_to_plat would be so
> > that drivers/usb/host/usb-uclass.c would have knowledge of it but I
> > only see that it is set there in usb_setup_ehci_gadget.
>
> So interaction with Gadget, that's what I was afraid of.
>
> > I added Peng, Stefano, and Simon to the thread to see if they see an
> > issue with doing away with of_to_plat setting the usb_plat->init_type
> > prior to probe.
>
> I added Lukasz too.

Marek,

Is there something you want me to change here?

I am happy to test gadget support as my board has an OTG connector.
Could you give me some pointers on how to configure a gadget in U-Boot
in order to test?

Best regards,

Tim


More information about the U-Boot mailing list