Skip to contentSkip to conversation

regulator: act8865: Add support to turn off all outputs

PATCH In review Romain Perier 2 participants 8 messages Sep 27, 2014 – Sep 28, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 regulator: act8865: Add support to turn off all outputs

When the property "active-semi,system-power-controller" is found in the devicetree, the function pm_power_off is defined. This function sends the rights bit fields to the global off control register. shutdown/poweroff commands are now supported for hardware components which use these PMU.

---
 drivers/regulator/act8865-regulator.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/regulator/act8865-regulator.c +29 -0
index afd06f9..6cf202d 100644
@@ -61,6 +61,8 @@
 #define	ACT8846_REG12_VSET	0xa0
 #define	ACT8846_REG12_CTRL	0xa1
 #define	ACT8846_REG13_CTRL	0xb1
+#define	ACT8846_GLB_OFF_CTRL	0xc3
+#define	ACT8846_OFF_SYSMASK	0x18
 
 /*
  * ACT8865 Global Register Map.
@@ -84,6 +86,7 @@
 #define	ACT8865_LDO3_CTRL	0x61
 #define	ACT8865_LDO4_VSET	0x64
 #define	ACT8865_LDO4_CTRL	0x65
+#define	ACT8865_MSTROFF		0x20
 
 /*
  * Field Definitions.
@@ -98,6 +101,8 @@
 
 struct act8865 {
 	struct regmap *regmap;
+	int off_reg;
+	int off_mask;
 };
 
 static const struct regmap_config act8865_regmap_config = {
@@ -275,6 +280,16 @@ static struct regulator_init_data
 	return NULL;
 }
 
+static struct i2c_client *act8865_i2c_client;
+static void act8865_power_off(void)
+{
+	struct act8865 *act8865;
+
+	act8865 = i2c_get_clientdata(act8865_i2c_client);
+	regmap_write(act8865->regmap, act8865->off_reg, act8865->off_mask);
+	while (1);
+}
+
 static int act8865_pmic_probe(struct i2c_client *client,
 			      const struct i2c_device_id *i2c_id)
 {
@@ -285,6 +300,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
 	int i, ret, num_regulators;
 	struct act8865 *act8865;
 	unsigned long type;
+	int off_reg, off_mask;
 
 	pdata = dev_get_platdata(dev);
 
@@ -304,10 +320,14 @@ static int act8865_pmic_probe(struct i2c_client *client,
 	case ACT8846:
 		regulators = act8846_regulators;
 		num_regulators = ARRAY_SIZE(act8846_regulators);
+		off_reg = ACT8846_GLB_OFF_CTRL;
+		off_mask = ACT8846_OFF_SYSMASK;
 		break;
 	case ACT8865:
 		regulators = act8865_regulators;
 		num_regulators = ARRAY_SIZE(act8865_regulators);
+		off_reg = ACT8865_SYS_CTRL;
+		off_mask = ACT8865_MSTROFF;
 		break;
 	default:
 		dev_err(dev, "invalid device id %lu\n", type);
@@ -345,6 +365,15 @@ static int act8865_pmic_probe(struct i2c_client *client,
 		return ret;
 	}
 
+	if (dev->of_node &&
+	    of_property_read_bool(dev->of_node,
+				  "active-semi,system-power-controller")) {
+		act8865_i2c_client = client;
+		act8865->off_reg = off_reg;
+		act8865->off_mask = off_mask;
+		pm_power_off = act8865_power_off;
+	}
+
 	/* Finally register devices */
 	for (i = 0; i < num_regulators; i++) {
 		const struct regulator_desc *desc = &regulators[i];
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/3 ARM: dts: rockchip: Enable power off in pmic for Radxa Rock

Add "active-semi,system-power-controller" property to act8846 node. shutdown/poweroff commands are now handled for this board.

---
 arch/arm/boot/dts/rk3188-radxarock.dts | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/boot/dts/rk3188-radxarock.dts +2 -0
index e04bf8f..5b6a937 100644
@@ -115,6 +115,8 @@
 		pinctrl-names = "default";
 		pinctrl-0 = <&act8846_dvs0_ctl>;
 
+		active-semi,system-power-controller;
+
 		regulators {
 			vcc_ddr: REG1 {
 				regulator-name = "VCC_DDR";
Signature · 1 line
1.9.1
#2 lore raw

PATCH 3/3 dt-bindings: Document the property system-power-controller for act8865 regulator

In reply to Romain Perier
---
 Documentation/devicetree/bindings/regulator/act8865-regulator.txt | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/regulator/act8865-regulator.txt +4 -0
index 865614b..653ddc1 100644
@@ -5,6 +5,10 @@ Required properties:
 - compatible: "active-semi,act8846" or "active-semi,act8865"
 - reg: I2C slave address
 
+Optional properties:
+- active-semi,system-power-controller: Telling whether or not this pmic is controlling
+  the system power
+
 Any standard regulator properties can be used to configure the single regulator.
 
 The valid names for regulators are:
Signature · 1 line
1.9.1
maintainer
#3 lore raw
In reply to Romain Perier
Quoted 4 lines · Romain Perier

When the property "active-semi,system-power-controller" is found in the devicetree, the function pm_power_off is defined. This function sends the rights bit fields to the global off control register. shutdown/poweroff commands are now supported for hardware components which use these PMU.

We really need to come up with a standard property for this and document it rather than continuing to add individual device specific properties all doing the same thing, and probably also some helper code and/or a standard operation for this - there's a lot of drivers implementing the same pattern here.

drivers/regulator/act8865-regulator.c static int act8865_pmic_probe(struct i2c_client *client, · line 371

Quoted 4 lines
drivers/regulator/act8865-regulator.c +4 -0
+	if (dev->of_node &&
+	    of_property_read_bool(dev->of_node,
+				  "active-semi,system-power-controller")) {
+		act8865_i2c_client = client;

Indentation seems messed up here - tabs vs spaces?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140928/60d61c13/attachment-0001.sig>

#4 lore raw

Hi Mark,

2014-09-28 12:33 GMT+02:00 Mark Brown <[email protected]>:

Quoted 11 lines · Romain Perier
Quoted 4 lines

When the property "active-semi,system-power-controller" is found in the devicetree, the function pm_power_off is defined. This function sends the rights bit fields to the global off control register. shutdown/poweroff commands are now supported for hardware components which use these PMU.

We really need to come up with a standard property for this and document it rather than continuing to add individual device specific properties all doing the same thing, and probably also some helper code and/or a standard operation for this - there's a lot of drivers implementing the same pattern here.

I completly agree about adding a unified and generic property for that purpose. I already proposed something for that on devicetree ML, see the thread "Proposal: generic property for system-power-controller". Unfortunately I did not get replies :) .

Quoted 7 lines

drivers/regulator/act8865-regulator.c static int act8865_pmic_probe(struct i2c_client *client, · line 371

Quoted 5 lines
drivers/regulator/act8865-regulator.c +4 -0
+     if (dev->of_node &&
+         of_property_read_bool(dev->of_node,
+                               "active-semi,system-power-controller")) {
+             act8865_i2c_client = client;

Indentation seems messed up here - tabs vs spaces?

Yes, I really don't understand where the problem is. I use good emacs settings to be compatible with kernel coding style and git diff does not show me indent/spaces problems :/ .
Sorry because this is a very boring issue when reviewing patches... I will investigate ^^

Romain

maintainer
#5 lore raw
Quoted 8 lines · PERIER Romain

2014-09-28 12:33 GMT+02:00 Mark Brown <[email protected]>:

Quoted 5 lines

We really need to come up with a standard property for this and document it rather than continuing to add individual device specific properties all doing the same thing, and probably also some helper code and/or a standard operation for this - there's a lot of drivers implementing the same pattern here.

Quoted 4 lines

I completly agree about adding a unified and generic property for that purpose. I already proposed something for that on devicetree ML, see the thread "Proposal: generic property for system-power-controller". Unfortunately I did not get replies :) .

Did you CC relevant maintainers and send a patch?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140928/a69323c8/attachment.sig>

#6 lore raw

2014-09-28 14:25 GMT+02:00 Mark Brown <[email protected]>:

Quoted 9 lines · PERIER Romain
Quoted 7 lines

2014-09-28 12:33 GMT+02:00 Mark Brown <[email protected]>:

Quoted 5 lines

We really need to come up with a standard property for this and document it rather than continuing to add individual device specific properties all doing the same thing, and probably also some helper code and/or a standard operation for this - there's a lot of drivers implementing the same pattern here.

Quoted 6 lines
Quoted 4 lines

I completly agree about adding a unified and generic property for that purpose. I already proposed something for that on devicetree ML, see the thread "Proposal: generic property for system-power-controller". Unfortunately I did not get replies :) .

Did you CC relevant maintainers and send a patch?

No I did not propose patches as I was an open discussion. Perhaps I might propose something as part of my contribution for act8865... (at least for the property)

#7 lore raw

Well, I will think about it and I will propose a separated patch with a generic property and helper functions.

2014-09-28 15:25 GMT+02:00 PERIER Romain <[email protected]>:

Quoted 20 lines

2014-09-28 14:25 GMT+02:00 Mark Brown <[email protected]>:

Quoted 9 lines · PERIER Romain
Quoted 7 lines

2014-09-28 12:33 GMT+02:00 Mark Brown <[email protected]>:

Quoted 5 lines

We really need to come up with a standard property for this and document it rather than continuing to add individual device specific properties all doing the same thing, and probably also some helper code and/or a standard operation for this - there's a lot of drivers implementing the same pattern here.

Quoted 6 lines
Quoted 4 lines

I completly agree about adding a unified and generic property for that purpose. I already proposed something for that on devicetree ML, see the thread "Proposal: generic property for system-power-controller". Unfortunately I did not get replies :) .

Did you CC relevant maintainers and send a patch?

No I did not propose patches as I was an open discussion. Perhaps I might propose something as part of my contribution for act8865... (at least for the property)