您的位置:首页 > 编程语言 > PHP开发

MTK MT8163 7.0 TP驱动简单移植

2016-12-16 21:00 2046 查看
本文只是依照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>;
};


其中:compatible = “mediatek,cap_touch” 必须对应

gt9xx_driver.c中的:

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点触摸

pinctrl 以CTP_pins_eint_output0 CTP_pins_eint_output1 为例:

dts里边定义:

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驱动调试过程!!!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: