aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/tps6586x.c
diff options
context:
space:
mode:
authorBill Huang <bilhuang@nvidia.com>2012-08-19 21:07:55 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-09-14 03:52:14 -0400
commit004c15a68076f5bdc343bed92efed81087cecbfb (patch)
tree719632562fd71bf6ec24cd0e9a72afbeda8ff6a6 /drivers/mfd/tps6586x.c
parent80633f05b0dbf5819ef28f626f2f0b7c885d1f88 (diff)
mfd: dt: tps6586x: Add power off control
Add DT property "ti,system-power-controller" telling whether or not this pmic is in charge of controlling the system power, so the power off routine can be hooked up to system call "pm_power_off". Based on the work by: Dan Willemsen <dwillemsen@nvidia.com> Signed-off-by: Bill Huang <bilhuang@nvidia.com> Tested-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/tps6586x.c')
-rw-r--r--drivers/mfd/tps6586x.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index 5f58370ccf55..95ef40754dd7 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -29,6 +29,10 @@
29#include <linux/mfd/core.h> 29#include <linux/mfd/core.h>
30#include <linux/mfd/tps6586x.h> 30#include <linux/mfd/tps6586x.h>
31 31
32#define TPS6586X_SUPPLYENE 0x14
33#define EXITSLREQ_BIT BIT(1)
34#define SLEEP_MODE_BIT BIT(3)
35
32/* interrupt control registers */ 36/* interrupt control registers */
33#define TPS6586X_INT_ACK1 0xb5 37#define TPS6586X_INT_ACK1 0xb5
34#define TPS6586X_INT_ACK2 0xb6 38#define TPS6586X_INT_ACK2 0xb6
@@ -409,6 +413,7 @@ static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien
409 pdata->subdevs = devs; 413 pdata->subdevs = devs;
410 pdata->gpio_base = -1; 414 pdata->gpio_base = -1;
411 pdata->irq_base = -1; 415 pdata->irq_base = -1;
416 pdata->pm_off = of_property_read_bool(np, "ti,system-power-controller");
412 417
413 return pdata; 418 return pdata;
414} 419}
@@ -441,6 +446,15 @@ static const struct regmap_config tps6586x_regmap_config = {
441 .cache_type = REGCACHE_RBTREE, 446 .cache_type = REGCACHE_RBTREE,
442}; 447};
443 448
449static struct device *tps6586x_dev;
450static void tps6586x_power_off(void)
451{
452 if (tps6586x_clr_bits(tps6586x_dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT))
453 return;
454
455 tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT);
456}
457
444static int __devinit tps6586x_i2c_probe(struct i2c_client *client, 458static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
445 const struct i2c_device_id *id) 459 const struct i2c_device_id *id)
446{ 460{
@@ -506,6 +520,11 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
506 goto err_add_devs; 520 goto err_add_devs;
507 } 521 }
508 522
523 if (pdata->pm_off && !pm_power_off) {
524 tps6586x_dev = &client->dev;
525 pm_power_off = tps6586x_power_off;
526 }
527
509 return 0; 528 return 0;
510 529
511err_add_devs: 530err_add_devs: