aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorGrazvydas Ignotas <notasas@gmail.com>2010-02-25 05:04:56 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-02-25 05:07:07 -0500
commit91143379b01b2020d8878d627ebe9dfb9d6eb4c8 (patch)
tree35f523b4de3ef3e773e7ada4413306af2de25321 /drivers/input/touchscreen
parenta1e1274747b2741188b554e35dc5d4056ef7beac (diff)
Input: ads7846 - add regulator support
The ADS7846/TSC2046 touchscreen controllers can (and usually are) connected to various regulators for power, so add regulator support. Valid regulator will now be required, so boards without complete regulator setup should either disable regulator framework or enable CONFIG_REGULATOR_DUMMY. Signed-off-by: Grazvydas Ignotas <notasas@gmail.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/ads7846.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 52d2ca147d8f..8b05d8e97543 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -27,6 +27,7 @@
27#include <linux/gpio.h> 27#include <linux/gpio.h>
28#include <linux/spi/spi.h> 28#include <linux/spi/spi.h>
29#include <linux/spi/ads7846.h> 29#include <linux/spi/ads7846.h>
30#include <linux/regulator/consumer.h>
30#include <asm/irq.h> 31#include <asm/irq.h>
31 32
32/* 33/*
@@ -85,6 +86,7 @@ struct ads7846 {
85 char name[32]; 86 char name[32];
86 87
87 struct spi_device *spi; 88 struct spi_device *spi;
89 struct regulator *reg;
88 90
89#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) 91#if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE)
90 struct attribute_group *attr_group; 92 struct attribute_group *attr_group;
@@ -788,6 +790,8 @@ static void ads7846_disable(struct ads7846 *ts)
788 } 790 }
789 } 791 }
790 792
793 regulator_disable(ts->reg);
794
791 /* we know the chip's in lowpower mode since we always 795 /* we know the chip's in lowpower mode since we always
792 * leave it that way after every request 796 * leave it that way after every request
793 */ 797 */
@@ -799,6 +803,8 @@ static void ads7846_enable(struct ads7846 *ts)
799 if (!ts->disabled) 803 if (!ts->disabled)
800 return; 804 return;
801 805
806 regulator_enable(ts->reg);
807
802 ts->disabled = 0; 808 ts->disabled = 0;
803 ts->irq_disabled = 0; 809 ts->irq_disabled = 0;
804 enable_irq(ts->spi->irq); 810 enable_irq(ts->spi->irq);
@@ -1139,6 +1145,19 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1139 1145
1140 ts->last_msg = m; 1146 ts->last_msg = m;
1141 1147
1148 ts->reg = regulator_get(&spi->dev, "vcc");
1149 if (IS_ERR(ts->reg)) {
1150 dev_err(&spi->dev, "unable to get regulator: %ld\n",
1151 PTR_ERR(ts->reg));
1152 goto err_free_gpio;
1153 }
1154
1155 err = regulator_enable(ts->reg);
1156 if (err) {
1157 dev_err(&spi->dev, "unable to enable regulator: %d\n", err);
1158 goto err_put_regulator;
1159 }
1160
1142 if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING, 1161 if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING,
1143 spi->dev.driver->name, ts)) { 1162 spi->dev.driver->name, ts)) {
1144 dev_info(&spi->dev, 1163 dev_info(&spi->dev,
@@ -1148,7 +1167,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1148 spi->dev.driver->name, ts); 1167 spi->dev.driver->name, ts);
1149 if (err) { 1168 if (err) {
1150 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); 1169 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
1151 goto err_free_gpio; 1170 goto err_disable_regulator;
1152 } 1171 }
1153 } 1172 }
1154 1173
@@ -1180,6 +1199,10 @@ static int __devinit ads7846_probe(struct spi_device *spi)
1180 ads784x_hwmon_unregister(spi, ts); 1199 ads784x_hwmon_unregister(spi, ts);
1181 err_free_irq: 1200 err_free_irq:
1182 free_irq(spi->irq, ts); 1201 free_irq(spi->irq, ts);
1202 err_disable_regulator:
1203 regulator_disable(ts->reg);
1204 err_put_regulator:
1205 regulator_put(ts->reg);
1183 err_free_gpio: 1206 err_free_gpio:
1184 if (ts->gpio_pendown != -1) 1207 if (ts->gpio_pendown != -1)
1185 gpio_free(ts->gpio_pendown); 1208 gpio_free(ts->gpio_pendown);
@@ -1208,6 +1231,9 @@ static int __devexit ads7846_remove(struct spi_device *spi)
1208 /* suspend left the IRQ disabled */ 1231 /* suspend left the IRQ disabled */
1209 enable_irq(ts->spi->irq); 1232 enable_irq(ts->spi->irq);
1210 1233
1234 regulator_disable(ts->reg);
1235 regulator_put(ts->reg);
1236
1211 if (ts->gpio_pendown != -1) 1237 if (ts->gpio_pendown != -1)
1212 gpio_free(ts->gpio_pendown); 1238 gpio_free(ts->gpio_pendown);
1213 1239