pm: Add power off control
Subsystems (5)
v2 cover pm: Add power off control
Add PM power_off control to rtc driver, along with this PMIC status is set to STATUS_OFF to shutdown PMIC if PWR_EN is toggled by RTC module.
System power off sequence:-
* Set PMIC STATUS_OFF when PMIC_POWER_EN is pulled low
* Enable PMIC_POWER_EN in rtc module
* Set rtc ALARM2 time
* Enable ALARM2 interrupt
These patches were tested on AM335x-Bone.
Changes from v1:
- Incorporated Vaibhav's comments on v1
* Changed the time rollover logic with the help of rtc-lib APIs
AnilKumar Ch (2):
ARM: dts: AM33XX: Set pmic-shutdown-controller for BeagleBone
ARM: dts: AM33XX: Enable system power off control in am335x-bone
Colin Foe-Parker (2):
mfd: tps65217: Set PMIC to shutdowm on PWR_EN toggle
rtc: OMAP: Add system pm_power_off to rtc driver
.../devicetree/bindings/regulator/tps65217.txt | 4 + Documentation/devicetree/bindings/rtc/rtc-omap.txt | 5 ++ arch/arm/boot/dts/am335x-bone.dts | 6 ++ drivers/mfd/tps65217.c | 12 +++ drivers/rtc/rtc-omap.c | 81 +++++++++++++++++++- 5 files changed, 107 insertions(+), 1 deletion(-)
Signature · 1 line
1.7.9.5
PATCH v2 1/4 mfd: tps65217: Set PMIC to shutdowm on PWR_EN toggle
From: Colin Foe-Parker <[email protected]>
Set tps65217 PMIC status to OFF if power enable toggle is supported. Also adds platform data flag, which should be passed from board init data.
--- .../devicetree/bindings/regulator/tps65217.txt | 4 ++++ drivers/mfd/tps65217.c | 12 ++++++++++++ 2 files changed, 16 insertions(+)
Documentation/devicetree/bindings/regulator/tps65217.txt +4 -0
@@ -11,6 +11,9 @@ Required properties: using the standard binding for regulators found at Documentation/devicetree/bindings/regulator/regulator.txt. +Optional properties: +- ti,pmic-shutdown-controller: Telling the PMIC to shutdown on PWR_EN toggle. + The valid names for regulators are: tps65217: dcdc1, dcdc2, dcdc3, ldo1, ldo2, ldo3 and ldo4
@@ -20,6 +23,7 @@ Example: tps: tps at 24 { compatible = "ti,tps65217"; + ti,pmic-shutdown-controller; regulators { dcdc1_reg: dcdc1 {
drivers/mfd/tps65217.c +12 -0
@@ -160,6 +160,7 @@ static int __devinit tps65217_probe(struct i2c_client *client,unsigned int version;unsigned int chip_id = ids->driver_data;const struct of_device_id *match; +bool status_off = false;int ret;if (client->dev.of_node) {
@@ -170,6 +171,8 @@ static int __devinit tps65217_probe(struct i2c_client *client,return -EINVAL ; } chip_id = (unsigned int )match->data; + status_off =of_property_read_bool (client->dev.of_node, +"ti,pmic-shutdown-controller" ); }if (!chip_id) {
@@ -207,6 +210,15 @@ static int __devinit tps65217_probe(struct i2c_client *client,return ret; } +/* Set the PMIC to shutdown on PWR_EN toggle */ +if (status_off) { + ret =tps65217_set_bits (tps,TPS65217_REG_STATUS , +TPS65217_STATUS_OFF ,TPS65217_STATUS_OFF , +TPS65217_PROTECT_NONE ); +if (ret) +dev_warn (tps->dev,"unable to set the status OFF\n" ); + } +dev_info (tps->dev,"TPS65217 ID %#x version 1.%d\n" , (version &TPS65217_CHIPID_CHIP_MASK ) >>4 , version &TPS65217_CHIPID_REV_MASK );
Signature · 1 line
1.7.9.5
PATCH v2 1/4 mfd: tps65217: Set PMIC to shutdowm on PWR_EN toggle
Quoted 5 lines · AnilKumar Ch
From: Colin Foe-Parker <[email protected]>
Set tps65217 PMIC status to OFF if power enable toggle is supported. Also adds platform data flag, which should be passed from board init data.
nit: changelog mentions platform_data, but the code is using DT.
Kevin
Quoted 67 lines
Signed-off-by Colin Foe-Parker <[email protected]>[[email protected]: move the additions to tps65217 MFD driver]Signed-off-by AnilKumar Ch <[email protected]>--- .../devicetree/bindings/regulator/tps65217.txt | 4 ++++ drivers/mfd/tps65217.c | 12 ++++++++++++ 2 files changed, 16 insertions(+)Documentation/devicetree/bindings/regulator/tps65217.txt +4
-0@@ -11,6 +11,9 @@ Required properties: using the standard binding for regulators found at Documentation/devicetree/bindings/regulator/regulator.txt. +Optional properties: +- ti,pmic-shutdown-controller: Telling the PMIC to shutdown on PWR_EN toggle. + The valid names for regulators are: tps65217: dcdc1, dcdc2, dcdc3, ldo1, ldo2, ldo3 and ldo4@@ -20,6 +23,7 @@ Example: tps: tps@24 { compatible = "ti,tps65217"; + ti,pmic-shutdown-controller; regulators { dcdc1_reg: dcdc1 {drivers/mfd/tps65217.c +12
-0@@ -160,6 +160,7 @@ static int __devinit tps65217_probe(struct i2c_client *client,unsigned int version;unsigned int chip_id = ids->driver_data;const struct of_device_id *match; +bool status_off = false;int ret;if (client->dev.of_node) {@@ -170,6 +171,8 @@ static int __devinit tps65217_probe(struct i2c_client *client,return -EINVAL ; } chip_id = (unsigned int )match->data; + status_off =of_property_read_bool (client->dev.of_node, +"ti,pmic-shutdown-controller" ); }if (!chip_id) {@@ -207,6 +210,15 @@ static int __devinit tps65217_probe(struct i2c_client *client,return ret; } +/* Set the PMIC to shutdown on PWR_EN toggle */ +if (status_off) { + ret =tps65217_set_bits (tps,TPS65217_REG_STATUS , +TPS65217_STATUS_OFF ,TPS65217_STATUS_OFF , +TPS65217_PROTECT_NONE ); +if (ret) +dev_warn (tps->dev,"unable to set the status OFF\n" ); + } +dev_info (tps->dev,"TPS65217 ID %#x version 1.%d\n" , (version &TPS65217_CHIPID_CHIP_MASK ) >>4 , version &TPS65217_CHIPID_REV_MASK );
PATCH v2 1/4 mfd: tps65217: Set PMIC to shutdowm on PWR_EN toggle
In reply to AnilKumar ChQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"AnilKumar" == AnilKumar Ch <[email protected]> writes:
s/shutdowm/shutdown/ in the subject.
AnilKumar> From: Colin Foe-Parker <[email protected]> AnilKumar> Set tps65217 PMIC status to OFF if power enable toggle is AnilKumar> supported. Also adds platform data flag, which should be AnilKumar> passed from board init data.
You're adding dt binding, not platform data.
AnilKumar> Signed-off-by: Colin Foe-Parker <[email protected]> AnilKumar> [anilkumar at ti.com: move the additions to tps65217 MFD driver] AnilKumar> Signed-off-by: AnilKumar Ch <[email protected]> AnilKumar> ---
AnilKumar> .../devicetree/bindings/regulator/tps65217.txt | 4 ++++ AnilKumar> drivers/mfd/tps65217.c | 12 ++++++++++++
AnilKumar> 2 files changed, 16 insertions(+)
AnilKumar> diff --git a/Documentation/devicetree/bindings/regulator/tps65217.txt b/Documentation/devicetree/bindings/regulator/tps65217.txt AnilKumar> index d316fb8..4f05d20 100644
AnilKumar> --- a/Documentation/devicetree/bindings/regulator/tps65217.txt
AnilKumar> +++ b/Documentation/devicetree/bindings/regulator/tps65217.txt
AnilKumar> @@ -11,6 +11,9 @@ Required properties:
AnilKumar> using the standard binding for regulators found at
AnilKumar> Documentation/devicetree/bindings/regulator/regulator.txt.
AnilKumar> +Optional properties:
AnilKumar> +- ti,pmic-shutdown-controller: Telling the PMIC to shutdown on PWR_EN toggle.
Ehh, I don't know the tps65217 particular well, but according to the datasheet the REG_STATUS_OFF bit enables/disables the PB_IN pin, not PWR_EN. It's also not only about powering down but also powering up again.
I don't feel this property name is very clear. Perhaps something about power button or push button monitor as it is called in the datasheet?
Signature · 1 line
Bye, Peter Korsgaard
PATCH v2 1/4 mfd: tps65217: Set PMIC to shutdowm on PWR_EN toggle
Quoted 3 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"AnilKumar" == AnilKumar Ch <[email protected]> writes:
s/shutdowm/shutdown/ in the subject.
I will change
Quoted 7 lines
AnilKumar> From: Colin Foe-Parker <[email protected]> AnilKumar> Set tps65217 PMIC status to OFF if power enable toggle is AnilKumar> supported. Also adds platform data flag, which should be AnilKumar> passed from board init data.
You're adding dt binding, not platform data.
I will change
Quoted 20 lines
AnilKumar> Signed-off-by: Colin Foe-Parker <[email protected]> AnilKumar> [anilkumar at ti.com: move the additions to tps65217 MFD driver] AnilKumar> Signed-off-by: AnilKumar Ch <[email protected]> AnilKumar> ---
AnilKumar> .../devicetree/bindings/regulator/tps65217.txt | 4 ++++ AnilKumar> drivers/mfd/tps65217.c | 12 ++++++++++++AnilKumar> 2 files changed, 16 insertions(+)
AnilKumar> diff --git
a/Documentation/devicetree/bindings/regulator/tps65217.txtb/Documentation/devicetree/bindings/regulator/tps65217.txtAnilKumar> index d316fb8..4f05d20 100644
AnilKumar> ---a/Documentation/devicetree/bindings/regulator/tps65217.txt
AnilKumar> +++b/Documentation/devicetree/bindings/regulator/tps65217.txt
AnilKumar> @@ -11,6 +11,9 @@ Required properties:
AnilKumar> using the standard binding for regulators found at
AnilKumar>Documentation/devicetree/bindings/regulator/regulator.txt.AnilKumar> +Optional properties:
AnilKumar> +- ti,pmic-shutdown-controller: Telling the PMIC to shutdown onPWR_ENtoggle.
Quoted 7 lines
Ehh, I don't know the tps65217 particular well, but according to the datasheet the
REG_STATUS_OFFbit enables/disables thePB_INpin, notPWR_EN. It's also not only about powering down but also powering up again.I don't feel this property name is very clear. Perhaps something about power button or push button monitor as it is called in the datasheet?
Here I am writing "TPS65217_STATUS_OFF" to status register, BIT(7). Description of this bit field: "OFF bit. Set this bit to 1 to enter OFF state when PWR_EN pin is pulled low. Bit is automatically reset to 0."
PWR_EN pin pull-down is doing by RTC module.
Regards
AnilKumar
PATCH v2 1/4 mfd: tps65217: Set PMIC to shutdowm on PWR_EN toggle
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"A" == AnilKumar, Chimata <[email protected]> writes:
Hi,
Quoted 2 lines
Quoted 2 lines
I don't feel this property name is very clear. Perhaps something about power button or push button monitor as it is called in the datasheet?
A> Here I am writing "TPS65217_STATUS_OFF" to status register, BIT(7). A> Description of this bit field: "OFF bit. Set this bit to 1 to enter A> OFF state when PWR_EN pin is pulled low. Bit is automatically reset A> to 0."
A> PWR_EN pin pull-down is doing by RTC module.
Ahh yes, sorry -ENOCOFFEE. I somehow misread the datasheet and looked at bit 0 instead.
Signature · 1 line
Bye, Peter Korsgaard
PATCH v2 2/4 rtc: OMAP: Add system pm_power_off to rtc driver
In reply to AnilKumar ChFrom: Colin Foe-Parker <[email protected]>
Add system power off control to rtc driver which is the in-charge of controlling the BeagleBone system power. The power_off routine can be hooked up to "pm_power_off" system call.
System power off sequence:-
* Set PMIC STATUS_OFF when PMIC_POWER_EN is pulled low
* Enable PMIC_POWER_EN in rtc module
* Set rtc ALARM2 time
* Enable ALARM2 interrupt
Added while (1); after the above steps to make sure that no other process acquire cpu. Otherwise we might see an unexpected behaviour because we are shutting down all the power rails of SoC except RTC.
--- Documentation/devicetree/bindings/rtc/rtc-omap.txt | 5 ++ drivers/rtc/rtc-omap.c | 81 +++++++++++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/rtc/rtc-omap.txt +5 -0
@@ -6,6 +6,10 @@ Required properties: - interrupts: rtc timer, alarm interrupts in order - interrupt-parent: phandle for the interrupt controller +Optional properties: +- ti,system-power-controller: Telling whether or not rtc is controlling + the system power. + Example: rtc at 1c23000 {
@@ -14,4 +18,5 @@ rtc at 1c23000 { interrupts = <19 19>; interrupt-parent = <&intc>; + ti,system-power-controller; };
drivers/rtc/rtc-omap.c +80 -1
125 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v2 3/4 ARM: dts: AM33XX: Set pmic-shutdown-controller for BeagleBone
In reply to AnilKumar ChSet ti,pmic-shutdown-controller for BeagleBone in am335x-bone.dts file, this flag is used by the driver to set tps65217 PMIC status to OFF when PWR_EN toggle.
--- arch/arm/boot/dts/am335x-bone.dts | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/boot/dts/am335x-bone.dts +2 -0
@@ -88,6 +88,8 @@ /include/ "tps65217.dtsi" &tps { + ti,pmic-shutdown-controller; + regulators { dcdc1_reg: regulator at 0 { regulator-always-on;
Signature · 1 line
1.7.9.5
PATCH v2 4/4 ARM: dts: AM33XX: Enable system power off control in am335x-bone
In reply to AnilKumar ChEnable system power off control for BeagleBone in am335x-bone.dts file under rtc node. RTC is the incharge of controlling the system power. This flag is used by the driver to hook up the pm_power_off system call.
--- arch/arm/boot/dts/am335x-bone.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/am335x-bone.dts +4 -0
@@ -52,6 +52,10 @@ }; }; + + rtc at 44e3e000 { + ti,system-power-controller; + }; }; leds {
Signature · 1 line
1.7.9.5
PATCH v2 4/4 ARM: dts: AM33XX: Enable system power off control in am335x-bone
Quoted 14 lines · AnilKumar Ch
Enable system power off control for BeagleBone in
am335x-bone.dtsfile under rtc node. RTC is the incharge of controlling the system power. This flag is used by the driver to hook up thepm_power_offsystem call.Signed-off-by AnilKumar Ch <[email protected]>--- arch/arm/boot/dts/am335x-bone.dts | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/boot/dts/am335x-bone.dts +0
-0
arch/arm/boot/dts/am335x-bone.dts line 59
Quoted 8 lines
arch/arm/boot/dts/am335x-bone.dts +4
-0@@ -52,6 +52,10 @@ }; }; + + rtc@44e3e000 { + ti,system-power-controller; + }; };
Also, I think this series is missing a patch that allows the RTC driver to be compiled on AM335x.
Kevin
PATCH v2 4/4 ARM: dts: AM33XX: Enable system power off control in am335x-bone
Quoted 18 lines · Kevin Hilman
Quoted 16 lines · AnilKumar Ch
Enable system power off control for BeagleBone in
am335x-bone.dtsfile under rtc node. RTC is the incharge of controlling the system power. This flag is used by the driver to hook up thepm_power_offsystem call.Signed-off-by AnilKumar Ch <[email protected]>--- arch/arm/boot/dts/am335x-bone.dts | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/boot/dts/am335x-bone.dts +0
-0@@ -52,6 +52,10 @@ };
Quoted 10 lines
arch/arm/boot/dts/am335x-bone.dts line 59
Quoted 6 lines
arch/arm/boot/dts/am335x-bone.dts +4
-0}; + + rtc at 44e3e000 { + ti,system-power-controller; + }; };Also, I think this series is missing a patch that allows the RTC driver to be compiled on AM335x.
Hi Kevin,
Yes I missed; I will submit that as a separate patch.
Thanks
AnilKumar