mfd: dt: tps6586x: Add power off control
authorBill Huang <bilhuang@nvidia.com>
Mon, 20 Aug 2012 01:07:55 +0000 (18:07 -0700)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 14 Sep 2012 07:52:14 +0000 (09:52 +0200)
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>
Documentation/devicetree/bindings/regulator/tps6586x.txt
drivers/mfd/tps6586x.c
include/linux/mfd/tps6586x.h

index d156e1b5db1233c5ffdb2c0f54e1f5bd6234da34..03dfa4e0aa75e9406e1eabb7e5a6806a9afc2cc1 100644 (file)
@@ -18,6 +18,10 @@ Required properties:
 - vinldo678-supply: The input supply for the LDO6, LDO7 and LDO8
 - vinldo9-supply: The input supply for the LDO9
 
+Optional properties:
+- ti,system-power-controller: Telling whether or not this pmic is controlling
+  the system power.
+
 Each regulator is defined using the standard binding for regulators.
 
 Example:
@@ -30,6 +34,8 @@ Example:
                #gpio-cells = <2>;
                gpio-controller;
 
+               ti,system-power-controller;
+
                sm0-supply = <&some_reg>;
                sm1-supply = <&some_reg>;
                sm2-supply = <&some_reg>;
index 5f58370ccf5502b1d6a729f2daa0db411a6e3e1d..95ef40754dd7f5360e1ae009857e1f76948b468d 100644 (file)
 #include <linux/mfd/core.h>
 #include <linux/mfd/tps6586x.h>
 
+#define TPS6586X_SUPPLYENE     0x14
+#define EXITSLREQ_BIT          BIT(1)
+#define SLEEP_MODE_BIT         BIT(3)
+
 /* interrupt control registers */
 #define TPS6586X_INT_ACK1      0xb5
 #define TPS6586X_INT_ACK2      0xb6
@@ -409,6 +413,7 @@ static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien
        pdata->subdevs = devs;
        pdata->gpio_base = -1;
        pdata->irq_base = -1;
+       pdata->pm_off = of_property_read_bool(np, "ti,system-power-controller");
 
        return pdata;
 }
@@ -441,6 +446,15 @@ static const struct regmap_config tps6586x_regmap_config = {
        .cache_type = REGCACHE_RBTREE,
 };
 
+static struct device *tps6586x_dev;
+static void tps6586x_power_off(void)
+{
+       if (tps6586x_clr_bits(tps6586x_dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT))
+               return;
+
+       tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT);
+}
+
 static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
                                        const struct i2c_device_id *id)
 {
@@ -506,6 +520,11 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client,
                goto err_add_devs;
        }
 
+       if (pdata->pm_off && !pm_power_off) {
+               tps6586x_dev = &client->dev;
+               pm_power_off = tps6586x_power_off;
+       }
+
        return 0;
 
 err_add_devs:
index f350fd0ba1dfd566374afb8afb86fdf1d1ba95ef..08f109f0f81c51380f1dc72f0e57cd1e5d825c18 100644 (file)
@@ -77,6 +77,7 @@ struct tps6586x_platform_data {
 
        int gpio_base;
        int irq_base;
+       bool pm_off;
 };
 
 /*