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 <zejiang.yu@nxp.com>
This commit is contained in:
Jason Yu 2024-03-11 13:08:54 +09:00 committed by Fabio Baltieri
parent 643c033a7f
commit d5b1a7d929

View file

@ -225,15 +225,17 @@ static int gt911_init(const struct device *dev)
return -ENODEV;
}
if (!gpio_is_ready_dt(&config->rst_gpio)) {
LOG_ERR("Reset GPIO controller device not ready");
return -ENODEV;
}
if (config->rst_gpio.port != NULL) {
if (!gpio_is_ready_dt(&config->rst_gpio)) {
LOG_ERR("Reset GPIO controller device not ready");
return -ENODEV;
}
r = gpio_pin_configure_dt(&config->rst_gpio, GPIO_OUTPUT_ACTIVE);
if (r < 0) {
LOG_ERR("Could not configure reset GPIO pin");
return r;
r = gpio_pin_configure_dt(&config->rst_gpio, GPIO_OUTPUT_ACTIVE);
if (r < 0) {
LOG_ERR("Could not configure reset GPIO pin");
return r;
}
}
if (config->alt_addr == 0x0) {
@ -252,13 +254,15 @@ static int gt911_init(const struct device *dev)
}
/* Delay at least 10 ms after power on before we configure gt911 */
k_sleep(K_MSEC(20));
/* reset the device and confgiure the addr mode0 */
gpio_pin_set_dt(&config->rst_gpio, 1);
/* hold down at least 1us, 1ms here */
k_sleep(K_MSEC(1));
gpio_pin_set_dt(&config->rst_gpio, 0);
/* hold down at least 5ms. This is the point the INT pin must be low. */
k_sleep(K_MSEC(5));
if (config->rst_gpio.port != NULL) {
/* reset the device and confgiure the addr mode0 */
gpio_pin_set_dt(&config->rst_gpio, 1);
/* hold down at least 1us, 1ms here */
k_sleep(K_MSEC(1));
gpio_pin_set_dt(&config->rst_gpio, 0);
/* hold down at least 5ms. This is the point the INT pin must be low. */
k_sleep(K_MSEC(5));
}
/* hold down 50ms to make sure the address available */
k_sleep(K_MSEC(50));
@ -359,7 +363,7 @@ static int gt911_init(const struct device *dev)
#define GT911_INIT(index) \
static const struct gt911_config gt911_config_##index = { \
.bus = I2C_DT_SPEC_INST_GET(index), \
.rst_gpio = GPIO_DT_SPEC_INST_GET(index, reset_gpios), \
.rst_gpio = GPIO_DT_SPEC_INST_GET_OR(index, reset_gpios, {0}), \
.int_gpio = GPIO_DT_SPEC_INST_GET(index, irq_gpios), \
.alt_addr = DT_INST_PROP_OR(index, alt_addr, 0), \
}; \