Skip to content

Commit 50e29d0

Browse files
DerekSnellcfriedt
authored andcommitted
shields: nxp: lcd_par_s035: fix gt911 touch initialization
Defers init of GT911 touch, MIPI DBI, and display device drivers. lcd_par_s035_init() in shield.c now initializes these to control the GT911 INT_GPIO state during the Reset sequence. Signed-off-by: Derek Snell <derek.snell@nxp.com>
1 parent de8cdf0 commit 50e29d0

File tree

6 files changed

+100
-10
lines changed

6 files changed

+100
-10
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright 2025 NXP
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
zephyr_library()
8+
zephyr_library_sources(shield.c)

boards/shields/lcd_par_s035/Kconfig.defconfig

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,4 @@ config INPUT_GT911_INTERRUPT
2828

2929
endif # LVGL
3030

31-
if INPUT
32-
33-
# GT911 driver drives reset pin low, so it needs to initialize before
34-
# the display driver but after the MIPI DBI driver
35-
config INPUT_INIT_PRIORITY
36-
default 82
37-
38-
endif # INPUT
39-
4031
endif # SHIELD_LCD_PAR_S035

boards/shields/lcd_par_s035/Kconfig.shield

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@
44
config SHIELD_LCD_PAR_S035
55
def_bool $(shields_list_contains,lcd_par_s035_spi) ||\
66
$(shields_list_contains,lcd_par_s035_8080)
7+
8+
config SHIELD_LCD_PAR_S035_INIT_PRIORITY
9+
int "LCD_PAR_S035 shield init priority"
10+
default 85
11+
depends on SHIELD_LCD_PAR_S035
12+
help
13+
SYSINIT() priority to initialize the shield

boards/shields/lcd_par_s035/lcd_par_s035_8080.overlay

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
zephyr,touch = &gt911_lcd_par_s035;
1313
};
1414

15+
aliases {
16+
mipi-dbi = &zephyr_mipi_dbi_parallel;
17+
};
18+
1519
lvgl_pointer {
1620
compatible = "zephyr,lvgl-pointer-input";
1721
input = <&gt911_lcd_par_s035>;
@@ -20,21 +24,25 @@
2024
};
2125
};
2226

27+
/* Initialization of touch, MIPI DBI and display devices is deferred to
28+
* lcd_par_s035_init() in shield.c
29+
*/
2330
&nxp_8080_touch_panel_i2c {
2431
status = "okay";
2532

2633
gt911_lcd_par_s035: gt911-lcd_par_s035@5d {
2734
compatible = "goodix,gt911";
2835
reg = <0x5d>;
2936
irq-gpios = <&nxp_lcd_8080_connector 9 GPIO_ACTIVE_HIGH>;
30-
reset-gpios = <&nxp_lcd_8080_connector 11 GPIO_ACTIVE_LOW>;
37+
zephyr,deferred-init;
3138
};
3239
};
3340

3441
&zephyr_mipi_dbi_parallel {
3542
status = "okay";
3643
#address-cells = <1>;
3744
#size-cells = <0>;
45+
zephyr,deferred-init;
3846

3947
st7796s: st7796s@0 {
4048
compatible = "sitronix,st7796s";
@@ -57,5 +65,6 @@
5765
ngc = [F0 09 0D 09 08 23 2E 33 46 38 13 13 2C 32];
5866
madctl = <0x28>;
5967
color-invert;
68+
zephyr,deferred-init;
6069
};
6170
};

boards/shields/lcd_par_s035/lcd_par_s035_spi.overlay

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
zephyr,touch = &gt911_lcd_par_s035;
1414
};
1515

16+
aliases {
17+
mipi-dbi = &zephyr_mipi_dbi_spi;
18+
};
19+
1620
lvgl_pointer {
1721
compatible = "zephyr,lvgl-pointer-input";
1822
input = <&gt911_lcd_par_s035>;
@@ -21,20 +25,25 @@
2125
};
2226
};
2327

