I²C is a communication protocol used to exchange information between cores. To see more about I²C, please follow this link Wikipedia:I²C.
Enable I2C-tools in LTIB into Package List:
Reboot your file system, there are three new I²C commands: i2cdetect, i2cdump and i2cset.
All examples below were tested in a iMX27ADS, but this programs seems to have the same behavior to all platforms.
This command lists all installed bus.
mx27# i2cdetect -l i2c-0 unknown MXC I2C Adapter Algorithm unavailable
There is one installed bus with address 0.
I2cdetect shows the installed chips too.
mx27# i2cdetect 0 WARNING! This program can confuse your I2C bus, cause data loss and worse! I will probe file /dev/i2c/0. I will probe address range 0x03-0x77. 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: XX XX XX XX XX XX XX XX XX XX XX XX XX 10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 20: XX XX XX XX XX XX XX XX XX XX XX XX XX 2d XX XX 30: UU XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 40: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX 60: XX XX XX XX XX XX XX XX XX XX UU XX XX XX XX XX 70: XX XX XX XX XX XX XX XX
There are several cores installed into bus i2c-0.
If you received an error message like this:
# i2cdetect 0 Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory
You will need to create the special file /dev/i2c-0 :
# mknod /dev/i2c-0 c 89 0
i2cdump shows a list of all registers for a core. For example, the command above shows registers for core with address 0x6a:
mx27# i2cdump 0 0x6a No size specified (using byte-data access) WARNING! This program can confuse your I2C bus, cause data loss and worse! I will probe file /dev/i2c/0, address 0x6a, mode byte 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef 00: 00 00 28 00 00 03 15 03 00 00 00 00 00 00 03 01 ..(..???......?? 10: 04 01 00 00 04 01 00 00 17 41 1d 00 09 09 1f 03 ??..??..?A?.???? 20: 00 00 40 00 08 00 0c 00 0f 01 00 00 00 00 08 11 ..@.?.?.??....?? 30: 00 0f 05 fe 0b 00 00 00 82 00 0c 02 00 00 01 00 .????...?.??..?. 40: 21 f0 7c 1f 00 00 01 00 7a 40 80 38 00 01 47 00 !?|?..?.z@?8.?G. 50: 3c 00 17 21 1b 1b 24 9f 00 3e 0f 0f 60 05 cd 03 <.?!??$?.>??`??? 60: 89 04 89 01 02 00 0a 05 00 19 ff 03 24 0f 78 00 ?????.??.?.?$?x. 70: 00 b2 06 14 04 08 00 a3 c8 15 05 15 3c 00 00 20 .?????.?????<.. 80: 07 2f 07 00 00 00 00 00 00 00 00 ff 03 1a 1a 1a ?/?.........???? 90: 1a 1a 40 03 00 00 00 00 00 00 00 00 00 00 e4 00 ??@?..........?. a0: 00 02 4d 00 96 00 1d 00 a0 00 db 00 7e 00 00 00 .?M.?.?.?.?.~... b0: 00 00 00 00 00 00 f0 00 00 00 00 00 00 00 00 00 ......?......... c0: 00 00 00 00 48 9c 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a ....H??????????? d0: 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a ???????????????? e0: 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a ???????????????? f0: 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a 1a ????????????????
To change some register value, use i2cset like in example below:
mx27# i2cset 0 0x6a 01 0x0008 w WARNING! This program can confuse your I2C bus, cause data loss and worse! I will write to device file /dev/i2c/0, chip address 0x6a, data address 0x00, data 0x08, mode word. Value 0x8 written, readback matched
Where: