Skip to content

Commit d5b1a7d

Browse files
zejiang0jasonfabiobaltieri
authored andcommitted
driver: input: gt911: Support case that no dedicated reset pin
On some boards, there is not dedicated reset pin for GT911, it might be the same pin with display IC, or might be tighted to a high level voltage. This patch makes the rst_gpio can be empty. Signed-off-by: Jason Yu <[email protected]>
1 parent 643c033 commit d5b1a7d

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

drivers/input/input_gt911.c

+20-16
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,17 @@ static int gt911_init(const struct device *dev)
225225
return -ENODEV;
226226
}
227227

228-
if (!gpio_is_ready_dt(&config->rst_gpio)) {
229-
LOG_ERR("Reset GPIO controller device not ready");
230-
return -ENODEV;
231-
}
228+
if (config->rst_gpio.port != NULL) {
229+
if (!gpio_is_ready_dt(&config->rst_gpio)) {
230+
LOG_ERR("Reset GPIO controller device not ready");
231+
return -ENODEV;
232+
}
232233

233-
r = gpio_pin_configure_dt(&config->rst_gpio, GPIO_OUTPUT_ACTIVE);
234-
if (r < 0) {
235-
LOG_ERR("Could not configure reset GPIO pin");
236-
return r;
234+
r = gpio_pin_configure_dt(&config->rst_gpio, GPIO_OUTPUT_ACTIVE);
235+
if (r < 0) {
236+
LOG_ERR("Could not configure reset GPIO pin");
237+
return r;
238+
}
237239
}
238240

239241
if (config->alt_addr == 0x0) {
@@ -252,13 +254,15 @@ static int gt911_init(const struct device *dev)
252254
}
253255
/* Delay at least 10 ms after power on before we configure gt911 */
254256
k_sleep(K_MSEC(20));
255-
/* reset the device and confgiure the addr mode0 */
256-
gpio_pin_set_dt(&config->rst_gpio, 1);
257-
/* hold down at least 1us, 1ms here */
258-
k_sleep(K_MSEC(1));
259-
gpio_pin_set_dt(&config->rst_gpio, 0);
260-
/* hold down at least 5ms. This is the point the INT pin must be low. */
261-
k_sleep(K_MSEC(5));
257+
if (config->rst_gpio.port != NULL) {
258+
/* reset the device and confgiure the addr mode0 */
259+
gpio_pin_set_dt(&config->rst_gpio, 1);
260+
/* hold down at least 1us, 1ms here */
261+
k_sleep(K_MSEC(1));
262+
gpio_pin_set_dt(&config->rst_gpio, 0);
263+
/* hold down at least 5ms. This is the point the INT pin must be low. */
264+
k_sleep(K_MSEC(5));
265+
}
262266
/* hold down 50ms to make sure the address available */
263267
k_sleep(K_MSEC(50));
264268

@@ -359,7 +363,7 @@ static int gt911_init(const struct device *dev)
359363
#define GT911_INIT(index) \
360364
static const struct gt911_config gt911_config_##index = { \
361365
.bus = I2C_DT_SPEC_INST_GET(index), \
362-
.rst_gpio = GPIO_DT_SPEC_INST_GET(index, reset_gpios), \
366+
.rst_gpio = GPIO_DT_SPEC_INST_GET_OR(index, reset_gpios, {0}), \
363367
.int_gpio = GPIO_DT_SPEC_INST_GET(index, irq_gpios), \
364368
.alt_addr = DT_INST_PROP_OR(index, alt_addr, 0), \
365369
}; \

0 commit comments

Comments
 (0)