From: Nishanth Menon <nm@ti.com>
To: linux-omap <linux-omap@vger.kernel.org>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Samuel Ortiz <sameo@linux.intel.com>, Saquib <saquib@ti.com>,
Nishanth Menon <nm@ti.com>
Subject: [PATCH 5/5] regulator: twl: add twl6030 set_mode
Date: Fri, 1 Apr 2011 10:22:46 +0530 [thread overview]
Message-ID: <1301633566-5212-6-git-send-email-nm@ti.com> (raw)
In-Reply-To: <1301633566-5212-1-git-send-email-nm@ti.com>
From: Saquib Herman <saquib@ti.com>
Current set_mode logic does not support 6030. The logic for 4030 is
not reusable for 6030 as the mode setting for 6030 now uses the new
CFG_STATE register. We hence rename the old get_status as being
specific to 4030.
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Saquib Herman <saquib@ti.com>
---
drivers/regulator/twl-regulator.c | 42 +++++++++++++++++++++++++++++-------
1 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index d2f7e71..bf7c402 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -262,15 +262,12 @@ static int twl6030reg_get_status(struct regulator_dev *rdev)
return REGULATOR_STATUS_OFF;
}
-static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode)
+static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
{
struct twlreg_info *info = rdev_get_drvdata(rdev);
unsigned message;
int status;
- if (twl_class_is_6030())
- return 0; /* FIXME return for 6030 regulator */
-
/* We can only set the mode through state machine commands... */
switch (mode) {
case REGULATOR_MODE_NORMAL:
@@ -299,6 +296,35 @@ static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode)
message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB);
}
+static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode)
+{
+ struct twlreg_info *info = rdev_get_drvdata(rdev);
+ int grp;
+ int val;
+
+ grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
+
+ if (grp < 0)
+ return grp;
+
+ /* Compose the state register settings */
+ val = grp << TWL6030_CFG_STATE_GRP_SHIFT;
+ /* We can only set the mode through state machine commands... */
+ switch (mode) {
+ case REGULATOR_MODE_NORMAL:
+ val |= TWL6030_CFG_STATE_ON;
+ break;
+ case REGULATOR_MODE_STANDBY:
+ val |= TWL6030_CFG_STATE_SLEEP;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, val);
+}
+
/*----------------------------------------------------------------------*/
/*
@@ -451,7 +477,7 @@ static struct regulator_ops twl4030ldo_ops = {
.disable = twlreg_disable,
.is_enabled = twl4030reg_is_enabled,
- .set_mode = twlreg_set_mode,
+ .set_mode = twl4030reg_set_mode,
.get_status = twl4030reg_get_status,
};
@@ -509,7 +535,7 @@ static struct regulator_ops twl6030ldo_ops = {
.disable = twlreg_disable,
.is_enabled = twl6030reg_is_enabled,
- .set_mode = twlreg_set_mode,
+ .set_mode = twl6030reg_set_mode,
.get_status = twl6030reg_get_status,
};
@@ -542,7 +568,7 @@ static struct regulator_ops twl4030fixed_ops = {
.disable = twlreg_disable,
.is_enabled = twl4030reg_is_enabled,
- .set_mode = twlreg_set_mode,
+ .set_mode = twl4030reg_set_mode,
.get_status = twl4030reg_get_status,
};
@@ -556,7 +582,7 @@ static struct regulator_ops twl6030fixed_ops = {
.disable = twlreg_disable,
.is_enabled = twl6030reg_is_enabled,
- .set_mode = twlreg_set_mode,
+ .set_mode = twl6030reg_set_mode,
.get_status = twl6030reg_get_status,
};
--
1.7.1
next prev parent reply other threads:[~2011-04-01 4:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-01 4:52 [PATCH 0/5] regulator: twl: make 6030 regulators useable Nishanth Menon
2011-04-01 4:52 ` [PATCH 1/5] regulator: twl: fix twl6030 enable/disable Nishanth Menon
2011-04-01 4:52 ` [PATCH 2/5] regulator: twl: remap has no meaning for 6030 Nishanth Menon
2011-04-01 4:52 ` [PATCH 3/5] regulator: twl: fix twl6030 regulator is_enabled Nishanth Menon
2011-04-01 4:52 ` [PATCH v2 4/5] regulator: twl: add twl6030 get_status Nishanth Menon
2011-04-01 5:01 ` Menon, Nishanth
2011-04-01 4:52 ` Nishanth Menon [this message]
2011-04-02 1:03 ` [PATCH 0/5] regulator: twl: make 6030 regulators useable Mark Brown
2011-04-05 9:06 ` Liam Girdwood
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=1301633566-5212-6-git-send-email-nm@ti.com \
--to=nm@ti.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-omap@vger.kernel.org \
--cc=lrg@slimlogic.co.uk \
--cc=sameo@linux.intel.com \
--cc=saquib@ti.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).