[PATCH v3 2/8] Pinmux: Port to RTEMS

Vijay Kumar Banerjee vijaykumar9597 at gmail.com
Sat Aug 3 20:19:39 UTC 2019


---
 Makefile.todo                                 | 13 ++++++
 buildset/default.ini                          |  1 +
 libbsd.py                                     | 33 +++++++++++++++
 rtemsbsd/include/bsp/nexus-devices.h          |  1 +
 .../machine/rtems-bsd-kernel-namespace.h      |  9 +++++
 .../include/rtems/bsd/local/fdt_pinctrl_if.h  | 40 +++++++++++++++++++
 rtemsbsd/local/fdt_pinctrl_if.c               | 27 +++++++++++++
 7 files changed, 124 insertions(+)
 create mode 100644 rtemsbsd/local/fdt_pinctrl_if.c

diff --git a/Makefile.todo b/Makefile.todo
index 42bedc15..de3d0c5b 100644
--- a/Makefile.todo
+++ b/Makefile.todo
@@ -47,6 +47,8 @@ GENERATED += $(LOCAL_INC)/gpiobus_if.h
 GENERATED += $(LOCAL_SRC)/gpiobus_if.c
 GENERATED += $(LOCAL_INC)/iicbus_if.h
 GENERATED += $(LOCAL_SRC)/iicbus_if.c
+GENERATED += $(LOCAL_INC)/fdt_pinctrl_if.h
+GENERATED += $(LOCAL_SRC)/fdt_pinctrl_if.c
 GENERATED += rtemsbsd/include/machine/rtems-bsd-regdomain.h
 GENERATED += rtemsbsd/rtems/rtems-bsd-regdomain.c
 
@@ -239,6 +241,17 @@ $(LOCAL_SRC)/sdhci_if.c: $(FREEBSD_SRC)/sys/dev/sdhci/sdhci_if.m
 	    -e 's|#include "sdhci_if.h"|#include <rtems/bsd/local/sdhci_if.h>|'
 	mv sdhci_if.c $@
 
+$(LOCAL_INC)/fdt_pinctrl_if.h: $(FREEBSD_SRC)/sys/dev/fdt/fdt_pinctrl_if.m
+	awk -f $(TOOLS)/makeobjops.awk $< -h
+	mv fdt_pinctrl_if.h $@
+
+$(LOCAL_SRC)/fdt_pinctrl_if.c: $(FREEBSD_SRC)/sys/dev/fdt/fdt_pinctrl_if.m
+	awk -f $(TOOLS)/makeobjops.awk $< -c
+	sed -i fdt_pinctrl_if.c \
+	    -e '1 i\#include <machine/rtems-bsd-kernel-space.h>\n' \
+	    -e 's|#include "fdt_pinctrl_if.h"|#include <rtems/bsd/local/fdt_pinctrl_if.h>|'
+	mv fdt_pinctrl_if.c $@
+
 $(LOCAL_SRC)/gpio_if.c: $(FREEBSD_SRC)/sys/dev/gpio/gpio_if.m
 	awk -f $(TOOLS)/makeobjops.awk $< -c
 	mv gpio_if.c $@
diff --git a/buildset/default.ini b/buildset/default.ini
index 4acb2368..eabaec5f 100644
--- a/buildset/default.ini
+++ b/buildset/default.ini
@@ -37,6 +37,7 @@ dev_usb_storage = on
 dev_usb_wlan = off
 dev_wlan_rtwn = off
 iic = on
+pinmux = on
 dhcpcd = on
 dpaa = on
 evdev = on
diff --git a/libbsd.py b/libbsd.py
index 12d4c2ed..7c3d84ca 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -777,6 +777,38 @@ class iic(builder.Module):
             mm.generator['source']()
         )
 
