WRTnode add i2c-gpio support

From WRTnode Wiki Site
Jump to: navigation, search
This page contains changes which are not marked for translation.

Other languages:
English 100% • ‎中文(中国大陆)‎ 100%

Mt7620n i2c driver stability is poor, we recommend using gpio to simulate i2c
I2C gpio configuration

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

I2c-gpio.png

patch
There is a warning when rmmod i2c-gpio-custom

wget https://raw.githubusercontent.com/WRTnode/openwrt-patches/master/R45620/WRTndoe-i2c-gpio-custom.patch
patch -p1 < WRTndoe-i2c-gpio-custom.patch 
--- 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 @@
 
 	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)

WRTNODE.dts
default WRTNODE.dts: gpio#1 as a reset button , gpio#38 as a led
For example,if you want use gpio#1

/*
 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

make V=s

Flash firmware then insmod module

insmod i2c-dev
insmod i2c-gpio-custom bus0=0,1,2  

parameter:<id> <sda> <scl>
<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)

ls /dev

I2c6.png