linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 1/5] regulator: twl: fix twl6030 enable/disable
Date: Fri,  1 Apr 2011 10:22:42 +0530	[thread overview]
Message-ID: <1301633566-5212-2-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>

TWL6030 requires an additional register write to CFG_STATE register
to explicitly state that the regulator is in a certain state. Merely
associating the regulator with the group is not enough. Add the
required register field definitions and fix the handling for
TWL6030 enable/disable.

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Saquib Herman <saquib@ti.com>
---
 drivers/regulator/twl-regulator.c |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 6a29285..3e9060c 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -76,6 +76,11 @@ struct twlreg_info {
 #define VREG_BC_PROC		3
 #define VREG_BC_CLK_RST		4
 
+/* TWL6030 LDO register values for CFG_STATE */
+#define TWL6030_CFG_STATE_OFF	0x00
+#define TWL6030_CFG_STATE_ON	0x01
+#define TWL6030_CFG_STATE_GRP_SHIFT	5
+
 static inline int
 twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset)
 {
@@ -149,6 +154,11 @@ static int twlreg_enable(struct regulator_dev *rdev)
 
 	ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
 
+	if (!ret && twl_class_is_6030())
+		ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE,
+				grp << TWL6030_CFG_STATE_GRP_SHIFT |
+				TWL6030_CFG_STATE_ON);
+
 	udelay(info->delay);
 
 	return ret;
@@ -158,17 +168,36 @@ static int twlreg_disable(struct regulator_dev *rdev)
 {
 	struct twlreg_info	*info = rdev_get_drvdata(rdev);
 	int			grp;
+	int			ret;
 
 	grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
 	if (grp < 0)
 		return grp;
 
+	/* For 6030, set the off state for all grps enabled */
+	if (twl_class_is_6030()) {
+		ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE,
+			(grp & (P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030)) <<
+				TWL6030_CFG_STATE_GRP_SHIFT |
+			TWL6030_CFG_STATE_OFF);
+		if (ret)
+			return ret;
+	}
+
 	if (twl_class_is_4030())
 		grp &= ~(P1_GRP_4030 | P2_GRP_4030 | P3_GRP_4030);
 	else
 		grp &= ~(P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030);
 
-	return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
+	ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_GRP, grp);
+
+	/* Next, associate cleared grp in state register */
+	if (!ret && twl_class_is_6030())
+		ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE,
+				grp << TWL6030_CFG_STATE_GRP_SHIFT |
+				TWL6030_CFG_STATE_OFF);
+
+	return ret;
 }
 
 static int twlreg_get_status(struct regulator_dev *rdev)
-- 
1.7.1


  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 ` Nishanth Menon [this message]
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 ` [PATCH 5/5] regulator: twl: add twl6030 set_mode Nishanth Menon
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-2-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).