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 | |
| 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>
| -rw-r--r-- | Documentation/devicetree/bindings/regulator/palmas-pmic.txt | 5 | ||||
| -rw-r--r-- | drivers/mfd/palmas.c | 33 | ||||
| -rw-r--r-- | include/linux/mfd/palmas.h | 1 |
3 files changed, 37 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt index d5a308629c57..02f4c0eb601e 100644 --- a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt +++ b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt | |||
| @@ -37,6 +37,9 @@ Optional nodes: | |||
| 37 | ti,smps-range - OTP has the wrong range set for the hardware so override | 37 | ti,smps-range - OTP has the wrong range set for the hardware so override |
| 38 | 0 - low range, 1 - high range. | 38 | 0 - low range, 1 - high range. |
| 39 | 39 | ||
| 40 | - ti,system-power-controller: Telling whether or not this pmic is controlling | ||
| 41 | the system power. | ||
| 42 | |||
| 40 | Example: | 43 | Example: |
| 41 | 44 | ||
| 42 | #include <dt-bindings/interrupt-controller/irq.h> | 45 | #include <dt-bindings/interrupt-controller/irq.h> |
| @@ -49,6 +52,8 @@ pmic { | |||
| 49 | 52 | ||
| 50 | ti,ldo6-vibrator; | 53 | ti,ldo6-vibrator; |
| 51 | 54 | ||
| 55 | ti,system-power-controller; | ||
| 56 | |||
| 52 | regulators { | 57 | regulators { |
| 53 | smps12_reg : smps12 { | 58 | smps12_reg : smps12 { |
| 54 | regulator-name = "smps12"; | 59 | regulator-name = "smps12"; |
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; |
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index 1a8dd7afe084..061cce0b119a 100644 --- a/include/linux/mfd/palmas.h +++ b/include/linux/mfd/palmas.h | |||
| @@ -258,6 +258,7 @@ struct palmas_platform_data { | |||
| 258 | */ | 258 | */ |
| 259 | int mux_from_pdata; | 259 | int mux_from_pdata; |
| 260 | u8 pad1, pad2; | 260 | u8 pad1, pad2; |
| 261 | bool pm_off; | ||
| 261 | 262 | ||
| 262 | struct palmas_pmic_platform_data *pmic_pdata; | 263 | struct palmas_pmic_platform_data *pmic_pdata; |
| 263 | struct palmas_gpadc_platform_data *gpadc_pdata; | 264 | struct palmas_gpadc_platform_data *gpadc_pdata; |
