|
| 1 | +From 7b9fd594eb77f3bfa7d1c927f874dd8118471aa0 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Philippe Simons <simons.philippe@gmail.com> |
| 3 | +Date: Thu, 21 Aug 2025 22:29:26 +0200 |
| 4 | +Subject: [PATCH 03/44] input: rmi4: add reset-gpio |
| 5 | + |
| 6 | +--- |
| 7 | + drivers/input/rmi4/rmi_driver.c | 1 - |
| 8 | + drivers/input/rmi4/rmi_driver.h | 2 ++ |
| 9 | + drivers/input/rmi4/rmi_i2c.c | 22 ++++++++++++++++++++++ |
| 10 | + 3 files changed, 24 insertions(+), 1 deletion(-) |
| 11 | + |
| 12 | +diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c |
| 13 | +index ccd9338a44db..083cb56cf867 100644 |
| 14 | +--- a/drivers/input/rmi4/rmi_driver.c |
| 15 | ++++ b/drivers/input/rmi4/rmi_driver.c |
| 16 | +@@ -31,7 +31,6 @@ |
| 17 | + #define RMI4_PAGE_MASK 0xFF00 |
| 18 | + |
| 19 | + #define RMI_DEVICE_RESET_CMD 0x01 |
| 20 | +-#define DEFAULT_RESET_DELAY_MS 100 |
| 21 | + |
| 22 | + void rmi_free_function_list(struct rmi_device *rmi_dev) |
| 23 | + { |
| 24 | +diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h |
| 25 | +index e84495caab15..5af5a82128a7 100644 |
| 26 | +--- a/drivers/input/rmi4/rmi_driver.h |
| 27 | ++++ b/drivers/input/rmi4/rmi_driver.h |
| 28 | +@@ -16,6 +16,8 @@ |
| 29 | + #define SYNAPTICS_INPUT_DEVICE_NAME "Synaptics RMI4 Touch Sensor" |
| 30 | + #define SYNAPTICS_VENDOR_ID 0x06cb |
| 31 | + |
| 32 | ++#define DEFAULT_RESET_DELAY_MS 100 |
| 33 | ++ |
| 34 | + #define GROUP(_attrs) { \ |
| 35 | + .attrs = _attrs, \ |
| 36 | + } |
| 37 | +diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c |
| 38 | +index 3c0c5fd44702..9707710a93f2 100644 |
| 39 | +--- a/drivers/input/rmi4/rmi_i2c.c |
| 40 | ++++ b/drivers/input/rmi4/rmi_i2c.c |
| 41 | +@@ -4,6 +4,7 @@ |
| 42 | + * Copyright (c) 2011 Unixphere |
| 43 | + */ |
| 44 | + |
| 45 | ++#include <linux/gpio/consumer.h> |
| 46 | + #include <linux/i2c.h> |
| 47 | + #include <linux/rmi.h> |
| 48 | + #include <linux/of.h> |
| 49 | +@@ -26,6 +27,7 @@ |
| 50 | + * @tx_buf_size: Size of the buffer |
| 51 | + * |
| 52 | + * @supplies: Array of voltage regulators |
| 53 | ++ * @reset_gpio: Reference to the reset GPIO |
| 54 | + * @startup_delay: Milliseconds to pause after powering up the regulators |
| 55 | + */ |
| 56 | + struct rmi_i2c_xport { |
| 57 | +@@ -39,7 +41,9 @@ struct rmi_i2c_xport { |
| 58 | + size_t tx_buf_size; |
| 59 | + |
| 60 | + struct regulator_bulk_data supplies[2]; |
| 61 | ++ struct gpio_desc *reset_gpio; |
| 62 | + u32 startup_delay; |
| 63 | ++ u32 reset_delay; |
| 64 | + }; |
| 65 | + |
| 66 | + #define RMI_PAGE_SELECT_REGISTER 0xff |
| 67 | +@@ -227,6 +231,15 @@ static int rmi_i2c_probe(struct i2c_client *client) |
| 68 | + return -ENODEV; |
| 69 | + } |
| 70 | + |
| 71 | ++ rmi_i2c->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", |
| 72 | ++ GPIOD_OUT_HIGH); |
| 73 | ++ if (IS_ERR(rmi_i2c->reset_gpio)) { |
| 74 | ++ error = PTR_ERR(rmi_i2c->reset_gpio); |
| 75 | ++ dev_err(&client->dev, "failed to get reset GPIO: %d\n", error); |
| 76 | ++ return error; |
| 77 | ++ } |
| 78 | ++ gpiod_set_consumer_name(rmi_i2c->reset_gpio, "rmi4 reset"); |
| 79 | ++ |
| 80 | + rmi_i2c->supplies[0].supply = "vdd"; |
| 81 | + rmi_i2c->supplies[1].supply = "vio"; |
| 82 | + error = devm_regulator_bulk_get(&client->dev, |
| 83 | +@@ -251,6 +264,15 @@ static int rmi_i2c_probe(struct i2c_client *client) |
| 84 | + |
| 85 | + msleep(rmi_i2c->startup_delay); |
| 86 | + |
| 87 | ++ if (rmi_i2c->reset_gpio) { |
| 88 | ++ of_property_read_u32(client->dev.of_node, "syna,reset-delay-ms", |
| 89 | ++ &rmi_i2c->reset_delay); |
| 90 | ++ gpiod_set_value_cansleep(rmi_i2c->reset_gpio, 0); |
| 91 | ++ usleep_range(10000, 20000); |
| 92 | ++ gpiod_set_value_cansleep(rmi_i2c->reset_gpio, 1); |
| 93 | ++ msleep(rmi_i2c->reset_delay ?: DEFAULT_RESET_DELAY_MS); |
| 94 | ++ } |
| 95 | ++ |
| 96 | + rmi_i2c->client = client; |
| 97 | + mutex_init(&rmi_i2c->page_mutex); |
| 98 | + |
| 99 | +-- |
| 100 | +2.43.0 |
| 101 | + |
0 commit comments