Permalink
Browse files

Add power-off support for the TWL4030 companion

This patch adds support for the power-off on shutdown feature of the TWL4030
  • Loading branch information...
berniwa authored and sakoman committed May 15, 2010
1 parent 07f49c7 commit a5e0f0df199048768eaf1d7e9dd512323d18661e
Showing with 46 additions and 0 deletions.
  1. +6 −0 drivers/mfd/Kconfig
  2. +40 −0 drivers/mfd/twl-core.c
View
@@ -207,6 +207,12 @@ config TWL4030_MADC
to build it as a dinamically loadable module. The module will be
called twl4030-madc.ko
+config TWL4030_POWEROFF
+ bool "TWL4030 Allow power-off on shutdown"
+ depends on TWL4030_CORE
+ help
+ Enables the CPU to power-off the system on shutdown
+
config TWL6030_PWM
tristate "TWL6030 PWM (Pulse Width Modulator) Support"
depends on TWL4030_CORE
View
@@ -122,6 +122,12 @@
#define twl_has_bci() false
#endif
+#if defined (CONFIG_TWL4030_POWEROFF)
+#define twl_has_poweroff() true
+#else
+#define twl_has_poweroff() false
+#endif
+
/* Triton Core internal information (BEGIN) */
/* Last - for index max*/
@@ -229,6 +235,10 @@
#define TWL5031 BIT(2) /* twl5031 has different registers */
#define TWL6030_CLASS BIT(3) /* TWL6030 class */
+/* for pm_power_off */
+#define PWR_P1_SW_EVENTS 0x10
+#define PWR_DEVOFF (1 << 0)
+
/*----------------------------------------------------------------------*/
/* is driver active, bound to a chip? */
@@ -1010,6 +1020,30 @@ static int twl_remove(struct i2c_client *client)
return 0;
}
+static void twl_poweroff(void)
+{
+ int err;
+ u8 val;
+
+ err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val,
+ PWR_P1_SW_EVENTS);
+ if (err) {
+ pr_err("%s: i2c error %d while reading TWL4030"
+ "PM_MASTER P1_SW_EVENTS\n",
+ DRIVER_NAME, err);
+ return;
+ }
+
+ val |= PWR_DEVOFF;
+
+ err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val,
+ PWR_P1_SW_EVENTS);
+ if (err)
+ pr_err("%s: i2c error %d while writing TWL4030"
+ "PM_MASTER P1_SW_EVENTS\n",
+ DRIVER_NAME, err);
+}
+
/* NOTE: this driver only handles a single twl4030/tps659x0 chip */
static int __devinit
twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
@@ -1097,6 +1131,12 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
}
+ if(twl_has_poweroff())
+ {
+ /* initialize pm_power_off routine */
+ pm_power_off = twl_poweroff;
+ }
+
status = add_children(pdata, id->driver_data);
fail:
if (status < 0)

0 comments on commit a5e0f0d

Please sign in to comment.