[PATCH rtems-libbsd v2 07/14] regulator: Add to build.

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


Update #3869.
---
 Makefile.todo                                 |  26 ++++++
 buildset/default.ini                          |   1 +
 libbsd.py                                     |  30 +++++++
 rtemsbsd/include/bsp/nexus-devices.h          |   3 +
 rtemsbsd/include/rtems/bsd/local/regdev_if.h  |  36 ++++++++
 rtemsbsd/include/rtems/bsd/local/regnode_if.h | 121 ++++++++++++++++++++++++++
 rtemsbsd/local/regdev_if.c                    |  27 ++++++
 rtemsbsd/local/regnode_if.c                   |  56 ++++++++++++
 8 files changed, 300 insertions(+)
 create mode 100644 rtemsbsd/include/rtems/bsd/local/regdev_if.h
 create mode 100644 rtemsbsd/include/rtems/bsd/local/regnode_if.h
 create mode 100644 rtemsbsd/local/regdev_if.c
 create mode 100644 rtemsbsd/local/regnode_if.c

diff --git a/Makefile.todo b/Makefile.todo
index 59e630e1..a05716ef 100644
--- a/Makefile.todo
+++ b/Makefile.todo
@@ -45,6 +45,10 @@ GENERATED += $(LOCAL_INC)/sdhci_if.h
 GENERATED += $(LOCAL_SRC)/sdhci_if.c
 GENERATED += $(LOCAL_INC)/gpiobus_if.h
 GENERATED += $(LOCAL_SRC)/gpiobus_if.c
+GENERATED += $(LOCAL_INC)/regdev_if.h
+GENERATED += $(LOCAL_SRC)/regdev_if.c
+GENERATED += $(LOCAL_INC)/regnode_if.h
+GENERATED += $(LOCAL_SRC)/regnode_if.c
 GENERATED += rtemsbsd/include/machine/rtems-bsd-regdomain.h
 GENERATED += rtemsbsd/rtems/rtems-bsd-regdomain.c
 GENERATED += freebsd/contrib/libpcap/pcap_version.h
@@ -231,6 +235,28 @@ $(LOCAL_SRC)/gpio_if.c: $(FREEBSD_SRC)/sys/dev/gpio/gpio_if.m
 	awk -f $(TOOLS)/makeobjops.awk $< -c
 	mv gpio_if.c $@
 
+$(LOCAL_INC)/regnode_if.h: $(FREEBSD_SRC)/sys/dev/extres/regulator/regnode_if.m
+	awk -f $(TOOLS)/makeobjops.awk $< -h
+	mv regnode_if.h $@
+
+$(LOCAL_SRC)/regnode_if.c: $(FREEBSD_SRC)/sys/dev/extres/regulator/regnode_if.m
+	awk -f $(TOOLS)/makeobjops.awk $< -c
+	sed -i regnode_if.c \
+	    -e '1 i\#include <machine/rtems-bsd-kernel-space.h>\n' \
+	    -e 's|#include "regnode_if.h"|#include <rtems/bsd/local/regnode_if.h>|'
+	mv regnode_if.c $@
+
+$(LOCAL_INC)/regdev_if.h: $(FREEBSD_SRC)/sys/dev/extres/regulator/regdev_if.m
+	awk -f $(TOOLS)/makeobjops.awk $< -h
+	mv regdev_if.h $@
+
+$(LOCAL_SRC)/regdev_if.c: $(FREEBSD_SRC)/sys/dev/extres/regulator/regdev_if.m
+	awk -f $(TOOLS)/makeobjops.awk $< -c
+	sed -i regdev_if.c \
+	    -e '1 i\#include <machine/rtems-bsd-kernel-space.h>\n' \
+	    -e 's|#include "regdev_if.h"|#include <rtems/bsd/local/regdev_if.h>|'
+	mv regdev_if.c $@
+
 $(LOCAL_SRC)/rtwn-rtl8192cfwT.c: $(FREEBSD_SRC)/sys/contrib/dev/rtwn/rtwn-rtl8192cfwT.fw.uu
 	uudecode -o /dev/stdout $< | python firmware-gen.py \
 	    -l "$(FREEBSD_SRC)/sys/contrib/dev/rtwn/LICENSE" \
