Commit 6f6deb48 authored by Hans de Goede's avatar Hans de Goede Committed by Dmitry Torokhov

Input: silead - add regulator support

On some tablets the touchscreen controller is powered by separate
regulators, add support for this.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent baf28d91
...@@ -18,6 +18,8 @@ Optional properties: ...@@ -18,6 +18,8 @@ Optional properties:
- touchscreen-inverted-y : See touchscreen.txt - touchscreen-inverted-y : See touchscreen.txt
- touchscreen-swapped-x-y : See touchscreen.txt - touchscreen-swapped-x-y : See touchscreen.txt
- silead,max-fingers : maximum number of fingers the touchscreen can detect - silead,max-fingers : maximum number of fingers the touchscreen can detect
- vddio-supply : regulator phandle for controller VDDIO
- avdd-supply : regulator phandle for controller AVDD
Example: Example:
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/input/touchscreen.h> #include <linux/input/touchscreen.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/regulator/consumer.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
...@@ -73,6 +74,7 @@ struct silead_ts_data { ...@@ -73,6 +74,7 @@ struct silead_ts_data {
struct i2c_client *client; struct i2c_client *client;
struct gpio_desc *gpio_power; struct gpio_desc *gpio_power;
struct input_dev *input; struct input_dev *input;
struct regulator_bulk_data regulators[2];
char fw_name[64]; char fw_name[64];
struct touchscreen_properties prop; struct touchscreen_properties prop;
u32 max_fingers; u32 max_fingers;
...@@ -433,6 +435,13 @@ static int silead_ts_set_default_fw_name(struct silead_ts_data *data, ...@@ -433,6 +435,13 @@ static int silead_ts_set_default_fw_name(struct silead_ts_data *data,
} }
#endif #endif
static void silead_disable_regulator(void *arg)
{
struct silead_ts_data *data = arg;
regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators);
}
static int silead_ts_probe(struct i2c_client *client, static int silead_ts_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
...@@ -465,6 +474,26 @@ static int silead_ts_probe(struct i2c_client *client, ...@@ -465,6 +474,26 @@ static int silead_ts_probe(struct i2c_client *client,
if (client->irq <= 0) if (client->irq <= 0)
return -ENODEV; return -ENODEV;
data->regulators[0].supply = "vddio";
data->regulators[1].supply = "avdd";
error = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators),
data->regulators);
if (error)
return error;
/*
* Enable regulators at probe and disable them at remove, we need
* to keep the chip powered otherwise it forgets its firmware.
*/
error = regulator_bulk_enable(ARRAY_SIZE(data->regulators),
data->regulators);
if (error)
return error;
error = devm_add_action_or_reset(dev, silead_disable_regulator, data);
if (error)
return error;
/* Power GPIO pin */ /* Power GPIO pin */
data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW); data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
if (IS_ERR(data->gpio_power)) { if (IS_ERR(data->gpio_power)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment