aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAmit Kucheria <amit.kucheria@verdurent.com>2009-10-19 08:11:00 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2009-12-13 13:21:24 -0500
commitb4ead61e570d7b7bcf20a5a1733dd0bc37236c99 (patch)
treebbac1d65426eadb7d2b2208a55ead373cdd91790 /drivers
parent890463f0ff2bc5c62470dba181a5362bf7a5b22e (diff)
mfd: Add support for remapping twl4030-power power states
The <RESOURCE>_REMAP register allows configuration of the <RESOURCE> in case of a sleep or off transition. Allow this property of resources to be configured (through twl4030_resconfig) and add code to parse these values to program the registers accordingly. Signed-off-by: Amit Kucheria <amit.kucheria@verdurent.com> Cc: linux-omap@vger.kernel.org Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/twl4030-power.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 2c38ac17ab64..3e41e0c0e4c6 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -75,6 +75,8 @@ static u8 twl4030_start_script_address = 0x2b;
75*/ 75*/
76#define DEV_GRP_OFFSET 0 76#define DEV_GRP_OFFSET 0
77#define TYPE_OFFSET 1 77#define TYPE_OFFSET 1
78#define REMAP_OFFSET 2
79#define DEDICATED_OFFSET 3
78 80
79/* Bit positions in the registers */ 81/* Bit positions in the registers */
80 82
@@ -88,6 +90,12 @@ static u8 twl4030_start_script_address = 0x2b;
88#define TYPE2_SHIFT 3 90#define TYPE2_SHIFT 3
89#define TYPE2_MASK (3 << TYPE2_SHIFT) 91#define TYPE2_MASK (3 << TYPE2_SHIFT)
90 92
93/* <RESOURCE>_REMAP */
94#define SLEEP_STATE_SHIFT 0
95#define SLEEP_STATE_MASK (0xf << SLEEP_STATE_SHIFT)
96#define OFF_STATE_SHIFT 4
97#define OFF_STATE_MASK (0xf << OFF_STATE_SHIFT)
98
91static u8 res_config_addrs[] = { 99static u8 res_config_addrs[] = {
92 [RES_VAUX1] = 0x17, 100 [RES_VAUX1] = 0x17,
93 [RES_VAUX2] = 0x1b, 101 [RES_VAUX2] = 0x1b,
@@ -325,6 +333,7 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
325 int err; 333 int err;
326 u8 type; 334 u8 type;
327 u8 grp; 335 u8 grp;
336 u8 remap;
328 337
329 if (rconfig->resource > TOTAL_RESOURCES) { 338 if (rconfig->resource > TOTAL_RESOURCES) {
330 pr_err("TWL4030 Resource %d does not exist\n", 339 pr_err("TWL4030 Resource %d does not exist\n",
@@ -380,6 +389,33 @@ static int __init twl4030_configure_resource(struct twl4030_resconfig *rconfig)
380 return err; 389 return err;
381 } 390 }
382 391
392 /* Set remap states */
393 err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &remap,
394 rconfig_addr + REMAP_OFFSET);
395 if (err < 0) {
396 pr_err("TWL4030 Resource %d remap could not be read\n",
397 rconfig->resource);
398 return err;
399 }
400
401 if (rconfig->remap_off >= 0) {
402 remap &= ~OFF_STATE_MASK;
403 remap |= rconfig->remap_off << OFF_STATE_SHIFT;
404 }
405
406 if (rconfig->remap_sleep >= 0) {
407 remap &= ~SLEEP_STATE_MASK;
408 remap |= rconfig->remap_off << SLEEP_STATE_SHIFT;
409 }
410
411 err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
412 remap,
413 rconfig_addr + REMAP_OFFSET);
414 if (err < 0) {
415 pr_err("TWL4030 failed to program remap\n");
416 return err;
417 }
418
383 return 0; 419 return 0;
384} 420}
385 421