+#
+# PINMUX
+#
+class pinmux(builder.Module):
+
+    def __init__(self, manager):
+        super(pinmux, self).__init__(manager, type(self).__name__)
+
+    def generate(self):
+        mm = self.manager
+        self.addKernelSpaceHeaderFiles(
+            [
+                'sys/arm/ti/ti_pinmux.h',
+                'sys/arm/ti/omap4/omap4_scm_padconf.h',
+                'sys/arm/ti/am335x/am335x_scm_padconf.h',
+            ]
+        )
+        self.addKernelSpaceSourceFiles(
+            [
+                'sys/arm/ti/ti_pinmux.c',
+                'sys/dev/fdt/fdt_pinctrl.c',
+                'sys/arm/ti/am335x/am335x_scm_padconf.c',
+            ],
+            mm.generator['source']()
+        )
+        self.addRTEMSSourceFiles(
+            [
+                'local/fdt_pinctrl_if.c',
+            ],
+            mm.generator['source']()
+        )
+
 #
 # USB
 #
@@ -5134,6 +5166,7 @@ def load(mm):
     mm.addModule(dev_input(mm))
     mm.addModule(evdev(mm))
     mm.addModule(iic(mm))
+    mm.addModule(pinmux(mm))
 
     mm.addModule(dev_usb(mm))
     mm.addModule(dev_usb_controller(mm))
diff --git a/rtemsbsd/include/bsp/nexus-devices.h b/rtemsbsd/include/bsp/nexus-devices.h
index 97f6d2b2..7c6ff380 100644
--- a/rtemsbsd/include/bsp/nexus-devices.h
+++ b/rtemsbsd/include/bsp/nexus-devices.h
@@ -54,6 +54,7 @@ RTEMS_BSD_DRIVER_SMC0(0x4e000000,  RVPBXA9_IRQ_ETHERNET);
 RTEMS_BSD_DEFINE_NEXUS_DEVICE(ofwbus, 0, 0, NULL);
 SYSINIT_DRIVER_REFERENCE(simplebus, ofwbus);
 SYSINIT_DRIVER_REFERENCE(ti_scm, simplebus);
+SYSINIT_DRIVER_REFERENCE(ti_pinmux, simplebus);
 SYSINIT_DRIVER_REFERENCE(am335x_prcm, simplebus);
 SYSINIT_DRIVER_REFERENCE(usbss, simplebus);
 SYSINIT_DRIVER_REFERENCE(musbotg, usbss);
diff --git a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
index 235c9886..e7bc6d6e 100644
--- a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
+++ b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
@@ -1226,6 +1226,10 @@
 #define	fdt_immr_va _bsd_fdt_immr_va
 #define	fdt_is_compatible_strict _bsd_fdt_is_compatible_strict
 #define	fdt_parent_addr_cells _bsd_fdt_parent_addr_cells
+#define	fdt_pinctrl_configure _bsd_fdt_pinctrl_configure
+#define	fdt_pinctrl_configure_by_name _bsd_fdt_pinctrl_configure_by_name
+#define	fdt_pinctrl_configure_tree _bsd_fdt_pinctrl_configure_tree
+#define	fdt_pinctrl_register _bsd_fdt_pinctrl_register
 #define	fdt_regsize _bsd_fdt_regsize
 #define	fib4_free_nh_ext _bsd_fib4_free_nh_ext
 #define	fib4_lookup_nh_basic _bsd_fib4_lookup_nh_basic
@@ -4965,6 +4969,7 @@
 #define	t_functions _bsd_t_functions
 #define	t_functions_inited _bsd_t_functions_inited
 #define	ti_am335x_clk_devmap _bsd_ti_am335x_clk_devmap
+#define	ti_am335x_pinmux_dev _bsd_ti_am335x_pinmux_dev
 #define	tick _bsd_tick
 #define	ticket_altqs_active _bsd_ticket_altqs_active
 #define	ticket_altqs_inactive _bsd_ticket_altqs_inactive
