使用F1C200S从零制作掌机之2.8寸TFT触摸屏(芯片ST7789V和GT911)适配

一、硬件

1.1 TFT屏幕

产品链接

资料链接

型号:HP28030

显示芯片:ST7789V

电容触摸芯片:GT911

分辨率:240*320

数据格式:RGB565

触摸点数:5

接口类型:SPI4线串口

image-20240716211537331

image-20240716211558533

1.2 硬件飞线

1.2.1 背光

限流电阻接多大呢?

背光源由 6 颗 LED 灯并联,每颗 LED 灯典型电流值 15mA,6 颗 LED 灯总电流为:6*15mA=90mA;在设计产 品时,要采用限流电路(通常加 10 欧姆左右的限流电阻),把背光源的总电流限制在 90mA 以内,防止背 光源长时间工作时发热,造成显示屏和背光源不可逆的永久损坏。

1.2.2 触摸
序号屏幕F1C200S
1GNDGND
2RST外部上拉(低电平复位)
3INT_3.3VPA1(下降沿触发)
4SDATWI0_SDA
5SCLTWI0_SCK
6VCC_3.3V3.3V
1.2.3 显示

使用SPI0,调试情况需要去掉SPI芯片,飞线接屏幕。

其他需要修改:R18和R19互换位置。去掉R44。去掉R43。

序号屏幕F1C200S
1GNDGND
2RESET外部上拉(低电平复位)
3SCLSPI0_CLK
4D/CPA0(1数据 0指令)
5CSXSPI0_CS
6SDASPI0_MOSI
7SDOSPI0_MISO
8GNDGND
9VDD3.3V
10LED-A3.3V
11LED-K串接10R电阻接地(测试就GND)
12LED-K串接10R电阻接地(测试就GND)
13LED-K串接10R电阻接地(测试就GND)
14LED-K串接10R电阻接地(测试就GND)

使用转接板

序号转接板F1C200S
13.33.3V
2GNDGND
3IO_BK 背光3.3V
4NC
5LCD_RST3.3V 外部上拉(低电平复位)
6LCD_SCLSPI0_CLK
7LCD_DCPA0(1数据 0指令)
8LCD_CSSPI0_CS
9SPI_MOSISPI0_MOSI
10SPI_MISOSPI0_MISO
11T_MISO
12T_MOSICP_SDA/TWI0_SDA
13T_PENCP_INT/PE11
14NC
15T_CS3.3V 外部上拉(低电平复位)
16T_CLKCP_SCL/TWI0_SCK

二、显示驱动

资料地址

2.1 修改驱动文件

drivers/staging/fbtft/fb_st7789v.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * FB driver for the ST7789V LCD Controller
 *
 * Copyright (C) 2015 Dennis Menschel
 */

#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <video/mipi_display.h>

#include "fbtft.h"

#define DRVNAME "fb_st7789v"

#define DEFAULT_GAMMA \
	"70 2C 2E 15 10 09 48 33 53 0B 19 18 20 25\n" \
	"70 2C 2E 15 10 09 48 33 53 0B 19 18 20 25"

/**
 * enum st7789v_command - ST7789V display controller commands
 *
 * @PORCTRL: porch setting
 * @GCTRL: gate control
 * @VCOMS: VCOM setting
 * @VDVVRHEN: VDV and VRH command enable
 * @VRHS: VRH set
 * @VDVS: VDV set
 * @VCMOFSET: VCOM offset set
 * @PWCTRL1: power control 1
 * @PVGAMCTRL: positive voltage gamma control
 * @NVGAMCTRL: negative voltage gamma control
 *
 * The command names are the same as those found in the datasheet to ease
 * looking up their semantics and usage.
 *
 * Note that the ST7789V display controller offers quite a few more commands
 * which have been omitted from this list as they are not used at the moment.
 * Furthermore, commands that are compliant with the MIPI DCS have been left
 * out as well to avoid duplicate entries.
 */
enum st7789v_command {
	PORCTRL = 0xB2,
	GCTRL = 0xB7,
	VCOMS = 0xBB,
	VDVVRHEN = 0xC2,
	VRHS = 0xC3,
	VDVS = 0xC4,
	VCMOFSET = 0xC5,
	PWCTRL1 = 0xD0,
	PVGAMCTRL = 0xE0,
	NVGAMCTRL = 0xE1,
};

#define MADCTL_BGR BIT(3) /* bitmask for RGB/BGR order */
#define MADCTL_MV BIT(5) /* bitmask for page/column order */
#define MADCTL_MX BIT(6) /* bitmask for column address order */
#define MADCTL_MY BIT(7) /* bitmask for page address order */

/**
 * init_display() - initialize the display controller
 *
 * @par: FBTFT parameter object
 *
 * Most of the commands in this init function set their parameters to the
 * same default values which are already in place after the display has been
 * powered up. (The main exception to this rule is the pixel format which
 * would default to 18 instead of 16 bit per pixel.)
 * Nonetheless, this sequence can be used as a template for concrete
 * displays which usually need some adjustments.
 *
 * Return: 0 on success, < 0 if error occurred.
 */
static int init_display(struct fbtft_par *par)
{
	/* turn off sleep mode */
	write_reg(par, 0x11);
	mdelay(120);
	write_reg(par, 0x36, 0);  // 方向
	write_reg(par, 0x3A, 0x05);
	write_reg(par, 0xB2, 0x0C, 0x0C, 0x00, 0x33, 0x33);
	write_reg(par, 0xB7, 0x71);
	write_reg(par, 0xBB, 0x3B); 
	write_reg(par, 0xC0, 0x2C);
	write_reg(par, 0xC2, 0x01);
	write_reg(par, 0xC3, 0x13);
	write_reg(par, 0xC4, 0x20);
	write_reg(par, 0xC6, 0x0F);
	write_reg(par, 0xD0, 0xA4, 0xA1);
	write_reg(par, 0xD6, 0xA1);

	//write_reg(par, 0x21);
	write_reg(par, 0x29);
	return 0;
}

/**
 * set_var() - apply LCD properties like rotation and BGR mode
 *
 * @par: FBTFT parameter object
 *
 * Return: 0 on success, < 0 if error occurred.
 */
static int set_var(struct fbtft_par *par)
{
	u8 madctl_par = 0;

	if (par->bgr)
		madctl_par |= MADCTL_BGR;
	switch (par->info->var.rotate) {
	case 0:
		break;
	case 90:
		madctl_par |= (MADCTL_MV | MADCTL_MY);   // BIT(5) | BIT(7) = 101
		break;
	case 180:
		madctl_par |= (MADCTL_MX | MADCTL_MY);   // BIT(6) | BIT(7) = 011
		break;
	case 270:
		madctl_par |= (MADCTL_MV | MADCTL_MX);   // BIT(5) | BIT(6) = 110
		break;
	default:
		return -EINVAL;
	}
	write_reg(par, MIPI_DCS_SET_ADDRESS_MODE, madctl_par);
	return 0;
}

/**
 * set_gamma() - set gamma curves
 *
 * @par: FBTFT parameter object
 * @curves: gamma curves
 *
 * Before the gamma curves are applied, they are preprocessed with a bitmask
 * to ensure syntactically correct input for the display controller.
 * This implies that the curves input parameter might be changed by this
 * function and that illegal gamma values are auto-corrected and not
 * reported as errors.
 *
 * Return: 0 on success, < 0 if error occurred.
 */
static int set_gamma(struct fbtft_par *par, u32 *curves)
{
	write_reg(par, PVGAMCTRL, 0xD0, 0x08, 0x0A, 0x0D, 0x0B, 0x07, 0x21, 0x33, 0x39, 0x39, 0x16, 0x16, 0x1F, 0x3C);
	write_reg(par, NVGAMCTRL, 0xD0, 0x00, 0x03, 0x01, 0x00, 0x10, 0x21, 0x32, 0x38, 0x16, 0x14, 0x14, 0x20, 0x3D); 
	
	return 0;
}

