regulator: mt6360: Add optional mediatek.power-off-sequence in bindings document
PATCH 1/2 regulator: mt6360: Add optional mediatek.power-off-sequence in bindings document
From: ChiYuan Huang <[email protected]>
Add optional mediatek.power-off-sequence in bindings document.
---
Hi,
Originally, we think it must write in platform dependent code like as bootloader. But after the evaluation, it must write only when system normal HALT or POWER_OFF. For the other cases, just follow HW immediate off by default.
--- .../devicetree/bindings/regulator/mt6360-regulator.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+)
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml +11 -0
@@ -24,6 +24,16 @@ properties: LDO_VIN3-supply: description: Input supply phandle(s) for LDO6/7 + mediatek,power-off-sequence: + description: | + Power off sequence time selection for BUCK1/BUCK2/LDO7/LDO6, respetively. + Cause these regulators are all default-on power. Each value from 0 to 63, + and step is 1. Each step means 2 millisecond delay. + Therefore, the power off sequence delay time range is from 0ms to 126ms. + $ref: "/schemas/types.yaml#/definitions/uint8-array" + minItems: 4 + maxItems: 4 + patternProperties: "^buck[12]$": $ref: "regulator.yaml#"
@@ -42,6 +52,7 @@ examples: #include <dt-bindings/regulator/mediatek,mt6360-regulator.h> regulator { compatible = "mediatek,mt6360-regulator"; + mediatek,power-off-sequence = /bits/ 8 <0 0 0 0>; LDO_VIN3-supply = <&BUCK2>; buck1 { regulator-compatible = "BUCK1";
Signature · 1 line
2.7.4
PATCH 2/2 regulator: mt6360: Add power off sequence config for default-on power
From: ChiYuan Huang <[email protected]>
Add power off sequence config for default-on power.
---
Hi,
Originally, we think it must write in platform dependent code like as bootloader. But after the evaluation, it must write only when system normal halt or power_off. For the other cases, just follow HW immediate off by default.
--- drivers/regulator/mt6360-regulator.c | 37 +++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
drivers/regulator/mt6360-regulator.c +36 -1
@@ -9,12 +9,17 @@#include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> +#include <linux/property.h> +#include <linux/reboot.h> #include <linux/regmap.h> #include <linux/regulator/driver.h> #include <linux/regulator/machine.h> #include <dt-bindings/regulator/mediatek,mt6360-regulator.h> +#define MT6360_REG_BUCK1_SEQTD 0x117 +#define MT6360_SEQOFF_REGNUM 4 +enum {MT6360_REGULATOR_BUCK1 =0 ,MT6360_REGULATOR_BUCK2 ,
@@ -45,6 +50,9 @@ struct mt6360_regulator_desc {struct mt6360_regulator_data {struct device *dev;struct regmap *regmap; +struct notifier_block reboot_notifier; +/* Only for BUCK1/BUCK2/LDO7/LDO6, these are default on power */ +u8 power_off_seq[MT6360_SEQOFF_REGNUM ]; };static irqreturn_t mt6360_pgb_event_handler (int irq,void *data)
@@ -394,10 +402,28 @@ static int mt6360_regulator_irq_register(struct platform_device *pdev,return 0 ; } +static int reboot_notify_call (struct notifier_block *nb,unsigned long action,void *data) +{ + struct mt6360_regulator_data *mrd = container_of(nb, struct mt6360_regulator_data, + reboot_notifier); +int ret; + +if (action !=SYS_HALT && action !=SYS_POWER_OFF ) +return NOTIFY_DONE ; + + ret =regmap_raw_write (mrd->regmap,MT6360_REG_BUCK1_SEQTD , mrd->power_off_seq, +MT6360_SEQOFF_REGNUM ); +if (ret) +dev_err (mrd->dev,"Failed to apply the power off sequence\n" ); + +return NOTIFY_DONE ; +} +static int mt6360_regulator_probe (struct platform_device *pdev) {struct mt6360_regulator_data *mrd;struct regulator_config config = {}; +struct fwnode_handle *fwnode;int i, ret; mrd =devm_kzalloc (&pdev->dev,sizeof (*mrd),GFP_KERNEL );
@@ -434,7 +460,16 @@ static int mt6360_regulator_probe(struct platform_device *pdev) } } -return 0 ; + fwnode =device_get_named_child_node (pdev->dev.parent,"regulator" ); +if (fwnode) { + ret =fwnode_property_read_u8_array (fwnode,"mediatek,power-off-sequence" , + mrd->power_off_seq,MT6360_SEQOFF_REGNUM ); +if (ret) +dev_warn (&pdev->dev,"Use no delay immediate off by default [%d]\n" , ret); + } + + mrd->reboot_notifier.notifier_call = reboot_notify_call; +return devm_register_reboot_notifier (&pdev->dev, &mrd->reboot_notifier); }static const struct platform_device_id mt6360_regulator_id_table[] = {
Signature · 1 line
2.7.4
Rob Herring
maintainerQuoted 11 lines · cy_huang
From: ChiYuan Huang <[email protected]>
Add optional mediatek.power-off-sequence in bindings document.
Signed-off-by ChiYuan Huang <[email protected]>---
Hi,Originally, we think it must write in platform dependent code like as bootloader. But after the evaluation, it must write only when system normal HALT or
POWER_OFF. For the other cases, just follow HW immediate off by default.
Wouldn't this be handled by PSCI implementation?
Quoted 11 lines
--- .../devicetree/bindings/regulator/mt6360-regulator.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+)Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml +0
-0@@ -24,6 +24,16 @@ properties: LDO_VIN3-supply: description: Input supply phandle(s) for LDO6/7
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml properties: · line 35
Quoted 10 lines
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml +9
-0+ mediatek,power-off-sequence: + description: | + Power off sequence time selection for BUCK1/BUCK2/LDO7/LDO6, respetively. + Cause these regulators are all default-on power. Each value from 0 to 63, + and step is 1. Each step means 2 millisecond delay. + Therefore, the power off sequence delay time range is from 0ms to 126ms. + $ref: "/schemas/types.yaml#/definitions/uint8-array" + minItems: 4 + maxItems: 4
So this is the delay between BUCK1 and BUCK2, then BUCK2 to LDO7, etcc? If we wanted to express this in DT, we'd made this generic which would need to be more flexible. A poweroff delay in each regulator (similar to the existing power on delay) would be sufficient for what you need I think.
Rob
Hi, Rob:
Rob Herring <[email protected]> 於 2021年6月12日 週六 上午4:16寫道:
Quoted 10 lines · cy_huang
Quoted 8 lines
From: ChiYuan Huang <[email protected]>
Add optional mediatek.power-off-sequence in bindings document.
Signed-off-by ChiYuan Huang <[email protected]>---
Hi,
Quoted 5 lines
Quoted 3 lines
Originally, we think it must write in platform dependent code like as bootloader. But after the evaluation, it must write only when system normal HALT or
POWER_OFF. For the other cases, just follow HW immediate off by default.Wouldn't this be handled by PSCI implementation?
No, the current application default on powers buck1/buck2/ldo7/ldo6 are for Dram power.
It's not the soc core power. It seems not appropriate to implement like as PSCI.
MT6360 play the role for the subpmic in the SOC application reference design.
Quoted 13 lines
Quoted 13 lines
--- .../devicetree/bindings/regulator/mt6360-regulator.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+)Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml +0
-0@@ -24,6 +24,16 @@ properties: LDO_VIN3-supply: description: Input supply phandle(s) for LDO6/7
Quoted 11 lines
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml properties: · line 35
Quoted 9 lines
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml +9
-0+ mediatek,power-off-sequence: + description: | + Power off sequence time selection for BUCK1/BUCK2/LDO7/LDO6, respetively. + Cause these regulators are all default-on power. Each value from 0 to 63, + and step is 1. Each step means 2 millisecond delay. + Therefore, the power off sequence delay time range is from 0ms to 126ms. + $ref: "/schemas/types.yaml#/definitions/uint8-array" + minItems: 4 + maxItems: 4So this is the delay between BUCK1 and BUCK2, then BUCK2 to LDO7, etcc?
No. you may misunderstand. there's an external 'Enable' pin that's connected to the main pmic.
The starting point of delay time are all from the external 'Enable' H to L. Not one-by-one delay time,
Quoted 4 lines
If we wanted to express this in DT, we'd made this generic which would need to be more flexible. A poweroff delay in each regulator (similar to the existing power on delay) would be sufficient for what you need I think.
Power on sequence already defined by the part number, It's not decided by SW. So for the flexibility, I implement it in DT.
Duel to there're many part number MT6360 P/UP/LP, etc. The difference are the power on sequence.
Do you have any suggestion about this situation?
PS: Due to DRAM power usage , sometimes it also need to customized by the DRAM that customer choosed.
It may differ from external DRAM part choosen following by JEDEC spec.
Quoted 2 lines
Rob
Mark Brown
maintainerQuoted 6 lines · ChiYuan Huang
Rob Herring <[email protected]> 於 2021年6月12日 週六 上午4:16寫道:
Quoted 3 lines
Quoted 3 lines
Originally, we think it must write in platform dependent code like as bootloader. But after the evaluation, it must write only when system normal HALT or
POWER_OFF. For the other cases, just follow HW immediate off by default.
Quoted 7 lines
Quoted 1 line
Wouldn't this be handled by PSCI implementation?
No, the current application default on powers buck1/buck2/ldo7/ldo6 are for Dram power.
It's not the soc core power. It seems not appropriate to implement like as PSCI.
MT6360 play the role for the subpmic in the SOC application reference design.
If this is part of the overall system power off that seems like it fits well enough into what PSCI is doing - it's got operations like SYSTEM_OFF which talk about the system as a whole.
Mark Brown <[email protected]> 於 2021年6月18日 週五 上午12:29寫道:
Quoted 16 lines · ChiYuan Huang
Quoted 6 lines
Rob Herring <[email protected]> 於 2021年6月12日 週六 上午4:16寫道:
Quoted 3 lines
Quoted 3 lines
Originally, we think it must write in platform dependent code like as bootloader. But after the evaluation, it must write only when system normal HALT or
POWER_OFF. For the other cases, just follow HW immediate off by default.Quoted 7 lines
Quoted 1 line
Wouldn't this be handled by PSCI implementation?
No, the current application default on powers buck1/buck2/ldo7/ldo6 are for Dram power.
It's not the soc core power. It seems not appropriate to implement like as PSCI.
MT6360 play the role for the subpmic in the SOC application reference design.
Quoted 3 lines
If this is part of the overall system power off that seems like it fits well enough into what PSCI is doing - it's got operations like
SYSTEM_OFFwhich talk about the system as a whole.
Thanks, I'll check and survey the PSCI about the SYSTEM_OFF. I think it may work.
Mark Brown
maintainerQuoted 7 lines · Rob Herring
Quoted 3 lines · cy_huang
Originally, we think it must write in platform dependent code like as bootloader. But after the evaluation, it must write only when system normal HALT or
POWER_OFF. For the other cases, just follow HW immediate off by default.Wouldn't this be handled by PSCI implementation?
Ideally I think...
Quoted 10 lines
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml properties: · line 35
Quoted 9 lines
Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml +9
-0+ mediatek,power-off-sequence: + description: | + Power off sequence time selection for BUCK1/BUCK2/LDO7/LDO6, respetively. + Cause these regulators are all default-on power. Each value from 0 to 63, + and step is 1. Each step means 2 millisecond delay. + Therefore, the power off sequence delay time range is from 0ms to 126ms. + $ref: "/schemas/types.yaml#/definitions/uint8-array" + minItems: 4 + maxItems: 4
Quoted 5 lines
So this is the delay between BUCK1 and BUCK2, then BUCK2 to LDO7, etcc? If we wanted to express this in DT, we'd made this generic which would need to be more flexible. A poweroff delay in each regulator (similar to the existing power on delay) would be sufficient for what you need I think.
It's not exactly a delay that's being described there - it's a series of timeslots, each regulator getting assigned to a timeslot. You could possibly do a general binding by specifying a delay from the start of the power off sequence and then (for this device) having the driver work out a mapping of those times to timeslots. That feels genericish, you might also have things like mode changes but it'd cover a lot of the cases.
On the other hand this is the sort of thing that is often just not configurable and where people often make weird and inflexible hardware so things that do implement it are likely to end up wanting to add a bunch of constraints which might be a lot of hassle.