summaryrefslogtreecommitdiff
path: root/drivers/mfd/max8907.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-09-18 16:51:19 -0600
committerSamuel Ortiz <sameo@linux.intel.com>2012-09-19 12:07:56 +0200
commit9582fdcb6fcf1b596a83b161a2ea886272d2a62f (patch)
treed880190567065d64e86b29194a0ec0ca23cfb50b /drivers/mfd/max8907.c
parent48a364b758f861b21747a5148f26aedc504edb7f (diff)
mfd: max8907: Add power off control
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>
Diffstat (limited to 'drivers/mfd/max8907.c')
-rw-r--r--drivers/mfd/max8907.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/mfd/max8907.c b/drivers/mfd/max8907.c
index 6497c98e030d..2303641dd052 100644
--- a/drivers/mfd/max8907.c
+++ b/drivers/mfd/max8907.c
@@ -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: