Commit 9c9e3214 authored by Linus Walleij's avatar Linus Walleij Committed by Lee Jones

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: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 5a826fee
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/regulator/consumer.h>
#include "stmpe.h" #include "stmpe.h"
static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks) static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks)
...@@ -1186,6 +1187,18 @@ int stmpe_probe(struct stmpe_client_info *ci, int partnum) ...@@ -1186,6 +1187,18 @@ int stmpe_probe(struct stmpe_client_info *ci, int partnum)
stmpe->variant = stmpe_variant_info[partnum]; stmpe->variant = stmpe_variant_info[partnum];
stmpe->regs = stmpe->variant->regs; stmpe->regs = stmpe->variant->regs;
stmpe->num_gpios = stmpe->variant->num_gpios; stmpe->num_gpios = stmpe->variant->num_gpios;
stmpe->vcc = devm_regulator_get_optional(ci->dev, "vcc");
if (!IS_ERR(stmpe->vcc)) {
ret = regulator_enable(stmpe->vcc);
if (ret)
dev_warn(ci->dev, "failed to enable VCC supply\n");
}
stmpe->vio = devm_regulator_get_optional(ci->dev, "vio");
if (!IS_ERR(stmpe->vio)) {
ret = regulator_enable(stmpe->vio);
if (ret)
dev_warn(ci->dev, "failed to enable VIO supply\n");
}
dev_set_drvdata(stmpe->dev, stmpe); dev_set_drvdata(stmpe->dev, stmpe);
if (ci->init) if (ci->init)
...@@ -1252,6 +1265,11 @@ int stmpe_probe(struct stmpe_client_info *ci, int partnum) ...@@ -1252,6 +1265,11 @@ int stmpe_probe(struct stmpe_client_info *ci, int partnum)
int stmpe_remove(struct stmpe *stmpe) int stmpe_remove(struct stmpe *stmpe)
{ {
if (!IS_ERR(stmpe->vio))
regulator_disable(stmpe->vio);
if (!IS_ERR(stmpe->vcc))
regulator_disable(stmpe->vcc);
mfd_remove_devices(stmpe->dev); mfd_remove_devices(stmpe->dev);
return 0; return 0;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
struct device; struct device;
struct regulator;
enum stmpe_block { enum stmpe_block {
STMPE_BLOCK_GPIO = 1 << 0, STMPE_BLOCK_GPIO = 1 << 0,
...@@ -62,6 +63,8 @@ struct stmpe_client_info; ...@@ -62,6 +63,8 @@ struct stmpe_client_info;
/** /**
* struct stmpe - STMPE MFD structure * struct stmpe - STMPE MFD structure
* @vcc: optional VCC regulator
* @vio: optional VIO regulator
* @lock: lock protecting I/O operations * @lock: lock protecting I/O operations
* @irq_lock: IRQ bus lock * @irq_lock: IRQ bus lock
* @dev: device, mostly for dev_dbg() * @dev: device, mostly for dev_dbg()
...@@ -80,6 +83,8 @@ struct stmpe_client_info; ...@@ -80,6 +83,8 @@ struct stmpe_client_info;
* @pdata: platform data * @pdata: platform data
*/ */
struct stmpe { struct stmpe {
struct regulator *vcc;
struct regulator *vio;
struct mutex lock; struct mutex lock;
struct mutex irq_lock; struct mutex irq_lock;
struct device *dev; struct device *dev;
......
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