搜索

2

主题

3

帖子

62

积分

注册会员

Rank: 2

积分
62
发表于 2020-11-16 15:41:31 3175 浏览 0 回复

MTK CTP调试过程

本帖最后由 YWXY 于 2020-11-16 15:41 编辑

驱动移植环境:
触摸屏:ft5x0x
主  控:MT6761
内  核:kernel-4.9
工  程:k61v1_64_bsp

1.硬件IO配置
1.1 使用DrvGen.exe工具(路径:vendor\mediatek\proprietary\scripts\dct\DrvGen.exe)配置vendor和kernel目录下的dws文件,路径如下:
vendor:vendor\mediatek\proprietary\bootable\bootloader\lk\target\k61v1_64_bsp\dct\dct\codegen.dws
kernel:kernel-4.9\drivers\misc\mediatek\dws\mt6761\k61v1_64_bsp.dws
依次配置中断(ENIT)、管脚(GPIO)、I2C。确保两个dws文件配置一致。

1.2 配置设备树原码(dts)文件,具体引脚须由硬件原理图获知,以实物测试验证。注意dws文件配置保持一致
文件路径:kernel-4.9\arch\arm64\boot\dts\mediatek\k61v1_64_bsp.dts
  1. &touch {
  2.         tpd-resolution = <720 1280>;/*分辨率*/
  3.         use-tpd-button = <0>;/*是否有TP按键,有为1,无为0.*/
  4.         tpd-key-num = <3>;/*TP按键个数*/
  5.         tpd-key-local= <139 172 158 0>;/*按键编码 一般设置为meun、home、back */
  6.         tpd-key-dim-local = <90 883 100 40 230 883 100 40 370 883 100 40 0 0 0 0>;
  7. /*<90 883 100 40> 代表meun key 中心坐标(90,883),100是key的宽度,40是高度*/
  8.         tpd-max-touch-num = <5>;/*支持最大的触摸点数*/
  9.         tpd-filter-enable = <1>;
  10.         tpd-filter-pixel-density = <186>;
  11.         tpd-filter-custom-prameters = <0 0 0 0 0 0 0 0 0 0 0 0>;
  12.         tpd-filter-custom-speed = <0 0 0>;
  13.         pinctrl-names = "default", "state_eint_as_int", "state_eint_output0", "state_eint_output1",
  14.                 "state_rst_output0", "state_rst_output1";
  15.         pinctrl-0 = <&ctp_pins_default>;
  16.         pinctrl-1 = <&ctp_pins_eint_as_int>;
  17.         pinctrl-2 = <&ctp_pins_eint_output0>;
  18.         pinctrl-3 = <&ctp_pins_eint_output1>;
  19.         pinctrl-4 = <&ctp_pins_rst_output0>;
  20.         pinctrl-5 = <&ctp_pins_rst_output1>;
  21.         status = "okay";
  22. };
复制代码
  1. &pio {
  2. /*配置中断pin*/
  3.         ctp_pins_default: eint0default {
  4.         };
  5.         ctp_pins_eint_as_int: eint@0 {
  6.                 pins_cmd_dat {
  7.                         pins = <PINMUX_GPIO0__FUNC_GPIO0>;
  8.                         slew-rate = <0>;
  9.                         bias-disable;
  10.                 };
  11.         };
  12.         ctp_pins_eint_output0: eintoutput0 {
  13.                 pins_cmd_dat {
  14.                         pins = <PINMUX_GPIO0__FUNC_GPIO0>;
  15.                         slew-rate = <1>;
  16.                         output-low;
  17.                 };
  18.         };
  19.         ctp_pins_eint_output1: eintoutput1 {
  20.                 pins_cmd_dat {
  21.                         pins = <PINMUX_GPIO0__FUNC_GPIO0>;
  22.                         slew-rate = <1>;
  23.                         output-high;
  24.                 };
  25.         };
  26. /*配置复位pin*/
  27.         ctp_pins_rst_output0: rstoutput0 {
  28.                 pins_cmd_dat {
  29.                         pins = <PINMUX_GPIO90__FUNC_GPIO90>;  //由adb调试得实际应为90
  30.                         slew-rate = <1>;
  31.                         output-low;
  32.                 };
  33.         };
  34.         ctp_pins_rst_output1: rstoutput1 {
  35.                 pins_cmd_dat {
  36.                         pins = <PINMUX_GPIO90__FUNC_GPIO90>; //由adb调试得实际应为90
  37.                         slew-rate = <1>;
  38.                         output-high;
  39.                 };
  40.         };
  41. };
复制代码
2.TP驱动移植
2.1 将TP驱动文件添加到touchscreen文件下
添加路径:kernel-4.9\drivers\input\touchscreen\mediatek\ft5x0x

2.2 修改配置文件
2.2.1 文件路径:kernel-4.9\drivers\input\touchscreen\mediatek\kconfig
添加如下代码:
  1. config TOUCHSCREEN_MTK_FT5X0X
  2.         bool "FT5X0X for Mediatek package"
  3.         default n
  4.         help
  5.           Say Y here if you have FT5X0X touch panel.
  6.           If unsure, say N.
  7.           To compile this dirver as a module, choose M here: the
  8.           module will be called.
  9. source "drivers/input/touchscreen/mediatek/ft5x0x/Kconfig"
复制代码
2.2.2 文件路径:kernel-4.9\drivers\input\touchscreen\mediatek\makefile
添加代码使触摸屏驱动文件编译进内核:
  1. obj-$(CONFIG_TOUCHSCREEN_MTK_FT5X0X)        +=  ft5x0x/
复制代码
2.2.3 文件路径:kernel-4.9\arch\arm64\configs\k61v1_64_bsp_defconfig
打开对应TP的宏
  1. CONFIG_TOUCHSCREEN_MTK_FT5X0X=y
复制代码
2.2.4 文件路径:device\mediateksample\k61v1_64_bsp\ProjectConfig.mk
设备层配置:
  1. CUSTOM_KERNEL_TOUCHPANEL = ft5x0x
复制代码
3.编译
编译通过后,烧录到硬件并验证触摸屏是否正常工作。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

返回列表
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


登录或注册
快速回复 返回顶部 返回列表