[U-Boot] [RFC] usb: ehci-mx6: Create MISC USB device wrapper

Simon Glass sjg at chromium.org
Tue Aug 13 09:34:28 UTC 2019


Hi Adam,

On Wed, 3 Apr 2019 at 09:28, Adam Ford <aford173 at gmail.com> wrote:
>
> On Wed, Apr 3, 2019 at 10:17 AM Adam Ford <aford173 at gmail.com> wrote:
> >
> > In preparation to support DM_USB_GADGET, this creates a misc
> > device which binds the host.  This is necessary because
> > U_BOOT_DRIVER(usb_mx6) is currently hard coded to UCLASS_USB
> > and if we want to support UCLASS_USB_GADGET_GENERIC we'll need
> > to bind a separate device in the future.
> >
> > Signed-off-by: Adam Ford <aford173 at gmail.com>
> >
> > diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> > index ba1e6bfa43..25c7e2d6a1 100644
> > --- a/drivers/usb/host/Kconfig
> > +++ b/drivers/usb/host/Kconfig
> > @@ -134,6 +134,7 @@ config USB_EHCI_MARVELL
> >
> >  config USB_EHCI_MX6
> >         bool "Support for i.MX6 on-chip EHCI USB controller"
> > +       select MISC
> >         depends on ARCH_MX6
> >         default y
> >         ---help---
> > diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
> > index 16abeef3b2..4003b8616f 100644
> > --- a/drivers/usb/host/ehci-mx6.c
> > +++ b/drivers/usb/host/ehci-mx6.c
> > @@ -19,6 +19,7 @@
> >  #include <asm/mach-types.h>
> >  #include <power/regulator.h>
> >  #include <linux/usb/otg.h>
> > +#include <dm/lists.h>
> >
> >  #include "ehci.h"
> >
> > @@ -567,7 +568,6 @@ static const struct udevice_id mx6_usb_ids[] = {
> >  U_BOOT_DRIVER(usb_mx6) = {
> >         .name   = "ehci_mx6",
> >         .id     = UCLASS_USB,
> > -       .of_match = mx6_usb_ids,
> >         .ofdata_to_platdata = ehci_usb_ofdata_to_platdata,
> >         .probe  = ehci_usb_probe,
> >         .remove = ehci_deregister,
> > @@ -576,4 +576,30 @@ U_BOOT_DRIVER(usb_mx6) = {
> >         .priv_auto_alloc_size = sizeof(struct ehci_mx6_priv_data),
> >         .flags  = DM_FLAG_ALLOC_PRIV_DMA,
> >  };
> > +
> > +static int mx6_usb_wrapper_bind(struct udevice *dev)
> > +{
> > +       const void *fdt = gd->fdt_blob;
> > +       int node = dev_of_offset(dev);
> > +       const char *name = fdt_get_name(fdt, node, NULL);
> > +       int ret;
> > +
> For clarification, this patch, this patch should behave just like it
> has been in the past.  The idea we'd check the dr_mode and/or ID pin
> inside mx6_usb_wrapper_bind.  Instead of binding the ehci_mx6 with
> UCLASS_USB all the time, we'd bind something with the
> UCLASS_USB_GADGET_GENERIC based on dr_mode and/or ID pin status.
> Before I go down a rabit hole, I thought I'd send out the RFC to see
> what people's thoughts are.  If someone else has this driver already
> updated to support DM_USB_GADGET or is working on it, I'll back off.

It looks reasonable to me, but Marek is the USB expert.

>
> > +       ret = device_bind_driver_to_node(dev,
> > +                                       "ehci_mx6",
> > +                                       name,
> > +                                       offset_to_ofnode(node),
> > +                                       &dev);
> > +       if (ret)
> > +               pr_err("mx6_usb - Unable to bind USB host node\n");
> > +
> > +       return ret;
> > +}
> > +
> > +U_BOOT_DRIVER(usb_mx6_wrapper) = {
> > +       .name   = "mx6-usb-wrapper",
> > +       .id     = UCLASS_MISC,
> > +       .of_match = mx6_usb_ids,
> > +       .bind = mx6_usb_wrapper_bind,
> > +};
> > +
> >  #endif
> > --
> > 2.17.1
> >

Regards,
SImon


More information about the U-Boot mailing list