]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/commitdiff
mfd: max8907: Add power off control
authorStephen Warren <swarren@nvidia.com>
Tue, 18 Sep 2012 22:51:19 +0000 (16:51 -0600)
committerSamuel Ortiz <sameo@linux.intel.com>
Wed, 19 Sep 2012 10:07:56 +0000 (12:07 +0200)
Add DT property "maxim,system-power-controller" to indicate whether the
PMIC is in charge of controlling the system power. If this is set, the
driver will provide the pm_power_off() function.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Documentation/devicetree/bindings/regulator/max8907.txt
drivers/mfd/max8907.c
include/linux/mfd/max8907.h

index 4fd847f0afc0f009cc04f88f073bd6f6c8f20c85..51e683b2bf4731d7702dae91b1cd6663b1ce6f1b 100644 (file)
@@ -16,6 +16,10 @@ Required properties:
   property, with valid values listed below. The content of each sub-node
   is defined by the standard binding for regulators; see regulator.txt.
 
+Optional properties:
+- maxim,system-power-controller: Boolean property indicating that the PMIC
+  controls the overall system power.
+
 Valid regulator-compatible values are:
 
   sd1, sd2, sd3, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8, ldo9, ldo10,
@@ -29,6 +33,8 @@ Example:
                        reg = <0x3c>;
                        interrupts = <0 86 0x4>;
 
+                       maxim,system-power-controller;
+
                        mbatt-supply = <&some_reg>;
                        in-v1-supply = <&mbatt_reg>;
                        ...
index 6497c98e030d821e22e2c5bb576b4420e8eeec59..2303641dd052fa652ed2c2264bd0c67e85aa7d42 100644 (file)
@@ -176,11 +176,26 @@ static const struct regmap_irq_chip max8907_rtc_irq_chip = {
        .num_irqs = ARRAY_SIZE(max8907_rtc_irqs),
 };
 
+struct max8907 *max8907_pm_off;
+static void max8907_power_off(void)
+{
+       regmap_update_bits(max8907_pm_off->regmap_gen, MAX8907_REG_RESET_CNFG,
+                       MAX8907_MASK_POWER_OFF, MAX8907_MASK_POWER_OFF);
+}
+
 static __devinit int max8907_i2c_probe(struct i2c_client *i2c,
                                       const struct i2c_device_id *id)
 {
        struct max8907 *max8907;
        int ret;
+       struct max8907_platform_data *pdata = dev_get_platdata(&i2c->dev);
+       bool pm_off = false;
+
+       if (pdata)
+               pm_off = pdata->pm_off;
+       else if (i2c->dev.of_node)
+               pm_off = of_property_read_bool(i2c->dev.of_node,
+                                       "maxim,system-power-controller");
 
        max8907 = devm_kzalloc(&i2c->dev, sizeof(struct max8907), GFP_KERNEL);
        if (!max8907) {
@@ -251,6 +266,11 @@ static __devinit int max8907_i2c_probe(struct i2c_client *i2c,
                goto err_add_devices;
        }
 
+       if (pm_off && !pm_power_off) {
+               max8907_pm_off = max8907;
+               pm_power_off = max8907_power_off;
+       }
+
        return 0;
 
 err_add_devices:
index 283531fde4e09e703c7480b471d34da2f8e7c0df..b06f7a6a1e8074854472f7fcdd75cf5645b7adfa 100644 (file)
 #define MAX8907_MASK_OUT5V_VINEN       0x10
 #define MAX8907_MASK_OUT5V_ENSRC       0x0E
 #define MAX8907_MASK_OUT5V_EN          0x01
+#define MAX8907_MASK_POWER_OFF         0x40
 
 /* Regulator IDs */
 #define MAX8907_MBATT  0
@@ -231,6 +232,7 @@ enum {
 
 struct max8907_platform_data {
        struct regulator_init_data *init_data[MAX8907_NUM_REGULATORS];
+       bool pm_off;
 };
 
 struct regmap_irq_chips_data;