aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/twl4030-power.c36
-rw-r--r--include/linux/i2c/twl4030.h3
2 files changed, 39 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
diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
index 5306a759cbde..e87cb270d8a1 100644
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -250,6 +250,7 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
250 250
251#define RES_TYPE_ALL 0x7 251#define RES_TYPE_ALL 0x7
252 252
253/* Resource states */
253#define RES_STATE_WRST 0xF 254#define RES_STATE_WRST 0xF
254#define RES_STATE_ACTIVE 0xE 255#define RES_STATE_ACTIVE 0xE
255#define RES_STATE_SLEEP 0x8 256#define RES_STATE_SLEEP 0x8
@@ -391,6 +392,8 @@ struct twl4030_resconfig {
391 u8 devgroup; /* Processor group that Power resource belongs to */ 392 u8 devgroup; /* Processor group that Power resource belongs to */
392 u8 type; /* Power resource addressed, 6 / broadcast message */ 393 u8 type; /* Power resource addressed, 6 / broadcast message */
393 u8 type2; /* Power resource addressed, 3 / broadcast message */ 394 u8 type2; /* Power resource addressed, 3 / broadcast message */
395 u8 remap_off; /* off state remapping */
396 u8 remap_sleep; /* sleep state remapping */
394}; 397};
395 398
396struct twl4030_power_data { 399struct twl4030_power_data {