RK3568系列18——Goodix触摸屏配置

  项目同时采用了基于GT9271/GT928/GT9210的触摸屏,配置单个触屏较为简单。需要注意的是必须正确配置触屏,使用i2cdetect命令才能正确认到设备,若没有上电的初始化过程,单纯使用i2cdetect命令可能会无法认到设备。

配置要点

  • 一个RESET脚:复位时拉低,芯片内部厂商推荐悬空,即不进行上下拉
  • 一个中断脚:定义可配置,默认低电平时发出中断信号,芯片内部厂商推荐悬空,即不进行上下拉
  • I2C地址:上电时中断若为高则为0x14,否则为0x5d,驱动默认初始化时拉低

遇到的问题

  • 开机认不到触屏设备:触屏的金手指太短了,完全插入会接触不到金手指,仅插入一部分解决
  • 有时能认到有时认不到:走线太长了,从主板->IO板->扩展板->触屏,RESET信号电压不够,增加电流强度解决
  • 驱动I2C通信超时:硬件忘记设置I2C上拉,飞线接2.2K电阻解决
  • I2C无法认到设备:I2C和供电脚电压不匹配,I2C是1.8V,供电、RESET、中断是3.3V,飞线更换I2C解决

DTS配置

  • 驱动有两套,一套是内核的开源驱动goodix.c,一套是厂家提供的gt9xx驱动,两套都可以使用
1
2
3
4
5
6
7
8
9
10
11
&pinctrl {
touch {
touch_int: touch-int {
rockchip,pins = <0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_none>;
};
touch_reset: touch-reset {
rockchip,pins = <0 RK_PB6 RK_FUNC_GPIO &pcfg_pull_none>;
};
/delete-node/ touch-gpio;
};
};

开源驱动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&i2c1 {
status = "okay";
clock-frequency = <400000>;

gt9271: gt9271@5d {
compatible = "goodix,gt9271";
reg = <0x5d>; // or 0x14
pinctrl-names = "default";
pinctrl-0 = <&touch_int &touch_reset>;
interrupt-parent = <&gpio0>;
interrupts = <RK_PB5 IRQ_TYPE_LEVEL_LOW>;
irq-gpios = <&gpio0 RK_PB5 IRQ_TYPE_LEVEL_LOW>;
reset-gpios = <&gpio0 RK_PB6 GPIO_ACTIVE_LOW>;

// touchscreen-inverted-x; # 驱动层面X轴对调
// touchscreen-inverted-y; # 驱动层面Y轴对调
// touchscreen-swapped-x-y; # 驱动层面对调X和Y轴
};
};

gt9xx驱动

  • Android 8.1的开源驱动不完善,但是自带的gt9xx驱动可以正常使用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&i2c1 {
status = "okay";

gt9271: gt9271@5d {
status = "okay";
compatible = "goodix,gt9xx";
reg = <0x5d>; // 0x5d or 0x14
tp-supply = <&vcc3v3_sys>;
pinctrl-names = "default";
pinctrl-0 = <&touchpanel_reset &touchpanel_irq>;
interrupt-parent = <&gpio0>;
interrupts = <RK_PA5 IRQ_TYPE_LEVEL_LOW>;
touch-gpio = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>;
reset-gpio = <&gpio0 RK_PB4 GPIO_ACTIVE_HIGH>;
tp-size = <9271>;
max-x = <1280>;
max-y = <800>;
};
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff kernel/drivers/input/touchscreen/gt9xx/gt9xx.c
@@ -60,6 +60,7 @@ static u8 m89or101 = TRUE;
static u8 bgt911 = FALSE;
static u8 bgt970 = FALSE;
static u8 bgt910 = FALSE;
+static u8 bgt927 = FALSE;
static u8 gtp_change_x2y = TRUE;
static u8 gtp_x_reverse = FALSE;
static u8 gtp_y_reverse = TRUE;
@@ -1453,6 +1454,11 @@ static s32 gtp_init_panel(struct goodix_ts_data *ts)
cfg_info_len[0] = CFG_GROUP_LEN(gtp_dat_7);
}

+ if (bgt927) {
+ send_cfg_buf[0] = gtp_dat_8_9_1;
+ cfg_info_len[0] = CFG_GROUP_LEN(gtp_dat_8_9_1);
+ }
+
GTP_DEBUG_FUNC();
GTP_DEBUG("Config Groups\' Lengths: %d, %d, %d, %d, %d, %d",
cfg_info_len[0], cfg_info_len[1], cfg_info_len[2], cfg_info_len[3],
@@ -2657,6 +2663,12 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id
gtp_change_x2y = TRUE;
gtp_x_reverse = FALSE;
gtp_y_reverse = TRUE;
+ } else if (val == 9271) {
+ m89or101 = FALSE;
+ bgt927 = TRUE;
+ gtp_change_x2y = FALSE;
+ gtp_x_reverse = FALSE;
+ gtp_y_reverse = FALSE;
}

ts->tp_regulator = devm_regulator_get(&client->dev, "tp");

内核配置

  内核默认没有加载Goodix的开源驱动,需要手动打开。

1
2
3
vim kernel/kernel/configs/alpha.config

CONFIG_TOUCHSCREEN_GOODIX=y