各位大神们好!我最近在做rk3288平台上ov426+ov6946的方案。
驱动在读取摄像头ID这里遇到了问题。
驱动的读i2c代码
static int ov6946_read_reg(struct i2c_client *client, u16 reg,
unsigned int len, u32 *val)
{
struct i2c_msg msg[2];
u8 buf[2]= { reg >> 8, reg & 0xff };
int ret;
msg[0].addr = client->addr;
msg[0].flags = client->flags;
msg[0].buf = buf;
msg[0].len = sizeof(buf);
msg[1].addr = client->addr;
msg[1].flags = client->flags | I2C_M_RD;
msg[1].buf = buf;
msg[1].len = 1;
ret = i2c_transfer(client->adapter, msg, 2);
if (ret >= 0) {
*val = buf[0];
return 0;
}
dev_err(&client->dev,
"read reg:0x%x result:0x%x failed !\n", reg,buf[0]);
return ret;
}
打印log出来是这样的
[root@rk3288:/]# dmesg | grep ov6946
[ 3.168255] ov6946 3-0036: driver version: 00.01.02
[ 3.168276] ov6946 3-0036: GPIO lookup for consumer reset
[ 3.168279] ov6946 3-0036: using device tree for GPIO lookup
[ 3.168299] of_get_named_gpiod_flags: parsed ‘reset-gpios’ property of node ‘/i2c@ff150000/ov6946@36[0]’ - status (0)
[ 3.168323] ov6946 3-0036: GPIO lookup for consumer pwdn
[ 3.168327] ov6946 3-0036: using device tree for GPIO lookup
[ 3.168344] of_get_named_gpiod_flags: parsed ‘pwdn-gpios’ property of node ‘/i2c@ff150000/ov6946@36[0]’ - status (0)
[ 3.168512] ov6946 3-0036: could not get default pinstate
[ 3.168517] ov6946 3-0036: could not get sleep pinstate
[ 3.168535] ov6946 3-0036: ERROR init controls(0)
[ 3.168543] ov6946 3-0036: ERROR init controls(0)
[ 3.170337] ov6946 3-0036: read reg:0x300a result:0x30 failed !
[ 3.170341] ov6946 3-0036: Unexpected sensor id(000000), ret(-6)
但奇怪的是在用户空间里可以正常读写
[root@rk3288:/]# i2cdetect -y 3
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – – – – – – –
10: – – – – – – – – – – – – – – – –
20: – – – – – – – – – – – – – – – –
30: – – – – – – 36 – – – – – – – – –
40: – – – – – – – – – – – – – – – –
50: – – – – – – – – – – – – – – – –
60: – – – – – – – – – – – – – – – –
70: – – – – – – – –
[root@rk3288:/]# i2ctransfer -y 3 w2@0x36 0x30 0x0a r1
0x69
麻烦大神们帮忙看一下!