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位,也就是需要右移一位