/**
 * blank() - blank the display
 *
 * @par: FBTFT parameter object
 * @on: whether to enable or disable blanking the display
 *
 * Return: 0 on success, < 0 if error occurred.
 */
static int blank(struct fbtft_par *par, bool on)
{
	if (on)
		write_reg(par, MIPI_DCS_SET_DISPLAY_OFF);
	else
		write_reg(par, MIPI_DCS_SET_DISPLAY_ON);
	return 0;
}

static struct fbtft_display display = {
	.regwidth = 8,
	.width = 240,
	.height = 320,
	.gamma_num = 2,
	.gamma_len = 14,
	.gamma = DEFAULT_GAMMA,
	.fbtftops = {
		.init_display = init_display,
		.set_var = set_var,
		.set_gamma = set_gamma,
		.blank = blank,
	},
};

FBTFT_REGISTER_DRIVER(DRVNAME, "sitronix,st7789v", &display);

MODULE_ALIAS("spi:" DRVNAME);
MODULE_ALIAS("platform:" DRVNAME);
MODULE_ALIAS("spi:st7789v");
MODULE_ALIAS("platform:st7789v");

MODULE_DESCRIPTION("FB driver for the ST7789V LCD Controller");
MODULE_AUTHOR("Dennis Menschel");
MODULE_LICENSE("GPL");

方向的问题:

if(USE_HORIZONTAL==0)
	Lcd_WriteData(0x08);   // 000
else if(USE_HORIZONTAL==1)
	Lcd_WriteData(0xC8);   // 110
else if(USE_HORIZONTAL==2)
	Lcd_WriteData(0x68);   // 011 
else 
	Lcd_WriteData(0xA8);   // 101

image-20240717151118638

2.2 修改设备树

链接:f1c200s_st7789v设备树。

需要注释掉RGB显示驱动部分。如果不注释会出现在/dev目录下出现2个fb设备。启动信息无法显示到屏幕。

suniv-f1c100s-licheepi-nano.dts

// SPDX-License-Identifier: (GPL-2.0+ OR X11)

/dts-v1/;
#include "suniv-f1c100s.dtsi"

/ {
	model = "Widora MangoPi R3";
	compatible = "allwinner,suniv-f1c200s",
			 "allwinner,suniv-f1c100s";

	aliases {
		//serial0 = &uart0;
		serial1 = &uart1;
	};

	chosen {
		stdout-path = "serial1:115200n8";
	};

/*
	panel: panel {
		compatible = "bananapi,s070wv20-ct16", "simple-panel";
	 	#address-cells = <1>;
	 	#size-cells = <0>;

	 	port@0 {
	 		reg = <0>;
	 		#address-cells = <1>;
	 		#size-cells = <0>;

	 		panel_input: endpoint@0 {
	 			reg = <0>;
	 			remote-endpoint = <&tcon0_out_lcd>;
			};
	 	};
	};
*/
	
/*
        backlight: backlight {
            	compatible = "pwm-backlight";
            	pwms = <&pwm 1 500000 0>;
            	pwm-names = "backlight";

            	brightness-levels = <0 4 8 16 32 64 128 255>;
            	default-brightness-level = <7>;
            	status = "okay";
        };
*/
};

