与之前不同的是,tp涉及到i2c或在spi了,大部分还是通过i2c地址来判别的,本例子也通过i2c来举例
1.配置对应的dtsi
$(LINUX_KERNEL_VERSION)/arch/arm/boot/dts/$(MTK_PLATFORM).dts
(分别对应内核版本,32还是64位,mtk平台)
在主dts中配置touch的设备节点,会与驱动里面对应
touch: touch {
compatible = "mediatek,touch";
};
在项目所在的dst里面配置设备相关信息,不过因为tp的设备类型可能有变化,所以一般单独定义
$(LINUX_KERNEL_VERSION)/arch/arm/boot/dts/$(yourprojectname).dts里面导入我们定义出来的定义文件
#include "cust_mt6761_touch_1600x720.dtsi"(本项目是mt6761平台,1600x720分辨率)根据自己情况定义,与定义文件名保持一致即可
/* TOUCH start */
&i2c0 {
clock-frequency = <400000>;
pinctrl-names = "default", "ts_int_active",
"ts_reset_active", "ts_int_suspend",
"ts_reset_suspend", "ts_i2c_mode",
"ts_eint_high";
pinctrl-0 = <&ctp_pins_default>;
pinctrl-1 = <&ctp_ts_int_active>;
pinctrl-2 = <&ctp_ts_reset_active>;
pinctrl-3 = <&ctp_ts_int_suspend>;
pinctrl-4 = <&ctp_ts_reset_suspend>;
pinctrl-5 = <&ctp_ts_i2c_mode>;
pinctrl-6 = <&ctp_ts_int_as_gpio>;
};
&touch {
tpd-resolution = <720 1600>;
lcm-resolution = <720 1600>;
tpd-cfg-version = "config17";
tpd-max-touch-num = <10>;
use-tpd-button = <0>;
tpd-key-num = <3>;
tpd-key-local= <139 172 158 0>;
tpd-key-dim-local = <40 980 40 40 120 980 40 40 200 980 40 40 0 0 0 0>;
interrupt-parent = <&pio>;
interrupts = <9 IRQ_TYPE_EDGE_FALLING 9 0>;
goodix,eint-gpio = <&pio 9 0x0>;
goodix,reset-gpio = <&pio 174 0x0>;
vtouch-supply = <&mt_pmic_vldo28_ldo_reg>;
/*jadard dt info*/
jadard,panel-sense-nums = <18 32>;
jadard,panel-coords = <0 720 0 1600>;
jadard,panel-max-points = <10>;
jadard,int-is-edge = <1>;
gpios=<&pio 9 0x0>,<&pio 174 0x0>;
jadard,irq-gpio = <&pio 9 0x0>;
jadard,rst-gpio = <&pio 174 0x0>;
/* Rotate cord when open blew lables */
/*goodix,x2x;*/
/*goodix,y2y;*/
tpd-filter-enable = <1>;
tpd-filter-pixel-density = <146>;
tpd-filter-custom-prameters = <0 0 0 0 0 0 0 0 0 0 0 0>;
tpd-filter-custom-speed = <0 0 0>;
status = "okay";
};
&pio {
ctp_pins_default: eintdefault {
};
ctp_ts_int_active: int_active {
pins_cmd_dat {
pinmux = <PINMUX_GPIO9__FUNC_GPIO9>;
input-enable;
bias-pill-up = <MTK_PUPD_SET_R1R0_11>;
};
};
ctp_ts_reset_active: reset_active {
pins_cmd_dat {
pinmux = <PINMUX_GPIO174__FUNC_GPIO174>;
slew-rate = <1>;
output-high;
};
};
ctp_ts_int_suspend: int_suspend {
pins_cmd_dat {
pinmux = <PINMUX_GPIO9__FUNC_GPIO9>;
slew-rate = <1>;
output-low;
};
};
ctp_ts_reset_suspend: reset_suspend {
pins_cmd_dat {
pinmux = <PINMUX_GPIO174__FUNC_GPIO174>;
slew-rate = <1>;
output-low;
};
};
ctp_ts_i2c_mode: i2cmode_default {
pins_cmd_dat {
pinmux = <PINMUX_GPIO83__FUNC_SCL0>,
<PINMUX_GPIO82__FUNC_SDA0>;
};
};
ctp_ts_int_as_gpio: int_high {
pins_cmd_dat {
pinmux = <PINMUX_GPIO9__FUNC_GPIO9>;
slew-rate = <1>;
output-high;
};
};
};
/* TOUCH end */
注意与自己项目原理图对应,改i2c通道,scl与sda,tp的eint引脚与reset引脚实际的gpio
2.修改dws,dws现在一般只有三条路径,都要保持一致
根据原理图,在scl,sda,tp_eint,tp_rst对应的gpio处修改
$(LINUX_KERNEL_VERSION)/drivers/misc/mediatek/dws/$(MTK_PLATFORM)/$(yourprojectname).dws
vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/$(yourprojectname)/dct/dct/codegen.dws
vendor/mediatek/proprietary/custom/$(yourprojectname)/kernel/dct/dct/codegen.dws
改dws,我推荐mtk自带的工具vendor/mediatek/proprietary/tools/dct/DrvGen.exe,不过需要在windows环境打开,修改goip与i2c与enit很方便
3.在user与userdebug的config文件创建驱动宏
$(LINUX_KERNEL_VERSION)/arch/arm/configs/$(yourprojectname)_debug_defconfig
$(LINUX_KERNEL_VERSION)/arch/arm/configs/$(yourprojectname)_defconfig
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_MTK_JDCHIPSET_XBD=y // y代表true is not set 为false
4.在驱动外的makefile与Kconfig添加驱动的加载路径
kernel-4.19/drivers/input/touchscreen/Makefile
obj-$(CONFIG_TOUCHSCREEN_MTK_JDCHIPSET_XBD) += jadard_xbd/ //后面这个是驱动名
这个宏与上面config文件里面宏匹配上了,如果为true,编译后面驱动,false不编译
kernel-4.19/drivers/input/touchscreen/Kconfig
config CONFIG_TOUCHSCREEN_MTK_JDCHIPSET_XBD
bool "MediaTek Touch Panel Driver"
help
Say Y here if you have MediaTek touch panel.
If unsure, say N.
To compile this dirver as a module, choose M here: the
module will be called.
或者简写为
config TOUCHSCREEN_MTK_JDCHIPSET_XBD
bool "jadard directory name"
default n
5.添加厂家给的驱动
$(LINUX_KERNEL_VERSION)/drivers/input/touchscreen/jadard_xbd(根据自己的驱动名)