我最近在海思平台上调gt911,我通过i2c tool工具,i2c_read 可以读到gt911的产品id,但是我加载驱动的时候,就读不到,对了好多遍RST INT上电时序,不知道为什么i2c不通
void gtp_reset_guitar(int ms)
{
set_gtp_reset_dir(OUTPUT_MODE);
set_gtp_reset_val(0);
msleep(20);
set_gtp_int_dir(OUTPUT_MODE);
set_gtp_int_val(1);
msleep(2);
set_gtp_reset_val(1);
mdelay(10);
set_gtp_int_dir(INPUT_MODE);
}
static struct i2c_board_info hi_info = { I2C_BOARD_INFO("gt9xx", 0x28),};
static int i2c_client_init(void)
{
struct i2c_adapter* i2c_adap;
i2c_adap = i2c_get_adapter(0);
gt911_client = i2c_new_device(i2c_adap, &hi_info);
i2c_put_adapter(i2c_adap);
}
以上代码是我的上电时序和i2c client 初始化,
int gtp_i2c_read(struct i2c_client *client, unsigned char *buf, int len)
{
int ret = -1;
unsigned int data;
unsigned char addr[2];
addr[0] = buf[0];
addr[1] = buf[1];
printk("addr = 0x%x 0x%x\n", addr[0], addr[1]);
unsigned char retry = 0;
struct i2c_msg msg[2];
msg[0].addr = client->addr;
msg[0].len = 2;
msg[0].buf = addr;//&buf[0];
msg[0].flags = !I2C_M_RD;
msg[1].addr = client->addr;
msg[1].len = 1;//len - 2;
msg[1].buf = &buf[2];
msg[1].flags = I2C_M_RD;
ret = i2c_transfer(client->adapter, msg, 2);
printk("i2c_transfer read ret = %d, buf[2] = 0x%x\n", ret, buf[2]);
return ret;
}
调了好几天了,i2c都读不到产品id