&spi0 {
	status = "okay";

	spi-nor@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "winbond,w25q128", "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <50000000>;
		status = "disabled";

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "u-boot";
				reg = <0x000000 0x70000>;
				read-only;
			};

			partition@1 {
				label = "kernel";
				reg = <0x70000 0x590000>;
				read-only;
			};

			partition@2 {
				label = "rom";
				reg = <0x600000 0x700000>;
				read-only;
			};

			partition@3 {
				label = "overlay";
				reg = <0xd00000 0x300000>;
			};
		};
	};

	spi-nand@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "spi-nand";
		reg = <0>;
		spi-max-frequency = <50000000>;
		status = "disabled";

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "u-boot";
				reg = <0x000000 0x100000>;
				read-only;
			};

			partition@1 {
				label = "kernel";
				reg = <0x100000 0x500000>;
				read-only;
			};

			partition@2 {
				label = "rom";
				reg = <0x600000 0x2a00000>;
				read-only;
			};

			partition@3 {
				label = "vendor";
				reg = <0x3000000 0x1000000>;
			};

			partition@4 {
				label = "overlay";
				reg = <0x4000000 0x3000000>;
			};
		};
	};
	
    st7789v@0 {
        status = "okay";
        compatible = "sitronix,st7789v";
        reg = <0>;
        spi-max-frequency =<32000000>;   //SPI时钟32M,先给50M试一下
        rotate =<90>;                    //屏幕旋转90度
        spi-cpol;
        spi-cpha;
        rgb;                             //颜色格式RGB
        fps =<30>;                       //刷新30帧率,先给60试一下
        buswidth =<8>;                   //总线宽度8
        reset-gpios=<&pio 4 12 GPIO_ACTIVE_LOW>;   //GPIOE12
        dc-gpios  =<&pio 0 0 GPIO_ACTIVE_HIGH>;   //GPIOA0
        debug =<1>;                     //不开启调试
    };
};

/*
&pwm {
	pinctrl-names = "default";
	pinctrl-0 = <&pwm1_pe_pins>;
	status = "okay";
};
*/

&uart1 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart1_pa_pins>;
	status = "okay";
};

&mmc0 {
	status = "okay";
	broken-cd;
};

&otg_sram {
	status = "okay";
};

&usb_otg {
	dr_mode = "otg"; /* otg host peripheral */
	status = "okay";
};

&usbphy {
	status = "okay";
};

&cedar_ve {
	status = "okay";
};

&ion {
	status = "okay";
};


/*
&de {
 	status = "okay";
};

&fe0 {
 	status = "okay";
};

&be0 {
 	status = "okay";
};

&tve0 {
 	status = "okay";
};

&tcon0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&lcd_rgb565_pins>;
 	status = "okay";
};

&tcon0_out {
 	tcon0_out_lcd: endpoint@0 {
 		reg = <0>;
 		remote-endpoint = <&panel_input>;
 	};
};
*/

&codec {
	allwinner,audio-routing =
		"Headphone", "HP",
		"Headphone", "HPCOM",
		"LINEIN", "Line In",
		"FMINL", "Left FM In",
		"FMINR", "Right FM In",
		"MIC", "Mic";
	status = "okay";
};

&i2c0 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c0_pd_pins>;
	status = "okay";

/*
	rtp@48 {
		compatible = "ti,tsc2007";
		reg = <0x48>;
		interrupt-parent = <&pio>;
		interrupts = <4 12 IRQ_TYPE_EDGE_FALLING>;
		gpios = <&pio 4 12 GPIO_ACTIVE_LOW>;
		pendown-gpio = <&pio 4 12 GPIO_ACTIVE_LOW>;
		ti,x-plate-ohms = <660>;
		wakeup-source;
		status = "okay";
	};
*/

	ctp@5d {
		compatible = "goodix,gt911";
		reg = <0x5d>;
		interrupt-parent = <&pio>;
		interrupts = <4 12 IRQ_TYPE_EDGE_FALLING>; // PE12
		irq-gpios = <&pio 4 12 GPIO_ACTIVE_HIGH>; // PE12
		reset-gpios = <&pio 0 0 GPIO_ACTIVE_HIGH>; // PA0
		status = "disabled";
	};
	ov2640: camera@30 {
		compatible = "ovti,ov2640";
		reg = <0x30>;
		pinctrl-0 = <&clk_out_pins>;
		pinctrl-names = "default";
		clocks = <&clk_out>;
		clock-names = "xvclk";
		assigned-clocks = <&clk_out>;
		assigned-clock-rates = <24000000>;
		status = "okay";

		port {
			ov2640_ep: endpoint {
				remote-endpoint = <&csi0_ep>;
				bus-width = <8>;
				hsync-active = <0>;
				vsync-active = <0>;
				pclk-sample = <1>;
			};
		};
	};
