搜索

19

主题

25

帖子

379

积分

中级会员

Rank: 3Rank: 3

积分
379
发表于 2020-7-27 17:27:25 6475 浏览 6 回复

MTK CTP porting

本帖最后由 software13 于 2020-7-27 17:39 编辑

TP启动过程及驱动概述:

Mtk Touch driver 驱动包括:Mtkplatform 虚拟平台设备驱动、Module touch IC 驱动、Inputsubsystem。
Mtk platform 设备驱动是mtk为了兼容多个touch IC驱动而设计出来的虚拟驱动,它会去遍历每一个touch IC驱动,直到其中一个初始化成功。
Linux input_subsystem是linux的输入子系统,我们的输入设备都要通过这个子系统进行上报事件以及设置事件的类型。
  1. static struct tpd_driver_t tpd_device_driver = {
  2.         .tpd_device_name = "FT5x0x",
  3.         .tpd_local_init = tpd_local_init,       //tp初始化,主要是注册iic、设置电压、注册中断等
  4.         .suspend = tpd_suspend,               //休眠
  5.         .resume = tpd_resume,                  //唤醒
  6.         .attrs = {
  7.                 .attr = ft5x0x_attrs,
  8.                 .num  = ARRAY_SIZE(ft5x0x_attrs),
  9.         },
  10. };
复制代码


                                                   TP启动流程









本帖子中包含更多资源

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

x
回复

使用道具 举报

19

主题

25

帖子

379

积分

中级会员

Rank: 3Rank: 3

积分
379
 楼主| 发表于 2020-7-27 17:51:56
本帖最后由 software13 于 2020-7-27 18:17 编辑

MTK平台添加新的TP:

1.将TP驱动文件添加到touchscreen文件下,路径:kernel-4.4\drivers\input\touchscreen\mediatek\ft5x0x
2.添加对应的TP配置:kernel-4.4\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"
复制代码
3.添加makefile:kernel-4.4\drivers\input\touchscreen\mediatek\makefile
  1. obj-$(CONFIG_TOUCHSCREEN_MTK_FT5X0X)        +=  ft5x0x/
复制代码
4.打开对应TP的宏(把不用的屏蔽掉) kernel-4.4\arch\arm64\configs\k63v1us_64_bsp_defconfig
  1. CONFIG_TOUCHSCREEN_MTK_FT5X0X=y
复制代码
5.添加TP设备:device\mediateksample\k63v1us_64_bsp\ProjectConfig.mk
  1. CUSTOM_KERNEL_TOUCHPANEL = ft5x0x(文件名)
复制代码

回复

使用道具 举报

430

主题

515

帖子

2102

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2102
QQ
发表于 2020-7-27 18:14:42
software13 发表于 2020-7-27 17:51
MTK平台添加新的TP:

缺少dts的配置
手机微信同号:13682654092
回复

使用道具 举报

19

主题

25

帖子

379

积分

中级会员

Rank: 3Rank: 3

积分
379
 楼主| 发表于 2020-7-27 18:18:29
本帖最后由 software13 于 2020-7-27 19:02 编辑

根据硬件接口配置dts:kernel-4.9\arch\arm\boot\dts\k61v1_32.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. };
  23. &pio {
  24. /*配置中断pin*/
  25.         ctp_pins_default: eint0default {
  26.         };
  27.         ctp_pins_eint_as_int: eint@0 {
  28.                 pins_cmd_dat {
  29.                         pins = <PINMUX_GPIO0__FUNC_GPIO0>;
  30.                         slew-rate = <0>;
  31.                         bias-disable;
  32.                 };
  33.         };
  34.         ctp_pins_eint_output0: eintoutput0 {
  35.                 pins_cmd_dat {
  36.                         pins = <PINMUX_GPIO0__FUNC_GPIO0>;
  37.                         slew-rate = <1>;
  38.                         output-low;
  39.                 };
  40.         };
  41.         ctp_pins_eint_output1: eintoutput1 {
  42.                 pins_cmd_dat {
  43.                         pins = <PINMUX_GPIO0__FUNC_GPIO0>;
  44.                         slew-rate = <1>;
  45.                         output-high;
  46.                 };
  47.         };
  48. /*配置复位pin*/
  49.         ctp_pins_rst_output0: rstoutput0 {
  50.                 pins_cmd_dat {
  51.                         pins = <PINMUX_GPIO90__FUNC_GPIO90>;
  52.                         slew-rate = <1>;
  53.                         output-low;
  54.                 };
  55.         };
  56.         ctp_pins_rst_output1: rstoutput1 {
  57.                 pins_cmd_dat {
  58.                         pins = <PINMUX_GPIO90__FUNC_GPIO90>;
  59.                         slew-rate = <1>;
  60. output-high;
  61.                 };
  62.         };
  63. };
复制代码

回复

使用道具 举报

0

主题

1

帖子

76

积分

注册会员

Rank: 2

积分
76
发表于 2020-8-27 14:14:04
XY6580开发板对应的哪个驱动文件路径,还有以上第四第五步路径位置
回复

使用道具 举报

430

主题

515

帖子

2102

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2102
QQ
发表于 2020-8-27 17:58:38
2587545155@qq.c 发表于 2020-8-27 14:14
XY6580开发板对应的哪个驱动文件路径,还有以上第四第五步路径位置

XY6580的内核配置文件在:kernel-3.18\arch\arm\configs\k80_bsp_defconfig
dts文件路径在:kernel-3.18\arch\arm\boot\dts\k80_bsp.dts
CTP的驱动路径在:kernel-3.18\drivers\input\touchscreen\mediatek\ft5x0x
手机微信同号:13682654092
回复

使用道具 举报

430

主题

515

帖子

2102

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2102
QQ
发表于 2020-9-8 19:10:48
本帖最后由 tangh 于 2020-9-8 19:15 编辑

该CTP的整篇移植部分缺少关于I2C的配置,MTK平台默认是将I2C的配置集成在了dws文件里面,通过工具直接修改dws文件并保存之后,编译时再会生成cust.dtsi文件,那我们如果需要更改ctp的i2c配置,方法如下:
android 8.1及以后

dws工具路径:vendor\mediatek\proprietary\scripts\dct\DrvGen.exe
DWS文件路径(MT6765为例):alps-release-p0.mp1-V5\kernel-4.9\drivers\misc\mediatek\dws\mt6765\k65v1_64_bsp.dws
详细的操作步骤参考附件中的图片所示:
保存之后,执行make -j24编译,查看生成文件:
alps-release-p0.mp1-V5\out\target\product\k65v1_64_bsp\obj\KERNEL_OBJ\arch\arm64\boot\dts\k65v1_64_bsp\cust.dtsi
  1.         cap_touch_mtk:cap_touch@38 {
  2.                 compatible = "mediatek,cap_touch";
  3.                 reg = <0x38>;
  4.                 status = "okay";
  5.         };
复制代码
说明已经修改到了。


本帖子中包含更多资源

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

x
手机微信同号:13682654092
回复

使用道具 举报

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

本版积分规则


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