MTK MT8163 7.0 TP驱动简单移植

MTK MT8163 7.0 TP驱动简单移植文章来源 http blog csdn net qf0727 article details 本文只是依照 MTK MT8163 7 0 框架移植进行的实际操作 基于驱动代码已经 ok 的情况下 并没有考虑到调试层面 如有需要必须抓 log 等各种方法进行调试 GT9xx 驱动及驱动文件简介 1

大家好,我是讯享网,很高兴认识大家。

文章来源:http://blog.csdn.net/qf0727/article/details/

本文只是依照MTK MT8163 7.0框架移植进行的实际操作,基于驱动代码已经ok的情况下,并没有考虑到调试层面,如有需要必须抓log等各种方法进行调试!
GT9xx驱动及驱动文件简介
1.GT9xx驱动基本信息
2.驱动文件说明
驱动移植step by step
3.touchscreen中driver复制及makefile Kconfig修改
4.硬件电路及gpio配置
5.dts defconfig中配置tp信息

GT9xx驱动及驱动文件简介
1.GT9xx驱动基本信息
这里写图片描述
讯享网
2.驱动文件说明

kernel-3.18/drivers/input/touchscreen/mediatek/GT9XX$ find . . ./gt9xx_extents.c ./Kconfig ./include ./include/tpd_gt9xx_common.h ./include/firmware1 ./include/firmware1/gt9xx_firmware.h ./include/config0 ./include/config0/gt9xx_config.h ./include/firmware0 ./include/firmware0/gt9xx_firmware.h ./include/config1 ./include/config1/gt9xx_config.h ./gt9xx_update.c ./gt9xx_driver.c ./goodix_tool.c ./Makefile

讯享网

(1)gt9xx_driver.c :驱动主功能文件,用来初始化触摸屏、实现驱动的挂载、读取上报坐标、休眠唤醒处理等触摸屏驱动的基本功能。
(2)./include/config0/gt9xx_config.h:存放CTP_CFG_GROUP数组及TP的配置信息,一般为TP厂提 供的(*cfg或*txt)文件里面的内容,tp参数调试好根据sensorID替换数组里面的内容即可。目前我们代码生效的是./include/config0/gt9xx_config.h调试tp参数改这
(3)./include/tpd_gt9xx_common.h:驱动头文件,包含驱动中要用到的一些宏和常量的定义、外部变量和函数的声明等。
(4)./include/firmware0/gt9xx_firmware.h:tp固件,汇顶提供
(5)goodix_tool.c:驱动中用于支持gtp_tools.apk工具和ADB工具的文件,该工具可以在装成整机后再在Android上层对触控IC进行测试、调试、检测等功能,强烈推荐在驱动中增加此功能,特别是使用COB(触控IC直接layout在主板上)模式的TP时,此工具能极大的方便整机上的TP调试
(6)gt9xx_update.c:驱动用于支持固件升级的文件,对于触摸屏驱动来说,该文件不是必需的。
(7)Kconfig:GTP的一些变量宏定义,依赖于TOUCHSCREEN_MTK_GT9XX,tp驱动必须确保config GTP_DRIVER_SEND_CFG为y,out/target/product/hiteq8163_tb_n/obj/KERNEL_OBJ/.config编译完成后,可以在找到相关config,确保此Kconfig中的配置生效,如不一直,彻查编译规则看哪里受影响了(调试期间遇到CONFIG_GTP_DRIVER_SEND_CFG=n是由于默认编译别的tp所致)

驱动移植step by step
3. touchscreen中driver复制及makefile Kconfig修改
(1)将原厂给的GT9XX/驱动文件拷贝至:kernel-3.18/drivers/input/touchscreen/mediatek/ 目录

讯享网kernel-3.18/drivers/input/touchscreen/mediatek/GT9XX$ ls goodix_tool.c gt9xx_driver.c gt9xx_extents.c gt9xx_update.c include Kconfig Makefile

(2)Makefile修改kernel-3.18/drivers/input/touchscreen/mediatek/Makefile
添加:

 +obj-$(CONFIG_TOUCHSCREEN_MTK_GT9XX) += GT9XX/

(3)Kconfig修改kernel-3.18/drivers/input/touchscreen/mediatek/Kconfig
添加:

讯享网183 config TOUCHSCREEN_MTK_GT9XX 184 bool "GT9XXTB hotknot for Mediatek package" 185 default n 186 help 187 Say Y here if you have GT9xx touch panel. 188 189 If unsure, say N. 190 191 To compile this dirver as a module, choose M here: the 192 module will be called. 193 194 source "drivers/input/touchscreen/mediatek/GT9XX/Kconfig"

4.硬件电路及gpio配置

TP接口电路:
这里写图片描述
这里写图片描述

芯片端接口电路:
这里写图片描述

根据上图的芯片端接口电路然后依据GPIOtable,可以找到相对应的GPIO号
EINT_CTP_INT 接的是TP的中断脚,同时也是对应芯片的GPIO35,并且可以看出中断号为 EINT46,对配置dts有用
GPIO_CTP_RST 接的是TP的复位脚,同时也是对应芯片的GPIO45
这里写图片描述

GPIO口配置:
打开:\vendor\mediatek\proprietary\bootable\bootloader\preloader\tools\dct\old_dct\DrvGen.exe
选择:

\vendor\mediatek\proprietary\bootable\bootloader\preloader\custom\hiteq8163_tb_n\dct\dct\codegen.dws

配置EINT_CTP_INT(GPIO35)为中断
配置GPIO_CTP_RST(GPIO45)为复位引脚
这里写图片描述

