* [PATCH 1/5] regulator: twl: fix twl6030 enable/disable
2011-04-01 4:52 [PATCH 0/5] regulator: twl: make 6030 regulators useable Nishanth Menon
@ 2011-04-01 4:52 ` Nishanth Menon
2011-04-01 4:52 ` [PATCH 2/5] regulator: twl: remap has no meaning for 6030 Nishanth Menon
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2011-04-01 4:52 UTC (permalink / raw)
To: linux-omap
Cc: Liam Girdwood, Mark Brown, Samuel Ortiz, Saquib, Nishanth Menon
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
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 2/5] regulator: twl: remap has no meaning for 6030
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 ` Nishanth Menon
2011-04-01 4:52 ` [PATCH 3/5] regulator: twl: fix twl6030 regulator is_enabled Nishanth Menon
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2011-04-01 4:52 UTC (permalink / raw)
To: linux-omap
Cc: Liam Girdwood, Mark Brown, Samuel Ortiz, Saquib, Nishanth Menon
From: Saquib Herman <saquib@ti.com>
TWL6030 does not have remap register. The current implementation
causes value of remap to be written to state register, accidentally
causing the regulators which are probed to be switched on as well.
This is wrong as regulators should be controllable based on calls
to enable/disable for TWL regulator framework. Further, the values
initialized make no sense as well. We hence remove this from the
initalizers and also write to remap register only if the TWL
is 4030.
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Saquib Herman <saquib@ti.com>
---
drivers/regulator/twl-regulator.c | 37 +++++++++++++++++--------------------
1 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 3e9060c..2e88865 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -517,10 +517,9 @@ static struct regulator_ops twl6030_fixed_resource = {
remap_conf) \
TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
remap_conf, TWL4030)
-#define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
- remap_conf) \
+#define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay) \
TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
- remap_conf, TWL6030)
+ 0x0, TWL6030)
#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) { \
.base = offset, \
@@ -539,13 +538,11 @@ static struct regulator_ops twl6030_fixed_resource = {
}, \
}
-#define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts, num, \
- remap_conf) { \
+#define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts, num) { \
.base = offset, \
.id = num, \
.min_mV = min_mVolts, \
.max_mV = max_mVolts, \
- .remap = remap_conf, \
.desc = { \
.name = #label, \
.id = TWL6030_REG_##label, \
@@ -574,11 +571,10 @@ static struct regulator_ops twl6030_fixed_resource = {
}, \
}
-#define TWL6030_FIXED_RESOURCE(label, offset, num, turnon_delay, remap_conf) { \
+#define TWL6030_FIXED_RESOURCE(label, offset, num, turnon_delay) { \
.base = offset, \
.id = num, \
.delay = turnon_delay, \
- .remap = remap_conf, \
.desc = { \
.name = #label, \
.id = TWL6030_REG_##label, \
@@ -618,17 +614,17 @@ static struct twlreg_info twl_regs[] = {
/* 6030 REG with base as PMC Slave Misc : 0x0030 */
/* Turnon-delay and remap configuration values for 6030 are not
verified since the specification is not public */
- TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300, 1, 0x21),
- TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300, 2, 0x21),
- TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300, 3, 0x21),
- TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300, 4, 0x21),
- TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300, 5, 0x21),
- TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300, 7, 0x21),
- TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15, 0, 0x21),
- TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16, 0, 0x21),
- TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17, 0, 0x21),
- TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 18, 0, 0x21),
- TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 48, 0, 0x21),
+ TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300, 1),
+ TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300, 2),
+ TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300, 3),
+ TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300, 4),
+ TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300, 5),
+ TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300, 7),
+ TWL6030_FIXED_LDO(VANA, 0x50, 2100, 15, 0),
+ TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 16, 0),
+ TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 17, 0),
+ TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 18, 0),
+ TWL6030_FIXED_RESOURCE(CLK32KG, 0x8C, 48, 0),
};
static int __devinit twlreg_probe(struct platform_device *pdev)
@@ -682,7 +678,8 @@ static int __devinit twlreg_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, rdev);
- twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP,
+ if (twl_class_is_4030())
+ twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP,
info->remap);
/* NOTE: many regulators support short-circuit IRQs (presentable
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 3/5] regulator: twl: fix twl6030 regulator is_enabled
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 ` Nishanth Menon
2011-04-01 4:52 ` [PATCH v2 4/5] regulator: twl: add twl6030 get_status Nishanth Menon
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2011-04-01 4:52 UTC (permalink / raw)
To: linux-omap
Cc: Liam Girdwood, Mark Brown, Samuel Ortiz, Saquib, Nishanth Menon
From: Saquib Herman <saquib@ti.com>
With TWL6030, it is not enough to ensure that the regulator is the
group of P1 group (CPU/Linux), but we need to check the state as far
as APP is concerned as well.
Split the current is_enabled to 6030 and 4030 specific ones. This
split impacts few macros and variables as well, but sets up the
stage for further fixes to set_mode and get_status in subsequent
patches.
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Saquib Herman <saquib@ti.com>
---
drivers/regulator/twl-regulator.c | 61 ++++++++++++++++++++++++++++---------
1 files changed, 46 insertions(+), 15 deletions(-)
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 2e88865..11d2e08 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -80,6 +80,10 @@ struct twlreg_info {
#define TWL6030_CFG_STATE_OFF 0x00
#define TWL6030_CFG_STATE_ON 0x01
#define TWL6030_CFG_STATE_GRP_SHIFT 5
+#define TWL6030_CFG_STATE_APP_SHIFT 2
+#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT)
+#define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\
+ TWL6030_CFG_STATE_APP_SHIFT)
static inline int
twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset)
@@ -123,18 +127,31 @@ static int twlreg_grp(struct regulator_dev *rdev)
#define P2_GRP_6030 BIT(1) /* "peripherals" */
#define P1_GRP_6030 BIT(0) /* CPU/Linux */
-static int twlreg_is_enabled(struct regulator_dev *rdev)
+static int twl4030reg_is_enabled(struct regulator_dev *rdev)
{
int state = twlreg_grp(rdev);
if (state < 0)
return state;
- if (twl_class_is_4030())
- state &= P1_GRP_4030;
- else
- state &= P1_GRP_6030;
- return state;
+ return state & P1_GRP_4030;
+}
+
+static int twl6030reg_is_enabled(struct regulator_dev *rdev)
+{
+ struct twlreg_info *info = rdev_get_drvdata(rdev);
+ int grp, val;
+
+ grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
+ if (grp < 0)
+ return grp;
+
+ grp &= P1_GRP_6030;
+
+ val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
+ val = TWL6030_CFG_STATE_APP(val);
+
+ return grp && (val == TWL6030_CFG_STATE_ON);
}
static int twlreg_enable(struct regulator_dev *rdev)
@@ -406,7 +423,7 @@ static struct regulator_ops twl4030ldo_ops = {
.enable = twlreg_enable,
.disable = twlreg_disable,
- .is_enabled = twlreg_is_enabled,
+ .is_enabled = twl4030reg_is_enabled,
.set_mode = twlreg_set_mode,
@@ -464,7 +481,7 @@ static struct regulator_ops twl6030ldo_ops = {
.enable = twlreg_enable,
.disable = twlreg_disable,
- .is_enabled = twlreg_is_enabled,
+ .is_enabled = twl6030reg_is_enabled,
.set_mode = twlreg_set_mode,
@@ -490,14 +507,28 @@ static int twlfixed_get_voltage(struct regulator_dev *rdev)
return info->min_mV * 1000;
}
-static struct regulator_ops twlfixed_ops = {
+static struct regulator_ops twl4030fixed_ops = {
+ .list_voltage = twlfixed_list_voltage,
+
+ .get_voltage = twlfixed_get_voltage,
+
+ .enable = twlreg_enable,
+ .disable = twlreg_disable,
+ .is_enabled = twl4030reg_is_enabled,
+
+ .set_mode = twlreg_set_mode,
+
+ .get_status = twlreg_get_status,
+};
+
+static struct regulator_ops twl6030fixed_ops = {
.list_voltage = twlfixed_list_voltage,
.get_voltage = twlfixed_get_voltage,
.enable = twlreg_enable,
.disable = twlreg_disable,
- .is_enabled = twlreg_is_enabled,
+ .is_enabled = twl6030reg_is_enabled,
.set_mode = twlreg_set_mode,
@@ -507,7 +538,7 @@ static struct regulator_ops twlfixed_ops = {
static struct regulator_ops twl6030_fixed_resource = {
.enable = twlreg_enable,
.disable = twlreg_disable,
- .is_enabled = twlreg_is_enabled,
+ .is_enabled = twl6030reg_is_enabled,
.get_status = twlreg_get_status,
};
@@ -516,10 +547,10 @@ static struct regulator_ops twl6030_fixed_resource = {
#define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
remap_conf) \
TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
- remap_conf, TWL4030)
+ remap_conf, TWL4030, twl4030fixed_ops)
#define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay) \
TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
- 0x0, TWL6030)
+ 0x0, TWL6030, twl6030fixed_ops)
#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) { \
.base = offset, \
@@ -555,7 +586,7 @@ static struct regulator_ops twl6030_fixed_resource = {
#define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \
- family) { \
+ family, operations) { \
.base = offset, \
.id = num, \
.min_mV = mVolts, \
@@ -565,7 +596,7 @@ static struct regulator_ops twl6030_fixed_resource = {
.name = #label, \
.id = family##_REG_##label, \
.n_voltages = 1, \
- .ops = &twlfixed_ops, \
+ .ops = &operations, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
}, \
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v2 4/5] regulator: twl: add twl6030 get_status
2011-04-01 4:52 [PATCH 0/5] regulator: twl: make 6030 regulators useable Nishanth Menon
` (2 preceding siblings ...)
2011-04-01 4:52 ` [PATCH 3/5] regulator: twl: fix twl6030 regulator is_enabled Nishanth Menon
@ 2011-04-01 4:52 ` 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
` (2 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: Nishanth Menon @ 2011-04-01 4:52 UTC (permalink / raw)
To: linux-omap
Cc: Liam Girdwood, Mark Brown, Samuel Ortiz, Saquib, Nishanth Menon
From: Saquib Herman <saquib@ti.com>
Current get_status logic does not support 6030 get_status.
The logic for 4030 is not reusable for 6030 as the status
check for 6030 now depends on the new CFG_STATE register.
We hence rename the old get_status as being specific to
4030 and remove the redundant check for the same.
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Saquib Herman <saquib@ti.com>
---
drivers/regulator/twl-regulator.c | 44 +++++++++++++++++++++++++++++-------
1 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 11d2e08..d2f7e71 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -79,6 +79,8 @@ struct twlreg_info {
/* TWL6030 LDO register values for CFG_STATE */
#define TWL6030_CFG_STATE_OFF 0x00
#define TWL6030_CFG_STATE_ON 0x01
+#define TWL6030_CFG_STATE_OFF2 0x02
+#define TWL6030_CFG_STATE_SLEEP 0x03
#define TWL6030_CFG_STATE_GRP_SHIFT 5
#define TWL6030_CFG_STATE_APP_SHIFT 2
#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT)
@@ -217,13 +219,10 @@ static int twlreg_disable(struct regulator_dev *rdev)
return ret;
}
-static int twlreg_get_status(struct regulator_dev *rdev)
+static int twl4030reg_get_status(struct regulator_dev *rdev)
{
int state = twlreg_grp(rdev);
- if (twl_class_is_6030())
- return 0; /* FIXME return for 6030 regulator */
-
if (state < 0)
return state;
state &= 0x0f;
@@ -236,6 +235,33 @@ static int twlreg_get_status(struct regulator_dev *rdev)
: REGULATOR_STATUS_STANDBY;
}
+static int twl6030reg_get_status(struct regulator_dev *rdev)
+{
+ struct twlreg_info *info = rdev_get_drvdata(rdev);
+ int val;
+
+ val = twlreg_grp(rdev);
+ if (val < 0)
+ return val;
+
+ val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
+
+ switch (TWL6030_CFG_STATE_APP(val)) {
+ case TWL6030_CFG_STATE_ON:
+ return REGULATOR_STATUS_NORMAL;
+
+ case TWL6030_CFG_STATE_SLEEP:
+ return REGULATOR_STATUS_STANDBY;
+
+ case TWL6030_CFG_STATE_OFF:
+ case TWL6030_CFG_STATE_OFF2:
+ default:
+ break;
+ }
+
+ return REGULATOR_STATUS_OFF;
+}
+
static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode)
{
struct twlreg_info *info = rdev_get_drvdata(rdev);
@@ -427,7 +453,7 @@ static struct regulator_ops twl4030ldo_ops = {
.set_mode = twlreg_set_mode,
- .get_status = twlreg_get_status,
+ .get_status = twl4030reg_get_status,
};
static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
@@ -485,7 +511,7 @@ static struct regulator_ops twl6030ldo_ops = {
.set_mode = twlreg_set_mode,
- .get_status = twlreg_get_status,
+ .get_status = twl6030reg_get_status,
};
/*----------------------------------------------------------------------*/
@@ -518,7 +544,7 @@ static struct regulator_ops twl4030fixed_ops = {
.set_mode = twlreg_set_mode,
- .get_status = twlreg_get_status,
+ .get_status = twl4030reg_get_status,
};
static struct regulator_ops twl6030fixed_ops = {
@@ -532,14 +558,14 @@ static struct regulator_ops twl6030fixed_ops = {
.set_mode = twlreg_set_mode,
- .get_status = twlreg_get_status,
+ .get_status = twl6030reg_get_status,
};
static struct regulator_ops twl6030_fixed_resource = {
.enable = twlreg_enable,
.disable = twlreg_disable,
.is_enabled = twl6030reg_is_enabled,
- .get_status = twlreg_get_status,
+ .get_status = twl6030reg_get_status,
};
/*----------------------------------------------------------------------*/
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v2 4/5] regulator: twl: add twl6030 get_status
2011-04-01 4:52 ` [PATCH v2 4/5] regulator: twl: add twl6030 get_status Nishanth Menon
@ 2011-04-01 5:01 ` Menon, Nishanth
0 siblings, 0 replies; 9+ messages in thread
From: Menon, Nishanth @ 2011-04-01 5:01 UTC (permalink / raw)
To: linux-omap
Cc: Liam Girdwood, Mark Brown, Samuel Ortiz, Saquib, Nishanth Menon
On Fri, Apr 1, 2011 at 10:22, Nishanth Menon <nm@ti.com> wrote:
Opps.. apologies.. the v2 in $subject was a typo.. not that impacts
either git am/patchworks/functionality.. but just fyi, in case anyone
wonders..
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/5] regulator: twl: add twl6030 set_mode
2011-04-01 4:52 [PATCH 0/5] regulator: twl: make 6030 regulators useable Nishanth Menon
` (3 preceding siblings ...)
2011-04-01 4:52 ` [PATCH v2 4/5] regulator: twl: add twl6030 get_status Nishanth Menon
@ 2011-04-01 4:52 ` 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
6 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2011-04-01 4:52 UTC (permalink / raw)
To: linux-omap
Cc: Liam Girdwood, Mark Brown, Samuel Ortiz, Saquib, Nishanth Menon
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
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 0/5] regulator: twl: make 6030 regulators useable
2011-04-01 4:52 [PATCH 0/5] regulator: twl: make 6030 regulators useable Nishanth Menon
` (4 preceding siblings ...)
2011-04-01 4:52 ` [PATCH 5/5] regulator: twl: add twl6030 set_mode Nishanth Menon
@ 2011-04-02 1:03 ` Mark Brown
2011-04-05 9:06 ` Liam Girdwood
6 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2011-04-02 1:03 UTC (permalink / raw)
To: Nishanth Menon; +Cc: linux-omap, Liam Girdwood, Samuel Ortiz, Saquib
On Fri, Apr 01, 2011 at 10:22:41AM +0530, Nishanth Menon wrote:
> TWL6030 regulator dynamic operations such as those on vaux2 and vaux3
> were reported to be broken on platforms such as pandaboard(OMAP4).
> Digging deeper into the code, found that 6030 regulator support
> requires quiet a bit of fixes to make it useable. Major change w.r.t
> TWL4030 has been the introduction of CFG_STATE register in TWL6030
> which is needed to be used for regulator control compared to messages
> which were used in TWL4030.
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 0/5] regulator: twl: make 6030 regulators useable
2011-04-01 4:52 [PATCH 0/5] regulator: twl: make 6030 regulators useable Nishanth Menon
` (5 preceding siblings ...)
2011-04-02 1:03 ` [PATCH 0/5] regulator: twl: make 6030 regulators useable Mark Brown
@ 2011-04-05 9:06 ` Liam Girdwood
6 siblings, 0 replies; 9+ messages in thread
From: Liam Girdwood @ 2011-04-05 9:06 UTC (permalink / raw)
To: Nishanth Menon; +Cc: linux-omap, Mark Brown, Samuel Ortiz, Saquib
On Fri, 2011-04-01 at 10:22 +0530, Nishanth Menon wrote:
> TWL6030 regulator dynamic operations such as those on vaux2 and vaux3
> were reported to be broken on platforms such as pandaboard(OMAP4).
> Digging deeper into the code, found that 6030 regulator support
> requires quiet a bit of fixes to make it useable. Major change w.r.t
> TWL4030 has been the introduction of CFG_STATE register in TWL6030
> which is needed to be used for regulator control compared to messages
> which were used in TWL4030.
All applied now.
Thanks
Liam
^ permalink raw reply [flat|nested] 9+ messages in thread