在DM385平台上面调试i2c接口 (DM81xx)
在i2c tools中有4个执行程序:
i2cdetect : 用来列举i2c 总线上面的所有的设备
i2cdump : 显示对应芯片的所有的寄存器的值
i2cget : 读取芯片的某个寄存器的值
i2cset : 写入芯片的某个寄存器的值
01、在linux系统启动后,侦测i2c总线接口;
先看一下dev 下面有哪些i2c设备
root@dm814x-evm:~# ls -l /dev/
drwxr-xr-x 2 root root 360 Jan 1 2000 block
drwxr-xr-x 2 root root 2080 Jan 1 2000 char
crw------- 1 root root 89, 1 Jan 1 2000 i2c-1
crw------- 1 root root 89, 2 Jan 1 2000 i2c-2
prw------- 1 root root 0 Jan 1 2000 initctl
drwxr-xr-x 2 root root 60 Jan 1 2000 input
|
侦测i2c总线下面有哪些设备,设备的地址是多少;
注意这里的i2c的地址范围是7bit ,0x03~0x77范围
root@dm814x-evm:~# i2cdetect -y -r 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- UU -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- 59 -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@dm814x-evm:~# i2cdetect -y -r 2
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- 58 -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
|
02、读取设备id的寄存器状态
root@dm814x-evm:~# i2cdump -f -y 2 0x58
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: 10 08 7d 00 02 00 00 00 51 58 0d 02 81 00 03 03 ??}.?...QX???.??
10: 80 80 00 80 00 00 10 0a 40 00 00 00 0c 00 00 00 ??.?..??@...?...
20: 00 00 04 80 00 f5 00 00 00 06 1e 04 00 f2 08 04 ..??.?...???.???
30: ff ff 00 00 6a 08 05 07 7a 00 d0 02 19 00 f0 00 ....j???z.???.?.
40: 25 03 40 00 04 00 07 00 7a 00 d0 02 01 00 15 00 %?@.?.?.z.???.?.
50: 7a 00 d0 02 8d 00 bc 02 26 00 dc 00 1e 09 34 03 z.???.??&.?.??4?
60: 00 09 40 1e 18 00 0b 00 00 1f 1f 02 10 04 64 20 .?@??.?..?????d
70: 7d 00 8a 64 04 02 0f 0f 03 05 20 1e 02 08 03 03 }.?d?????? ?????
80: 0a 00 5a 06 00 03 22 00 00 16 1d 64 00 00 0a 04 ?.Z?.?"..??d..??
90: 10 80 80 00 00 00 60 50 00 00 00 0a 05 05 03 bc ???...`P...?????
a0: bc 00 0d 02 90 01 78 00 44 40 03 d8 05 00 01 00 ?.????x.D@???.?.
b0: 00 10 20 e4 e4 00 1b 04 40 00 00 01 d7 0f 00 00 .? ??.??@..???..
c0: 00 88 88 c9 01 00 00 00 00 a5 ff 7e 01 00 00 00 .????....?.~?...
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 25 25 00 00 25 25 25 25 01 00 00 00 00 00 00 25 %%..%%%%?......%
f0: 02 00 00 00 00 00 00 00 00 25 25 25 25 25 0f 01 ?........%%%%%??
|
设置寄存器0x0d的值为0x35
root@dm814x-evm:~# i2cset -f -y 2 0x58 0x0d 0x35
root@dm814x-evm:~# i2cdump -f -y 2 0x58
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: 10 18 ab 00 02 00 00 00 51 58 0d 02 35 35 03 03 ???.?...QX??55??
10: 80 80 00 80 00 00 10 0a 40 00 00 00 0c 00 00 00 ??.?..??@...?...
20: 00 00 14 80 00 f5 00 00 00 06 1e 04 00 f2 08 04 ..??.?...???.???
30: ff ff 00 00 6a 08 05 07 7a 00 d0 02 19 00 f0 00 ....j???z.???.?.
40: 25 03 40 00 04 00 07 00 7a 00 d0 02 01 00 15 00 %?@.?.?.z.???.?.
50: 7a 00 d0 02 8d 00 bc 02 26 00 dc 00 1e 09 34 03 z.???.??&.?.??4?
60: 00 09 40 1e 18 00 0b 00 00 1f 1f 02 10 04 64 20 .?@??.?..?????d
70: 7d 00 8a 64 04 02 0f 0f 03 05 20 1e 02 08 03 03 }.?d?????? ?????
80: 0a 00 5a 06 00 03 22 00 00 16 1d 64 00 00 0a 04 ?.Z?.?"..??d..??
90: 10 80 80 00 00 00 60 50 00 00 00 0a 05 05 03 bc ???...`P...?????
a0: bc 00 0d 02 90 01 78 00 44 40 03 d8 05 00 01 00 ?.????x.D@???.?.
b0: 00 10 20 e4 e4 00 1b 04 40 00 00 01 d7 0f 00 00 .? ??.??@..???..
c0: 00 88 88 c9 01 00 00 00 00 a5 ff 7e 01 00 00 00 .????....?.~?...
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 1d 1d 00 00 25 25 25 25 02 00 00 00 00 00 00 25 ??..%%%%?......%
f0: 02 00 00 00 00 00 00 00 00 25 25 25 25 25 0f 01 ?........%%%%%??
|
读取寄存器0x0d的值
root@dm814x-evm:~# i2cget -f -y 2 0x58 0x0d
0x35
|
03、在内核中添加总线接口
root@ubuntu-virtual-machine:/opt/IPNC_RDK/Source/ti_tools/ipnc_psp_arago/kernel/arch/arm/mach-omap2# svn diff board-dm385_evm.c
Index: board-dm385_evm.c
=========================================================
--- board-dm385_evm.c (版本 149)
+++ board-dm385_evm.c (工作副本)
@@ -241,7 +241,7 @@
.tps65910_pmic_init_data = tps65911_reg_data,
};
-static struct i2c_board_info __initdata ti814x_i2c_boardinfo[] = {
+static struct i2c_board_info __initdata ti814x_i2c_boardinfo0[] = {
{
I2C_BOARD_INFO("tps65911", 0x2D),
.platform_data = &tps65911_pdata,
@@ -248,13 +248,18 @@
},
};
+static struct i2c_board_info __initdata ti814x_i2c_boardinfo1[] = {
+};
+
static void __init ti814x_evm_i2c_init(void)
{
/* There are 4 instances of I2C in TI814X but currently only one
* instance is being used on the TI8148 EVM
*/
- omap_register_i2c_bus(1, 100, ti814x_i2c_boardinfo,
- ARRAY_SIZE(ti814x_i2c_boardinfo));
+ omap_register_i2c_bus(1, 100, ti814x_i2c_boardinfo0,
+ ARRAY_SIZE(ti814x_i2c_boardinfo0));
+ omap_register_i2c_bus(2, 100, ti814x_i2c_boardinfo1,
+ ARRAY_SIZE(ti814x_i2c_boardinfo1));
}
static u8 dm385_iis_serializer_direction[] = { |
|