IC(Inter-Integrated Circuit,集成电路总线)由飞利浦公司在1980年代提出,此接口使用两根信号线实现一主多从的通信,一根是双向的数据线SDA,另一根是时钟线SCL。所有接到I2C总线设备上的串行数据SDA都接到总线的SDA上,各设备的时钟线SCL接到总线的SCL上。
Rockchip I2C 控制器支持下列功能︰
# cat /sys/kernel/debug/pinctrl/pinctrl-rockchip-pinctrl/pinmux-pins | grep i2c
pin 9 (gpio0-9): fdd40000.i2c (GPIO UNCLAIMED) function i2c0 group i2c0-xfer
pin 10 (gpio0-10): fdd40000.i2c (GPIO UNCLAIMED) function i2c0 group i2c0-xfer
pin 11 (gpio0-11): fe5a0000.i2c (GPIO UNCLAIMED) function i2c1 group i2c1-xfer
pin 12 (gpio0-12): fe5a0000.i2c (GPIO UNCLAIMED) function i2c1 group i2c1-xfer
pin 107 (gpio3-11): fe5e0000.i2c (GPIO UNCLAIMED) function i2c5 group i2c5m0-xfer
pin 108 (gpio3-12): fe5e0000.i2c (GPIO UNCLAIMED) function i2c5 group i2c5m0-xfer
pin 138 (gpio4-10): fe5d0000.i2c (GPIO UNCLAIMED) function i2c4 group i2c4m0-xfer
pin 139 (gpio4-11): fe5d0000.i2c (GPIO UNCLAIMED) function i2c4 group i2c4m0-xfer
# ls /dev/i2c-*
/dev/i2c-0 /dev/i2c-1 /dev/i2c-4 /dev/i2c-5 /dev/i2c-6 /dev/i2c-7
# 列出所有可用 I2C 总线
# i2cdetect -l
i2c-0 i2c rk3x-i2c I2C adapter
i2c-1 i2c rk3x-i2c I2C adapter
i2c-4 i2c rk3x-i2c I2C adapter
i2c-5 i2c rk3x-i2c I2C adapter
i2c-6 i2c DP-AUX I2C adapter
i2c-7 i2c DesignWare HDMI I2C adapter
# 扫描指定总线(例如总线 5)
# sudo i2cdetect -y 5
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- 64 -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
# i2cdump -f -y 5 0x51
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
10: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
20: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
30: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
40: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
50: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
60: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
70: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
80: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
90: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
a0: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
b0: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
c0: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
d0: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
e0: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
f0: 00 00 09 47 13 01 08 01 21 80 80 80 82 88 8a 00 ..?G????!??????.
# i2cget -f -y 5 0x51 0xD0
0x00
# sudo i2cset -f -y 5 0x51 0x00 0x55