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