/*
	ov5640: camera@3c {
		compatible = "ovti,ov5640";
		reg = <0x3c>;
		pinctrl-0 = <&clk_out_pins>;
		pinctrl-names = "default";
		clocks = <&clk_out>;
		clock-names = "xclk";
		assigned-clocks = <&clk_out>;
		assigned-clock-rates = <24000000>;
		status = "disabled";

		port {
			ov5640_ep: endpoint {
				remote-endpoint = <&csi0_ep>;
				bus-width = <8>;
				hsync-active = <0>;
				vsync-active = <0>;
				pclk-sample = <1>;
			};
		};
	};
*/
};

&csi0 {
	pinctrl-names = "default";
	pinctrl-0 = <&csi0_pins>;
	packed-format;
	status = "okay";

	port {
		csi0_ep: endpoint {
			remote-endpoint = <&ov2640_ep>;
			bus-width = <8>;
			hsync-active = <0>;
			vsync-active = <0>;
			pclk-sample = <1>;
		};
	};
};

2.3 修改内核配置

开启SPI驱动的时候必须选择A31。

image-20240724171006906

开启fb驱动支持。

image-20240724171501918

选择编译ST7789V驱动。

image-20240725141002714

将控制台映射到fb功能开启。

image-20240724171548426

启动logo显示。

image-20240724171623168

2.4 编译,测试

重新拷贝zImage、设备树。

image-20240725135219282

屏幕出现启动信息。

image-20240725141944799

测试cat /dev/urandom > /dev/fb0

image-20240725140842012

测试cat /dev/zero> /dev/fb0

image-20240725140827761

测试echo hello > /dev/tty1

image-20240725140812226

设备树debug改为0,改为60帧,改为50Mhz。再继续测试,也没问题。

2.5 出现的问题

2.5.1 gpio申请失败

设备树中引脚配置冲突。

2.5.2 屏幕不受控制

使用cat /dev/urandom > /dev/fb0 又有时有反应。使用逻辑分析仪分析SPI4线和DC线的时序,发现DC线命令和数据的状态反。修改设备树。

2.5.3 启动信息不在屏幕上显示

使用cat /sys/class/graphics/fb*/name查看有2个设备。

在/dev目录下也有2个fb设备。

猜想,可能存在冲突。解决思路,注释掉RGB屏幕相关设备树内容。修改后,正常。

root@wangpi:~# cat /sys/class/graphics/fb*/name
fb_st7789v
root@wangpi:~# ls /dev/fb*
/dev/fb0
2.5.4 颜色反色

驱动文件中屏幕的初始化代码,不反转颜色。

2.5.6 fb与tty的映射
root@wangpi:~# echo hello > /dev/tty1
2.5.7 CS片选被拉高

在抓时序的过程中,CS在片选的时候,中间会有拉高信号。认为R43电阻拉高片选线应该没有问题,但是去掉就好了。不明所以,莫名其妙,去掉好用就行了。

三、触摸驱动

资料地址

驱动IC:GT911

3.1 配置内核

image-20240725165642204

3.2 修改设备树

suniv-f1c100s-licheepi-nano.dts

// SPDX-License-Identifier: (GPL-2.0+ OR X11)

/dts-v1/;
#include "suniv-f1c100s.dtsi"

/ {
	model = "Widora MangoPi R3";
	compatible = "allwinner,suniv-f1c200s",
			 "allwinner,suniv-f1c100s";

	aliases {
		//serial0 = &uart0;
		serial1 = &uart1;
	};

	chosen {
		stdout-path = "serial1:115200n8";
	};

/*
	panel: panel {
		compatible = "bananapi,s070wv20-ct16", "simple-panel";
	 	#address-cells = <1>;
	 	#size-cells = <0>;

	 	port@0 {
	 		reg = <0>;
	 		#address-cells = <1>;
	 		#size-cells = <0>;

	 		panel_input: endpoint@0 {
	 			reg = <0>;
	 			remote-endpoint = <&tcon0_out_lcd>;
			};
	 	};
	};
*/
	
/*
        backlight: backlight {
            	compatible = "pwm-backlight";
            	pwms = <&pwm 1 500000 0>;
            	pwm-names = "backlight";

            	brightness-levels = <0 4 8 16 32 64 128 255>;
            	default-brightness-level = <7>;
            	status = "okay";
        };
*/
};

