Skip to content

Commit

Permalink
drivers: input: ft5336: Add support for reset GPIO and FT3267 IC
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
danieldegrasse committed Jul 18, 2023
1 parent 95a75a0 commit ccdfacd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
5 changes: 3 additions & 2 deletions drivers/input/Kconfig.ft5336
Expand Up @@ -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

Expand Down
22 changes: 20 additions & 2 deletions drivers/input/input_ft5336.c
@@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -150,8 +152,23 @@ 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;
}
/* Delay 5 ms to reset controller */
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");
Expand Down Expand Up @@ -189,6 +206,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),)) \
}; \
Expand Down
12 changes: 10 additions & 2 deletions dts/bindings/input/focaltech,ft5336.yaml
@@ -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"

Expand All @@ -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.

0 comments on commit ccdfacd

Please sign in to comment.