diff options
author | Saquib Herman <saquib@ti.com> | 2011-04-01 00:52:46 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2011-05-27 05:34:36 -0400 |
commit | 1a39962fc4d1fccdf45fef2656b37acbae5fa793 (patch) | |
tree | 969bf649d7eb2db1db20038002e935e5570ff9a6 /drivers/regulator/twl-regulator.c | |
parent | 9a0244ad719258b0ae6064ad7da937cddcb109e0 (diff) |
regulator: twl: add twl6030 set_mode
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>
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.c | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 2d4218ac8535..2a808c25f982 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) | |||
262 | return REGULATOR_STATUS_OFF; | 262 | return REGULATOR_STATUS_OFF; |
263 | } | 263 | } |
264 | 264 | ||
265 | static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode) | 265 | static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode) |
266 | { | 266 | { |
267 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 267 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
268 | unsigned message; | 268 | unsigned message; |
269 | int status; | 269 | int status; |
270 | 270 | ||
271 | if (twl_class_is_6030()) | ||
272 | return 0; /* FIXME return for 6030 regulator */ | ||
273 | |||
274 | /* We can only set the mode through state machine commands... */ | 271 | /* We can only set the mode through state machine commands... */ |
275 | switch (mode) { | 272 | switch (mode) { |
276 | case REGULATOR_MODE_NORMAL: | 273 | case REGULATOR_MODE_NORMAL: |
@@ -299,6 +296,35 @@ static int twlreg_set_mode(struct regulator_dev *rdev, unsigned mode) | |||
299 | message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB); | 296 | message & 0xff, TWL4030_PM_MASTER_PB_WORD_LSB); |
300 | } | 297 | } |
301 | 298 | ||
299 | static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode) | ||
300 | { | ||
301 | struct twlreg_info *info = rdev_get_drvdata(rdev); | ||
302 | int grp; | ||
303 | int val; | ||
304 | |||
305 | grp = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_GRP); | ||
306 | |||
307 | if (grp < 0) | ||
308 | return grp; | ||
309 | |||
310 | /* Compose the state register settings */ | ||
311 | val = grp << TWL6030_CFG_STATE_GRP_SHIFT; | ||
312 | /* We can only set the mode through state machine commands... */ | ||
313 | switch (mode) { | ||
314 | case REGULATOR_MODE_NORMAL: | ||
315 | val |= TWL6030_CFG_STATE_ON; | ||
316 | break; | ||
317 | case REGULATOR_MODE_STANDBY: | ||
318 | val |= TWL6030_CFG_STATE_SLEEP; | ||
319 | break; | ||
320 | |||
321 | default: | ||
322 | return -EINVAL; | ||
323 | } | ||
324 | |||
325 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, val); | ||
326 | } | ||
327 | |||
302 | /*----------------------------------------------------------------------*/ | 328 | /*----------------------------------------------------------------------*/ |
303 | 329 | ||
304 | /* | 330 | /* |
@@ -451,7 +477,7 @@ static struct regulator_ops twl4030ldo_ops = { | |||
451 | .disable = twlreg_disable, | 477 | .disable = twlreg_disable, |
452 | .is_enabled = twl4030reg_is_enabled, | 478 | .is_enabled = twl4030reg_is_enabled, |
453 | 479 | ||
454 | .set_mode = twlreg_set_mode, | 480 | .set_mode = twl4030reg_set_mode, |
455 | 481 | ||
456 | .get_status = twl4030reg_get_status, | 482 | .get_status = twl4030reg_get_status, |
457 | }; | 483 | }; |
@@ -509,7 +535,7 @@ static struct regulator_ops twl6030ldo_ops = { | |||
509 | .disable = twlreg_disable, | 535 | .disable = twlreg_disable, |
510 | .is_enabled = twl6030reg_is_enabled, | 536 | .is_enabled = twl6030reg_is_enabled, |
511 | 537 | ||
512 | .set_mode = twlreg_set_mode, | 538 | .set_mode = twl6030reg_set_mode, |
513 | 539 | ||
514 | .get_status = twl6030reg_get_status, | 540 | .get_status = twl6030reg_get_status, |
515 | }; | 541 | }; |
@@ -542,7 +568,7 @@ static struct regulator_ops twl4030fixed_ops = { | |||
542 | .disable = twlreg_disable, | 568 | .disable = twlreg_disable, |
543 | .is_enabled = twl4030reg_is_enabled, | 569 | .is_enabled = twl4030reg_is_enabled, |
544 | 570 | ||
545 | .set_mode = twlreg_set_mode, | 571 | .set_mode = twl4030reg_set_mode, |
546 | 572 | ||
547 | .get_status = twl4030reg_get_status, | 573 | .get_status = twl4030reg_get_status, |
548 | }; | 574 | }; |
@@ -556,7 +582,7 @@ static struct regulator_ops twl6030fixed_ops = { | |||
556 | .disable = twlreg_disable, | 582 | .disable = twlreg_disable, |
557 | .is_enabled = twl6030reg_is_enabled, | 583 | .is_enabled = twl6030reg_is_enabled, |
558 | 584 | ||
559 | .set_mode = twlreg_set_mode, | 585 | .set_mode = twl6030reg_set_mode, |
560 | 586 | ||
561 | .get_status = twl6030reg_get_status, | 587 | .get_status = twl6030reg_get_status, |
562 | }; | 588 | }; |