aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaquib Herman <saquib@ti.com>2011-04-01 00:52:44 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2011-05-27 05:34:36 -0400
commitb2456779f39e33ad63a63aabe9af77d1113f106e (patch)
tree4f2c79b3ad6f1687aeed1f20f9d4492b49dbaa83
parent776dc923f5c9cd0eea61475ed61350e377ad98b5 (diff)
regulator: twl: fix twl6030 regulator is_enabled
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> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@vega.(none)>
-rw-r--r--drivers/regulator/twl-regulator.c61
1 files changed, 46 insertions, 15 deletions
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index 821fd4206ade..cae168f0f7b3 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -80,6 +80,10 @@ struct twlreg_info {
80#define TWL6030_CFG_STATE_OFF 0x00 80#define TWL6030_CFG_STATE_OFF 0x00
81#define TWL6030_CFG_STATE_ON 0x01 81#define TWL6030_CFG_STATE_ON 0x01
82#define TWL6030_CFG_STATE_GRP_SHIFT 5 82#define TWL6030_CFG_STATE_GRP_SHIFT 5
83#define TWL6030_CFG_STATE_APP_SHIFT 2
84#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT)
85#define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\
86 TWL6030_CFG_STATE_APP_SHIFT)
83 87
84static inline int 88static inline int
85twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset) 89twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset)
@@ -123,18 +127,31 @@ static int twlreg_grp(struct regulator_dev *rdev)
123#define P2_GRP_6030 BIT(1) /* "peripherals" */ 127#define P2_GRP_6030 BIT(1) /* "peripherals" */
124#define P1_GRP_6030 BIT(0) /* CPU/Linux */ 128#define P1_GRP_6030 BIT(0) /* CPU/Linux */
125 129
126static int twlreg_is_enabled(struct regulator_dev *rdev) 130static int twl4030reg_is_enabled(struct regulator_dev *rdev)
127{ 131{
128 int state = twlreg_grp(rdev); 132 int state = twlreg_grp(rdev);
129 133
130 if (state < 0) 134 if (state < 0)
131 return state; 135 return state;
132 136
133 if (twl_class_is_4030()) 137 return state & P1_GRP_4030;
134 state &= P1_GRP_4030; 138}
135 else 139
136 state &= P1_GRP_6030; 140static int twl6030reg_is_enabled(struct regulator_dev *rdev)
137 return state; 141{
142 struct twlreg_info *info = rdev_get_drvdata(rdev);
143 int grp, val;
144
145 grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP);
146 if (grp < 0)
147 return grp;
148
149 grp &= P1_GRP_6030;
150
151 val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
152 val = TWL6030_CFG_STATE_APP(val);
153
154 return grp && (val == TWL6030_CFG_STATE_ON);
138} 155}
139 156
140static int twlreg_enable(struct regulator_dev *rdev) 157static int twlreg_enable(struct regulator_dev *rdev)
@@ -406,7 +423,7 @@ static struct regulator_ops twl4030ldo_ops = {
406 423
407 .enable = twlreg_enable, 424 .enable = twlreg_enable,
408 .disable = twlreg_disable, 425 .disable = twlreg_disable,
409 .is_enabled = twlreg_is_enabled, 426 .is_enabled = twl4030reg_is_enabled,
410 427
411 .set_mode = twlreg_set_mode, 428 .set_mode = twlreg_set_mode,
412 429
@@ -464,7 +481,7 @@ static struct regulator_ops twl6030ldo_ops = {
464 481
465 .enable = twlreg_enable, 482 .enable = twlreg_enable,
466 .disable = twlreg_disable, 483 .disable = twlreg_disable,
467 .is_enabled = twlreg_is_enabled, 484 .is_enabled = twl6030reg_is_enabled,
468 485
469 .set_mode = twlreg_set_mode, 486 .set_mode = twlreg_set_mode,
470 487
@@ -490,14 +507,28 @@ static int twlfixed_get_voltage(struct regulator_dev *rdev)
490 return info->min_mV * 1000; 507 return info->min_mV * 1000;
491} 508}
492 509
493static struct regulator_ops twlfixed_ops = { 510static struct regulator_ops twl4030fixed_ops = {
511 .list_voltage = twlfixed_list_voltage,
512
513 .get_voltage = twlfixed_get_voltage,
514
515 .enable = twlreg_enable,
516 .disable = twlreg_disable,
517 .is_enabled = twl4030reg_is_enabled,
518
519 .set_mode = twlreg_set_mode,
520
521 .get_status = twlreg_get_status,
522};
523
524static struct regulator_ops twl6030fixed_ops = {
494 .list_voltage = twlfixed_list_voltage, 525 .list_voltage = twlfixed_list_voltage,
495 526
496 .get_voltage = twlfixed_get_voltage, 527 .get_voltage = twlfixed_get_voltage,
497 528
498 .enable = twlreg_enable, 529 .enable = twlreg_enable,
499 .disable = twlreg_disable, 530 .disable = twlreg_disable,
500 .is_enabled = twlreg_is_enabled, 531 .is_enabled = twl6030reg_is_enabled,
501 532
502 .set_mode = twlreg_set_mode, 533 .set_mode = twlreg_set_mode,
503 534
@@ -507,7 +538,7 @@ static struct regulator_ops twlfixed_ops = {
507static struct regulator_ops twl6030_fixed_resource = { 538static struct regulator_ops twl6030_fixed_resource = {
508 .enable = twlreg_enable, 539 .enable = twlreg_enable,
509 .disable = twlreg_disable, 540 .disable = twlreg_disable,
510 .is_enabled = twlreg_is_enabled, 541 .is_enabled = twl6030reg_is_enabled,
511 .get_status = twlreg_get_status, 542 .get_status = twlreg_get_status,
512}; 543};
513 544
@@ -516,10 +547,10 @@ static struct regulator_ops twl6030_fixed_resource = {
516#define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ 547#define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
517 remap_conf) \ 548 remap_conf) \
518 TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ 549 TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
519 remap_conf, TWL4030) 550 remap_conf, TWL4030, twl4030fixed_ops)
520#define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay) \ 551#define TWL6030_FIXED_LDO(label, offset, mVolts, num, turnon_delay) \
521 TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ 552 TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \
522 0x0, TWL6030) 553 0x0, TWL6030, twl6030fixed_ops)
523 554
524#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) { \ 555#define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) { \
525 .base = offset, \ 556 .base = offset, \
@@ -555,7 +586,7 @@ static struct regulator_ops twl6030_fixed_resource = {
555 586
556 587
557#define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \ 588#define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \
558 family) { \ 589 family, operations) { \
559 .base = offset, \ 590 .base = offset, \
560 .id = num, \ 591 .id = num, \
561 .min_mV = mVolts, \ 592 .min_mV = mVolts, \
@@ -565,7 +596,7 @@ static struct regulator_ops twl6030_fixed_resource = {
565 .name = #label, \ 596 .name = #label, \
566 .id = family##_REG_##label, \ 597 .id = family##_REG_##label, \
567 .n_voltages = 1, \ 598 .n_voltages = 1, \
568 .ops = &twlfixed_ops, \ 599 .ops = &operations, \
569 .type = REGULATOR_VOLTAGE, \ 600 .type = REGULATOR_VOLTAGE, \
570 .owner = THIS_MODULE, \ 601 .owner = THIS_MODULE, \
571 }, \ 602 }, \