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 <aford...@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

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to