public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: ads7846: add regulator support
@ 2010-02-04 13:39 Grazvydas Ignotas
  2010-02-04 14:24 ` Mark Brown
  0 siblings, 1 reply; 11+ messages in thread
From: Grazvydas Ignotas @ 2010-02-04 13:39 UTC (permalink / raw)
  To: linux-input; +Cc: Dmitry Torokhov, linux-omap, Grazvydas Ignotas

The ADS7846/TSC2046 touchscreen controllers can (and usually are)
connected to various regulators for power, so add regulator support.
Make it optional for now to avoid breaking all current users of this
driver.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
---
 drivers/input/touchscreen/ads7846.c |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 52d2ca1..5da902a 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -27,6 +27,7 @@
 #include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
+#include <linux/regulator/consumer.h>
 #include <asm/irq.h>
 
 /*
@@ -85,6 +86,7 @@ struct ads7846 {
 	char			name[32];
 
 	struct spi_device	*spi;
+	struct regulator	*reg;
 
 #if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
 	struct attribute_group	*attr_group;
@@ -788,6 +790,9 @@ static void ads7846_disable(struct ads7846 *ts)
 		}
 	}
 
+	if (!IS_ERR(ts->reg))
+		regulator_disable(ts->reg);
+
 	/* we know the chip's in lowpower mode since we always
 	 * leave it that way after every request
 	 */
@@ -799,6 +804,9 @@ static void ads7846_enable(struct ads7846 *ts)
 	if (!ts->disabled)
 		return;
 
+	if (!IS_ERR(ts->reg))
+		regulator_enable(ts->reg);
+
 	ts->disabled = 0;
 	ts->irq_disabled = 0;
 	enable_irq(ts->spi->irq);
@@ -1139,6 +1147,13 @@ static int __devinit ads7846_probe(struct spi_device *spi)
 
 	ts->last_msg = m;
 
+	ts->reg = regulator_get(&spi->dev, "vcc");
+	if (!IS_ERR(ts->reg)) {
+		err = regulator_enable(ts->reg);
+		if (err)
+			goto err_put_regulator;
+	}
+
 	if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING,
 			spi->dev.driver->name, ts)) {
 		dev_info(&spi->dev,
@@ -1148,7 +1163,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
 				  spi->dev.driver->name, ts);
 		if (err) {
 			dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
-			goto err_free_gpio;
+			goto err_disable_regulator;
 		}
 	}
 
@@ -1180,7 +1195,12 @@ static int __devinit ads7846_probe(struct spi_device *spi)
 	ads784x_hwmon_unregister(spi, ts);
  err_free_irq:
 	free_irq(spi->irq, ts);
- err_free_gpio:
+ err_disable_regulator:
+	if (!IS_ERR(ts->reg))
+		regulator_disable(ts->reg);
+ err_put_regulator:
+	if (!IS_ERR(ts->reg))
+		regulator_put(ts->reg);
 	if (ts->gpio_pendown != -1)
 		gpio_free(ts->gpio_pendown);
  err_cleanup_filter:
@@ -1208,6 +1228,11 @@ static int __devexit ads7846_remove(struct spi_device *spi)
 	/* suspend left the IRQ disabled */
 	enable_irq(ts->spi->irq);
 
+	if (!IS_ERR(ts->reg)) {
+		regulator_disable(ts->reg);
+		regulator_put(ts->reg);
+	}
+
 	if (ts->gpio_pendown != -1)
 		gpio_free(ts->gpio_pendown);
 
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-02-09  8:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-04 13:39 [PATCH] Input: ads7846: add regulator support Grazvydas Ignotas
2010-02-04 14:24 ` Mark Brown
2010-02-04 14:52   ` Grazvydas Ignotas
2010-02-04 16:21     ` Mark Brown
2010-02-04 18:08       ` Dmitry Torokhov
2010-02-04 18:59         ` Mark Brown
2010-02-05 20:45       ` Mike Rapoport
2010-02-08 11:30         ` Mark Brown
2010-02-09  8:55           ` Mike Rapoport
2010-02-04 15:08   ` Mike Rapoport
2010-02-04 16:03     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox