This patch adds the BitBangedI2c kernel module parameter, which allows
to expose bit-banged i2c buses to the operating system. This is necessary
for custom board designs based on igb-supported chips that wish to
make use of the available i2c pins.

Signed-off-by: Jean-Hugues Deschenes <jean-hugues.desche...@octasic.com>
Index: igb-5.2.9.4/src/igb.h
===================================================================
--- igb-5.2.9.4.orig/src/igb.h  2014-12-11 11:48:34.820033342 -0500
+++ igb-5.2.9.4/src/igb.h       2014-12-19 10:20:50.335856480 -0500
@@ -601,6 +601,8 @@
        unsigned int vfs_allocated_count;
        /* Malicious Driver Detection flag. Valid only when SR-IOV is enabled */
        bool mdd;
+       /* Flag for unconditionally exposing the SFP pins as I2C bus (not just 
i350) */
+       uint i2cbb;
        int int_mode;
        u32 rss_queues;
        u32 tss_queues;
Index: igb-5.2.9.4/src/igb_main.c
===================================================================
--- igb-5.2.9.4.orig/src/igb_main.c     2014-12-11 11:49:06.268034458 -0500
+++ igb-5.2.9.4/src/igb_main.c  2014-12-11 11:49:23.368035065 -0500
@@ -1725,8 +1725,8 @@
 {
        s32 status = E1000_SUCCESS;
 
-       /* I2C interface supported on i350 devices */
-       if (adapter->hw.mac.type != e1000_i350)
+       /* I2C interface supported on i350 devices (unless forced) */
+       if (adapter->hw.mac.type != e1000_i350 && !adapter->i2cbb)
                return E1000_SUCCESS;
 
        /* Initialize the i2c bus which is controlled by the registers.
@@ -2032,7 +2032,9 @@
 
        igb_init_dmac(adapter, pba);
        /* Re-initialize the thermal sensor on i350 devices. */
-       if (mac->type == e1000_i350 && hw->bus.func == 0) {
+       if (adapter->i2cbb)
+               e1000_set_i2c_bb(hw);
+       else if (mac->type == e1000_i350 && hw->bus.func == 0) {
                /*
                 * If present, re-initialize the external thermal sensor
                 * interface.
Index: igb-5.2.9.4/src/igb_param.c
===================================================================
--- igb-5.2.9.4.orig/src/igb_param.c    2014-12-11 11:48:34.796033341 -0500
+++ igb-5.2.9.4/src/igb_param.c 2014-12-19 10:23:23.675856396 -0500
@@ -178,6 +178,19 @@
 IGB_PARAM(MDD,
        "Malicious Driver Detection (0/1), default 1 = enabled. Only available 
when max_vfs is greater than 0");
 
+#ifdef HAVE_I2C_SUPPORT
+/* BitBangedI2c (Enable bit-banged i2c bus)
+ *
+ * Always enabled on i350.
+ *
+ * Valid Range: 0, 1
+ *
+ * Default Value:  0
+ */
+IGB_PARAM(BitBangedI2c,
+       "Bit-banged i2c busses (0/1), default 0 = disabled. Always enabled on 
i350.");
+#endif /* HAVE_I2C_SUPPORT */
+
 #ifdef DEBUG
 
 /* Disable Hardware Reset on Tx Hang
@@ -868,5 +881,29 @@
                }
 #endif
        }
+#ifdef HAVE_I2C_SUPPORT
+       { /* BitBangedI2c - Enable bit-banged i2c bus support. */
+               struct igb_option opt = {
+                       .type = enable_option,
+                       .name = "Bit-banged i2c",
+                       .err  = "defaulting to 0",
+                       .def  = OPTION_DISABLED,
+                       .arg  = { .r = { .min = OPTION_DISABLED,
+                                        .max = OPTION_ENABLED } }
+               };
+
+#ifdef module_param_array
+               if (num_BitBangedI2c > bd) {
+#endif
+                       adapter->i2cbb = BitBangedI2c[bd];
+                       igb_validate_option((uint *)&adapter->i2cbb, &opt,
+                                           adapter);
+#ifdef module_param_array
+               } else {
+                       adapter->i2cbb = opt.def;
+               }
+#endif
+       }
+#endif /* HAVE_I2C_SUPPORT */
 }
 


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel&#174; Ethernet, visit 
http://communities.intel.com/community/wired

Reply via email to