[PATCH 5/8] Add nexus support for am335x USB driver.
Sichen Zhao
1473996754 at qq.com
Wed Jul 5 02:56:27 UTC 2017
---
freebsd/sys/arm/ti/am335x/am335x_musb.c | 14 ++++
freebsd/sys/arm/ti/am335x/am335x_prcm.c | 10 +++
freebsd/sys/arm/ti/am335x/am335x_usbss.c | 19 +++++
freebsd/sys/arm/ti/ti_scm.c | 7 ++
rtemsbsd/include/bsp/nexus-devices.h | 12 +++
rtemsbsd/include/machine/rtems-bsd-nexus-bus.h | 108 +++++++++++++++++++++++++
6 files changed, 170 insertions(+)
diff --git a/freebsd/sys/arm/ti/am335x/am335x_musb.c b/freebsd/sys/arm/ti/am335x/am335x_musb.c
index 52d799c..fff217e 100644
--- a/freebsd/sys/arm/ti/am335x/am335x_musb.c
+++ b/freebsd/sys/arm/ti/am335x/am335x_musb.c
@@ -223,11 +223,13 @@ musbotg_wrapper_interrupt(void *arg)
static int
musbotg_probe(device_t dev)
{
+#ifndef __rtems__
if (!ofw_bus_status_okay(dev))
return (ENXIO);
if (!ofw_bus_is_compatible(dev, "ti,musb-am33xx"))
return (ENXIO);
+#endif /* __rtems__ */
device_set_desc(dev, "TI AM33xx integrated USB OTG controller");
@@ -310,6 +312,7 @@ musbotg_attach(device_t dev)
}
sc->sc_otg.sc_platform_data = sc;
+#ifndef __rtems__
if (OF_getprop(ofw_bus_get_node(dev), "dr_mode", mode,
sizeof(mode)) > 0) {
if (strcasecmp(mode, "host") == 0)
@@ -323,6 +326,13 @@ musbotg_attach(device_t dev)
else
sc->sc_otg.sc_mode = MUSB2_HOST_MODE;
}
+#else /* __rtems__ */
+ /* Beaglebone defaults: USB0 device, USB1 HOST. */
+ if (sc->sc_otg.sc_id == 0)
+ sc->sc_otg.sc_mode = MUSB2_DEVICE_MODE;
+ else
+ sc->sc_otg.sc_mode = MUSB2_HOST_MODE;
+#endif /* __rtems__ */
/*
* software-controlled function
@@ -417,5 +427,9 @@ static driver_t musbotg_driver = {
static devclass_t musbotg_devclass;
+#ifdef __rtems__
+DRIVER_MODULE(musbotg, nexus, musbotg_driver, musbotg_devclass, 0, 0);
+#else /* __rtems__ */
DRIVER_MODULE(musbotg, usbss, musbotg_driver, musbotg_devclass, 0, 0);
+#endif /* __rtems__ */
MODULE_DEPEND(musbotg, usbss, 1, 1, 1);
diff --git a/freebsd/sys/arm/ti/am335x/am335x_prcm.c b/freebsd/sys/arm/ti/am335x/am335x_prcm.c
index 5494e86..5ba452a 100644
--- a/freebsd/sys/arm/ti/am335x/am335x_prcm.c
+++ b/freebsd/sys/arm/ti/am335x/am335x_prcm.c
@@ -415,6 +415,10 @@ static int
am335x_prcm_probe(device_t dev)
{
+#ifdef __rtems__
+ device_set_desc(dev, "AM335x Power and Clock Management");
+ return(BUS_PROBE_DEFAULT);
+#else /* __rtems__ */
if (!ofw_bus_status_okay(dev))
return (ENXIO);
@@ -424,6 +428,7 @@ am335x_prcm_probe(device_t dev)
}
return (ENXIO);
+#endif /* __rtems__ */
}
static int
@@ -475,8 +480,13 @@ static driver_t am335x_prcm_driver = {
static devclass_t am335x_prcm_devclass;
+#ifdef __rtems__
+DRIVER_MODULE(am335x_prcm, nexus, am335x_prcm_driver,
+ am335x_prcm_devclass, 0, 0);
+#else /* __rtems__ */
DRIVER_MODULE(am335x_prcm, simplebus, am335x_prcm_driver,
am335x_prcm_devclass, 0, 0);
+#endif /* __rtems__ */
MODULE_VERSION(am335x_prcm, 1);
MODULE_DEPEND(am335x_prcm, ti_scm, 1, 1, 1);
diff --git a/freebsd/sys/arm/ti/am335x/am335x_usbss.c b/freebsd/sys/arm/ti/am335x/am335x_usbss.c
index d7b43a2..9f8f912 100644
--- a/freebsd/sys/arm/ti/am335x/am335x_usbss.c
+++ b/freebsd/sys/arm/ti/am335x/am335x_usbss.c
@@ -116,11 +116,13 @@ static int
usbss_probe(device_t dev)
{
+#ifndef __rtems__
if (!ofw_bus_status_okay(dev))
return (ENXIO);
if (!ofw_bus_is_compatible(dev, "ti,am33xx-usb"))
return (ENXIO);
+#endif /* __rtems__ */
device_set_desc(dev, "TI AM33xx integrated USB OTG controller");
@@ -168,6 +170,7 @@ usbss_attach(device_t dev)
device_printf(dev, "TI AM335X USBSS v%d.%d.%d\n",
(rev >> 8) & 7, (rev >> 6) & 3, rev & 63);
+#ifndef __rtems__
node = ofw_bus_get_node(dev);
if (node == -1) {
@@ -176,17 +179,20 @@ usbss_attach(device_t dev)
}
simplebus_init(dev, node);
+#endif /* __rtems__ */
/*
* Allow devices to identify.
*/
bus_generic_probe(dev);
+#ifndef __rtems__
/*
* Now walk the OFW tree and attach top-level devices.
*/
for (node = OF_child(node); node > 0; node = OF_peer(node))
simplebus_add_device(dev, node, 0, NULL, -1, NULL);
+#endif /* __rtems__ */
return (bus_generic_attach(dev));
}
@@ -218,9 +224,22 @@ static device_method_t usbss_methods[] = {
DEVMETHOD_END
};
+#ifdef __rtems__
+static driver_t usbss_driver = {
+ "usbss",
+ usbss_methods,
+ sizeof(struct usbss_softc),
+};
+#endif /* __rtems__ */
+#ifndef __rtems__
DEFINE_CLASS_1(usbss, usbss_driver, usbss_methods,
sizeof(struct usbss_softc), simplebus_driver);
+#endif /* __rtems__ */
static devclass_t usbss_devclass;
+#ifdef __rtems__
+DRIVER_MODULE(usbss, nexus, usbss_driver, usbss_devclass, 0, 0);
+#else /* __rtems__ */
DRIVER_MODULE(usbss, simplebus, usbss_driver, usbss_devclass, 0, 0);
+#endif /* __rtems__ */
MODULE_DEPEND(usbss, usb, 1, 1, 1);
diff --git a/freebsd/sys/arm/ti/ti_scm.c b/freebsd/sys/arm/ti/ti_scm.c
index d3cbb4f..2ea9975 100644
--- a/freebsd/sys/arm/ti/ti_scm.c
+++ b/freebsd/sys/arm/ti/ti_scm.c
@@ -90,6 +90,7 @@ static struct ti_scm_softc *ti_scm_sc;
static int
ti_scm_probe(device_t dev)
{
+#ifndef __rtems__
if (!ofw_bus_status_okay(dev))
return (ENXIO);
@@ -99,6 +100,7 @@ ti_scm_probe(device_t dev)
if (ti_scm_sc) {
return (EEXIST);
}
+#endif /* __rtems__ */
device_set_desc(dev, "TI Control Module");
return (BUS_PROBE_DEFAULT);
@@ -174,5 +176,10 @@ static driver_t ti_scm_driver = {
static devclass_t ti_scm_devclass;
+#ifdef __rtems__
+EARLY_DRIVER_MODULE(ti_scm, nexus, ti_scm_driver, ti_scm_devclass, 0, 0,
+ BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
+#else /* __rtems__ */
EARLY_DRIVER_MODULE(ti_scm, simplebus, ti_scm_driver, ti_scm_devclass, 0, 0,
BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
+#endif /* __rtems__ */
diff --git a/rtemsbsd/include/bsp/nexus-devices.h b/rtemsbsd/include/bsp/nexus-devices.h
index 1fbf756..6fe4f7d 100644
--- a/rtemsbsd/include/bsp/nexus-devices.h
+++ b/rtemsbsd/include/bsp/nexus-devices.h
@@ -46,6 +46,18 @@
RTEMS_BSD_DRIVER_SMC0(0x4e000000, RVPBXA9_IRQ_ETHERNET);
+#elif defined(LIBBSP_ARM_BEAGLE_BSP_H)
+
+#include <bsp/irq.h>
+
+RTEMS_BSD_DRIVER_MUSB1(0x47401c00, 0x47401800, 0x13);
+RTEMS_BSD_DRIVER_MUSB0(0x47401400, 0x47401000, 0x12);
+RTEMS_BSD_DRIVER_USBSS(0x47400000);
+RTEMS_BSD_DRIVER_AM335x_PRCM(0x44e00000);
+RTEMS_BSD_DRIVER_TI_SCM(0x44e10000);
+
+RTEMS_BSD_DRIVER_USB;
+
#elif defined(LIBBSP_ARM_LPC32XX_BSP_H)
#include <bsp/irq.h>
diff --git a/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h b/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h
index 06048b7..fc15bab 100644
--- a/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h
+++ b/rtemsbsd/include/machine/rtems-bsd-nexus-bus.h
@@ -40,6 +40,8 @@
* RTEMS_BSD_DRIVER_XILINX_ZYNQ_SLCR
* RTEMS_BSD_DRIVER_LPC32XX_PWR
* RTEMS_BSD_DRIVER_LPC32XX_TSC
+ * RTEMS_BSD_DRIVER_TI_SCM
+ * RTEMS_BSD_DRIVER_AM335x_PRCM
*
* Buses:
* RTEMS_BSD_DRIVER_PC_LEGACY
@@ -53,6 +55,9 @@
* RTEMS_BSD_DRIVER_MMC
* RTEMS_BSD_DRIVER_USB
* RTEMS_BSD_DRIVER_USB_MASS
+ * RTEMS_BSD_DRIVER_USBSS
+ * RTEMS_BSD_DRIVER_MUSB0
+ * RTEMS_BSD_DRIVER_MUSB1
*
* Networking:
* RTEMS_BSD_DRIVER_SMC0
@@ -158,6 +163,40 @@ extern "C" {
&lpc_tsc0_res[0])
#endif /* RTEMS_BSD_DRIVER_LPC32XX_TSC */
+/*
+ * Ti SCM
+ */
+#if !defined(RTEMS_BSD_DRIVER_TI_SCM)
+ #define RTEMS_BSD_DRIVER_TI_SCM(_base) \
+ static const rtems_bsd_device_resource ti_scm_res[] = { \
+ { \
+ .type = RTEMS_BSD_RES_MEMORY, \
+ .start_request = 0, \
+ .start_actual = (_base) \
+ } \
+ }; \
+ RTEMS_BSD_DEFINE_NEXUS_DEVICE(ti_scm, 0, \
+ RTEMS_ARRAY_SIZE(ti_scm_res), \
+ &ti_scm_res[0])
+#endif /* RTEMS_BSD_DRIVER_TI_SCM */
+
+/*
+ * AM335x PRCM
+ */
+#if !defined(RTEMS_BSD_DRIVER_AM335x_PRCM)
+ #define RTEMS_BSD_DRIVER_AM335x_PRCM(_base) \
+ static const rtems_bsd_device_resource am335x_prcm_res[] = { \
+ { \
+ .type = RTEMS_BSD_RES_MEMORY, \
+ .start_request = 0, \
+ .start_actual = (_base) \
+ } \
+ }; \
+ RTEMS_BSD_DEFINE_NEXUS_DEVICE(am335x_prcm, 0, \
+ RTEMS_ARRAY_SIZE(am335x_prcm_res),\
+ &am335x_prcm_res[0])
+#endif /* RTEMS_BSD_DRIVER_AM335x_PRCM */
+
/**
** Physical Buses
**/
@@ -255,6 +294,75 @@ extern "C" {
SYSINIT_DRIVER_REFERENCE(umass, uhub)
#endif /* RTEMS_BSD_DRIVER_USB_MASS */
+/*
+ * USBSS driver.
+ */
+#if !defined(RTEMS_BSD_DRIVER_USBSS)
+ #define RTEMS_BSD_DRIVER_USBSS(_base) \
+ static const rtems_bsd_device_resource usbss_res[] = { \
+ { \
+ .type = RTEMS_BSD_RES_MEMORY, \
+ .start_request = 0, \
+ .start_actual = (_base) \
+ } \
+ }; \
+ RTEMS_BSD_DEFINE_NEXUS_DEVICE(usbss, 0, \
+ RTEMS_ARRAY_SIZE(usbss_res), \
+ &usbss_res[0])
+#endif /* RTEMS_BSD_DRIVER_USBSS */
+
+/*
+ * MUSB0 driver.
+ */
+#if !defined(RTEMS_BSD_DRIVER_MUSB0)
+ #define RTEMS_BSD_DRIVER_MUSB0(_base0, _base1, _irq) \
+ static const rtems_bsd_device_resource musbotg0_res[] = { \
+ { \
+ .type = RTEMS_BSD_RES_MEMORY, \
+ .start_request = 0, \
+ .start_actual = (_base0) \
+ }, { \
+ .type = RTEMS_BSD_RES_MEMORY, \
+ .start_request = 1, \
+ .start_actual = (_base1) \
+ }, { \
+ .type = RTEMS_BSD_RES_IRQ, \
+ .start_request = 0, \
+ .start_actual = (_irq) \
+ } \
+ \
+ }; \
+ RTEMS_BSD_DEFINE_NEXUS_DEVICE(musbotg, 0, \
+ RTEMS_ARRAY_SIZE(musbotg0_res), \
+ &musbotg0_res[0])
+#endif /* RTEMS_BSD_DRIVER_MUSB0 */
+
+/*
+ * MUSB1 driver.
+ */
+#if !defined(RTEMS_BSD_DRIVER_MUSB1)
+ #define RTEMS_BSD_DRIVER_MUSB1(_base0, _base1, _irq) \
+ static const rtems_bsd_device_resource musbotg1_res[] = { \
+ { \
+ .type = RTEMS_BSD_RES_MEMORY, \
+ .start_request = 0, \
+ .start_actual = (_base0) \
+ }, { \
+ .type = RTEMS_BSD_RES_MEMORY, \
+ .start_request = 1, \
+ .start_actual = (_base1) \
+ }, { \
+ .type = RTEMS_BSD_RES_IRQ, \
+ .start_request = 0, \
+ .start_actual = (_irq) \
+ } \
+ \
+ }; \
+ RTEMS_BSD_DEFINE_NEXUS_DEVICE(musbotg, 1, \
+ RTEMS_ARRAY_SIZE(musbotg1_res), \
+ &musbotg1_res[0])
+#endif /* RTEMS_BSD_DRIVER_MUSB1 */
+
/**
** Networking
**/
--
2.7.4
More information about the devel
mailing list