@@ -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;
}
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@crapouillou.net> --- drivers/input/touchscreen/atmel_mxt_ts.c | 25 +++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)