Skip to contentSkip to conversation

input: touchscreen: silead: Add regulator support

PATCH Superseded Hans de Goede 2 participants 4 messages Nov 16, 2016 – Nov 17, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 input: touchscreen: silead: Add regulator support

On some tablets the touchscreen controller is powered by separate regulators, add support for this.

---
Changes in v2:
-Use devm_regulator_bulk_get() and friends
-Use devm_add_action_or_reset() to disable the regulator

---
 .../bindings/input/touchscreen/silead_gsl1680.txt  |  2 ++
 drivers/input/touchscreen/silead.c                 | 29 ++++++++++++++++++++++
 2 files changed, 31 insertions(+)
Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt +2 -0
index e844c3f..b726823 100644
@@ -22,6 +22,8 @@ Optional properties:
 - touchscreen-inverted-y  : See touchscreen.txt
 - touchscreen-swapped-x-y : See touchscreen.txt
 - 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:
 
drivers/input/touchscreen/silead.c +29 -0
index f502c84..404830a 100644
@@ -29,6 +29,7 @@
 #include <linux/input/touchscreen.h>
 #include <linux/pm.h>
 #include <linux/irq.h>
+#include <linux/regulator/consumer.h>
 
 #include <asm/unaligned.h>
 
@@ -73,6 +74,7 @@ struct silead_ts_data {
 	struct i2c_client *client;
 	struct gpio_desc *gpio_power;
 	struct input_dev *input;
+	struct regulator_bulk_data regulators[2];
 	char fw_name[64];
 	struct touchscreen_properties prop;
 	u32 max_fingers;
@@ -433,6 +435,13 @@ static int silead_ts_set_default_fw_name(struct silead_ts_data *data,
 }
 #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,
 			   const struct i2c_device_id *id)
 {
@@ -465,6 +474,26 @@ static int silead_ts_probe(struct i2c_client *client,
 	if (client->irq <= 0)
 		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 */
 	data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
 	if (IS_ERR(data->gpio_power)) {
Signature · 1 line
2.9.3
maintainer
#1 lore raw

PATCH v2 1/1 input: touchscreen: silead: Add regulator support

Quoted 66 lines · Hans de Goede

On some tablets the touchscreen controller is powered by separate regulators, add support for this.

---
Changes in v2:

(quoted diff) +0 -3
-Use devm_regulator_bulk_get() and friends
-Use devm_add_action_or_reset() to disable the regulator
---
 .../bindings/input/touchscreen/silead_gsl1680.txt  |  2 ++
 drivers/input/touchscreen/silead.c                 | 29 ++++++++++++++++++++++
 2 files changed, 31 insertions(+)
Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt +2 -0
index e844c3f..b726823 100644
@@ -22,6 +22,8 @@ Optional properties:
 - touchscreen-inverted-y  : See touchscreen.txt
 - touchscreen-swapped-x-y : See touchscreen.txt
 - 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:
 
drivers/input/touchscreen/silead.c +10 -0
index f502c84..404830a 100644
@@ -29,6 +29,7 @@
 #include <linux/input/touchscreen.h>
 #include <linux/pm.h>
 #include <linux/irq.h>
+#include <linux/regulator/consumer.h>
 
 #include <asm/unaligned.h>
 
@@ -73,6 +74,7 @@ struct silead_ts_data {
 	struct i2c_client *client;
 	struct gpio_desc *gpio_power;
 	struct input_dev *input;
+	struct regulator_bulk_data regulators[2];
 	char fw_name[64];
 	struct touchscreen_properties prop;
 	u32 max_fingers;
@@ -433,6 +435,13 @@ static int silead_ts_set_default_fw_name(struct silead_ts_data *data,
 }
 #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,
 			   const struct i2c_device_id *id)
 {
@@ -465,6 +474,26 @@ static int silead_ts_probe(struct i2c_client *client,
 	if (client->irq <= 0)
 		return -ENODEV;
 
+	data->regulators[0].supply = "vddio";

drivers/input/touchscreen/silead.c static int silead_ts_probe(struct i2c_client *client, · line 487

Quoted 10 lines
drivers/input/touchscreen/silead.c +10 -0
+	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.
+	 */

Hmm, this burns power though. Why can't we reload firmware on resume (it should be already cached)? Does it take too long?

Thanks.

Quoted 15 lines
drivers/input/touchscreen/silead.c +9 -0
+	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 */
 	data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
 	if (IS_ERR(data->gpio_power)) {
Signature · 1 line
2.9.3
Signature · 1 line
Dmitry
#2 lore raw

PATCH v2 1/1 input: touchscreen: silead: Add regulator support

HI,

Quoted 66 lines · Dmitry Torokhov
Quoted 65 lines · Hans de Goede

On some tablets the touchscreen controller is powered by separate regulators, add support for this.

---
Changes in v2:

(quoted diff) +0 -3
-Use devm_regulator_bulk_get() and friends
-Use devm_add_action_or_reset() to disable the regulator
---
 .../bindings/input/touchscreen/silead_gsl1680.txt  |  2 ++
 drivers/input/touchscreen/silead.c                 | 29 ++++++++++++++++++++++
 2 files changed, 31 insertions(+)
Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt +2 -0
index e844c3f..b726823 100644
@@ -22,6 +22,8 @@ Optional properties:
 - touchscreen-inverted-y  : See touchscreen.txt
 - touchscreen-swapped-x-y : See touchscreen.txt
 - 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:
 
drivers/input/touchscreen/silead.c +9 -0
index f502c84..404830a 100644
@@ -29,6 +29,7 @@
 #include <linux/input/touchscreen.h>
 #include <linux/pm.h>
 #include <linux/irq.h>
+#include <linux/regulator/consumer.h>
 
 #include <asm/unaligned.h>
 
@@ -73,6 +74,7 @@ struct silead_ts_data {
 	struct i2c_client *client;
 	struct gpio_desc *gpio_power;
 	struct input_dev *input;
+	struct regulator_bulk_data regulators[2];
 	char fw_name[64];
 	struct touchscreen_properties prop;
 	u32 max_fingers;
@@ -433,6 +435,13 @@ static int silead_ts_set_default_fw_name(struct silead_ts_data *data,
 }
 #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,
 			   const struct i2c_device_id *id)
 {
@@ -465,6 +474,26 @@ static int silead_ts_probe(struct i2c_client *client,
 	if (client->irq <= 0)
 		return -ENODEV;
 
Quoted 14 lines

drivers/input/touchscreen/silead.c static int silead_ts_probe(struct i2c_client *client, · line 487

Quoted 11 lines
drivers/input/touchscreen/silead.c +11 -0
+	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.
+	 */

Hmm, this burns power though. Why can't we reload firmware on resume (it should be already cached)?

We already put the device in low-power mode using the power pin. Of the 20 or so different tablets I've with this touchscreen controller only 2 actually have a separate regulator for the controller, so I do not believe that powering down the regulator will be a big win, otherwise all tablets would have had this.

Quoted 1 line

Does it take too long?

It is a couple of kB written one 32-bit word at a time over i2c, so it's not fast.

Regards,

Hans

Quoted 19 lines

Thanks.

Quoted 15 lines
drivers/input/touchscreen/silead.c +9 -1
+	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 */
 	data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
 	if (IS_ERR(data->gpio_power)) {
--

2.9.3

maintainer
#3 lore raw

PATCH v2 1/1 input: touchscreen: silead: Add regulator support

Quoted 90 lines · Hans de Goede

HI,

Quoted 66 lines · Dmitry Torokhov
Quoted 65 lines · Hans de Goede

On some tablets the touchscreen controller is powered by separate regulators, add support for this.

---
Changes in v2:

(quoted diff) +0 -3
-Use devm_regulator_bulk_get() and friends
-Use devm_add_action_or_reset() to disable the regulator
---

.../bindings/input/touchscreen/silead_gsl1680.txt | 2 ++
drivers/input/touchscreen/silead.c | 29 ++++++++++++++++++++++

2 files changed, 31 insertions(+)
Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt +2 -3
index e844c3f..b726823 100644
@@ -22,6 +22,8 @@ Optional properties:
- touchscreen-inverted-y  : See touchscreen.txt
- touchscreen-swapped-x-y : See touchscreen.txt
- 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:

drivers/input/touchscreen/silead.c +9 -0
index f502c84..404830a 100644
@@ -29,6 +29,7 @@
 #include <linux/input/touchscreen.h>
 #include <linux/pm.h>
 #include <linux/irq.h>
+#include <linux/regulator/consumer.h>
 
 #include <asm/unaligned.h>
 
@@ -73,6 +74,7 @@ struct silead_ts_data {
 	struct i2c_client *client;
 	struct gpio_desc *gpio_power;
 	struct input_dev *input;
+	struct regulator_bulk_data regulators[2];
 	char fw_name[64];
 	struct touchscreen_properties prop;
 	u32 max_fingers;
@@ -433,6 +435,13 @@ static int silead_ts_set_default_fw_name(struct silead_ts_data *data,
 }
 #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,
 			   const struct i2c_device_id *id)
 {
@@ -465,6 +474,26 @@ static int silead_ts_probe(struct i2c_client *client,
 	if (client->irq <= 0)
 		return -ENODEV;
 
Quoted 14 lines

drivers/input/touchscreen/silead.c static int silead_ts_probe(struct i2c_client *client, · line 487

Quoted 11 lines
drivers/input/touchscreen/silead.c +11 -0
+	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.
+	 */

Hmm, this burns power though. Why can't we reload firmware on resume (it should be already cached)?

We already put the device in low-power mode using the power pin. Of the 20 or so different tablets I've with this touchscreen controller only 2 actually have a separate regulator for the controller, so I do not believe that powering down the regulator will be a big win, otherwise all tablets would have had this.

Quoted 4 lines
Quoted 1 line

Does it take too long?

It is a couple of kB written one 32-bit word at a time over i2c, so it's not fast.

OK, fair enough. Applied, thank you.

Signature · 1 line
Dmitry