From 7daba22c41bbb0f7ca2e295203cc3aada263acbf Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Wed, 1 Mar 2023 14:48:36 -0600 Subject: [PATCH] drivers: kscan: fix GT911 support when not using interrupt Fix support for GT911 touchscreen driver when not using interrupt. The controller still requires that the INT pin be set to input in order to correctly respond to I2C queries. Also, the GT911 requires that the INT pin is not configured until the RESET pin has been low at least 10 ms after reset, so add an additional delay during initialization to account for this. Signed-off-by: Daniel DeGrasse --- drivers/kscan/kscan_gt911.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/kscan/kscan_gt911.c b/drivers/kscan/kscan_gt911.c index d60eb45634b..f394540e182 100644 --- a/drivers/kscan/kscan_gt911.c +++ b/drivers/kscan/kscan_gt911.c @@ -242,7 +242,8 @@ static int gt911_init(const struct device *dev) LOG_ERR("Could not configure int GPIO pin"); return r; } - + /* 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, 0); /* hold down at least 1us, 1ms here */ @@ -253,8 +254,6 @@ static int gt911_init(const struct device *dev) gpio_pin_set_dt(&config->int_gpio, 0); /* hold down 50ms to make sure the address available */ k_sleep(K_MSEC(50)); - -#ifdef CONFIG_KSCAN_GT911_INTERRUPT if (!device_is_ready(config->int_gpio.port)) { LOG_ERR("Interrupt GPIO controller device not ready"); return -ENODEV; @@ -266,6 +265,7 @@ static int gt911_init(const struct device *dev) return r; } +#ifdef CONFIG_KSCAN_GT911_INTERRUPT r = gpio_pin_interrupt_configure_dt(&config->int_gpio, GPIO_INT_EDGE_TO_ACTIVE); if (r < 0) {