diff options
author | Bill Huang <bilhuang@nvidia.com> | 2013-08-08 07:45:05 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2013-08-14 13:53:17 -0400 |
commit | b81eec09a484c588ead035003ce7555ca8a9963a (patch) | |
tree | b6da5dbb56f0718cd9e67134e14ffda1ce2b0e65 /drivers/mfd/palmas.c | |
parent | 3134bcae4f70d56df31a5b024c54115d4f504727 (diff) |
mfd: palmas: Add power off control
Hook up "pm_power_off" to palmas power off routine if there is DT
property "ti,system-power-controller" defined, so platform which is
powered by this regulator can be powered off properly.
Acked-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Mallikarjun Kasoju <mkasoju@nvidia.com>
Signed-off-by: Bill Huang <bilhuang@nvidia.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd/palmas.c')
-rw-r--r-- | drivers/mfd/palmas.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c index e4d1c706df8b..220a34d71f8d 100644 --- a/drivers/mfd/palmas.c +++ b/drivers/mfd/palmas.c | |||
@@ -229,6 +229,32 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c, | |||
229 | PALMAS_POWER_CTRL_ENABLE2_MASK; | 229 | PALMAS_POWER_CTRL_ENABLE2_MASK; |
230 | if (i2c->irq) | 230 | if (i2c->irq) |
231 | palmas_set_pdata_irq_flag(i2c, pdata); | 231 | palmas_set_pdata_irq_flag(i2c, pdata); |
232 | |||
233 | pdata->pm_off = of_property_read_bool(node, | ||
234 | "ti,system-power-controller"); | ||
235 | } | ||
236 | |||
237 | static struct palmas *palmas_dev; | ||
238 | static void palmas_power_off(void) | ||
239 | { | ||
240 | unsigned int addr; | ||
241 | int ret, slave; | ||
242 | |||
243 | if (!palmas_dev) | ||
244 | return; | ||
245 | |||
246 | slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE); | ||
247 | addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_DEV_CTRL); | ||
248 | |||
249 | ret = regmap_update_bits( | ||
250 | palmas_dev->regmap[slave], | ||
251 | addr, | ||
252 | PALMAS_DEV_CTRL_DEV_ON, | ||
253 | 0); | ||
254 | |||
255 | if (ret) | ||
256 | pr_err("%s: Unable to write to DEV_CTRL_DEV_ON: %d\n", | ||
257 | __func__, ret); | ||
232 | } | 258 | } |
233 | 259 | ||
234 | static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST; | 260 | static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST; |
@@ -423,10 +449,13 @@ no_irq: | |||
423 | */ | 449 | */ |
424 | if (node) { | 450 | if (node) { |
425 | ret = of_platform_populate(node, NULL, NULL, &i2c->dev); | 451 | ret = of_platform_populate(node, NULL, NULL, &i2c->dev); |
426 | if (ret < 0) | 452 | if (ret < 0) { |
427 | goto err_irq; | 453 | goto err_irq; |
428 | else | 454 | } else if (pdata->pm_off && !pm_power_off) { |
455 | palmas_dev = palmas; | ||
456 | pm_power_off = palmas_power_off; | ||
429 | return ret; | 457 | return ret; |
458 | } | ||
430 | } | 459 | } |
431 | 460 | ||
432 | return ret; | 461 | return ret; |