[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200315100416.14151-2-paul@crapouillou.net>
Date: Sun, 15 Mar 2020 11:04:16 +0100
From: Paul Cercueil <paul@...pouillou.net>
To: Nick Dyer <nick@...anahar.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>
Cc: linux-input@...r.kernel.org, devicetree@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Paul Cercueil <paul@...pouillou.net>
Subject: [PATCH 2/2] input: atmel_mxt_ts: Add support for optional regulator
Add support for an optional "vdd" regulator, as some platforms require a
regulator to be enabled for the touchscreen to be enabled.
Signed-off-by: Paul Cercueil <paul@...pouillou.net>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 25 +++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index ae60442efda0..b3511dad475a 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -22,6 +22,7 @@
#include <linux/interrupt.h>
#include <linux/of.h>
#include <linux/property.h>
+#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/gpio/consumer.h>
#include <asm/unaligned.h>
@@ -308,6 +309,7 @@ struct mxt_data {
struct t7_config t7_cfg;
struct mxt_dbg dbg;
struct gpio_desc *reset_gpio;
+ struct regulator *vdd;
/* Cached parameters from object table */
u16 T5_address;
@@ -3103,6 +3105,22 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
disable_irq(client->irq);
+ data->vdd = devm_regulator_get_optional(&client->dev, "vdd");
+ if (IS_ERR(data->vdd)) {
+ error = PTR_ERR(data->vdd);
+ dev_err(&client->dev, "Failed to get regulator: %d\n", error);
+ return error;
+ }
+
+ if (data->vdd) {
+ error = regulator_enable(data->vdd);
+ if (error) {
+ dev_err(&client->dev,
+ "Failed to enable regulator: %d\n", error);
+ return error;
+ }
+ }
+
if (data->reset_gpio) {
msleep(MXT_RESET_GPIO_TIME);
gpiod_set_value(data->reset_gpio, 1);
@@ -3111,7 +3129,7 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
error = mxt_initialize(data);
if (error)
- return error;
+ goto err_disable_regulator;
error = sysfs_create_group(&client->dev.kobj, &mxt_attr_group);
if (error) {
@@ -3125,6 +3143,9 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
err_free_object:
mxt_free_input_device(data);
mxt_free_object_table(data);
+err_disable_regulator:
+ if (data->vdd)
+ regulator_disable(data->vdd);
return error;
}
@@ -3136,6 +3157,8 @@ static int mxt_remove(struct i2c_client *client)
sysfs_remove_group(&client->dev.kobj, &mxt_attr_group);
mxt_free_input_device(data);
mxt_free_object_table(data);
+ if (data->vdd)
+ regulator_disable(data->vdd);
return 0;
}
--
2.25.1
Powered by blists - more mailing lists