[PATCH v2 2/5] iicbus: port to RTEMS
Vijay Kumar Banerjee
vijaykumar9597 at gmail.com
Sat Jun 8 12:49:54 UTC 2019
---
Makefile.todo | 11 ++
buildset/default.ini | 1 +
libbsd.py | 35 ++++
rtemsbsd/include/bsp/nexus-devices.h | 4 +
.../machine/rtems-bsd-kernel-namespace.h | 29 +++
rtemsbsd/include/rtems/bsd/local/iicbus_if.h | 166 ++++++++++++++++++
rtemsbsd/local/iicbus_if.c | 76 ++++++++
7 files changed, 322 insertions(+)
create mode 100644 rtemsbsd/include/rtems/bsd/local/iicbus_if.h
create mode 100644 rtemsbsd/local/iicbus_if.c
diff --git a/Makefile.todo b/Makefile.todo
index 9754ddb6..74188531 100644
--- a/Makefile.todo
+++ b/Makefile.todo
@@ -215,6 +215,17 @@ $(LOCAL_SRC)/gpiobus_if.c: $(FREEBSD_SRC)/sys/dev/gpio/gpiobus_if.m
-e 's|#include "gpiobus_if.h"|#include <rtems/bsd/local/gpiobus_if.h>|'
mv gpiobus_if.c $@
+$(LOCAL_INC)/iicbus_if.h: $(FREEBSD_SRC)/sys/dev/iicbus/iicbus_if.m
+ awk -f $(TOOLS)/makeobjops.awk $< -h
+ mv iicbus_if.h $@
+
+$(LOCAL_SRC)/iicbus_if.c: $(FREEBSD_SRC)/sys/dev/iicbus/iicbus_if.m
+ awk -f $(TOOLS)/makeobjops.awk $< -c
+ sed -i iicbus_if.c \
+ -e '1 i\#include <machine/rtems-bsd-kernel-space.h>\n' \
+ -e 's|#include "iicbus_if.h"|#include <rtems/bsd/local/iicbus_if.h>|'
+ mv iicbus_if.c $@
+
$(LOCAL_INC)/sdhci_if.h: $(FREEBSD_SRC)/sys/dev/sdhci/sdhci_if.m
awk -f $(TOOLS)/makeobjops.awk $< -h
mv sdhci_if.h $@
diff --git a/buildset/default.ini b/buildset/default.ini
index f25fe9a3..4acb2368 100644
--- a/buildset/default.ini
+++ b/buildset/default.ini
@@ -36,6 +36,7 @@ dev_usb_serial = on
dev_usb_storage = on
dev_usb_wlan = off
dev_wlan_rtwn = off
+iic = on
dhcpcd = on
dpaa = on
evdev = on
diff --git a/libbsd.py b/libbsd.py
index d99e3ad8..a25d3a8a 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -125,6 +125,7 @@ _defaults = {
('freebsd/sys/sys', '**/*.h', 'sys'),
('freebsd/sys/vm', '**/*.h', 'vm'),
('freebsd/sys/dev/mii', '**/*.h', 'dev/mii'),
+ ('freebsd/sys/dev/iicbus', '**/*.h', 'dev/iicbus'),
('linux/include', '**/*.h', ''),
('mDNSResponder/mDNSCore', 'mDNSDebug.h', ''),
('mDNSResponder/mDNSCore', 'mDNSEmbeddedAPI.h', ''),
@@ -741,6 +742,39 @@ class evdev(builder.Module):
mm.generator['source']()
)
+#
+# IIC
+#
+class iic(builder.Module):
+
+ def __init__(self, manager):
+ super(iic, self).__init__(manager, type(self).__name__)
+
+ def generate(self):
+ mm = self.manager
+ self.addKernelSpaceHeaderFiles(
+ [
+ 'sys/dev/iicbus/iicbus.h',
+ 'sys/dev/iicbus/iic.h',
+ 'sys/dev/iicbus/iiconf.h',
+ ]
+ )
+ self.addKernelSpaceSourceFiles(
+ [
+ 'sys/dev/iicbus/iic.c',
+ 'sys/dev/iicbus/iicbus.c',
+ 'sys/dev/iicbus/iiconf.c',
+ 'sys/dev/iicbus/ofw_iicbus.c',
+ ],
+ mm.generator['source']()
+ )
+ self.addRTEMSSourceFiles(
+ [
+ 'local/iicbus_if.c',
+ ],
+ mm.generator['source']()
+ )
+
#
# USB
#
@@ -5096,6 +5130,7 @@ def load(mm):
mm.addModule(mmc_ti(mm))
mm.addModule(dev_input(mm))
mm.addModule(evdev(mm))
+ mm.addModule(iic(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 a916c664..97f6d2b2 100644
--- a/rtemsbsd/include/bsp/nexus-devices.h
+++ b/rtemsbsd/include/bsp/nexus-devices.h
@@ -61,6 +61,10 @@ SYSINIT_DRIVER_REFERENCE(sdhci_ti, simplebus);
SYSINIT_DRIVER_REFERENCE(mmcsd, mmc);
SYSINIT_DRIVER_REFERENCE(cpsw, cpswss);
SYSINIT_DRIVER_REFERENCE(ukphy, miibus);
+SYSINIT_DRIVER_REFERENCE(rtems_i2c, simplebus);
+SYSINIT_DRIVER_REFERENCE(ofw_iicbus, rtems_i2c);
+SYSINIT_DRIVER_REFERENCE(iic, iicbus);
+SYSINIT_DRIVER_REFERENCE(iicbus, rtems_i2c);
#ifdef RTEMS_BSD_MODULE_NET80211
SYSINIT_DRIVER_REFERENCE(rtwn_usb, uhub);
SYSINIT_MODULE_REFERENCE(wlan_ratectl_none);
diff --git a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
index 83c4366a..235c9886 100644
--- a/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
+++ b/rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h
@@ -1989,6 +1989,33 @@
#define igmp_input _bsd_igmp_input
#define igmp_mtx _bsd_igmp_mtx
#define igmp_slowtimo _bsd_igmp_slowtimo
+#define iic2errno _bsd_iic2errno
+#define iicbb_devclass _bsd_iicbb_devclass
+#define iicbb_driver _bsd_iicbb_driver
+#define iicbus_block_read _bsd_iicbus_block_read
+#define iicbus_block_write _bsd_iicbus_block_write
+#define iicbus_devclass _bsd_iicbus_devclass
+#define iicbus_driver _bsd_iicbus_driver
+#define iicbus_generic_intr _bsd_iicbus_generic_intr
+#define iicbus_init_frequency _bsd_iicbus_init_frequency
+#define iicbus_intr _bsd_iicbus_intr
+#define iicbus_null_callback _bsd_iicbus_null_callback
+#define iicbus_null_repeated_start _bsd_iicbus_null_repeated_start
+#define iicbus_read _bsd_iicbus_read
+#define iicbus_read_byte _bsd_iicbus_read_byte
+#define iicbus_release_bus _bsd_iicbus_release_bus
+#define iicbus_repeated_start _bsd_iicbus_repeated_start
+#define iicbus_request_bus _bsd_iicbus_request_bus
+#define iicbus_start _bsd_iicbus_start
+#define iicbus_started _bsd_iicbus_started
+#define iicbus_stop _bsd_iicbus_stop
+#define iicbus_transfer _bsd_iicbus_transfer
+#define iicbus_transfer_excl _bsd_iicbus_transfer_excl
+#define iicbus_transfer_gen _bsd_iicbus_transfer_gen
+#define iicbus_write _bsd_iicbus_write
+#define iicbus_write_byte _bsd_iicbus_write_byte
+#define iicdev_readfrom _bsd_iicdev_readfrom
+#define iicdev_writeto _bsd_iicdev_writeto
#define im6o_mc_filter _bsd_im6o_mc_filter
#define imo_multi_filter _bsd_imo_multi_filter
#define in4_cksum _bsd_in4_cksum
@@ -3021,6 +3048,8 @@
#define ofw_gpiobus_parse_gpios _bsd_ofw_gpiobus_parse_gpios
#define ofw_gpiobus_register_provider _bsd_ofw_gpiobus_register_provider
#define ofw_gpiobus_unregister_provider _bsd_ofw_gpiobus_unregister_provider
+#define ofw_iicbus_devclass _bsd_ofw_iicbus_devclass
+#define ofw_iicbus_driver _bsd_ofw_iicbus_driver
#define ofw_parse_bootargs _bsd_ofw_parse_bootargs
#define ofw_reg_to_paddr _bsd_ofw_reg_to_paddr
#define OF_write _bsd_OF_write
diff --git a/rtemsbsd/include/rtems/bsd/local/iicbus_if.h b/rtemsbsd/include/rtems/bsd/local/iicbus_if.h
new file mode 100644
index 00000000..7fafbb60
--- /dev/null
+++ b/rtemsbsd/include/rtems/bsd/local/iicbus_if.h
@@ -0,0 +1,166 @@
+/*
+ * This file is produced automatically.
+ * Do not modify anything in here by hand.
+ *
+ * Created from source file
+ * freebsd-org/sys/dev/iicbus/iicbus_if.m
+ * with
+ * makeobjops.awk
+ *
+ * See the source file for legal information
+ */
+
+
+#ifndef _iicbus_if_h_
+#define _iicbus_if_h_
+
+/** @brief Unique descriptor for the IICBUS_INTR() method */
+extern struct kobjop_desc iicbus_intr_desc;
+/** @brief A function implementing the IICBUS_INTR() method */
+typedef int iicbus_intr_t(device_t dev, int event, char *buf);
+
+static __inline int IICBUS_INTR(device_t dev, int event, char *buf)
+{
+ kobjop_t _m;
+ int rc;
+ KOBJOPLOOKUP(((kobj_t)dev)->ops,iicbus_intr);
+ rc = ((iicbus_intr_t *) _m)(dev, event, buf);
+ return (rc);
+}
+
+/** @brief Unique descriptor for the IICBUS_CALLBACK() method */
+extern struct kobjop_desc iicbus_callback_desc;
+/** @brief A function implementing the IICBUS_CALLBACK() method */
+typedef int iicbus_callback_t(device_t dev, int index, caddr_t data);
+
+static __inline int IICBUS_CALLBACK(device_t dev, int index, caddr_t data)
+{
+ kobjop_t _m;
+ int rc;
+ KOBJOPLOOKUP(((kobj_t)dev)->ops,iicbus_callback);
+ rc = ((iicbus_callback_t *) _m)(dev, index, data);
+ return (rc);
+}
+
+/** @brief Unique descriptor for the IICBUS_REPEATED_START() method */
+extern struct kobjop_desc iicbus_repeated_start_desc;
+/** @brief A function implementing the IICBUS_REPEATED_START() method */
+typedef int iicbus_repeated_start_t(device_t dev, u_char slave, int timeout);
+
+static __inline int IICBUS_REPEATED_START(device_t dev, u_char slave,
+ int timeout)
+{
+ kobjop_t _m;
+ int rc;
+ KOBJOPLOOKUP(((kobj_t)dev)->ops,iicbus_repeated_start);
+ rc = ((iicbus_repeated_start_t *) _m)(dev, slave, timeout);
+ return (rc);
+}
+
+/** @brief Unique descriptor for the IICBUS_START() method */
+extern struct kobjop_desc iicbus_start_desc;
+/** @brief A function implementing the IICBUS_START() method */
+typedef int iicbus_start_t(device_t dev, u_char slave, int timeout);
+
+static __inline int IICBUS_START(device_t dev, u_char slave, int timeout)
+{
+ kobjop_t _m;
+ int rc;
+ KOBJOPLOOKUP(((kobj_t)dev)->ops,iicbus_start);
+ rc = ((iicbus_start_t *) _m)(dev, slave, timeout);
+ return (rc);
+}
+
+/** @brief Unique descriptor for the IICBUS_STOP() method */
+extern struct kobjop_desc iicbus_stop_desc;
+/** @brief A function implementing the IICBUS_STOP() method */
+typedef int iicbus_stop_t(device_t dev);
+
+static __inline int IICBUS_STOP(device_t dev)
+{
+ kobjop_t _m;
+ int rc;
+ KOBJOPLOOKUP(((kobj_t)dev)->ops,iicbus_stop);
+ rc = ((iicbus_stop_t *) _m)(dev);
+ return (rc);
+}
+
+/** @brief Unique descriptor for the IICBUS_READ() method */
+extern struct kobjop_desc iicbus_read_desc;
+/** @brief A function implementing the IICBUS_READ() method */
+typedef int iicbus_read_t(device_t dev, char *buf, int len, int *bytes,
+ int last, int delay);
+
+static __inline int IICBUS_READ(device_t dev, char *buf, int len, int *bytes,
+ int last, int delay)
+{
+ kobjop_t _m;
+ int rc;
+ KOBJOPLOOKUP(((kobj_t)dev)->ops,iicbus_read);
+ rc = ((iicbus_read_t *) _m)(dev, buf, len, bytes, last, delay);
+ return (rc);
+}
+
+/** @brief Unique descriptor for the IICBUS_WRITE() method */
+extern struct kobjop_desc iicbus_write_desc;
+/** @brief A function implementing the IICBUS_WRITE() method */
+typedef int iicbus_write_t(device_t dev, const char *buf, int len, int *bytes,
+ int timeout);
+
+static __inline int IICBUS_WRITE(device_t dev, const char *buf, int len,
+ int *bytes, int timeout)
+{
+ kobjop_t _m;
+ int rc;
+ KOBJOPLOOKUP(((kobj_t)dev)->ops,iicbus_write);
+ rc = ((iicbus_write_t *) _m)(dev, buf, len, bytes, timeout);
+ return (rc);
+}
+
+/** @brief Unique descriptor for the IICBUS_RESET() method */
+extern struct kobjop_desc iicbus_reset_desc;
+/** @brief A function implementing the IICBUS_RESET() method */
+typedef int iicbus_reset_t(device_t dev, u_char speed, u_char addr,
+ u_char *oldaddr);
+
+static __inline int IICBUS_RESET(device_t dev, u_char speed, u_char addr,
+ u_char *oldaddr)
+{
+ kobjop_t _m;
+ int rc;
+ KOBJOPLOOKUP(((kobj_t)dev)->ops,iicbus_reset);
+ rc = ((iicbus_reset_t *) _m)(dev, speed, addr, oldaddr);
+ return (rc);
+}
+
+/** @brief Unique descriptor for the IICBUS_TRANSFER() method */
+extern struct kobjop_desc iicbus_transfer_desc;
+/** @brief A function implementing the IICBUS_TRANSFER() method */
+typedef int iicbus_transfer_t(device_t dev, struct iic_msg *msgs,
+ uint32_t nmsgs);
+
+static __inline int IICBUS_TRANSFER(device_t dev, struct iic_msg *msgs,
+ uint32_t nmsgs)
+{
+ kobjop_t _m;
+ int rc;
+ KOBJOPLOOKUP(((kobj_t)dev)->ops,iicbus_transfer);
+ rc = ((iicbus_transfer_t *) _m)(dev, msgs, nmsgs);
+ return (rc);
+}
+
+/** @brief Unique descriptor for the IICBUS_GET_FREQUENCY() method */
+extern struct kobjop_desc iicbus_get_frequency_desc;
+/** @brief A function implementing the IICBUS_GET_FREQUENCY() method */
+typedef u_int iicbus_get_frequency_t(device_t dev, u_char speed);
+
+static __inline u_int IICBUS_GET_FREQUENCY(device_t dev, u_char speed)
+{
+ kobjop_t _m;
+ u_int rc;
+ KOBJOPLOOKUP(((kobj_t)dev)->ops,iicbus_get_frequency);
+ rc = ((iicbus_get_frequency_t *) _m)(dev, speed);
+ return (rc);
+}
+
+#endif /* _iicbus_if_h_ */
diff --git a/rtemsbsd/local/iicbus_if.c b/rtemsbsd/local/iicbus_if.c
new file mode 100644
index 00000000..68099c34
--- /dev/null
+++ b/rtemsbsd/local/iicbus_if.c
@@ -0,0 +1,76 @@
+#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/iicbus/iicbus_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/bus.h>
+#include <dev/iicbus/iic.h>
+#include <rtems/bsd/local/iicbus_if.h>
+
+
+static int iicbus_nosupport(void)
+{
+
+ return (ENODEV);
+}
+
+static u_int
+iicbus_default_frequency(device_t bus, u_char speed)
+{
+
+ return (100000);
+}
+
+struct kobjop_desc iicbus_intr_desc = {
+ 0, { &iicbus_intr_desc, (kobjop_t)kobj_error_method }
+};
+
+struct kobjop_desc iicbus_callback_desc = {
+ 0, { &iicbus_callback_desc, (kobjop_t)kobj_error_method }
+};
+
+struct kobjop_desc iicbus_repeated_start_desc = {
+ 0, { &iicbus_repeated_start_desc, (kobjop_t)iicbus_nosupport }
+};
+
+struct kobjop_desc iicbus_start_desc = {
+ 0, { &iicbus_start_desc, (kobjop_t)iicbus_nosupport }
+};
+
+struct kobjop_desc iicbus_stop_desc = {
+ 0, { &iicbus_stop_desc, (kobjop_t)iicbus_nosupport }
+};
+
+struct kobjop_desc iicbus_read_desc = {
+ 0, { &iicbus_read_desc, (kobjop_t)iicbus_nosupport }
+};
+
+struct kobjop_desc iicbus_write_desc = {
+ 0, { &iicbus_write_desc, (kobjop_t)iicbus_nosupport }
+};
+
+struct kobjop_desc iicbus_reset_desc = {
+ 0, { &iicbus_reset_desc, (kobjop_t)kobj_error_method }
+};
+
+struct kobjop_desc iicbus_transfer_desc = {
+ 0, { &iicbus_transfer_desc, (kobjop_t)kobj_error_method }
+};
+
+struct kobjop_desc iicbus_get_frequency_desc = {
+ 0, { &iicbus_get_frequency_desc, (kobjop_t)iicbus_default_frequency }
+};
+
--
2.20.1
More information about the devel
mailing list