Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 284572
b: refs/heads/master
c: 26cc3ab
h: refs/heads/master
v: v3
  • Loading branch information
Igor Grinberg authored and Samuel Ortiz committed Jan 8, 2012
1 parent 4c2d374 commit 39174b7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aeb5032b3f8b9ab69daa545777433fa94b3494c4
refs/heads/master: 26cc3ab984cd00e95cb58ba5aaea4238ea56c700
42 changes: 40 additions & 2 deletions trunk/drivers/mfd/twl4030-power.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
static u8 twl4030_start_script_address = 0x2b;

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

#define PHY_TO_OFF_PM_MASTER(p) (p - 0x36)
#define PHY_TO_OFF_PM_RECEIVER(p) (p - 0x5b)
Expand Down Expand Up @@ -511,12 +512,27 @@ int twl4030_remove_script(u8 flags)
return err;
}

/*
* In master mode, start the power off sequence.
* After a successful execution, TWL shuts down the power to the SoC
* and all peripherals connected to it.
*/
void twl4030_power_off(void)
{
int err;

err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, PWR_DEVOFF,
TWL4030_PM_MASTER_P1_SW_EVENTS);
if (err)
pr_err("TWL4030 Unable to power off\n");
}

void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
{
int err = 0;
int i;
struct twl4030_resconfig *resconfig;
u8 address = twl4030_start_script_address;
u8 val, address = twl4030_start_script_address;

err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
TWL4030_PM_MASTER_KEY_CFG1,
Expand Down Expand Up @@ -548,6 +564,28 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
}
}

/* Board has to be wired properly to use this feature */
if (twl4030_scripts->use_poweroff && !pm_power_off) {
/* Default for SEQ_OFFSYNC is set, lets ensure this */
err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val,
TWL4030_PM_MASTER_CFG_P123_TRANSITION);
if (err) {
pr_warning("TWL4030 Unable to read registers\n");

} else if (!(val & SEQ_OFFSYNC)) {
val |= SEQ_OFFSYNC;
err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val,
TWL4030_PM_MASTER_CFG_P123_TRANSITION);
if (err) {
pr_err("TWL4030 Unable to setup SEQ_OFFSYNC\n");
goto relock;
}
}

pm_power_off = twl4030_power_off;
}

relock:
err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0,
TWL4030_PM_MASTER_PROTECT_KEY);
if (err)
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/i2c/twl.h
Original file line number Diff line number Diff line change
Expand Up @@ -652,10 +652,12 @@ struct twl4030_power_data {
unsigned num;
struct twl4030_resconfig *resource_config;
#define TWL4030_RESCONFIG_UNDEF ((u8)-1)
bool use_poweroff; /* Board is wired for TWL poweroff */
};

extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts);
extern int twl4030_remove_script(u8 flags);
extern void twl4030_power_off(void);

struct twl4030_codec_data {
unsigned int digimic_delay; /* in ms */
Expand Down

0 comments on commit 39174b7

Please sign in to comment.