[PATCH 4/8] Port am335x usb driver to RTEMS.

Sichen Zhao 1473996754 at qq.com
Wed Jul 5 02:56:26 UTC 2017


---
 freebsd/sys/arm/ti/am335x/am335x_prcm.c |  8 ++++++++
 freebsd/sys/arm/ti/ti_cpuid.h           | 19 +++++++++++++++++++
 freebsd/sys/arm/ti/ti_prcm.c            |  2 ++
 freebsd/sys/arm/ti/ti_scm.c             |  2 ++
 libbsd.py                               | 30 ++++++++++++++++++++++++++++++
 libbsd_waf.py                           |  6 ++++++
 6 files changed, 67 insertions(+)

diff --git a/freebsd/sys/arm/ti/am335x/am335x_prcm.c b/freebsd/sys/arm/ti/am335x/am335x_prcm.c
index 1d10f7f..5494e86 100644
--- a/freebsd/sys/arm/ti/am335x/am335x_prcm.c
+++ b/freebsd/sys/arm/ti/am335x/am335x_prcm.c
@@ -36,12 +36,18 @@ __FBSDID("$FreeBSD$");
 #include <sys/module.h>
 #include <sys/malloc.h>
 #include <sys/rman.h>
+#ifndef __rtems__
 #include <sys/timeet.h>
+#endif /* __rtems__ */
 #include <sys/timetc.h>
+#ifndef __rtems__
 #include <sys/watchdog.h>
+#endif /* __rtems__ */
 #include <machine/bus.h>
 #include <machine/cpu.h>
+#ifndef __rtems__
 #include <machine/intr.h>
+#endif /* __rtems__ */
 
 #include <arm/ti/tivar.h>
 #include <arm/ti/ti_scm.h>
@@ -438,7 +444,9 @@ am335x_prcm_attach(device_t dev)
 	sc->bsh = rman_get_bushandle(sc->res[0]);
 
 	am335x_prcm_sc = sc;
+#ifndef __rtems__
 	ti_cpu_reset = am335x_prcm_reset;
+#endif /* __rtems__ */
 
 	if (am335x_clk_get_sysclk_freq(NULL, &sysclk) != 0)
 		sysclk = 0;
diff --git a/freebsd/sys/arm/ti/ti_cpuid.h b/freebsd/sys/arm/ti/ti_cpuid.h
index 715f080..213714b 100644
--- a/freebsd/sys/arm/ti/ti_cpuid.h
+++ b/freebsd/sys/arm/ti/ti_cpuid.h
@@ -29,6 +29,9 @@
 
 #ifndef _TI_CPUID_H_
 #define	_TI_CPUID_H_
+#ifdef __rtems__
+#include <bsp.h>
+#endif /* __rtems__ */
 
 #define	OMAP_MAKEREV(d, a, b, c) \
 	(uint32_t)(((d) << 16) | (((a) & 0xf) << 8) | (((b) & 0xf) << 4) | ((c) & 0xf))
@@ -70,7 +73,23 @@
 #define	CHIP_OMAP_4	0
 #define	CHIP_AM335X	1
 
+#ifdef __rtems__
+#ifdef IS_AM335X
+#define SOC_TI_AM335X
+#else
+#warning Unknown SOC.
+#endif
+
+#if defined(SOC_TI_AM335X)
+#define _ti_chip CHIP_AM335X
+#elif defined(SOC_OMAP4)
+#define _ti_chip CHIP_OMAP_4
+#else
+#define _ti_chip -1
+#endif
+#else /* __rtems__ */
 extern int _ti_chip;
