drivers: input: ft5336: Add support for reset GPIO and FT3267 IC

Add support for resetting controller at boot, and update FT5336
documentation to indicate that the FT3267 IC is also supported by this
driver.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
Daniel DeGrasse 2023-03-16 12:06:29 -05:00 committed by Carles Cufí
parent e692e57c68
commit 066c40bbb0
3 changed files with 37 additions and 6 deletions

View file

@ -3,14 +3,15 @@
# SPDX-License-Identifier: Apache-2.0
menuconfig INPUT_FT5336
bool "FT5XX6/FT6XX6 capacitive touch panel driver"
bool "FT3267/FT5XX6/FT6XX6 capacitive touch panel driver"
default y
depends on DT_HAS_FOCALTECH_FT5336_ENABLED
select I2C
help
Enable driver for multiple Focaltech capacitive touch panel
controllers. This driver should support FT5x06, FT5606, FT5x16,
FT6x06, Ft6x36, FT5x06i, FT5336, FT3316, FT5436i, FT5336i and FT5x46.
FT6x06, Ft6x36, FT5x06i, FT5336, FT3316, FT5436i, FT3267,
FT5336i and FT5x46.
if INPUT_FT5336

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 NXP
* Copyright (c) 2020,2023 NXP
* Copyright (c) 2020 Mark Olsson <mark@markolsson.se>
* Copyright (c) 2020 Teslabs Engineering S.L.
*
@ -39,6 +39,7 @@ LOG_MODULE_REGISTER(ft5336, CONFIG_INPUT_LOG_LEVEL);
struct ft5336_config {
/** I2C bus. */
struct i2c_dt_spec bus;
struct gpio_dt_spec reset_gpio;
#ifdef CONFIG_INPUT_FT5336_INTERRUPT
/** Interrupt GPIO information. */
struct gpio_dt_spec int_gpio;
@ -140,6 +141,7 @@ static int ft5336_init(const struct device *dev)
{
const struct ft5336_config *config = dev->config;
struct ft5336_data *data = dev->data;
int r;
if (!device_is_ready(config->bus.bus)) {
LOG_ERR("I2C controller device not ready");
@ -150,8 +152,27 @@ static int ft5336_init(const struct device *dev)
k_work_init(&data->work, ft5336_work_handler);
if (config->reset_gpio.port != NULL) {
/* Enable reset GPIO, and pull down */
r = gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_INACTIVE);
if (r < 0) {
LOG_ERR("Could not enable reset GPIO");
return r;
}
/*
* Datasheet requires reset be held low 1 ms, or
* 1 ms + 100us if powering on controller. Hold low for
* 5 ms to be safe.
*/
k_sleep(K_MSEC(5));
/* Pull reset pin high to complete reset sequence */
r = gpio_pin_set_dt(&config->reset_gpio, 1);
if (r < 0) {
return r;
}
}
#ifdef CONFIG_INPUT_FT5336_INTERRUPT
int r;
if (!device_is_ready(config->int_gpio.port)) {
LOG_ERR("Interrupt GPIO controller device not ready");
@ -189,6 +210,7 @@ static int ft5336_init(const struct device *dev)
#define FT5336_INIT(index) \
static const struct ft5336_config ft5336_config_##index = { \
.bus = I2C_DT_SPEC_INST_GET(index), \
.reset_gpio = GPIO_DT_SPEC_INST_GET_OR(index, reset_gpios, {0}), \
IF_ENABLED(CONFIG_INPUT_FT5336_INTERRUPT, \
(.int_gpio = GPIO_DT_SPEC_INST_GET(index, int_gpios),)) \
}; \

View file

@ -1,7 +1,7 @@
# Copyright (c) 2020 NXP
# Copyright (c) 2020,2023 NXP
# SPDX-License-Identifier: Apache-2.0
description: FT5XX6/FT6XX6 capacitive touch panels
description: FT3267/FT5XX6/FT6XX6 capacitive touch panels
compatible: "focaltech,ft5336"
@ -10,3 +10,11 @@ include: i2c-device.yaml
properties:
int-gpios:
type: phandle-array
description: |
Interrupt GPIO. Used by the controller to signal touch data is
available. Active low.
reset-gpios:
type: phandle-array
description: |
Reset GPIO. Used to reset the controller during initialization, and
to wake it from hibernation mode. Active low.