1. 问题一:tp的驱动添加之后,下载到机器直接死机
平台:高通8x12
TP IC: GT9157
在平台文件中添加如下信息:
goodix@5d{
compatible = "goodix,gt9xx";
reg = <0x5d>;
interrupt-parent = <&msmgpio>;
interrupts = <1 0x2008>;
reset-gpios = <&msmgpio 0 0x00>;
interrupt-gpios = <&msmgpio 1 0x00>;
vdd-supply = <&pm8110_l19>;
vcc-i2c-supply = <&pm8110_l14>;
goodix,panel-coords = <0 0 720 1360>;
goodix,display-coords = <0 0 720 1280>;
goodix,button-map= <139 102 158>;
goodix,product-id = "915";
goodix,enable-power-off;
goodix,cfg-data0 = [
41 E0 01 56 03 05 35 41 01 0F 19 0A 50
3C 03 05 00 00 FF FF 00 00 04 16 17 18
14 8B 0A 0B 4D 00 B2 04 00 00 00 02 32
11 3C 41 00 00 00 00 00 32 00 00 11 32
78 94 C5 02 00 00 00 04 B0 36 00 94 41
00 80 4D 00 6D 5C 00 5E 6E 00 5E 10 30
50 00 F7 36 2A FF FF 17 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 14 10 00 32 1E 02 04 06 08 0A
0C 0E 10 12 14 16 FF FF FF 00 00 00 00
00 00 00 00 00 00 00 0F 00 00 00 00 24
16 22 18 21 1C 20 1D 1F 1E 13 0A 08 12
06 10 04 0F 02 0C 00 FF FF FF FF FF 00
00 00 FF FF FF FF FF FF FF FF FF FF FF
FF FF 35 01];
};
kernel中已经存在GT的驱动--gt9xx.c,这个驱动兼容大部分汇顶系列的tp ic,中间出现的问题这个驱动怎么加载不上,于是就开始查看驱动文件,分析过程,刚开始的上电,panel初始化都没有问题,直到看到这么一段函数:
ret = gtp_check_product_id(client);
if (ret != 0) {
dev_err(&client->dev, "GTP Product id doesn't match.\n");
goto exit_free_irq;
}
函数里面怎么写的,继续往下看:
/*******************************************************
Function:
Read and check chip id.
Input:
client: i2c device
Output:
read operation return.
0: succeed, otherwise: failed
*******************************************************/
static int gtp_check_product_id(struct i2c_client *client)
{
int ret = 0;
char product_id[GTP_PRODUCT_ID_MAXSIZE];
struct goodix_ts_data *ts = i2c_get_clientdata(client);
/* 04 bytes are used for the Product-id in the register space.*/
u8 buf[GTP_PRODUCT_ID_BUFFER_MAXSIZE] =
{
GTP_REG_PRODUCT_ID >> 8, GTP_REG_PRODUCT_ID & 0xff };
ret = gtp_i2c_read(client, buf, sizeof(buf));
if (ret < 0) {
dev_err(&client->dev, "GTP read version failed.\n");
return -EIO;
}
if (buf[5] == 0x00) {
/* copy (GTP_PRODUCT_ID_MAXSIZE - 1) from buffer. Ex: 915 */
strlcpy(product_id, &buf[2], GTP_PRODUCT_ID_MAXSIZE - 1);
} else {
if (buf[5] == 'S' || buf[5] == 's')
chip_gt9xxs = 1;
/* copy GTP_PRODUCT_ID_MAXSIZE from buffer. Ex: 915s */
strlcpy(product_id, &buf[2], GTP_PRODUCT_ID_MAXSIZE);
}
dev_info(&client->dev, "Goodix Product ID = %s\n", product_id);
ret = strcmp(product_id, ts->pdata->product_id);
if (ret != 0)
return -EINVAL;
return ret;
}
原来这一段函数会读取IC的product_id寄存器,读到的值会跟goodix,product-id = "915"; 设定的值比较,如果相同,则匹配成功,否则exit_free_irq(这种情况会直接导致IRQ中断时序错乱,导致死机)。最后,项目中实际用到的IC为gt9157,那么goodix,product-id = "9157",匹配成功,机器现在可以正常启动了。
同时从GT9157资料中知道,GT9157 的 I2C 从设备地址有两组,分别为 0xBA/0xBB 和 0x28/0x29。主控在上电初
始化时控制 Reset 和 INT 口状态进行设定,这个可以从驱动中看到原函数。
驱动中I2C从设备的地址使用地址的低7位,也就是需要右移一位