本帖最后由 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 - &touch {
- tpd-resolution = <720 1280>;/*分辨率*/
- use-tpd-button = <0>;/*是否有TP按键,有为1,无为0.*/
- tpd-key-num = <3>;/*TP按键个数*/
- tpd-key-local= <139 172 158 0>;/*按键编码 一般设置为meun、home、back */
- tpd-key-dim-local = <90 883 100 40 230 883 100 40 370 883 100 40 0 0 0 0>;
- /*<90 883 100 40> 代表meun key 中心坐标(90,883),100是key的宽度,40是高度*/
- tpd-max-touch-num = <5>;/*支持最大的触摸点数*/
- tpd-filter-enable = <1>;
- tpd-filter-pixel-density = <186>;
- 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";
- };
复制代码- &pio {
- /*配置中断pin*/
- ctp_pins_default: eint0default {
- };
- ctp_pins_eint_as_int: eint@0 {
- pins_cmd_dat {
- pins = <PINMUX_GPIO0__FUNC_GPIO0>;
- slew-rate = <0>;
- bias-disable;
- };
- };
- ctp_pins_eint_output0: eintoutput0 {
- pins_cmd_dat {
- pins = <PINMUX_GPIO0__FUNC_GPIO0>;
- slew-rate = <1>;
- output-low;
- };
- };
- ctp_pins_eint_output1: eintoutput1 {
- pins_cmd_dat {
- pins = <PINMUX_GPIO0__FUNC_GPIO0>;
- slew-rate = <1>;
- output-high;
- };
- };
- /*配置复位pin*/
- ctp_pins_rst_output0: rstoutput0 {
- pins_cmd_dat {
- pins = <PINMUX_GPIO90__FUNC_GPIO90>; //由adb调试得实际应为90
- slew-rate = <1>;
- output-low;
- };
- };
- ctp_pins_rst_output1: rstoutput1 {
- pins_cmd_dat {
- pins = <PINMUX_GPIO90__FUNC_GPIO90>; //由adb调试得实际应为90
- slew-rate = <1>;
- output-high;
- };
- };
- };
复制代码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 添加如下代码: - config TOUCHSCREEN_MTK_FT5X0X
- bool "FT5X0X for Mediatek package"
- default n
- help
- Say Y here if you have FT5X0X touch panel.
- If unsure, say N.
- To compile this dirver as a module, choose M here: the
- module will be called.
- source "drivers/input/touchscreen/mediatek/ft5x0x/Kconfig"
复制代码2.2.2 文件路径:kernel-4.9\drivers\input\touchscreen\mediatek\makefile 添加代码使触摸屏驱动文件编译进内核: - obj-$(CONFIG_TOUCHSCREEN_MTK_FT5X0X) += ft5x0x/
复制代码2.2.3 文件路径:kernel-4.9\arch\arm64\configs\k61v1_64_bsp_defconfig 打开对应TP的宏 - CONFIG_TOUCHSCREEN_MTK_FT5X0X=y
复制代码2.2.4 文件路径:device\mediateksample\k61v1_64_bsp\ProjectConfig.mk 设备层配置: - CUSTOM_KERNEL_TOUCHPANEL = ft5x0x
复制代码3.编译 编译通过后,烧录到硬件并验证触摸屏是否正常工作。 |