Hook up "pm_power_off" to palmas power off routine if there is DTany reason why it wont fit in drivers/power/reset/ is'nt it the right place to add this?
property "ti,system-power-controller" defined, so platform which is
powered by this regulator can be powered off properly.
Based on work by:
Mallikarjun Kasoju <mkasoju@xxxxxxxxxx>
Signed-off-by: Bill Huang <bilhuang@xxxxxxxxxx>
cc: Mallikarjun Kasoju <mkasoju@xxxxxxxxxx>
---
.../devicetree/bindings/regulator/palmas-pmic.txt | 5 +++++
drivers/mfd/palmas.c | 23 ++++++++++++++++++--
include/linux/mfd/palmas.h | 1 +
3 files changed, 27 insertions(+), 2 deletions(-)controller or master?
diff --git a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
index 30b0581..4adca2a 100644
--- a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
+++ b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
@@ -36,6 +36,9 @@ Optional nodes:
ti,smps-range - OTP has the wrong range set for the hardware so override
0 - low range, 1 - high range.
+- ti,system-power-controller: Telling whether or not this pmic is controlling
+ the system power.slave = PALMAS_BASE_TO_SLAVE(base);
+
Example:
#include <dt-bindings/interrupt-controller/irq.h>
@@ -48,6 +51,8 @@ pmic {
ti,ldo6-vibrator;
+ ti,system-power-controller;
+
regulators {
smps12_reg : smps12 {
regulator-name = "smps12";
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
index e4d1c70..0662b21 100644
--- a/drivers/mfd/palmas.c
+++ b/drivers/mfd/palmas.c
@@ -229,6 +229,22 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c,
PALMAS_POWER_CTRL_ENABLE2_MASK;
if (i2c->irq)
palmas_set_pdata_irq_flag(i2c, pdata);
+
+ pdata->pm_off = of_property_read_bool(node,
+ "ti,system-power-controller");
+}
+
+static struct palmas *palmas_dev;
+static void palmas_power_off(void)
+{
+ unsigned int addr;
+
+ if (!palmas_dev)
+ return;
+
+ addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_DEV_CTRL);
+
+ regmap_update_bits(palmas_dev->regmap[0], addr, 1, 0);