aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/twl-regulator.c
diff options
context:
space:
mode:
authorSaquib Herman <saquib@ti.com>2011-04-01 00:52:45 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2011-05-27 05:34:36 -0400
commit9a0244ad719258b0ae6064ad7da937cddcb109e0 (patch)
tree9167b909da9d98cc576a2443be74a49739b0f316 /drivers/regulator/twl-regulator.c
parentb2456779f39e33ad63a63aabe9af77d1113f106e (diff)
regulator: twl: add twl6030 get_status
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> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@vega.(none)>
Diffstat (limited to 'drivers/regulator/twl-regulator.c')
-rw-r--r--drivers/regulator/twl-regulator.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index cae168f0f7b3..2d4218ac8535 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -79,6 +79,8 @@ struct twlreg_info {
79/* TWL6030 LDO register values for CFG_STATE */ 79/* TWL6030 LDO register values for CFG_STATE */
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_OFF2 0x02
83#define TWL6030_CFG_STATE_SLEEP 0x03
82#define TWL6030_CFG_STATE_GRP_SHIFT 5 84#define TWL6030_CFG_STATE_GRP_SHIFT 5
83#define TWL6030_CFG_STATE_APP_SHIFT 2 85#define TWL6030_CFG_STATE_APP_SHIFT 2
84#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT) 86#define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT)
@@ -217,13 +219,10 @@ static int twlreg_disable(struct regulator_dev *rdev)
217 return ret; 219 return ret;
218} 220}
219 221
220static int twlreg_get_status(struct regulator_dev *rdev) 222static int twl4030reg_get_status(struct regulator_dev *rdev)
221{ 223{
222 int state = twlreg_grp(rdev); 224 int state = twlreg_grp(rdev);
223 225
224 if (twl_class_is_6030())
225 return 0; /* FIXME return for 6030 regulator */
226
227 if (state < 0) 226 if (state < 0)
228 return state; 227 return state;
229 state &= 0x0f; 228 state &= 0x0f;
@@ -236,6 +235,33 @@ static int twlreg_get_status(struct regulator_dev *rdev)
236 : REGULATOR_STATUS_STANDBY; 235 : REGULATOR_STATUS_STANDBY;
237} 236}
238 237
238static int twl6030reg_get_status(struct regulator_dev *rdev)
239{
240 struct twlreg_info *info = rdev_get_drvdata(rdev);
241 int val;
242
243 val = twlreg_grp(rdev);
244 if (val < 0)
245 return val;
246
247 val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE);
248
249 switch (TWL6030_CFG_STATE_APP(val)) {
250 case TWL6030_CFG_STATE_ON:
251 return REGULATOR_STATUS_NORMAL;
252
253 case TWL6030_CFG_STATE_SLEEP:
254 return REGULATOR_STATUS_STANDBY;
255
256 case TWL6030_CFG_STATE_OFF:
257 case TWL6030_CFG_STATE_OFF2:
258 default:
259 break;
260 }
261
262 return REGULATOR_STATUS_OFF;
263}
264
239static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode) 265static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode)
240{ 266{
241 struct twlreg_info *info = rdev_get_drvdata(rdev); 267 struct twlreg_info *info = rdev_get_drvdata(rdev);
@@ -427,7 +453,7 @@ static struct regulator_ops twl4030ldo_ops = {
427 453
428 .set_mode = twlreg_set_mode, 454 .set_mode = twlreg_set_mode,
429 455
430 .get_status = twlreg_get_status, 456 .get_status = twl4030reg_get_status,
431}; 457};
432 458
433static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index) 459static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned index)
@@ -485,7 +511,7 @@ static struct regulator_ops twl6030ldo_ops = {
485 511
486 .set_mode = twlreg_set_mode, 512 .set_mode = twlreg_set_mode,
487 513
488 .get_status = twlreg_get_status, 514 .get_status = twl6030reg_get_status,
489}; 515};
490 516
491/*----------------------------------------------------------------------*/ 517/*----------------------------------------------------------------------*/
@@ -518,7 +544,7 @@ static struct regulator_ops twl4030fixed_ops = {
518 544
519 .set_mode = twlreg_set_mode, 545 .set_mode = twlreg_set_mode,
520 546
521 .get_status = twlreg_get_status, 547 .get_status = twl4030reg_get_status,
522}; 548};
523 549
524static struct regulator_ops twl6030fixed_ops = { 550static struct regulator_ops twl6030fixed_ops = {
@@ -532,14 +558,14 @@ static struct regulator_ops twl6030fixed_ops = {
532 558
533 .set_mode = twlreg_set_mode, 559 .set_mode = twlreg_set_mode,
534 560
535 .get_status = twlreg_get_status, 561 .get_status = twl6030reg_get_status,
536}; 562};
537 563
538static struct regulator_ops twl6030_fixed_resource = { 564static struct regulator_ops twl6030_fixed_resource = {
539 .enable = twlreg_enable, 565 .enable = twlreg_enable,
540 .disable = twlreg_disable, 566 .disable = twlreg_disable,
541 .is_enabled = twl6030reg_is_enabled, 567 .is_enabled = twl6030reg_is_enabled,
542 .get_status = twlreg_get_status, 568 .get_status = twl6030reg_get_status,
543}; 569};
544 570
545/*----------------------------------------------------------------------*/ 571/*----------------------------------------------------------------------*/