28+
/* Initialization of touch, MIPI DBI and display devices is deferred to
29+
* lcd_par_s035_init() in shield.c
30+
*/
2431
&nxp_pmod_touch_panel_i2c {
2532
status = "okay";
2633

2734
gt911_lcd_par_s035: gt911-lcd_par_s035@5d {
2835
compatible = "goodix,gt911";
2936
reg = <0x5d>;
3037
irq-gpios = <&nxp_lcd_pmod_connector 12 GPIO_ACTIVE_HIGH>;
38+
zephyr,deferred-init;
3139
};
3240
};
3341

3442
&zephyr_mipi_dbi_spi {
3543
status = "okay";
3644
#address-cells = <1>;
3745
#size-cells = <0>;
46+
zephyr,deferred-init;
3847

3948
st7796s: st7796s@0 {
4049
compatible = "sitronix,st7796s";
@@ -64,5 +73,6 @@
6473
ngc = [F0 09 0D 09 08 23 2E 33 46 38 13 13 2C 32];
6574
madctl = <0x28>;
6675
color-invert;
76+
zephyr,deferred-init;
6777
};
6878
};
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2025 NXP
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/device.h>
7+
#include <zephyr/drivers/gpio.h>
8+
9+
#include <zephyr/logging/log.h>
10+
LOG_MODULE_REGISTER(lcd_par_s035);
11+
12+
#define INT_GPIO_DT_SPEC GPIO_DT_SPEC_GET(DT_NODELABEL(gt911_lcd_par_s035), irq_gpios)
13+
14+
static int lcd_par_s035_init(void)
15+
{
16+
int ret;
17+
18+
#ifdef CONFIG_INPUT_GT911
19+
static const struct gpio_dt_spec int_gpio = INT_GPIO_DT_SPEC;
20+
21+
if (!gpio_is_ready_dt(&int_gpio)) {
22+
LOG_ERR("GT911 INT_GPIO controller device not ready");
23+
return -ENODEV;
24+
}
25+
26+
/*
27+
* We need to configure the int-pin to 0, in order to enter the
28+
* AddressMode0. Keeping the INT pin low during the reset sequence
29+
* should result in the device selecting an I2C address of 0x5D.
30+
*/
31+
ret = gpio_pin_configure_dt(&int_gpio, GPIO_OUTPUT_INACTIVE);
32+
if (ret != 0) {
33+
LOG_ERR("Failed to configure GT911 INT_GPIO: %d", ret);
34+
return ret;
35+
}
36+
#endif /* CONFIG_INPUT_GT911 */
37+
38+
#ifdef CONFIG_MIPI_DBI
39+
ret = device_init(DEVICE_DT_GET(DT_ALIAS(mipi_dbi)));
40+
if (ret != 0) {
41+
LOG_ERR("Failed to init mipi_dbi: %d", ret);
42+
return ret;
43+
}
44+
#endif /* CONFIG_MIPI_DBI */
45+
46+
#ifdef CONFIG_DISPLAY
47+
ret = device_init(DEVICE_DT_GET(DT_NODELABEL(st7796s)));
48+
if (ret != 0) {
49+
LOG_ERR("Failed to init st7796s display driver: %d", ret);
50+
return ret;
51+
}
52+
#endif /* CONFIG_DISPLAY */
53+
54+
#ifdef CONFIG_INPUT_GT911
55+
ret = device_init(DEVICE_DT_GET(DT_NODELABEL(gt911_lcd_par_s035)));
56+
if (ret != 0) {
57+
LOG_ERR("Failed to init gt911_lcd_par_s035 input driver: %d", ret);
58+
return ret;
59+
}
60+
#endif /* CONFIG_DISPLAY */
61+
62+
return 0;
63+
}
64+
65+
SYS_INIT(lcd_par_s035_init, POST_KERNEL, CONFIG_SHIELD_LCD_PAR_S035_INIT_PRIORITY);

0 commit comments

Comments
 (0)