1、平台信息
CPU:S905D3
TP:GT9271
2、硬件连接
GT9271 S905D3
I2C I2C4(I2C4_SDA_TP/I2C4_SCL_TP)
TP_INT GPIO7_A6_u
TP_RST GPIO7_A5_u
【初始流程】
1、设备数配置
kernel/arch/arm64/boot/dts/amlogic/xxx.dts
&i2c4 {
status = "okay";
ts@5d {
compatible = "goodix,gt9xx";
status = "okay";
reg = <0x5d>;
goodix,irq-gpio = <&gpio7 GPIO_A6 IRQ_TYPE_LEVEL_LOW>;
goodix,rst-gpio = <&gpio7 GPIO_A5 GPIO_ACTIVE_LOW>;
goodix,cfg-group0 = [
42 D0 02 00 05 05 75 01 01 0F 24
0F 64 3C 03 05 00 00 00 02 00 00
00 16 19 1C 14 8C 0E 0E 24 00 31
0D 00 00 00 83 33 1D 00 41 00 00
00 00 00 08 0A 00 2B 1C 3C 94 D5
03 08 00 00 04 93 1E 00 82 23 00
74 29 00 69 2F 00 5F 37 00 5F 20
40 60 00 F0 40 30 55 50 27 00 00
00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 14 19 00 00
50 50 02 04 06 08 0A 0C 0E 10 12
14 16 18 1A 1C 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 1D
1E 1F 20 21 22 24 26 28 29 2A 1C
18 16 14 13 12 10 0F 0C 0A 08 06
04 02 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 9C 01
];
};
2、驱动流程梳理
// 周期处理任务
static void gtp_esd_check_func(struct work_struct *work)
{
// 检查ic是否工作异常,异常时复位ic
#ifdef GTP_CONFIG_OF // 重新上下电
gtp_power_switch(ts->client, 0);
msleep(20);
gtp_power_switch(ts->client, 1);
msleep(20);
#endif
gtp_reset_guitar(ts->client, 50); // 复位ic
msleep(50);
gtp_send_cfg(ts->client); // 重新下发配置数据
}
// 中断下半部
static void goodix_ts_work_func(struct work_struct *work)
{
// 读取触控信息
// To-do
// 触控唤醒功能,点亮屏幕
input_report_key(ts->input_dev, KEY_POWER, 1);
input_sync(ts->input_dev);
input_report_key(ts->input_dev, KEY_POWER, 0);
input_sync(ts->input_dev);
// 上报触控位置
input_report_key(ts->input_dev, touch_key_array, key_value & (0x01<
// 当提交输入设备产生的输入事件之后,需调用input_sync通知输入子系统处理设备产生的完整事件
input_sync(ts->input_dev);
// 重新使能中断
gtp_irq_enable(ts);
}
// 中断上半部
static irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id)
{
// 将任务提交到工作队列,提交后在下半部执行函数goodix_ts_work_func
queue_work(goodix_wq, &ts->work);
}
static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
...
// 解析goodix,irq-gpio/goodix,rst-gpio属性
gtp_parse_dt(&client->dev);
// 初始化一个任务,任务处理入口:goodix_ts_work_func
INIT_WORK(&ts->work, goodix_ts_work_func);
ret = gtp_request_io_port(ts);
ret = gtp_init_panel(ts);
//创建/proc/gt9xx_config读写文件节点
proc_create(GT91XX_CONFIG_PROC_FILE, 0666, NULL, &config_proc_ops);
//申请中断处理回调
ret = gtp_request_irq(ts); -> request_irq(xxx, goodix_ts_irq_handler, ...);
/* 注册suspend/resume回调 goodix_ts_early_suspend/goodix_ts_late_resume */
gtp_register_powermanger(ts);
}
static struct i2c_driver goodix_ts_driver = {
.probe = goodix_ts_probe,
...
};
static int __init goodix_ts_init(void)
{
//创建一个专用的内核线程来执行提交到工作队列中的函数
goodix_wq = create_singlethread_workqueue("goodix_wq");
#if GTP_ESD_PROTECT
// 查询 IC 的工作状态,如果发现工作异常,则复位IC
INIT_DELAYED_WORK(>p_esd_check_work, gtp_esd_check_func);
gtp_esd_check_workqueue = create_workqueue("gtp_esd_check");
#endif
ret = i2c_add_driver(&goodix_ts_driver);
}
3、启动加载日志
<4>[ 3.142669] <<-GTP-INFO->> GTP driver installing...
<4>[ 3.142774] <<-GTP-INFO->> GTP Driver Version: V2.2<2014/01/14>
<4>[ 3.142782] <<-GTP-INFO->> GTP Driver Built@18:18:52, Apr 20 2021
<4>[ 3.142787] <<-GTP-INFO->> GTP I2C Address: 0x14
<7>[ 3.142798] of_get_named_gpio_flags exited with status 230
<7>[ 3.142804] of_get_named_gpio_flags exited with status 229
<4>[ 3.142808] irq_pin = 230
<4>[ 3.142837] <<-GTP-INFO->> Guitar reset
<6>[ 3.243381] [WLAN_RFKILL]: wifi turn on power. 156
<4>[ 3.263061] gtp_i2c_test start
<4>[ 3.263611] <<-GTP-INFO->> IC Version: 9271_1070
<4>[ 3.263619] jon_debug:lcd_panel_id:50
<4>[ 3.263624] jon_debug:reset
<4>[ 3.263628] <<-GTP-INFO->> Guitar reset
<6>[ 3.366378] EHCI: rk_ehci_hcd_enable, enable host controller
<4>[ 3.450020] wifi_platform_bus_enumerate device present 1
<4>[ 3.450028] ======== Card detection to detect SDIO card! ========
<6>[ 3.450034] mmc1:mmc host rescan start!
<4>[ 3.450041] ============= hong dw_mci_set_sdio_status gpio4_c1 val_io=1
<4>[ 3.469695] jon_debug:gtp_init_panel,1467
<4>[ 3.469702] jon_debug:gtp_init_panel,1506
<4>[ 3.470094] <<-GTP-INFO->> CTP_CONFIG_GROUP1 used, config length: 186
<4>[ 3.470481] <<-GTP-INFO->> Driver send config.
<4>[ 3.477724] <<-GTP-INFO->> X_MAX: 800, Y_MAX: 1280, TRIGGER: 0x01
<4>[ 3.489385] <<-GTP-INFO->> create proc entry gt9xx_config success
<6>[ 3.489471] input: Goodix-TS as /devices/virtual/input/input1
<4>[ 3.489596] <<-GTP-ERROR->> Request IRQ failed!ERRNO:0.
<4>[ 3.489609] <<-GTP-INFO->> GTP works in polling mode.
【调试记录】
1、查看中断统计
root@rk3288_box:/ # cat /proc/interrupts | grep i2c-4
96: 2029804 0 0 0 GIC i2c-4
root@rk3288_box:/ # cat /proc/interrupts | grep gt
198: 1 0 0 0 GPIO gt9xx
2、查看触摸芯片配置
root@rk3288_box:/ # cat /proc/gt9xx_config
==== GT9XX config init value====
0x42 0x20 0x03 0x00 0x05 0x05 0x35 0x20
0x22 0x08 0x2D 0x0F 0x73 0x5F 0x03 0x05
1、平台信息
CPU:S905D3
TP:GT9271
2、硬件连接
GT9271 S905D3
I2C I2C4(I2C4_SDA_TP/I2C4_SCL_TP)
TP_INT GPIO7_A6_u
TP_RST GPIO7_A5_u
【初始流程】
1、设备数配置
kernel/arch/arm64/boot/dts/amlogic/xxx.dts
&i2c4 {
status = "okay";
ts@5d {
compatible = "goodix,gt9xx";
status = "okay";
reg = <0x5d>;
goodix,irq-gpio = <&gpio7 GPIO_A6 IRQ_TYPE_LEVEL_LOW>;
goodix,rst-gpio = <&gpio7 GPIO_A5 GPIO_ACTIVE_LOW>;
goodix,cfg-group0 = [
42 D0 02 00 05 05 75 01 01 0F 24
0F 64 3C 03 05 00 00 00 02 00 00
00 16 19 1C 14 8C 0E 0E 24 00 31
0D 00 00 00 83 33 1D 00 41 00 00
00 00 00 08 0A 00 2B 1C 3C 94 D5
03 08 00 00 04 93 1E 00 82 23 00
74 29 00 69 2F 00 5F 37 00 5F 20
40 60 00 F0 40 30 55 50 27 00 00
00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 14 19 00 00
50 50 02 04 06 08 0A 0C 0E 10 12
14 16 18 1A 1C 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 1D
1E 1F 20 21 22 24 26 28 29 2A 1C
18 16 14 13 12 10 0F 0C 0A 08 06
04 02 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 9C 01
];
};
2、驱动流程梳理
// 周期处理任务
static void gtp_esd_check_func(struct work_struct *work)
{
// 检查ic是否工作异常,异常时复位ic
#ifdef GTP_CONFIG_OF // 重新上下电
gtp_power_switch(ts->client, 0);
msleep(20);
gtp_power_switch(ts->client, 1);
msleep(20);
#endif
gtp_reset_guitar(ts->client, 50); // 复位ic
msleep(50);
gtp_send_cfg(ts->client); // 重新下发配置数据
}
// 中断下半部
static void goodix_ts_work_func(struct work_struct *work)
{
// 读取触控信息
// To-do
// 触控唤醒功能,点亮屏幕
input_report_key(ts->input_dev, KEY_POWER, 1);
input_sync(ts->input_dev);
input_report_key(ts->input_dev, KEY_POWER, 0);
input_sync(ts->input_dev);
// 上报触控位置
input_report_key(ts->input_dev, touch_key_array, key_value & (0x01<
// 当提交输入设备产生的输入事件之后,需调用input_sync通知输入子系统处理设备产生的完整事件
input_sync(ts->input_dev);
// 重新使能中断
gtp_irq_enable(ts);
}
// 中断上半部
static irqreturn_t goodix_ts_irq_handler(int irq, void *dev_id)
{
// 将任务提交到工作队列,提交后在下半部执行函数goodix_ts_work_func
queue_work(goodix_wq, &ts->work);
}
static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
...
// 解析goodix,irq-gpio/goodix,rst-gpio属性
gtp_parse_dt(&client->dev);
// 初始化一个任务,任务处理入口:goodix_ts_work_func
INIT_WORK(&ts->work, goodix_ts_work_func);
ret = gtp_request_io_port(ts);
ret = gtp_init_panel(ts);
//创建/proc/gt9xx_config读写文件节点
proc_create(GT91XX_CONFIG_PROC_FILE, 0666, NULL, &config_proc_ops);
//申请中断处理回调
ret = gtp_request_irq(ts); -> request_irq(xxx, goodix_ts_irq_handler, ...);
/* 注册suspend/resume回调 goodix_ts_early_suspend/goodix_ts_late_resume */
gtp_register_powermanger(ts);
}
static struct i2c_driver goodix_ts_driver = {
.probe = goodix_ts_probe,
...
};
static int __init goodix_ts_init(void)
{
//创建一个专用的内核线程来执行提交到工作队列中的函数
goodix_wq = create_singlethread_workqueue("goodix_wq");
#if GTP_ESD_PROTECT
// 查询 IC 的工作状态,如果发现工作异常,则复位IC
INIT_DELAYED_WORK(>p_esd_check_work, gtp_esd_check_func);
gtp_esd_check_workqueue = create_workqueue("gtp_esd_check");
#endif
ret = i2c_add_driver(&goodix_ts_driver);
}
3、启动加载日志
<4>[ 3.142669] <<-GTP-INFO->> GTP driver installing...
<4>[ 3.142774] <<-GTP-INFO->> GTP Driver Version: V2.2<2014/01/14>
<4>[ 3.142782] <<-GTP-INFO->> GTP Driver Built@18:18:52, Apr 20 2021
<4>[ 3.142787] <<-GTP-INFO->> GTP I2C Address: 0x14
<7>[ 3.142798] of_get_named_gpio_flags exited with status 230
<7>[ 3.142804] of_get_named_gpio_flags exited with status 229
<4>[ 3.142808] irq_pin = 230
<4>[ 3.142837] <<-GTP-INFO->> Guitar reset
<6>[ 3.243381] [WLAN_RFKILL]: wifi turn on power. 156
<4>[ 3.263061] gtp_i2c_test start
<4>[ 3.263611] <<-GTP-INFO->> IC Version: 9271_1070
<4>[ 3.263619] jon_debug:lcd_panel_id:50
<4>[ 3.263624] jon_debug:reset
<4>[ 3.263628] <<-GTP-INFO->> Guitar reset
<6>[ 3.366378] EHCI: rk_ehci_hcd_enable, enable host controller
<4>[ 3.450020] wifi_platform_bus_enumerate device present 1
<4>[ 3.450028] ======== Card detection to detect SDIO card! ========
<6>[ 3.450034] mmc1:mmc host rescan start!
<4>[ 3.450041] ============= hong dw_mci_set_sdio_status gpio4_c1 val_io=1
<4>[ 3.469695] jon_debug:gtp_init_panel,1467
<4>[ 3.469702] jon_debug:gtp_init_panel,1506
<4>[ 3.470094] <<-GTP-INFO->> CTP_CONFIG_GROUP1 used, config length: 186
<4>[ 3.470481] <<-GTP-INFO->> Driver send config.
<4>[ 3.477724] <<-GTP-INFO->> X_MAX: 800, Y_MAX: 1280, TRIGGER: 0x01
<4>[ 3.489385] <<-GTP-INFO->> create proc entry gt9xx_config success
<6>[ 3.489471] input: Goodix-TS as /devices/virtual/input/input1
<4>[ 3.489596] <<-GTP-ERROR->> Request IRQ failed!ERRNO:0.
<4>[ 3.489609] <<-GTP-INFO->> GTP works in polling mode.
【调试记录】
1、查看中断统计
root@rk3288_box:/ # cat /proc/interrupts | grep i2c-4
96: 2029804 0 0 0 GIC i2c-4
root@rk3288_box:/ # cat /proc/interrupts | grep gt
198: 1 0 0 0 GPIO gt9xx
2、查看触摸芯片配置
root@rk3288_box:/ # cat /proc/gt9xx_config
==== GT9XX config init value====
0x42 0x20 0x03 0x00 0x05 0x05 0x35 0x20
0x22 0x08 0x2D 0x0F 0x73 0x5F 0x03 0x05
举报