diff options
author | Mike Turquette <mturquette@ti.com> | 2010-02-22 12:16:30 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-03-07 16:17:32 -0500 |
commit | 11a441ce82d6ffecfd39b324024de0cd630b36c1 (patch) | |
tree | c220e9954055e4c9c0c8f556811de11a56e91092 /drivers | |
parent | 3d8ca8c0b9fe42d005360e255fbf7a6f8580ef87 (diff) |
mfd: Introduce remove_script function for twl4030
New function twl4030_remove_script(u8 flags) takes a script type as
defined in twl.h and prevents any script already loaded in that position
from running. This is accomplished by programming SEQ_ADD_* to 0x3f,
the END_OF_SCRIPT value, where SEQ_ADD_* is determined by flags.
(Future) users of this function include OMAP board files for machines
facing a race condition between sleep and warm reset.
Signed-off-by: Mike Turquette <mturquette@ti.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mfd/twl4030-power.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c index 5b045ff4a2c2..7efa8789a3a2 100644 --- a/drivers/mfd/twl4030-power.c +++ b/drivers/mfd/twl4030-power.c | |||
@@ -461,6 +461,56 @@ out: | |||
461 | return err; | 461 | return err; |
462 | } | 462 | } |
463 | 463 | ||
464 | int twl4030_remove_script(u8 flags) | ||
465 | { | ||
466 | int err = 0; | ||
467 | |||
468 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_1, | ||
469 | R_PROTECT_KEY); | ||
470 | if (err) { | ||
471 | pr_err("twl4030: unable to unlock PROTECT_KEY\n"); | ||
472 | return err; | ||
473 | } | ||
474 | |||
475 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, R_KEY_2, | ||
476 | R_PROTECT_KEY); | ||
477 | if (err) { | ||
478 | pr_err("twl4030: unable to unlock PROTECT_KEY\n"); | ||
479 | return err; | ||
480 | } | ||
481 | |||
482 | if (flags & TWL4030_WRST_SCRIPT) { | ||
483 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, | ||
484 | R_SEQ_ADD_WARM); | ||
485 | if (err) | ||
486 | return err; | ||
487 | } | ||
488 | if (flags & TWL4030_WAKEUP12_SCRIPT) { | ||
489 | if (err) | ||
490 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, | ||
491 | R_SEQ_ADD_S2A12); | ||
492 | return err; | ||
493 | } | ||
494 | if (flags & TWL4030_WAKEUP3_SCRIPT) { | ||
495 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, | ||
496 | R_SEQ_ADD_S2A3); | ||
497 | if (err) | ||
498 | return err; | ||
499 | } | ||
500 | if (flags & TWL4030_SLEEP_SCRIPT) { | ||
501 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, END_OF_SCRIPT, | ||
502 | R_SEQ_ADD_A2S); | ||
503 | if (err) | ||
504 | return err; | ||
505 | } | ||
506 | |||
507 | err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY); | ||
508 | if (err) | ||
509 | pr_err("TWL4030 Unable to relock registers\n"); | ||
510 | |||
511 | return err; | ||
512 | } | ||
513 | |||
464 | void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts) | 514 | void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts) |
465 | { | 515 | { |
466 | int err = 0; | 516 | int err = 0; |