* [U-Boot] [RFC] usb: ehci-mx6: Create MISC USB device wrapper
@ 2019-04-03 15:17 Adam Ford
2019-04-03 15:28 ` Adam Ford
0 siblings, 1 reply; 3+ messages in thread
From: Adam Ford @ 2019-04-03 15:17 UTC (permalink / raw)
To: u-boot
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@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;
+
+ 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [RFC] usb: ehci-mx6: Create MISC USB device wrapper
2019-04-03 15:17 [U-Boot] [RFC] usb: ehci-mx6: Create MISC USB device wrapper Adam Ford
@ 2019-04-03 15:28 ` Adam Ford
2019-08-13 9:34 ` Simon Glass
0 siblings, 1 reply; 3+ messages in thread
From: Adam Ford @ 2019-04-03 15:28 UTC (permalink / raw)
To: u-boot
On Wed, Apr 3, 2019 at 10:17 AM Adam Ford <aford173@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@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.
> + 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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [RFC] usb: ehci-mx6: Create MISC USB device wrapper
2019-04-03 15:28 ` Adam Ford
@ 2019-08-13 9:34 ` Simon Glass
0 siblings, 0 replies; 3+ messages in thread
From: Simon Glass @ 2019-08-13 9:34 UTC (permalink / raw)
To: u-boot
Hi Adam,
On Wed, 3 Apr 2019 at 09:28, Adam Ford <aford173@gmail.com> wrote:
>
> On Wed, Apr 3, 2019 at 10:17 AM Adam Ford <aford173@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@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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-13 9:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03 15:17 [U-Boot] [RFC] usb: ehci-mx6: Create MISC USB device wrapper Adam Ford
2019-04-03 15:28 ` Adam Ford
2019-08-13 9:34 ` Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.