mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
Input: stmfts - add optional reset GPIO support
Add support for an optional "reset-gpios" property. If present, the driver drives the reset line high at probe time and releases it during power-on, after the regulators have been enabled. Signed-off-by: Petr Hodina <petr.hodina@protonmail.com> Co-developed-by: David Heidelberg <david@ixit.cz> Signed-off-by: David Heidelberg <david@ixit.cz> Link: https://patch.msgid.link/20260409-stmfts5-v4-8-64fe62027db5@ixit.cz Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
dd78ec391f
commit
8a1f9de80e
|
|
@ -5,6 +5,7 @@
|
|||
// Copyright (c) 2017 Andi Shyti <andi@etezian.org>
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/input/mt.h>
|
||||
#include <linux/input/touchscreen.h>
|
||||
|
|
@ -77,6 +78,7 @@ static const struct regulator_bulk_data stmfts_supplies[] = {
|
|||
struct stmfts_data {
|
||||
struct i2c_client *client;
|
||||
struct input_dev *input;
|
||||
struct gpio_desc *reset_gpio;
|
||||
struct led_classdev led_cdev;
|
||||
struct mutex mutex;
|
||||
|
||||
|
|
@ -539,6 +541,15 @@ static int stmfts_read_system_info(struct stmfts_data *sdata)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void stmfts_reset(struct stmfts_data *sdata)
|
||||
{
|
||||
gpiod_set_value_cansleep(sdata->reset_gpio, 1);
|
||||
msleep(20);
|
||||
|
||||
gpiod_set_value_cansleep(sdata->reset_gpio, 0);
|
||||
msleep(50);
|
||||
}
|
||||
|
||||
static int stmfts_configure(struct stmfts_data *sdata)
|
||||
{
|
||||
int err;
|
||||
|
|
@ -585,6 +596,9 @@ static int stmfts_power_on(struct stmfts_data *sdata)
|
|||
*/
|
||||
msleep(20);
|
||||
|
||||
if (sdata->reset_gpio)
|
||||
stmfts_reset(sdata);
|
||||
|
||||
err = stmfts_read_system_info(sdata);
|
||||
if (err)
|
||||
goto err_disable_regulators;
|
||||
|
|
@ -617,6 +631,10 @@ static void stmfts_power_off(void *data)
|
|||
struct stmfts_data *sdata = data;
|
||||
|
||||
disable_irq(sdata->client->irq);
|
||||
|
||||
if (sdata->reset_gpio)
|
||||
gpiod_set_value_cansleep(sdata->reset_gpio, 1);
|
||||
|
||||
regulator_bulk_disable(ARRAY_SIZE(stmfts_supplies), sdata->supplies);
|
||||
}
|
||||
|
||||
|
|
@ -672,6 +690,11 @@ static int stmfts_probe(struct i2c_client *client)
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
sdata->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
|
||||
if (IS_ERR(sdata->reset_gpio))
|
||||
return dev_err_probe(dev, PTR_ERR(sdata->reset_gpio),
|
||||
"Failed to get GPIO 'reset'\n");
|
||||
|
||||
sdata->input = devm_input_allocate_device(dev);
|
||||
if (!sdata->input)
|
||||
return -ENOMEM;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user