&spi0 {
	status = "okay";

	spi-nor@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "winbond,w25q128", "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <50000000>;
		status = "disabled";

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "u-boot";
				reg = <0x000000 0x70000>;
				read-only;
			};

			partition@1 {
				label = "kernel";
				reg = <0x70000 0x590000>;
				read-only;
			};

			partition@2 {
				label = "rom";
				reg = <0x600000 0x700000>;
				read-only;
			};

			partition@3 {
				label = "overlay";
				reg = <0xd00000 0x300000>;
			};
		};
	};

	spi-nand@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "spi-nand";
		reg = <0>;
		spi-max-frequency = <50000000>;
		status = "disabled";

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "u-boot";
				reg = <0x000000 0x100000>;
				read-only;
			};

			partition@1 {
				label = "kernel";
				reg = <0x100000 0x500000>;
				read-only;
			};

			partition@2 {
				label = "rom";
				reg = <0x600000 0x2a00000>;
				read-only;
			};

			partition@3 {
				label = "vendor";
				reg = <0x3000000 0x1000000>;
			};

			partition@4 {
				label = "overlay";
				reg = <0x4000000 0x3000000>;
			};
		};
	};
	
    st7789v@0 {
        status = "okay";
        compatible = "sitronix,st7789v";
        reg = <0>;
        spi-max-frequency =<50000000>;   //SPI时钟32M,先给50M试一下
        rotate =<90>;                    //屏幕旋转90度
        spi-cpol;
        spi-cpha;
        rgb;                             //颜色格式RGB
        fps =<60>;                       //刷新30帧率,先给60试一下
        buswidth =<8>;                   //总线宽度8
        reset-gpios=<&pio 4 12 GPIO_ACTIVE_LOW>;   //GPIOE12
        dc-gpios  =<&pio 0 0 GPIO_ACTIVE_HIGH>;   //GPIOA0
        debug =<0>;                     //不开启调试
    };
};

/*
&pwm {
	pinctrl-names = "default";
	pinctrl-0 = <&pwm1_pe_pins>;
	status = "okay";
};
*/

&uart1 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart1_pa_pins>;
	status = "okay";
};

&mmc0 {
	status = "okay";
	broken-cd;
};

&otg_sram {
	status = "okay";
};

&usb_otg {
	dr_mode = "otg"; /* otg host peripheral */
	status = "okay";
};

&usbphy {
	status = "okay";
};

&cedar_ve {
	status = "okay";
};

&ion {
	status = "okay";
};


/*
&de {
 	status = "okay";
};

&fe0 {
 	status = "okay";
};

&be0 {
 	status = "okay";
};

&tve0 {
 	status = "okay";
};

&tcon0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&lcd_rgb565_pins>;
 	status = "okay";
};

&tcon0_out {
 	tcon0_out_lcd: endpoint@0 {
 		reg = <0>;
 		remote-endpoint = <&panel_input>;
 	};
};
*/

&codec {
	allwinner,audio-routing =
		"Headphone", "HP",
		"Headphone", "HPCOM",
		"LINEIN", "Line In",
		"FMINL", "Left FM In",
		"FMINR", "Right FM In",
		"MIC", "Mic";
	status = "okay";
};

&i2c0 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c0_pd_pins>;
	status = "okay";