@@ -4979,6 +4984,10 @@
 #define	_timeout_task_init _bsd__timeout_task_init
 #define	timevaladd _bsd_timevaladd
 #define	timevalsub _bsd_timevalsub
+#define	ti_pinmux_padconf_get _bsd_ti_pinmux_padconf_get
+#define	ti_pinmux_padconf_get_gpiomode _bsd_ti_pinmux_padconf_get_gpiomode
+#define	ti_pinmux_padconf_set _bsd_ti_pinmux_padconf_set
+#define	ti_pinmux_padconf_set_gpiomode _bsd_ti_pinmux_padconf_set_gpiomode
 #define	ti_prcm_clk_disable _bsd_ti_prcm_clk_disable
 #define	ti_prcm_clk_enable _bsd_ti_prcm_clk_enable
 #define	ti_prcm_clk_get_source_freq _bsd_ti_prcm_clk_get_source_freq
diff --git a/rtemsbsd/include/rtems/bsd/local/fdt_pinctrl_if.h b/rtemsbsd/include/rtems/bsd/local/fdt_pinctrl_if.h
index e69de29b..6343de41 100644
--- a/rtemsbsd/include/rtems/bsd/local/fdt_pinctrl_if.h
+++ b/rtemsbsd/include/rtems/bsd/local/fdt_pinctrl_if.h
@@ -0,0 +1,40 @@
+/*
+ * This file is produced automatically.
+ * Do not modify anything in here by hand.
+ *
+ * Created from source file
+ *   freebsd-org/sys/dev/fdt/fdt_pinctrl_if.m
+ * with
+ *   makeobjops.awk
+ *
+ * See the source file for legal information
+ */
+
+
+#ifndef _fdt_pinctrl_if_h_
+#define _fdt_pinctrl_if_h_
+
+
+#include <sys/tslog.h>
+
+/** @brief Unique descriptor for the FDT_PINCTRL_CONFIGURE() method */
+extern struct kobjop_desc fdt_pinctrl_configure_desc;
+/** @brief A function implementing the FDT_PINCTRL_CONFIGURE() method */
+typedef int fdt_pinctrl_configure_t(device_t pinctrl, phandle_t cfgxref);
+
+static __inline int FDT_PINCTRL_CONFIGURE(device_t pinctrl, phandle_t cfgxref)
+{
+	kobjop_t _m;
+	int rc;
+
+TSENTER2(device_get_name(pinctrl));
+
+	KOBJOPLOOKUP(((kobj_t)pinctrl)->ops,fdt_pinctrl_configure);
+	rc = ((fdt_pinctrl_configure_t *) _m)(pinctrl, cfgxref);
+
+TSEXIT2(device_get_name(pinctrl));
+
+	return (rc);
+}
+
+#endif /* _fdt_pinctrl_if_h_ */
diff --git a/rtemsbsd/local/fdt_pinctrl_if.c b/rtemsbsd/local/fdt_pinctrl_if.c
new file mode 100644
index 00000000..9609add0
--- /dev/null
+++ b/rtemsbsd/local/fdt_pinctrl_if.c
@@ -0,0 +1,27 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
+/*
+ * This file is produced automatically.
+ * Do not modify anything in here by hand.
+ *
+ * Created from source file
+ *   freebsd-org/sys/dev/fdt/fdt_pinctrl_if.m
+ * with
+ *   makeobjops.awk
+ *
+ * See the source file for legal information
+ */
+
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/kernel.h>
+#include <sys/kobj.h>
+#include <sys/types.h>
+#include <sys/bus.h>
+#include <dev/ofw/openfirm.h>
+#include <rtems/bsd/local/fdt_pinctrl_if.h>
+
+struct kobjop_desc fdt_pinctrl_configure_desc = {
+	0, { &fdt_pinctrl_configure_desc, (kobjop_t)kobj_error_method }
+};
+
-- 
2.20.1




More information about the devel mailing list