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

Jean-Jacques Hiblot jjhiblot at ti.com
Mon Mar 26 13:50:25 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 v3:
- use the live tree API in the omap5 glue logic

Changes in v2: None

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

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index a7249b7..ae34eeb 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 9819489..a47446a 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -59,6 +59,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..5ce3af6
--- /dev/null
+++ b/drivers/usb/host/dwc3-omap-glue.c
@@ -0,0 +1,60 @@
+/*
+ * 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>
+#include <dm/of_access.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static inline bool is_ofnode_compatible(ofnode node, const char *compat)
+{
+	const void *fdt = gd->fdt_blob;
+
+	if (ofnode_is_np(node))
+		return of_device_is_compatible(ofnode_to_np(node), compat,
+					       NULL, NULL);
+	else
+		return !fdt_node_check_compatible(fdt, ofnode_to_offset(node),
+						  compat);
+}
+
+static int omap5_dwc3_glue_bind(struct udevice *dev)
+{
+	bool found = false;
+	ofnode node;
+
+	dev_for_each_subnode(node, dev) {
+		if (is_ofnode_compatible(node, "snps,dwc3")) {
+			found = true;
+			break;
+		}
+	}
+
+	if (!found) {
+		dev_err(dev, "Can't find subnode compatible with dwc3");
+		return -ENOENT;
+	}
+
+	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