概述
1>将驱动code加入源码kernel目录,touch driver是drivers/input/touchscreen
可以直接放到这里,也可以新建个目录放进去,看自己喜好~我是建了个目录,会清晰一些
用的是cypress的touch,根据产品名称建了目录,把driver code都放进去
2>下一步就是把driver code加入编译了
cyttsp6目录拥有自己的Makefile和Kconfig文件,但是我们先要把cyttsp6目录加入编译,他自己的makefile才会被调到
①修改drivers/input/touchscreen的Makefile,加入编译条件CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6
注意这里编译条件名字不能随便起,要根据cyttsp6的Makefile内容一致,这是cyttsp6的Makefile:
obj-$(CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6) += cyttsp6.o
编译条件CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6,保持一致(/touchscreen的Makefile修改)
obj-$(CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6) += cyttsp6/
②修改drivers/input/touchscreen的Kconfig,引入cyttsp6的Kconfig文件
source "drivers/input/touchscreen/cyttsp6/Kconfig"
③cyttsp6中的Makefile和Kconfig也需要适当修改,把不存在文件的编译条件去掉,缺少的文件编译加上
总之哪里报错或者发现哪个必要文件没有编译进去,就检查Makefile和Kconfig就可以了
④在config开关文件中把以上涉及到的CONFIG条件都打开,这里用的是arch/arm64/configs/msm_defconfig
CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6=y
CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6_MT_A=y
CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6_I2C=y
CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6_BUTTON=y
CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6_PROXIMITY=y
CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6_DEVICETREE_SUPPORT=y
CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6_LOADER=y
CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6_DEVICE_ACCESS=y
CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP6_DEBUG_MDL=y
⑤在out对应目录检查是否生成对应的.o文件
3>修改dtsi文件,添加driver节点
①将TP的示例dtsi文件中驱动节点添加到对应i2c下,例如我这是i2c3,具体值根据原理图即可
②这里TP节点名称是tsc@24,地址是0x24,需要在其上级节点修改ranges值(地址转换表),即这里添加的<0x24 0x24>,
至于tsc节点里面的属性值都代表什么意思,可以参考其hardware register guide,在驱动code里也有表现,如cy,mt下的cy,flags表示touch的方向
③还需要根据原理图来修改节点的interrupt pin,reset pin等
&soc {
i2c_3: i2c@7577000 { /* BLSP1 QUP3 */
compatible = "qcom,i2c-msm-v2";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x7577000 0x1000>;
reg-names = "qup_phys_addr";
interrupt-names = "qup_irq";
interrupts = <0 97 0>;
......
disp_ser_1:serializer@0c {
compatible = "ti,ds90ub947q";
reg = <0x0c>;
#address-cells = <1>;
#size-cells = <0>;
ranges = <0x2c 0x2c>,
<0x24 0x24>;
disp_des_1: deserializer@2c {
compatible = "ti,ds90ub948q";
reg = <0x2c>;
slave-mode;
};
tsc@24 {
compatible = "cy,cyttsp6_i2c_adapter";
reg = <0x24>;
/* GPIO 38, high-to-low edge triggered */
interrupts = <22 0>;
interrupt-parent = <&tlmm>;
cy,core {
cy,irq_gpio = <22>;
/*cy,rst_gpio = <48>;*/
/*cy,err_gpio = <49>;*/
/* Enable cy,max_xfer_len to limit max I2C/SPI transfer length */
cy,max_xfer_len = <64>;
cy,btn_keys = <172 /* KEY_HOMEPAGE */
/* previously was KEY_HOME, new Android versions use KEY_HOMEPAGE */
139 /* KEY_MENU */
158 /* KEY_BACK */
217 /* KEY_SEARCH */
114 /* KEY_VOLUMEDOWN */
115 /* KEY_VOLUMEUP */
212 /* KEY_CAMERA */
116>; /* KEY_POWER */
cy,btn_keys-tag = <0>;
cy,mt {
cy,inp_dev_name = "cyttsp6_mt";
/* CY_MT_FLAG_FLIP | CY_MT_FLAG_INV_X | CY_MT_FLAG_INV_Y */
cy,flags = <0x18>;
cy,abs =
/* ABS_MT_POSITION_X, CY_ABS_MIN_X, CY_ABS_MAX_X, 0, 0 */
<0x35 0 1526 0 0
/* ABS_MT_POSITION_Y, CY_ABS_MIN_Y, CY_ABS_MAX_Y, 0, 0 */
0x36 0 768 0 0
/* ABS_MT_PRESSURE, CY_ABS_MIN_P, CY_ABS_MAX_P, 0, 0 */
0x3a 0 255 0 0
/* CY_IGNORE_VALUE, CY_ABS_MIN_W, CY_ABS_MAX_W, 0, 0 */
0xffff 0 255 0 0
/* ABS_MT_TRACKING_ID, CY_ABS_MIN_T, CY_ABS_MAX_T, 0, 0 */
0x39 0 15 0 0
/* ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0 */
0x30 0 255 0 0
/* ABS_MT_TOUCH_MINOR, 0, 255, 0, 0 */
0x31 0 255 0 0
/* ABS_MT_ORIENTATION, -127, 127, 0, 0 */
0x34 0xffffff81 127 0 0
/* ABS_MT_TOOL_TYPE, 0, MT_TOOL_MAX, 0, 0 */
0x37 0 1 0 0
/* ABS_DISTANCE, 0, 255, 0, 0 */
0x19 0 255 0 0>;
cy,vkeys_x = <1366>;
cy,vkeys_y = <768>;
cy,virtual_keys = /* KeyCode CenterX CenterY Width Height */
/* KEY_BACK */
<158 1360 90 160 180
/* KEY_MENU */
139 1360 270 160 180
/* KEY_HOMEPAGE */
172 1360 450 160 180
/* KEY SEARCH */
217 1360 630 160 180>;
};
cy,btn {
cy,inp_dev_name = "cyttsp6_btn";
};
cy,proximity {
cy,inp_dev_name = "cyttsp6_proximity";
cy,abs =
/* ABS_DISTANCE, CY_PROXIMITY_MIN_VAL, CY_PROXIMITY_MAX_VAL, 0, 0 */
<0x19 0 1 0 0>;
};
};
};
④最后需要把上步修改的interrupt pin设置成gpio function(pinctrl.dtsi中)
setb_9: setb_9 {
mux {
pins = "gpio22";
function = "gpio";
};
config {
pins = "gpio22";
drive-strength = <16>;
bias-disable;
};
};
理论上做完这些,编译boot.img烧入,touch应该至少能动了
4>添加idc配置文件,配置TP的类型、方向等
PRODUCT_COPY_FILES += device/qcom/msm8996/cyttsp6_mt.idc:system/usr/idc/cyttsp6_mt.idc
这是idc文件内容
touch.deviceType = touchScreen
touch.orientationAware = 1
keyboard.orientationAware = 1
keyboard.builtIn = 1
cursor.mode = navigation
cursor.orientationAware = 1
remount后直接push进去,或者编译system烧入,即可
最后
以上就是受伤芝麻为你收集整理的Touch driver porting的全部内容,希望文章能够帮你解决Touch driver porting所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复