aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2014-05-08 17:16:35 -0400
committerLee Jones <lee.jones@linaro.org>2014-05-09 05:51:12 -0400
commit9c9e321455fb806108f9dbb1872bacfd42c6002b (patch)
tree564f5a10a3614781c3f79e17410145af959f85e2
parent5a826feedc331a2d5ced2afd832199a70b3af891 (diff)
mfd: stmpe: add optional regulators
The STMPE has VCC and VIO supply lines, and sometimes (as on Ux500) this comes from a software-controlled regulator. Make it possible to supply the STMPE with power from these regulators. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--drivers/mfd/stmpe.c18
-rw-r--r--include/linux/mfd/stmpe.h5
2 files changed, 23 insertions, 0 deletions
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 9fa2dd6d38bd..294731be1a15 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -20,6 +20,7 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/mfd/core.h> 21#include <linux/mfd/core.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/regulator/consumer.h>
23#include "stmpe.h" 24#include "stmpe.h"
24 25
25static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks) 26static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks)
@@ -1186,6 +1187,18 @@ int stmpe_probe(struct stmpe_client_info *ci, int partnum)
1186 stmpe->variant = stmpe_variant_info[partnum]; 1187 stmpe->variant = stmpe_variant_info[partnum];
1187 stmpe->regs = stmpe->variant->regs; 1188 stmpe->regs = stmpe->variant->regs;
1188 stmpe->num_gpios = stmpe->variant->num_gpios; 1189 stmpe->num_gpios = stmpe->variant->num_gpios;
1190 stmpe->vcc = devm_regulator_get_optional(ci->dev, "vcc");
1191 if (!IS_ERR(stmpe->vcc)) {
1192 ret = regulator_enable(stmpe->vcc);
1193 if (ret)
1194 dev_warn(ci->dev, "failed to enable VCC supply\n");
1195 }
1196 stmpe->vio = devm_regulator_get_optional(ci->dev, "vio");
1197 if (!IS_ERR(stmpe->vio)) {
1198 ret = regulator_enable(stmpe->vio);
1199 if (ret)
1200 dev_warn(ci->dev, "failed to enable VIO supply\n");
1201 }
1189 dev_set_drvdata(stmpe->dev, stmpe); 1202 dev_set_drvdata(stmpe->dev, stmpe);
1190 1203
1191 if (ci->init) 1204 if (ci->init)
@@ -1252,6 +1265,11 @@ int stmpe_probe(struct stmpe_client_info *ci, int partnum)
1252 1265
1253int stmpe_remove(struct stmpe *stmpe) 1266int stmpe_remove(struct stmpe *stmpe)
1254{ 1267{
1268 if (!IS_ERR(stmpe->vio))
1269 regulator_disable(stmpe->vio);
1270 if (!IS_ERR(stmpe->vcc))
1271 regulator_disable(stmpe->vcc);
1272
1255 mfd_remove_devices(stmpe->dev); 1273 mfd_remove_devices(stmpe->dev);
1256 1274
1257 return 0; 1275 return 0;
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index 48395a69a7e9..980898620e57 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -11,6 +11,7 @@
11#include <linux/mutex.h> 11#include <linux/mutex.h>
12 12
13struct device; 13struct device;
14struct regulator;
14 15
15enum stmpe_block { 16enum stmpe_block {
16 STMPE_BLOCK_GPIO = 1 << 0, 17 STMPE_BLOCK_GPIO = 1 << 0,
@@ -62,6 +63,8 @@ struct stmpe_client_info;
62 63
63/** 64/**
64 * struct stmpe - STMPE MFD structure 65 * struct stmpe - STMPE MFD structure
66 * @vcc: optional VCC regulator
67 * @vio: optional VIO regulator
65 * @lock: lock protecting I/O operations 68 * @lock: lock protecting I/O operations
66 * @irq_lock: IRQ bus lock 69 * @irq_lock: IRQ bus lock
67 * @dev: device, mostly for dev_dbg() 70 * @dev: device, mostly for dev_dbg()
@@ -80,6 +83,8 @@ struct stmpe_client_info;
80 * @pdata: platform data 83 * @pdata: platform data
81 */ 84 */
82struct stmpe { 85struct stmpe {
86 struct regulator *vcc;
87 struct regulator *vio;
83 struct mutex lock; 88 struct mutex lock;
84 struct mutex irq_lock; 89 struct mutex irq_lock;
85 struct device *dev; 90 struct device *dev;