From: Linus Walleij <linus.walleij@linaro.org>
To: Samuel Ortiz <sameo@linux.intel.com>,
Lee Jones <lee.jones@linaro.org>,
linux-kernel@vger.kernel.org
Cc: Linus Walleij <linus.walleij@linaro.org>
Subject: [RESEND PATCH 2/6] mfd: stmpe: add optional regulators
Date: Thu, 8 May 2014 23:16:35 +0200 [thread overview]
Message-ID: <1399583799-23517-2-git-send-email-linus.walleij@linaro.org> (raw)
In-Reply-To: <1399583799-23517-1-git-send-email-linus.walleij@linaro.org>
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>
---
drivers/mfd/stmpe.c | 18 ++++++++++++++++++
include/linux/mfd/stmpe.h | 5 +++++
2 files changed, 23 insertions(+)
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 6155230ae29c..692452442ead 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -20,6 +20,7 @@
#include <linux/slab.h>
#include <linux/mfd/core.h>
#include <linux/delay.h>
+#include <linux/regulator/consumer.h>
#include "stmpe.h"
static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks)
@@ -1172,6 +1173,18 @@ int stmpe_probe(struct stmpe_client_info *ci, int partnum)
stmpe->variant = stmpe_variant_info[partnum];
stmpe->regs = stmpe->variant->regs;
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);
if (ci->init)
@@ -1238,6 +1251,11 @@ int stmpe_probe(struct stmpe_client_info *ci, int partnum)
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);
return 0;
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index 3f8798e4a87d..575a86c7fcbd 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -11,6 +11,7 @@
#include <linux/mutex.h>
struct device;
+struct regulator;
enum stmpe_block {
STMPE_BLOCK_GPIO = 1 << 0,
@@ -62,6 +63,8 @@ struct stmpe_client_info;
/**
* struct stmpe - STMPE MFD structure
+ * @vcc: optional VCC regulator
+ * @vio: optional VIO regulator
* @lock: lock protecting I/O operations
* @irq_lock: IRQ bus lock
* @dev: device, mostly for dev_dbg()
@@ -79,6 +82,8 @@ struct stmpe_client_info;
* @pdata: platform data
*/
struct stmpe {
+ struct regulator *vcc;
+ struct regulator *vio;
struct mutex lock;
struct mutex irq_lock;
struct device *dev;
--
1.9.0
next prev parent reply other threads:[~2014-05-08 21:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 21:16 [RESEND PATCH 1/6] mfd: stmpe: root out static GPIO and IRQ assignments Linus Walleij
2014-05-08 21:16 ` Linus Walleij [this message]
2014-05-09 8:09 ` [RESEND PATCH 2/6] mfd: stmpe: add optional regulators Lee Jones
2014-05-08 21:16 ` [RESEND PATCH 3/6] mfd: stmpe: probe properly from the device tree Linus Walleij
2014-05-09 8:10 ` Lee Jones
2014-05-08 21:16 ` [RESEND PATCH 4/6] mfd: stmpe: mask off unused blocks properly Linus Walleij
2014-05-09 8:10 ` Lee Jones
2014-05-09 8:09 ` [RESEND PATCH 1/6] mfd: stmpe: root out static GPIO and IRQ assignments Lee Jones
2014-05-09 9:31 ` [GIT PULL] First pull-request for the IB between MFD and GPIO Lee Jones
2014-05-09 9:55 ` [GIT PULL v2] " Lee Jones
2014-05-13 6:42 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399583799-23517-2-git-send-email-linus.walleij@linaro.org \
--to=linus.walleij@linaro.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).