diff --git a/buildset/default.ini b/buildset/default.ini
index ac8c9c48..b17f2b59 100644
--- a/buildset/default.ini
+++ b/buildset/default.ini
@@ -54,6 +54,7 @@ nvme = on
 opencrypto = on
 pci = on
 pf = on
+regulator = on
 rtems = on
 tests = on
 tty = on
diff --git a/libbsd.py b/libbsd.py
index e0690601..4f8fb4d2 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -5032,6 +5032,35 @@ class imx(builder.Module):
             mm.generator['source']()
         )
 
+class regulator(builder.Module):
+    def __init__(self, manager):
+        super(regulator, self).__init__(manager, type(self).__name__)
+
+    def generate(self):
+        mm = self.manager
+        self.addRTEMSSourceFiles(
+            [
+                'local/regdev_if.c',
+                'local/regnode_if.c',
+            ],
+            mm.generator['source']()
+        )
+        self.addKernelSpaceHeaderFiles(
+            [
+                'sys/dev/extres/regulator/regulator.h',
+                'sys/dev/extres/regulator/regulator_fixed.h',
+            ]
+        )
+        self.addKernelSpaceSourceFiles(
+            [
+                'sys/dev/extres/regulator/regulator.c',
+                'sys/dev/extres/regulator/regulator_bus.c',
+                'sys/dev/extres/regulator/regulator_fixed.c',
+                'sys/dev/gpio/gpioregulator.c',
+            ],
+            mm.generator['source']()
+        )
+
 #
 # Tests
 #
@@ -5189,6 +5218,7 @@ def load(mm):
 
     mm.addModule(nvme(mm))
     mm.addModule(imx(mm))
+    mm.addModule(regulator(mm))
 
     # Add in_chksum
     mm.addModule(in_cksum(mm))
diff --git a/rtemsbsd/include/bsp/nexus-devices.h b/rtemsbsd/include/bsp/nexus-devices.h
index 92665409..0a210bd9 100644
--- a/rtemsbsd/include/bsp/nexus-devices.h
+++ b/rtemsbsd/include/bsp/nexus-devices.h
@@ -136,6 +136,9 @@ SYSINIT_DRIVER_REFERENCE(imx51_gpio, simplebus);
 SYSINIT_DRIVER_REFERENCE(sdhci_fsl, simplebus);
 RTEMS_BSD_DRIVER_MMC;
 
+SYSINIT_DRIVER_REFERENCE(ofw_regulator_bus, simplebus);
+SYSINIT_DRIVER_REFERENCE(gpioregulator, simplebus);
+
 #elif defined(LIBBSP_ARM_LPC24XX_BSP_H)
 
 RTEMS_BSD_DEFINE_NEXUS_DEVICE(ohci, 0, 0, NULL);
