TP associated pin DTS as defined in
our project TP reset pin is GPIO158, interrupt pin is GPIO1, known by the schematic drawing down our TP mounted on I2c0, supply voltage of 3.3v is PMIC 2.8V power supply voltage by conversion over i2c level, the supply voltage needs to be configured pmic 2.8v
/* TOUCH start */
&touch {
tpd-resolution = <800 1280>;//分辨率
use-tpd-button = <0>;//如果TP有待按键。则定义值为1
tpd-key-num = <3>;//按键的数量
tpd-key-local= <139 172 158 0>;//按键的编码,一般为KEY_MENU,KEY_HOMEPAGE,KEY_BACK的键值
tpd-key-dim-local = <90 883 100 40 230 883 100 40 370 883 100 40 0 0 0 0>;//按键的布局信息,包含按键的宽度,高度,中心点的坐标
tpd-max-touch-num = <5>;//支持的最大触摸点数
tpd-filter-enable = <0>; //fae suggest this change to improve effect
tpd-filter-pixel-density = <146>;
tpd-filter-custom-prameters = <0 0 0 0 0 0 0 0 0 0 0 0>;
tpd-filter-custom-speed = <0 0 0>;
pinctrl-names = "default", "state_eint_as_int", "state_eint_output0", "state_eint_output1",
"state_rst_output0", "state_rst_output1";
pinctrl-0 = <&ctp_pins_default>;
pinctrl-1 = <&ctp_pins_eint_as_int>;
pinctrl-2 = <&ctp_pins_eint_output0>;
pinctrl-3 = <&ctp_pins_eint_output1>;
pinctrl-4 = <&ctp_pins_rst_output0>;
pinctrl-5 = <&ctp_pins_rst_output1>;
status = "okay";
};
&pio {
ctp_pins_default: eint0default {
};
ctp_pins_eint_as_int: eint@0 {
pins_cmd_dat {
pins = <PINMUX_GPIO1__FUNC_GPIO1>;
slew-rate = <0>;
bias-disable;
};
};
ctp_pins_eint_output0: eintoutput0 {
pins_cmd_dat {
pins = <PINMUX_GPIO1__FUNC_GPIO1>;
slew-rate = <1>;
output-low;
};
};
ctp_pins_eint_output1: eintoutput1 {
pins_cmd_dat {
pins = <PINMUX_GPIO1__FUNC_GPIO1>;
slew-rate = <1>;
output-high;
};
};
ctp_pins_rst_output0: rstoutput0 {
pins_cmd_dat {
pins = <PINMUX_GPIO158__FUNC_GPIO158>;
slew-rate = <1>;
output-low;
};
};
ctp_pins_rst_output1: rstoutput1 {
pins_cmd_dat {
pins = <PINMUX_GPIO158__FUNC_GPIO158>;
slew-rate = <1>;
output-high;
};
};
};
/* TOUCH end */
&i2c0 {
status = "okay";
goodix_touch@5e {
compatible = "mediatek,goodix_touch"; //用于匹配GT9xx这个TP驱动
reg = <0x5e>;//GT9xx I2c的地址
interrupt-parent = <&pio>; //中断脚
interrupts = <1 IRQ_TYPE_EDGE_RISING 1 0>;//中断模式是上升沿触发
//vtouch-supply = <&mt_pmic_vldo28_ldo_reg>; //原生MTK节点TP 2.8V PMIC供电
reg-tp-supply = <&mt_pmic_vldo28_ldo_reg>; //由于我们代码上修改了TP 2.8V PMIC供电节点获取是以reg-tp-supply这个字符获取的原生的是由vtouch-supply这个获取的
rst-gpio = <&pio 158 0>;//TP的复位引脚
int-gpio = <&pio 1 0>;//TP的中断引脚
status = "okay";
};
}
驱动流程表:
TP驱动的注册 :mtk_tpd.c
注册成功后调用probe探测方法
probe方法里实现的动作,注册TP设备,获取TP dts相关信息,为TP设备申请内核内存空间,分配一个输入设备
特定TP的注册
创建一个TP回调函数,用于TP 在LCD亮屏和灭屏时调用
如果是cap TP驱动则进行初始化
最后实现input设备注册,把设备加入input设备链表,生成“dev/input/eventx”节点,和进行虚拟按键初始化以及一些TP属性的创建
int tpd_get_gpio_info 这个函数是获取Tp dts节点信息就是获取中断和复位引脚的状态
** touch_resume_workqueue_callback该函数主要是用于判断LCD是亮屏还是灭屏通过调用回调函数 tpd_fb_notifier_callback通知TP是否工作**
回调函数tpd_fb_notifier_callback接受到通知后,通知TP是否工作
tpd_create_attributes这个函数是创建TP的一些系统属性
特定TP驱动的初始化:我这里用汇顶GT9xx驱动为例: gt9xx_driver.c
首先获取i2c0上的gt9xx驱动设备节点的dts信息,然后注册 i2c0上的 gt9xx 汇顶TP驱动到TP驱动链表中
void tpd_get_dts_info(void)该函数是获取touch tp节点的信息
void tpd_get_dts_info(void)该函数从touch tp节点的信息获取dts信息
int tpd_driver_add该函数会添加新的TP驱动到TP驱动链表中,即会把GT9xx添加到TP驱动链表中
当新TP驱动tpd_device_driver添加成功会调用tpd_local_init这个本地方法
TP本地方法里实现了esd防静电检测队列的创建,TP相关电压检测队列的创建,分配DMA i2c对象,我们封装的TP2.8V供电接口还是就是原生的2.8v供电接口
下来本地方法里会注册I2c从设备驱动,如果注册失败tpd_load_status 值会为0,同时进行按键和虚拟按键的初始化,以及记录TP供应商的一些信息
注册gt9xx tp驱动,调用probe探测方法
** tpd_i2c_probe探测方法里实现了获取平台数据,获取int中断和rst复位引脚的状态以及I2c上电通信,我们添加的初始化接口,通过I2c通信的读接口读取TP固件信息**
接下来会初始化TP固件参数,增加了我们自定义的TP方向的接口,以及创建TP节点信息,初始化写进去的参数,创建一条内核线程,如果有虚拟按键,就初始化虚拟按键
最后,探测方法里还实现按键初始化,TP中断的使能,esd防静电开启,创建一条用于更新TP固件的线程,实现远离和靠近屏幕是TP的唤醒功能
最终如果探测方法里的动作都实现了,会记录tpd_load_status = 1,表示gt9xx TP驱动成功注册
of_get_gt9xx_platform_data这个函数获取int中断和rst复位引脚信息
static int gtp_get_gpio_res(void)该函数是配置int中断和rst复位引脚
tpd_power_on函数是上电,下载TP固件
tpd_power_on函数接下来上电并下载TP固件成功,同时测试i2c是否上电通信成功
gtp_read_version这个函数是通过i2c读取TP固件版本信息
gtp_init_panel初始化TP厂商给的TP参数
TP参数
gt91xx_config_proc = proc_create(GT91XX_CONFIG_PROC_FILE, 0660, NULL, >_upgrade_proc_fops);这个在创建节点时会使用到两个操作方法进行
gt_upgrade_proc_fops里面定义了读和写方法
Creating a core thread interrupts thread = kthread_run (touch_event_handler, 0, TPD_DEVICE);
touch_event_handler interrupt the core thread is to achieve reporting, raising his hand and press event