Skip to contentSkip to conversation

mfd: palmas: Add power off control

PATCH In review Bill Huang 3 participants 5 messages Mar 14, 2013 – Mar 16, 2013

Subsystems (2)
lore
Share & tools
lore

Bill Huang

author
#0 lore raw

PATCH 1/1 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.

Based on work by:
Mallikarjun Kasoju <[email protected]>

---
 drivers/mfd/palmas.c       |   25 +++++++++++++++++++++++--
 include/linux/mfd/palmas.h |    1 +
 2 files changed, 24 insertions(+), 2 deletions(-)
drivers/mfd/palmas.c +23 -2
index bbdbc50..ee8180d 100644
@@ -283,6 +283,22 @@ static void palmas_dt_to_pdata(struct device_node *node,
 		pdata->power_ctrl = PALMAS_POWER_CTRL_NSLEEP_MASK |
 					PALMAS_POWER_CTRL_ENABLE1_MASK |
 					PALMAS_POWER_CTRL_ENABLE2_MASK;
+
+	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);
 }
 
 static int palmas_i2c_probe(struct i2c_client *i2c,
@@ -435,10 +451,15 @@ static int palmas_i2c_probe(struct i2c_client *i2c,
 	 */
 	if (node) {
 		ret = of_platform_populate(node, NULL, NULL, &i2c->dev);
-		if (ret < 0)
+		if (ret < 0) {
 			goto err_irq;
-		else
+		} else {
+			if (pdata->pm_off && !pm_power_off) {
+				palmas_dev = palmas;
+				pm_power_off = palmas_power_off;
+			}
 			return ret;
+		}
 	}
 
 	children = kmemdup(palmas_children, sizeof(palmas_children),
include/linux/mfd/palmas.h +1 -0
index a4d13d7..a447e54 100644
@@ -232,6 +232,7 @@ struct palmas_platform_data {
 	 */
 	int mux_from_pdata;
 	u8 pad1, pad2;
+	bool pm_off;
 
 	struct palmas_pmic_platform_data *pmic_pdata;
 	struct palmas_gpadc_platform_data *gpadc_pdata;
Signature · 1 line
1.7.9.5
#1 lore raw

drivers/mfd/palmas.c static void palmas_dt_to_pdata(struct device_node *node, · line 288

Quoted 8 lines · Bill Huang

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.

drivers/mfd/palmas.c +2 -0
 
+	pdata->pm_off = of_property_read_bool(node,
+			"ti,system-power-controller");

You would need to add that property to the DT binding documentation for this device.

author
#2 lore raw
Quoted 5 lines · Stephen Warren
Quoted 3 lines · Bill Huang

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.

Quoted 7 lines

drivers/mfd/palmas.c static void palmas_dt_to_pdata(struct device_node *node, · line 288

Quoted 4 lines
drivers/mfd/palmas.c +2 -0
 
+	pdata->pm_off = of_property_read_bool(node,
+			"ti,system-power-controller");

You would need to add that property to the DT binding documentation for this device.

Does it work that some time later Laxmain helps to add it when he submits his pmic bindings for Palmas?

#3 lore raw
Quoted 8 lines · Bill Huang
Quoted 7 lines · Stephen Warren
Quoted 5 lines · Bill Huang

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.

drivers/mfd/palmas.c +0 -0
Quoted 8 lines
Quoted 5 lines

drivers/mfd/palmas.c static void palmas_dt_to_pdata(struct device_node *node, · line 288

Quoted 2 lines
drivers/mfd/palmas.c +2 -0
+	pdata->pm_off = of_property_read_bool(node,
+			"ti,system-power-controller");

You would need to add that property to the DT binding documentation for this device.

Does it work that some time later Laxmain helps to add it when he submits his pmic bindings for Palmas?

I'll note that Ian Lartey and Graeme Gregory actually seem to be the people defining the PMIC bindings for Palmas. See:

http://comments.gmane.org/gmane.linux.documentation/9948

Or is Laxman planning to send some updates to that?

But irrespective of that no, I don't think that influences this at all; if you introduce driver support for new DT content, then either that DT content should already be documented in the binding, or this patch should add it to the documentation.

author
#4 lore raw
Quoted 21 lines · Stephen Warren
Quoted 8 lines · Bill Huang
Quoted 7 lines · Stephen Warren
Quoted 5 lines · Bill Huang

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.

drivers/mfd/palmas.c +0 -0
Quoted 8 lines
Quoted 5 lines

drivers/mfd/palmas.c static void palmas_dt_to_pdata(struct device_node *node, · line 288

Quoted 2 lines
drivers/mfd/palmas.c +2 -0
+	pdata->pm_off = of_property_read_bool(node,
+			"ti,system-power-controller");

You would need to add that property to the DT binding documentation for this device.

Does it work that some time later Laxmain helps to add it when he submits his pmic bindings for Palmas?

I'll note that Ian Lartey and Graeme Gregory actually seem to be the people defining the PMIC bindings for Palmas. See:

Quoted 8 lines

http://comments.gmane.org/gmane.linux.documentation/9948

Or is Laxman planning to send some updates to that?

But irrespective of that no, I don't think that influences this at all; if you introduce driver support for new DT content, then either that DT content should already be documented in the binding, or this patch should add it to the documentation.

Thanks, here I just need to add a property into the DT bindings but currently there is no any Palmas binding document exist so that means I have to hold off the patch.