+#endif /* __rtems__ */
 
 static __inline int ti_chip(void)
 {
diff --git a/freebsd/sys/arm/ti/ti_prcm.c b/freebsd/sys/arm/ti/ti_prcm.c
index b4dd03f..04b1b6b 100644
--- a/freebsd/sys/arm/ti/ti_prcm.c
+++ b/freebsd/sys/arm/ti/ti_prcm.c
@@ -55,7 +55,9 @@ __FBSDID("$FreeBSD$");
 
 #include <machine/bus.h>
 #include <machine/resource.h>
+#ifndef __rtems__
 #include <machine/intr.h>
+#endif /* __rtems__ */
 
 #include <arm/ti/ti_cpuid.h>
 #include <arm/ti/ti_prcm.h>
diff --git a/freebsd/sys/arm/ti/ti_scm.c b/freebsd/sys/arm/ti/ti_scm.c
index 2e54262..d3cbb4f 100644
--- a/freebsd/sys/arm/ti/ti_scm.c
+++ b/freebsd/sys/arm/ti/ti_scm.c
@@ -66,7 +66,9 @@ __FBSDID("$FreeBSD$");
 #include <dev/ofw/openfirm.h>
 #include <dev/ofw/ofw_bus.h>
 #include <dev/ofw/ofw_bus_subr.h>
+#ifndef __rtems__
 #include <dev/fdt/fdt_pinctrl.h>
+#endif /* __rtems__ */
 
 #include "ti_scm.h"
 
diff --git a/libbsd.py b/libbsd.py
index e171a9d..c53d5a00 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -890,6 +890,35 @@ def dev_usb_storage_add_on(mm):
     return mod
 
 #
+# BBB USB
+#
+def dev_usb_controller_bbb(mm):
+    mod = builder.Module('dev_usb_controller_bbb')
+    mod.addDependency(mm['dev_usb'])
+    mod.addKernelSpaceHeaderFiles(
+        [
+            'sys/arm/ti/ti_cpuid.h',
+            'sys/arm/ti/ti_prcm.h',
+            'sys/arm/ti/ti_scm.h',
+            'sys/arm/ti/tivar.h',
+            'sys/arm/ti/am335x/am335x_scm.h',
+            'sys/dev/usb/controller/musb_otg.h',
+        ]
+    )
+    mod.addKernelSpaceSourceFiles(
+        [
+            'sys/arm/ti/ti_scm.c',
+            'sys/arm/ti/am335x/am335x_prcm.c',
+            'sys/arm/ti/am335x/am335x_usbss.c',
+            'sys/arm/ti/ti_prcm.c',
+            'sys/arm/ti/am335x/am335x_musb.c',
+            'sys/dev/usb/controller/musb_otg.c',
+        ],
+        mm.generator['source']()
+    )
+    return mod
+
+#
 # USB Template
 #
 def dev_usb_template(mm):
@@ -3195,6 +3224,7 @@ def sources(mm):
     mm.addModule(cam(mm))
     mm.addModule(dev_usb_storage(mm))
     #mm.addModule(dev_usb_storage_add_on(mm))
+    mm.addModule(dev_usb_controller_bbb(mm))
 
     #mm.addModule(dev_usb_template(mm))
 
diff --git a/libbsd_waf.py b/libbsd_waf.py
index 30765de..5d0d5d0 100644
--- a/libbsd_waf.py
+++ b/libbsd_waf.py
@@ -731,6 +731,11 @@ def build(bld):
 
     source = ['freebsd/sys/arm/lpc/if_lpe.c',
               'freebsd/sys/arm/lpc/lpc_pwr.c',
+              'freebsd/sys/arm/ti/am335x/am335x_musb.c',
+              'freebsd/sys/arm/ti/am335x/am335x_prcm.c',
+              'freebsd/sys/arm/ti/am335x/am335x_usbss.c',
+              'freebsd/sys/arm/ti/ti_prcm.c',
+              'freebsd/sys/arm/ti/ti_scm.c',
               'freebsd/sys/arm/xilinx/zy7_slcr.c',
               'freebsd/sys/cam/cam.c',
               'freebsd/sys/cam/scsi/scsi_all.c',
@@ -896,6 +901,7 @@ def build(bld):
               'freebsd/sys/dev/tsec/if_tsec_fdt.c',
               'freebsd/sys/dev/usb/controller/dwc_otg.c',
               'freebsd/sys/dev/usb/controller/ehci.c',
+              'freebsd/sys/dev/usb/controller/musb_otg.c',
               'freebsd/sys/dev/usb/controller/ohci.c',
               'freebsd/sys/dev/usb/controller/usb_controller.c',
               'freebsd/sys/dev/usb/input/atp.c',
-- 
2.7.4






More information about the devel mailing list