regulator: palmas: add support for external control of rails
PATCH v3 1/1 regulator: palmas: add support for external control of rails
Palmas rails like LDOs, SMPSs, REGENs, SYSENs can be enable and disable by register programming through I2C communication as well as it can be enable/disable with the external control input ENABLE1, ENABLE2 and NSLEEP.
Add support for configuring these rails to be controlled by external control inputs. This is require to configure the rail's control register as well as configuration of resource register.
Provide the external input names through parameter "roof-floor". Updated the DT binding document to details different value of the roof-floor.
---
Changes from V1:
- Fix typos: palams ->palmas
Changes from V2:
- Make roof-floor with optional argument. If no argument then assume NSLEEP control.
PS: This patch was part of series (3/3)
regulator: palmas: add support for external control of rail
Patch 1/3 and 2/3 is already applied as 1/3 is in the regulator tree and Patch 2/3 is in the mfd tree by Samuel.
This patch (was 3/3) very much depends on the 2/3 for compilation and hence it need to go on same tree as 2/3 to avoid any compilation error.
.../devicetree/bindings/regulator/palmas-pmic.txt | 12 ++- drivers/regulator/palmas-regulator.c | 153 +++++++++++++++++++- 2 files changed, 156 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/regulator/palmas-pmic.txt +9 -3
@@ -26,11 +26,17 @@ Optional nodes: For ti,palmas-pmic - smps12, smps123, smps3 depending on OTP, smps45, smps457, smps7 depending on variant, smps6, smps[8-9], - smps10_out2, smps10_out1, do[1-9], ldoln, ldousb. + smps10_out2, smps10_out1, ldo[1-9], ldoln, ldousb. Optional sub-node properties: ti,warm-reset - maintain voltage during warm reset(boolean) - ti,roof-floor - control voltage selection by pin(boolean) + ti,roof-floor - This takes as optional argument on platform supporting + the rail from desired external control. If there is no argument then + it will be assume that it is controlled by NSLEEP pin. + The valid value for external pins are: + ENABLE1 then 1, + ENABLE2 then 2 or + NSLEEP then 3. ti,mode-sleep - mode to adopt in pmic sleep 0 - off, 1 - auto, 2 - eco, 3 - forced pwm ti,smps-range - OTP has the wrong range set for the hardware so override
@@ -61,7 +67,7 @@ pmic { regulator-always-on; regulator-boot-on; ti,warm-reset; - ti,roof-floor; + ti,roof-floor = 0x1; /* ENABLE1 control */ ti,mode-sleep = <0>; ti,smps-range = <1>; };
drivers/regulator/palmas-regulator.c +147 -6
382 lines not on this page · raw message
Signature · 1 line
1.7.1.1
Documentation/devicetree/bindings/regulator/palmas-pmic.txt
Quoted 12 lines · Laxman Dewangan
Palmas rails like LDOs, SMPSs, REGENs, SYSENs can be enable and disable by register programming through I2C communication as well as it can be enable/disable with the external control input ENABLE1, ENABLE2 and NSLEEP.
Add support for configuring these rails to be controlled by external control inputs. This is require to configure the rail's control register as well as configuration of resource register.
Provide the external input names through parameter "roof-floor". Updated the DT binding document to details different value of the roof-floor.
Documentation/devicetree/bindings/regulator/palmas-pmic.txt +0
-0
The binding changes look reasonable and backwards-compatible, so they're good. Just one nit:
(In the example, I assume:)
Documentation/devicetree/bindings/regulator/palmas-pmic.txt pmic { · line 70
Quoted 5 lines
Documentation/devicetree/bindings/regulator/palmas-pmic.txt +1
-1regulator-always-on; regulator-boot-on; ti,warm-reset; - ti,roof-floor; + ti,roof-floor = 0x1; /* ENABLE1 control */
You need <> around the value, so better:
ti,roof-floor = <0x1>; /* ENABLE1 control */
or better:
ti,roof-floor = <1>; /* ENABLE1 control */
(even better might be a header file that defines names for those constants...)
Quoted 14 lines
drivers/regulator/palmas-regulator.c +5
-3@@ -746,9 +854,24 @@ static void palmas_dt_to_pdata(struct device *dev,of_property_read_bool (palmas_matches[idx].of_node,"ti,warm-reset" ); - pdata->reg_init[idx]->roof_floor = -of_property_read_bool (palmas_matches[idx].of_node, -"ti,roof-floor" ); + ret =of_property_read_u32 (palmas_matches[idx].of_node, +"ti,roof-floor" , &prop); +/* EINVAL: Property not found */ +if (ret != -EINVAL ) { +int econtrol;
drivers/regulator/palmas-regulator.c static void palmas_dt_to_pdata(struct device *dev, · line 871
Quoted 10 lines
drivers/regulator/palmas-regulator.c +10
-0+ +/* use default value, when no value is specified */ + econtrol =PALMAS_EXT_CONTROL_NSLEEP ; +if (!ret) { +if (prop ==1 ) + econtrol =PALMAS_EXT_CONTROL_ENABLE1 ; +else if (prop ==2 ) + econtrol =PALMAS_EXT_CONTROL_ENABLE2 ; +else if (prop ==3 ) + econtrol =PALMAS_EXT_CONTROL_NSLEEP ;
Should probably at least WARN() here if the value is invalid?
Quoted 3 lines
drivers/regulator/palmas-regulator.c +3
-0+ } + pdata->reg_init[idx]->roof_floor = econtrol; + }
Mark Brown
maintainerdrivers/regulator/palmas-regulator.c static void palmas_dt_to_pdata(struct device *dev, · line 871
Quoted 8 lines · Laxman Dewangan
drivers/regulator/palmas-regulator.c +8
-0+ econtrol =PALMAS_EXT_CONTROL_NSLEEP ; +if (!ret) { +if (prop ==1 ) + econtrol =PALMAS_EXT_CONTROL_ENABLE1 ; +else if (prop ==2 ) + econtrol =PALMAS_EXT_CONTROL_ENABLE2 ; +else if (prop ==3 ) + econtrol =PALMAS_EXT_CONTROL_NSLEEP ;
Since Stephen identified an issue as well... this looks like a switch
statement. Otherwise this looks fine.