/*
	rtp@48 {
		compatible = "ti,tsc2007";
		reg = <0x48>;
		interrupt-parent = <&pio>;
		interrupts = <4 12 IRQ_TYPE_EDGE_FALLING>;
		gpios = <&pio 4 12 GPIO_ACTIVE_LOW>;
		pendown-gpio = <&pio 4 12 GPIO_ACTIVE_LOW>;
		ti,x-plate-ohms = <660>;
		wakeup-source;
		status = "okay";
	};
*/

	ctp@14 {
		compatible = "goodix,gt911";
		reg = <0x14>;   // 0x5d
		interrupt-parent = <&pio>;
		interrupts = <4 11 IRQ_TYPE_EDGE_FALLING>; // PE11
		irq-gpios = <&pio 4 11 GPIO_ACTIVE_HIGH>; // PE11
		reset-gpios = <&pio 4 10 GPIO_ACTIVE_HIGH>; // PE10
		status = "okay";
		touchscreen-size-x = <240>;
		touchscreen-size-y = <320>;
		touchscreen-swapped-x-y;
		touchscreen-inverted-y;
	};
	
/*
	ov2640: camera@30 {
		compatible = "ovti,ov2640";
		reg = <0x30>;
		pinctrl-0 = <&clk_out_pins>;
		pinctrl-names = "default";
		clocks = <&clk_out>;
		clock-names = "xvclk";
		assigned-clocks = <&clk_out>;
		assigned-clock-rates = <24000000>;
		status = "okay";

		port {
			ov2640_ep: endpoint {
				remote-endpoint = <&csi0_ep>;
				bus-width = <8>;
				hsync-active = <0>;
				vsync-active = <0>;
				pclk-sample = <1>;
			};
		};
	};
*/

/*
	ov5640: camera@3c {
		compatible = "ovti,ov5640";
		reg = <0x3c>;
		pinctrl-0 = <&clk_out_pins>;
		pinctrl-names = "default";
		clocks = <&clk_out>;
		clock-names = "xclk";
		assigned-clocks = <&clk_out>;
		assigned-clock-rates = <24000000>;
		status = "disabled";

		port {
			ov5640_ep: endpoint {
				remote-endpoint = <&csi0_ep>;
				bus-width = <8>;
				hsync-active = <0>;
				vsync-active = <0>;
				pclk-sample = <1>;
			};
		};
	};
*/
};

/*
&csi0 {
	pinctrl-names = "default";
	pinctrl-0 = <&csi0_pins>;
	packed-format;
	status = "okay";

	port {
		csi0_ep: endpoint {
			remote-endpoint = <&ov2640_ep>;
			bus-width = <8>;
			hsync-active = <0>;
			vsync-active = <0>;
			pclk-sample = <1>;
		};
	};
};
*/

3.3 配置tslib

参考:https://blog.csdn.net/weixin_36117563/article/details/140269173

ts_calibrate

ts_print

ts_test

均可正常使用。

3.4 测试

evtest /dev/input/event0

image-20240725170412858

3.5 问题

3.5.1 gpio申请错误

中断引脚需要选择的引脚不支持中断。从PA1改为PE11。

image-20240725160811149

image-20240725160748894

3.5.2 i2c总线没有0x5d

使用命令i2cdetect -y 0 查看是否发现设备,发现没有0x5d。

root@wangpi:~# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- --
10: -- -- -- -- UU -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

查看GT911芯片手册,确认地址。发现地址有2个,由初始化时序确定。地址为0x14或0x5d。

image-20240725161033307

3.5.3 测试的时候发现x,y坐标反

使用evtest时候获得的坐标值与期望不一致,修改设备树。

	touchscreen-size-x = <240>;
	touchscreen-size-y = <320>;
	touchscreen-swapped-x-y;
	touchscreen-inverted-y;

四、参考

显示驱动参考链接:

https://www.cnblogs.com/twzy/p/15160836.html

https://www.cnblogs.com/hfwz/p/16028968.html

https://www.bilibili.com/read/cv9947785/

https://blog.csdn.net/qq_33552551/article/details/133740350

触摸参考链接:

https://blog.csdn.net/weixin_45881223/article/details/126176885

https://blog.csdn.net/qq_50299271/article/details/131610509

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值