linux device adapted touch screen (gt1151)

Record the process of gt1151 touch drive adapter, which is controlled by the full log D1s dot screen strong core.

First, to find the touch driver source, you can go to the github repository of goodix and find a generic driver code with the following links:
https://github.com/goodix/gt1x_driver_generic.git

Drivers/input/touchscreen/gt1x_in Tina's kernel corresponding driver directory after downloading New, add a new directory gt1x_new, here's the driver code and the dts adapter.

DTS Configuration

To configure DTS first, it is necessary to define the hardware pin configuration before configuring dts. Looking at the hardware schematic diagram, I know that I use i2c2 to drive (PD20, PD21). In this SDK, I2C is called twi. First, the corresponding pin is reused as I2C function, and DTS is modified as follows:

	twi2_pins_a: twi2@0 {
		//pins = "PE12", "PE13";
		pins = "PD20", "PD21";
		function = "twi2";
		drive-strength = <10>;
	};

	twi2_pins_b: twi2@1 {
		//pins = "PE12", "PE13";
		pins = "PD20", "PD21";
		function = "gpio_in";
	};

Then there is the touch screen dts configuration under the twi2 bus, which can be used as a reference in the official documentation:

Optional properties

  • goodix,charger-configx: chip configuration data used in charger mode, if you
    hava enabled CONFIG_GTP_CHAGER_SWITCH, you need to add this property.
    x stands for sendor ID.
  • goodix,smartcover-configx: chip configuration data used in smartcover mode, if
    you have enabled CONFIG_GTP_SMARTCOVER, you need to add this property.

Example

	i2c@f9927000 { /*Goodix BLSP1 QUP5 */
		goodix_ts@5d {
			compatible = "goodix,gt1x";
			reg = <0x5d>;
			interrupt-parent = <&msmgpio>;
			interrupts = <17 0x2008>;
			vdd_ana-supply = <&pm8226_l19>;
			goodix,reset-gpio = <&msmgpio 16 0x00>;
			goodix,irq-gpio = <&msmgpio 17 0x00>;
			goodix,default-config0 = [
				5c 00 12 11 10 11 5f 00 cc bb
				22 00 11 00 00 00 00 00 00 00
				...
			];
			goodix,charger-config2 = [
				5f 00 12 11 10 11 5f 00 cc bb
				23 00 11 00 00 00 00 00 00 00
				...
			];
			/* if you have disable CONFIG_GTP_INT_SEL_SYNC,
			 * please add properties below.
			 * You should config goodix_int_pull_up node in
			 * the pinctrl dtsi file */
			pinctrl-names = "default";
			pinctrl-0 = <&goodix_int_pull_up>;

};

From the example above, I can get my modified dts configuration

	goodix_ts@14 {
		compatible = "goodix,gt1x";
		reg = <0x14>;
		interrupt-parent = <&pio>;
		interrupts = <PD 12 IRQ_TYPE_EDGE_FALLING>;
		//vdd_ana-supply = <&pm8226_l19>;
		goodix,reset-gpio = <&pio PD 13 GPIO_ACTIVE_HIGH>;
		goodix,irq-gpio = <&pio PD 12 GPIO_ACTIVE_HIGH>;
		goodix,default-config1 = [
			46  D0  02  00  05  05  3D  14  08  80
			.....
			.....
			//Omit some parameters
		];
	};

vdd_ana-supply does not need to be used anymore, it is mainly to determine the i2c address, reset-gpio and irq-gpio pin configuration. Then default-config data is the configuration parameter that the touch screen manufacturer will provide. Notice the default-configX, where the serial number of X, requires you to read the sensor id by touch loading. Now I don't know if I can comment out the configuration part of default-config first, and wait until the code is ready to run to get the sensor id added back and forth.

Driver Code Adaptation

Open linux kernel code
drivers/input/touchscreen/Kconfig file with our touch kconfig path at the end

source "drivers/input/touchscreen/gt1x_new/Kconfig
endif

Add at the end of the drivers/input/touchscreen/Makefile file file

obj-$(CONFIG_INPUT_TOUCHSCREEN)    += gt1x_new/

Use make kernel_in the Tina root directory Menuconfig to select our new touch driver
Device Drivers > Input device support > Touchscreens

There are other settings you can do to get inside

Then you can compile, of course, some errors will inevitably occur during the first compilation. Since D1s is riscv architecture different from arm, I need to change gt1x_here Generic. Header file reference in H file #include <asm/uaccess. H>Change to #include <linux/uaccess. H> and compile again to pass.

Look at the startup log

I read the i2c from address 0x14, sensor ID 1, so default-configX in our previous dts can be changed to default-config1, which I've already done here.
input2 is basically fine.

Run the test tool to see if it is available, execute evtest/dev/input/event2,

You can also use the getevent tool, and you will see the print information on the touch screen

Keywords: Linux ARM riscv

Added by yuraupt on Fri, 18 Feb 2022 12:44:24 +0200