Skip to content

Commit

Permalink
Bug Labs base callback provided for pm_power_off such that base actua…
Browse files Browse the repository at this point in the history
…lly powers off on shutdown.

Signed-off-by: Matt Isaacs <izzy@buglabs.net>
  • Loading branch information
Matt Isaacs committed Mar 31, 2011
1 parent de23cf3 commit 1e46ae8
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion drivers/mfd/twl4030-power.c
Expand Up @@ -33,6 +33,13 @@

static u8 twl4030_start_script_address = 0x2b;

#if defined(CONFIG_TWL4030_STARTON_DISABLE) || \
defined(CONFIG_TWL4030_STARTON_DISABLE_MODULE)
#define twl_has_starton_disable() true
#else
#define twl_has_starton_disable() false
#endif

#define PWR_P1_SW_EVENTS 0x10
#define PWR_DEVOFF (1<<0)

Expand Down Expand Up @@ -417,6 +424,31 @@ static int __init load_twl4030_script(struct twl4030_script *tscript,
return err;
}

static void twl4030_power_off(void)
{
int err;
u8 val;

printk(KERN_INFO "%s\n", __FUNCTION__);
err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val,
PWR_P1_SW_EVENTS);
if (err) {
pr_err("TWL4030 i2c error %d while reading TWL4030"
"PM_MASTER P1_SW_EVENTS\n",
err);
return;
}

val |= PWR_DEVOFF;
err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val,
PWR_P1_SW_EVENTS);

if (err)
pr_err("TWL4030 i2c error %d while writing TWL4030"
"PM_MASTER P1_SW_EVENTS\n",
err);
}

void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
{
int err = 0;
Expand Down Expand Up @@ -451,7 +483,8 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)

}
}


pm_power_off = twl4030_power_off;
err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY);
if (err)
pr_err("TWL4030 Unable to relock registers\n");
Expand Down

0 comments on commit 1e46ae8

Please sign in to comment.