diff --git a/rtemsbsd/include/rtems/bsd/local/regdev_if.h b/rtemsbsd/include/rtems/bsd/local/regdev_if.h
new file mode 100644
index 00000000..4a75810f
--- /dev/null
+++ b/rtemsbsd/include/rtems/bsd/local/regdev_if.h
@@ -0,0 +1,36 @@
+/*
+ * This file is produced automatically.
+ * Do not modify anything in here by hand.
+ *
+ * Created from source file
+ *   freebsd-org/sys/dev/extres/regulator/regdev_if.m
+ * with
+ *   makeobjops.awk
+ *
+ * See the source file for legal information
+ */
+
+
+#ifndef _regdev_if_h_
+#define _regdev_if_h_
+
+
+int regdev_default_ofw_map(device_t , phandle_t, int, pcell_t *, intptr_t *);
+
+/** @brief Unique descriptor for the REGDEV_MAP() method */
+extern struct kobjop_desc regdev_map_desc;
+/** @brief A function implementing the REGDEV_MAP() method */
+typedef int regdev_map_t(device_t provider_dev, phandle_t xref, int ncells,
+                         pcell_t *cells, intptr_t *id);
+
+static __inline int REGDEV_MAP(device_t provider_dev, phandle_t xref,
+                               int ncells, pcell_t *cells, intptr_t *id)
+{
+	kobjop_t _m;
+	int rc;
+	KOBJOPLOOKUP(((kobj_t)provider_dev)->ops,regdev_map);
+	rc = ((regdev_map_t *) _m)(provider_dev, xref, ncells, cells, id);
+	return (rc);
+}
+
+#endif /* _regdev_if_h_ */
diff --git a/rtemsbsd/include/rtems/bsd/local/regnode_if.h b/rtemsbsd/include/rtems/bsd/local/regnode_if.h
new file mode 100644
index 00000000..225af442
--- /dev/null
+++ b/rtemsbsd/include/rtems/bsd/local/regnode_if.h
@@ -0,0 +1,121 @@
+/*
+ * This file is produced automatically.
+ * Do not modify anything in here by hand.
+ *
+ * Created from source file
+ *   freebsd-org/sys/dev/extres/regulator/regnode_if.m
+ * with
+ *   makeobjops.awk
+ *
+ * See the source file for legal information
+ */
+
+
+#ifndef _regnode_if_h_
+#define _regnode_if_h_
+
+
+struct regnode;
+
+/** @brief Unique descriptor for the REGNODE_INIT() method */
+extern struct kobjop_desc regnode_init_desc;
+/** @brief A function implementing the REGNODE_INIT() method */
+typedef int regnode_init_t(struct regnode *regnode);
+
+static __inline int REGNODE_INIT(struct regnode *regnode)
+{
+	kobjop_t _m;
+	int rc;
+	KOBJOPLOOKUP(((kobj_t)regnode)->ops,regnode_init);
+	rc = ((regnode_init_t *) _m)(regnode);
+	return (rc);
+}
+
+/** @brief Unique descriptor for the REGNODE_ENABLE() method */
+extern struct kobjop_desc regnode_enable_desc;
+/** @brief A function implementing the REGNODE_ENABLE() method */
+typedef int regnode_enable_t(struct regnode *regnode, bool enable, int *udelay);
+
+static __inline int REGNODE_ENABLE(struct regnode *regnode, bool enable,
+                                   int *udelay)
+{
+	kobjop_t _m;
+	int rc;
+	KOBJOPLOOKUP(((kobj_t)regnode)->ops,regnode_enable);
+	rc = ((regnode_enable_t *) _m)(regnode, enable, udelay);
+	return (rc);
+}
+
+/** @brief Unique descriptor for the REGNODE_STATUS() method */
+extern struct kobjop_desc regnode_status_desc;
+/** @brief A function implementing the REGNODE_STATUS() method */
+typedef int regnode_status_t(struct regnode *regnode, int *status);
+
+static __inline int REGNODE_STATUS(struct regnode *regnode, int *status)
+{
+	kobjop_t _m;
+	int rc;
+	KOBJOPLOOKUP(((kobj_t)regnode)->ops,regnode_status);
+	rc = ((regnode_status_t *) _m)(regnode, status);
+	return (rc);
+}
+
+/** @brief Unique descriptor for the REGNODE_SET_VOLTAGE() method */
+extern struct kobjop_desc regnode_set_voltage_desc;
+/** @brief A function implementing the REGNODE_SET_VOLTAGE() method */
+typedef int regnode_set_voltage_t(struct regnode *regnode, int min_uvolt,
+                                  int max_uvolt, int *udelay);
+
+static __inline int REGNODE_SET_VOLTAGE(struct regnode *regnode, int min_uvolt,
+                                        int max_uvolt, int *udelay)
+{
+	kobjop_t _m;
+	int rc;
+	KOBJOPLOOKUP(((kobj_t)regnode)->ops,regnode_set_voltage);
+	rc = ((regnode_set_voltage_t *) _m)(regnode, min_uvolt, max_uvolt, udelay);
+	return (rc);
+}
+
+/** @brief Unique descriptor for the REGNODE_GET_VOLTAGE() method */
+extern struct kobjop_desc regnode_get_voltage_desc;
+/** @brief A function implementing the REGNODE_GET_VOLTAGE() method */
+typedef int regnode_get_voltage_t(struct regnode *regnode, int *uvolt);
+
+static __inline int REGNODE_GET_VOLTAGE(struct regnode *regnode, int *uvolt)
+{
+	kobjop_t _m;
+	int rc;
+	KOBJOPLOOKUP(((kobj_t)regnode)->ops,regnode_get_voltage);
+	rc = ((regnode_get_voltage_t *) _m)(regnode, uvolt);
+	return (rc);
+}
+
+/** @brief Unique descriptor for the REGNODE_CHECK_VOLTAGE() method */
+extern struct kobjop_desc regnode_check_voltage_desc;
+/** @brief A function implementing the REGNODE_CHECK_VOLTAGE() method */
+typedef int regnode_check_voltage_t(struct regnode *regnode, int uvolt);
+
+static __inline int REGNODE_CHECK_VOLTAGE(struct regnode *regnode, int uvolt)
+{
+	kobjop_t _m;
+	int rc;
+	KOBJOPLOOKUP(((kobj_t)regnode)->ops,regnode_check_voltage);
+	rc = ((regnode_check_voltage_t *) _m)(regnode, uvolt);
+	return (rc);
+}
+
+/** @brief Unique descriptor for the REGNODE_STOP() method */
+extern struct kobjop_desc regnode_stop_desc;
+/** @brief A function implementing the REGNODE_STOP() method */
+typedef int regnode_stop_t(struct regnode *regnode, int *udelay);
+
+static __inline int REGNODE_STOP(struct regnode *regnode, int *udelay)
+{
+	kobjop_t _m;
+	int rc;
+	KOBJOPLOOKUP(((kobj_t)regnode)->ops,regnode_stop);
+	rc = ((regnode_stop_t *) _m)(regnode, udelay);
+	return (rc);
+}
+
+#endif /* _regnode_if_h_ */
diff --git a/rtemsbsd/local/regdev_if.c b/rtemsbsd/local/regdev_if.c
new file mode 100644
index 00000000..8ca156a6
--- /dev/null
+++ b/rtemsbsd/local/regdev_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/extres/regulator/regdev_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 <dev/ofw/ofw_bus.h>
+#include <machine/bus.h>
+#include <rtems/bsd/local/regdev_if.h>
+
+struct kobjop_desc regdev_map_desc = {
+	0, { &regdev_map_desc, (kobjop_t)regdev_default_ofw_map }
+};
+
diff --git a/rtemsbsd/local/regnode_if.c b/rtemsbsd/local/regnode_if.c
new file mode 100644
index 00000000..ea2c2497
--- /dev/null
+++ b/rtemsbsd/local/regnode_if.c
@@ -0,0 +1,56 @@
+#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/extres/regulator/regnode_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 <rtems/bsd/local/regnode_if.h>
+
+
+static int
+regnode_default_stop(struct regnode *regnode, int *udelay)
+{
+
+	return(REGNODE_ENABLE(regnode, false, udelay));
+}
+
+struct kobjop_desc regnode_init_desc = {
+	0, { &regnode_init_desc, (kobjop_t)kobj_error_method }
+};
+
+struct kobjop_desc regnode_enable_desc = {
+	0, { &regnode_enable_desc, (kobjop_t)kobj_error_method }
+};
+
+struct kobjop_desc regnode_status_desc = {
+	0, { &regnode_status_desc, (kobjop_t)kobj_error_method }
+};
+
+struct kobjop_desc regnode_set_voltage_desc = {
+	0, { &regnode_set_voltage_desc, (kobjop_t)kobj_error_method }
+};
+
+struct kobjop_desc regnode_get_voltage_desc = {
+	0, { &regnode_get_voltage_desc, (kobjop_t)kobj_error_method }
+};
+
+struct kobjop_desc regnode_check_voltage_desc = {
+	0, { &regnode_check_voltage_desc, (kobjop_t)kobj_error_method }
+};
+
+struct kobjop_desc regnode_stop_desc = {
+	0, { &regnode_stop_desc, (kobjop_t)regnode_default_stop }
+};
+
-- 
2.16.4



More information about the devel mailing list