[PATCH rtems-libbsd v2 11/14] ehci_imx: Port to RTEMS

Christian Mauderer christian.mauderer at embedded-brains.de
Tue Apr 14 14:51:12 UTC 2020


Update #3869.
---
 freebsd/sys/arm/freescale/imx/imx6_usbphy.c | 11 +++++++++++
 freebsd/sys/dev/usb/controller/ehci_imx.c   | 12 ++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/freebsd/sys/arm/freescale/imx/imx6_usbphy.c b/freebsd/sys/arm/freescale/imx/imx6_usbphy.c
index 8f47507b..ad545601 100644
--- a/freebsd/sys/arm/freescale/imx/imx6_usbphy.c
+++ b/freebsd/sys/arm/freescale/imx/imx6_usbphy.c
@@ -91,6 +91,17 @@ usbphy_detach(device_t dev)
 	return (0);
 }
 
+#ifdef __rtems__
+#define BUS_SPACE_PHYSADDR(res, offs) \
+	((u_int)(rman_get_start(res)+(offs)))
+
+void
+imx6_anatop_write_4(bus_size_t offset, uint32_t value)
+{
+
+	bus_space_write_4(0, 0x20c8000, offset, value);
+}
+#endif /* __rtems__ */
 static int
 usbphy_attach(device_t dev)
 {
diff --git a/freebsd/sys/dev/usb/controller/ehci_imx.c b/freebsd/sys/dev/usb/controller/ehci_imx.c
index a872fb62..d158df1d 100644
--- a/freebsd/sys/dev/usb/controller/ehci_imx.c
+++ b/freebsd/sys/dev/usb/controller/ehci_imx.c
@@ -303,6 +303,16 @@ imx_ehci_probe(device_t dev)
 		return (ENXIO);
 
 	if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) {
+#ifdef __rtems__
+		char dr_mode[24];
+
+		if (OF_getprop(ofw_bus_get_node(dev), "dr_mode",
+		    &dr_mode, sizeof(dr_mode)) > 0 &&
+		    strcasecmp(dr_mode, "host") != 0) {
+			return (ENXIO);
+		}
+#endif /* __rtems__ */
+
 		device_set_desc(dev, "Freescale i.MX integrated USB controller");
 		return (BUS_PROBE_DEFAULT);
 	}
@@ -437,8 +447,10 @@ imx_ehci_attach(device_t dev)
 		goto out;
 	}
 
+#ifndef __rtems__
 	/* Turn on clocks. */
 	imx_ccm_usb_enable(dev);
+#endif /* __rtems__ */
 
 	/* Disable overcurrent detection, if configured to do so. */
 	if (OF_hasprop(ofw_bus_get_node(sc->dev), "disable-over-current"))
-- 
2.16.4



More information about the devel mailing list