[U-Boot] [PATCH v2 02/10] usb: omap5: Add glue logic to support DM for USB host

Jean-Jacques Hiblot jjhiblot at ti.com
Wed Mar 14 16:18:38 UTC 2018


The omap5 uses the dwc3. The dwc3 supports the driver model but it requires
some glue logic to load the the driver.

Signed-off-by: Jean-Jacques Hiblot <jjhiblot at ti.com>
---

Changes in v2: None

 drivers/usb/host/Kconfig          | 10 +++++++++
 drivers/usb/host/Makefile         |  1 +
 drivers/usb/host/dwc3-omap-glue.c | 47 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+)
 create mode 100644 drivers/usb/host/dwc3-omap-glue.c

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 90b2f78..405ab5f 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -79,6 +79,16 @@ config USB_XHCI_DRA7XX_INDEX
 	  Select the DRA7XX xHCI USB index.
 	  Current supported values: 0, 1.
 
+config USB_DM_XHCI_OMAP
+	bool "Support for OMAP family on-chip xHCI USB controller (DM version)"
+	depends on DM_USB
+	depends on ARCH_OMAP2PLUS
+	default y if DRA7XX
+	help
+	  Enables support for the on-chip xHCI controller on TI OMAP family SoCs
+	  using the Driver Model.
+	  This driver provides the glue logic to probe the generic dwc3 driver.
+
 config USB_XHCI_FSL
 	bool "Support for NXP Layerscape on-chip xHCI USB controller"
 	default y if ARCH_LS1021A || FSL_LSCH3 || FSL_LSCH2
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 7f9ba24..416d0eb 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -60,6 +60,7 @@ obj-$(CONFIG_USB_XHCI_OMAP) += xhci-omap.o
 obj-$(CONFIG_USB_XHCI_PCI) += xhci-pci.o
 obj-$(CONFIG_USB_XHCI_RCAR) += xhci-rcar.o
 obj-$(CONFIG_USB_XHCI_STI) += dwc3-sti-glue.o
+obj-$(CONFIG_USB_DM_XHCI_OMAP) += dwc3-omap-glue.o
 
 # designware
 obj-$(CONFIG_USB_DWC2) += dwc2.o
diff --git a/drivers/usb/host/dwc3-omap-glue.c b/drivers/usb/host/dwc3-omap-glue.c
new file mode 100644
index 0000000..1110fb6
--- /dev/null
+++ b/drivers/usb/host/dwc3-omap-glue.c
@@ -0,0 +1,47 @@
+/*
+ * OMAP5 family DWC3 specific Glue layer
+ *
+ * Copyright (c) 2017
+ * Jean-Jacques Hiblot <jjhiblot at ti.com>
+ * based on dwc3-sti-glue
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int omap5_dwc3_glue_bind(struct udevice *dev)
+{
+	int dwc3_node;
+
+	/* check if one subnode is present */
+	dwc3_node = fdt_first_subnode(gd->fdt_blob, dev_of_offset(dev));
+	if (dwc3_node <= 0) {
+		printf("Can't find subnode for %s\n", dev->name);
+		return -ENODEV;
+	}
+	/* check if the subnode compatible string is the dwc3 one*/
+	if (fdt_node_check_compatible(gd->fdt_blob, dwc3_node,
+				      "snps,dwc3") != 0) {
+		printf("Can't find dwc3 subnode for %s\n", dev->name);
+		return -ENODEV;
+	}
+
+	return dm_scan_fdt_dev(dev);
+}
+
+static const struct udevice_id omap5_dwc3_glue_ids[] = {
+	{ .compatible = "ti,dwc3" },
+	{ }
+};
+
+U_BOOT_DRIVER(dwc3_omap5_glue) = {
+	.name = "dwc3_omap5_glue",
+	.id = UCLASS_MISC,
+	.of_match = omap5_dwc3_glue_ids,
+	.bind = omap5_dwc3_glue_bind,
+};
-- 
2.7.4



More information about the U-Boot mailing list