From WRTnode Wiki
Jump to: navigation, search

I2C configuration

make menuconfig 
Kernel modules  --->   I2C support  --->  <*> kmod-i2c-gpio-custom.



This patch is in order to solve the problem after the uninstall driver can not be loaded again.(if not loaded again, can be ignored)

--- a/package/kernel/i2c-gpio-custom/src/i2c-gpio-custom.c	2014-07-01 11:30:31.149861607 +0000
+++ b/package/kernel/i2c-gpio-custom/src/i2c-gpio-custom.c	2015-07-28 08:15:20.000000000 +0000
@@ -96,7 +96,7 @@
static void i2c_gpio_custom_cleanup(void)
    int i;
    for (i = 0; i < nr_devices; i++)
        if (devices[i])
-           platform_device_put(devices[i]);
+           platform_device_unregister(devices[i]);
 static int __init i2c_gpio_custom_add_one(unsigned int id, unsigned int *params)

Release pins register

The default WRTNODE.dts:gpio#1 is used as the reset button.
But here I would like to use gpio#1 and gpio#2 as the I2C pin, all the need to remove the gpio#1 registration.

vim WRTNODE.dts 
  gpio-keys-polled {
         compatible = "gpio-keys-polled";
         #address-cells = <1>;
         #size-cells = <0>;
         poll-interval = <20>;
         reset {
             label = "reset";
             gpios = <&gpio0 1 1>;
             linux,code = <0x198>;

Compile & flash firmware

Please refer to 如何刷新WRTnode的固件

loading the module

After compiling the firmware, enter the system, need to load the corresponding module to load the I2C equipment, the use of the command:

insmod i2c-dev
  1. If it is the WRTnode1 series of the board, please use the
insmod i2c-gpio-custom bus0=0,1,2  
  1. If it is the WRTnode2 series of the board, please use the
insmod i2c-gpio-custom bus0=0,5,4
  1. GPIO detailed information, please refer to GPIO资源

The order of parameters i2c-gpio-custom for: busx=<id>,<sda>,<scl> (x to 0~3, said a total of more than 4 can control the i2c-gpio controller) <id> ID to used as device_id for the corresponding bus (required)
<sda> GPIO pin ID to used for SDA (required)
<scl> GPIO pin ID to used for SCL (required)

$cd /dev