5.dts defconfig中配置tp信息
(1)dts修改:kernel-3.18/arch/arm64/boot/dts/hiteq8163_tb_n.dts
主要修改如下两个节点:

讯享网 cap_touch@5D { compatible = "mediatek,cap_touch"; reg = <0x5D>; interrupt-parent = <&pio>; interrupts = <46 IRQ_TYPE_EDGE_FALLING>; int-gpio = <&pio 35 0>; rst-gpio = <&pio 45 0>; }; 
static const struct of_device_id gt9xx_dt_match[] = { {.compatible = "mediatek,cap_touch"}, {},}; 

一般修改以下几个:
reg = <0x5D> 指的是TP I2C设备地址(7位) 我们用的是0x5D
interrupts = <46 IRQ_TYPE_EDGE_FALLING> 指的是中断号46(GPIOtable里能看到),下降沿触发
int-gpio = <&pio 35 0>; 中断脚 GPIO35(根据硬件接法修改)
rst-gpio = <&pio 45 0>; 复位脚GPIO45(根据硬件接法修改)

讯享网&touch { vtouch-supply = <&mt6323_vgp2_reg>; tpd-resolution = <768 1024>; use-tpd-button = <0>; tpd-key-num = <4>; tpd-key-local= <139 172 158 0>; tpd-key-dim-local = <60 850 50 30 180 850 50 30 300 850 50 30 420 850 50 30>; tpd-max-touch-num = <5>; tpd-filter-enable = <1>; tpd-filter-pixel-density = <124>; 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"; };

一般修改以下几个:
tpd-resolution = <768 1024>; tp范围,依据屏分辨率而定我们用的屏是7.85寸768*1024的故参数修改为 <768 1024>
tpd-max-touch-num = <5>; 表示最多支持5点触摸

 CTP_pins_eint_output0: eintoutput0 { pins_cmd_dat { pins = <MT8163_PIN_35_KPROW2__FUNC_GPIO35>; slew-rate = <1>; output-low; }; }; CTP_pins_eint_output1: eintoutput1 { pins_cmd_dat { pins = <MT8163_PIN_35_KPROW2__FUNC_GPIO35>; slew-rate = <1>; output-high; }; }; 

继续查找:
MT8163_PIN_35_KPROW2__FUNC_GPIO35
mt8163-pinfunc.h中(此文件就是全GPIO口全功能定义的函数):

讯享网254 #define MT8163_PIN_35_KPROW2__FUNC_GPIO35 (MTK_PIN_NO(35) | 0) 255 #define MT8163_PIN_35_KPROW2__FUNC_KPROW2 (MTK_PIN_NO(35) | 1) 256 #define MT8163_PIN_35_KPROW2__FUNC_USB_DRVVBUS (MTK_PIN_NO(35) | 2) 257 #define MT8163_PIN_35_KPROW2__FUNC_EXT_FRAME_SYNC (MTK_PIN_NO(35) | 3) 258 #define MT8163_PIN_35_KPROW2__FUNC_CONN_TEST_CK (MTK_PIN_NO(35) | 4) 259 #define MT8163_PIN_35_KPROW2__FUNC_DBG_MON_B_6 (MTK_PIN_NO(35) | 7)

(2)defconfig修改
kernel-3.18/arch/arm64/configs/hiteq8163_tb_n_debug_defconfig (编译版本eng userdebug生效)
kernel-3.18/arch/arm64/configs/hiteq8163_tb_n_defconfig(编译版本user生效)
定义+CONFIG_TOUCHSCREEN_MTK_GT9XX=y 去掉之前的tp配置即可

 CONFIG_INPUT_TOUCHSCREEN=y CONFIG_TOUCHSCREEN_MTK=y -CONFIG_TOUCHSCREEN_MTK_FT5X0X=y -CONFIG_FT5X0X_FIRMWARE="firmware1" -CONFIG_FT_AUTO_UPGRADE_SUPPORT=y +CONFIG_TOUCHSCREEN_MTK_GT9XX=y +#CONFIG_TOUCHSCREEN_MTK_FT5X0X=y +#CONFIG_FT5X0X_FIRMWARE="firmware1" +#CONFIG_FT_AUTO_UPGRADE_SUPPORT=y

由上面可以总结出,我们移植要修改的东西主要是
kernel-3.18/drivers/input/touchscreen/mediatek/ 目录添加GT9XX/驱动文件
kernel-3.18/drivers/input/touchscreen/mediatek/Makefile 与
kernel-3.18/drivers/input/touchscreen/mediatek/Kconfig添加编译GT9XX/目录驱动文件的规则

\vendor\mediatek\proprietary\bootable\bootloader\preloader\custom\hiteq8163_tb_n\dct\dct\codegen.dws 配置GPIO口

kernel-3.18/arch/arm64/boot/dts/hiteq8163_tb_n.dts 修改tp配置节点cap_touch,主要是GPIO中断复位及tp IIC地址;&touch配置tp相关参数,虚拟按键,多点触碰,触碰x y大小(依据屏分辨率),以及pinctrl配置

/kernel-3.18/arch/arm64/configs/hiteq8163_tb_n_debug_defconfigh或/kernel-3.18/arch/arm64/configs/hiteq8163_tb_n_defconfig配置CONFIG_TOUCHSCREEN_MTK_GT9XX=y以及去掉之前的TP配置信息!

之后有机会再更新具体的tp驱动调试过程!!!!!

小讯
上一篇 2025-04-07 09:57
下一篇 2025-04-11 20:24

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/42019.html