diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2013-08-21 06:48:16 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-09-16 19:31:03 -0400 |
commit | 32b6d3f6027a05f42987f74deed48dc13cd5a11d (patch) | |
tree | 6461173e52d2f39d4b86193764dd3b1d3bbdadb2 /drivers/regulator/palmas-regulator.c | |
parent | 272b98c6455f00884f0350f775c5342358ebb73f (diff) |
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.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/palmas-regulator.c')
-rw-r--r-- | drivers/regulator/palmas-regulator.c | 164 |
1 files changed, 158 insertions, 6 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 488dfe7ce9a6..3c08e1b5b289 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c | |||
@@ -33,6 +33,7 @@ struct regs_info { | |||
33 | u8 vsel_addr; | 33 | u8 vsel_addr; |
34 | u8 ctrl_addr; | 34 | u8 ctrl_addr; |
35 | u8 tstep_addr; | 35 | u8 tstep_addr; |
36 | int sleep_id; | ||
36 | }; | 37 | }; |
37 | 38 | ||
38 | static const struct regs_info palmas_regs_info[] = { | 39 | static const struct regs_info palmas_regs_info[] = { |
@@ -42,6 +43,7 @@ static const struct regs_info palmas_regs_info[] = { | |||
42 | .vsel_addr = PALMAS_SMPS12_VOLTAGE, | 43 | .vsel_addr = PALMAS_SMPS12_VOLTAGE, |
43 | .ctrl_addr = PALMAS_SMPS12_CTRL, | 44 | .ctrl_addr = PALMAS_SMPS12_CTRL, |
44 | .tstep_addr = PALMAS_SMPS12_TSTEP, | 45 | .tstep_addr = PALMAS_SMPS12_TSTEP, |
46 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS12, | ||
45 | }, | 47 | }, |
46 | { | 48 | { |
47 | .name = "SMPS123", | 49 | .name = "SMPS123", |
@@ -49,12 +51,14 @@ static const struct regs_info palmas_regs_info[] = { | |||
49 | .vsel_addr = PALMAS_SMPS12_VOLTAGE, | 51 | .vsel_addr = PALMAS_SMPS12_VOLTAGE, |
50 | .ctrl_addr = PALMAS_SMPS12_CTRL, | 52 | .ctrl_addr = PALMAS_SMPS12_CTRL, |
51 | .tstep_addr = PALMAS_SMPS12_TSTEP, | 53 | .tstep_addr = PALMAS_SMPS12_TSTEP, |
54 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS12, | ||
52 | }, | 55 | }, |
53 | { | 56 | { |
54 | .name = "SMPS3", | 57 | .name = "SMPS3", |
55 | .sname = "smps3-in", | 58 | .sname = "smps3-in", |
56 | .vsel_addr = PALMAS_SMPS3_VOLTAGE, | 59 | .vsel_addr = PALMAS_SMPS3_VOLTAGE, |
57 | .ctrl_addr = PALMAS_SMPS3_CTRL, | 60 | .ctrl_addr = PALMAS_SMPS3_CTRL, |
61 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS3, | ||
58 | }, | 62 | }, |
59 | { | 63 | { |
60 | .name = "SMPS45", | 64 | .name = "SMPS45", |
@@ -62,6 +66,7 @@ static const struct regs_info palmas_regs_info[] = { | |||
62 | .vsel_addr = PALMAS_SMPS45_VOLTAGE, | 66 | .vsel_addr = PALMAS_SMPS45_VOLTAGE, |
63 | .ctrl_addr = PALMAS_SMPS45_CTRL, | 67 | .ctrl_addr = PALMAS_SMPS45_CTRL, |
64 | .tstep_addr = PALMAS_SMPS45_TSTEP, | 68 | .tstep_addr = PALMAS_SMPS45_TSTEP, |
69 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS45, | ||
65 | }, | 70 | }, |
66 | { | 71 | { |
67 | .name = "SMPS457", | 72 | .name = "SMPS457", |
@@ -69,6 +74,7 @@ static const struct regs_info palmas_regs_info[] = { | |||
69 | .vsel_addr = PALMAS_SMPS45_VOLTAGE, | 74 | .vsel_addr = PALMAS_SMPS45_VOLTAGE, |
70 | .ctrl_addr = PALMAS_SMPS45_CTRL, | 75 | .ctrl_addr = PALMAS_SMPS45_CTRL, |
71 | .tstep_addr = PALMAS_SMPS45_TSTEP, | 76 | .tstep_addr = PALMAS_SMPS45_TSTEP, |
77 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS45, | ||
72 | }, | 78 | }, |
73 | { | 79 | { |
74 | .name = "SMPS6", | 80 | .name = "SMPS6", |
@@ -76,12 +82,14 @@ static const struct regs_info palmas_regs_info[] = { | |||
76 | .vsel_addr = PALMAS_SMPS6_VOLTAGE, | 82 | .vsel_addr = PALMAS_SMPS6_VOLTAGE, |
77 | .ctrl_addr = PALMAS_SMPS6_CTRL, | 83 | .ctrl_addr = PALMAS_SMPS6_CTRL, |
78 | .tstep_addr = PALMAS_SMPS6_TSTEP, | 84 | .tstep_addr = PALMAS_SMPS6_TSTEP, |
85 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS6, | ||
79 | }, | 86 | }, |
80 | { | 87 | { |
81 | .name = "SMPS7", | 88 | .name = "SMPS7", |
82 | .sname = "smps7-in", | 89 | .sname = "smps7-in", |
83 | .vsel_addr = PALMAS_SMPS7_VOLTAGE, | 90 | .vsel_addr = PALMAS_SMPS7_VOLTAGE, |
84 | .ctrl_addr = PALMAS_SMPS7_CTRL, | 91 | .ctrl_addr = PALMAS_SMPS7_CTRL, |
92 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS7, | ||
85 | }, | 93 | }, |
86 | { | 94 | { |
87 | .name = "SMPS8", | 95 | .name = "SMPS8", |
@@ -89,108 +97,128 @@ static const struct regs_info palmas_regs_info[] = { | |||
89 | .vsel_addr = PALMAS_SMPS8_VOLTAGE, | 97 | .vsel_addr = PALMAS_SMPS8_VOLTAGE, |
90 | .ctrl_addr = PALMAS_SMPS8_CTRL, | 98 | .ctrl_addr = PALMAS_SMPS8_CTRL, |
91 | .tstep_addr = PALMAS_SMPS8_TSTEP, | 99 | .tstep_addr = PALMAS_SMPS8_TSTEP, |
100 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS8, | ||
92 | }, | 101 | }, |
93 | { | 102 | { |
94 | .name = "SMPS9", | 103 | .name = "SMPS9", |
95 | .sname = "smps9-in", | 104 | .sname = "smps9-in", |
96 | .vsel_addr = PALMAS_SMPS9_VOLTAGE, | 105 | .vsel_addr = PALMAS_SMPS9_VOLTAGE, |
97 | .ctrl_addr = PALMAS_SMPS9_CTRL, | 106 | .ctrl_addr = PALMAS_SMPS9_CTRL, |
107 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS9, | ||
98 | }, | 108 | }, |
99 | { | 109 | { |
100 | .name = "SMPS10_OUT2", | 110 | .name = "SMPS10_OUT2", |
101 | .sname = "smps10-in", | 111 | .sname = "smps10-in", |
102 | .ctrl_addr = PALMAS_SMPS10_CTRL, | 112 | .ctrl_addr = PALMAS_SMPS10_CTRL, |
113 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS10, | ||
103 | }, | 114 | }, |
104 | { | 115 | { |
105 | .name = "SMPS10_OUT1", | 116 | .name = "SMPS10_OUT1", |
106 | .sname = "smps10-out2", | 117 | .sname = "smps10-out2", |
107 | .ctrl_addr = PALMAS_SMPS10_CTRL, | 118 | .ctrl_addr = PALMAS_SMPS10_CTRL, |
119 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SMPS10, | ||
108 | }, | 120 | }, |
109 | { | 121 | { |
110 | .name = "LDO1", | 122 | .name = "LDO1", |
111 | .sname = "ldo1-in", | 123 | .sname = "ldo1-in", |
112 | .vsel_addr = PALMAS_LDO1_VOLTAGE, | 124 | .vsel_addr = PALMAS_LDO1_VOLTAGE, |
113 | .ctrl_addr = PALMAS_LDO1_CTRL, | 125 | .ctrl_addr = PALMAS_LDO1_CTRL, |
126 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO1, | ||
114 | }, | 127 | }, |
115 | { | 128 | { |
116 | .name = "LDO2", | 129 | .name = "LDO2", |
117 | .sname = "ldo2-in", | 130 | .sname = "ldo2-in", |
118 | .vsel_addr = PALMAS_LDO2_VOLTAGE, | 131 | .vsel_addr = PALMAS_LDO2_VOLTAGE, |
119 | .ctrl_addr = PALMAS_LDO2_CTRL, | 132 | .ctrl_addr = PALMAS_LDO2_CTRL, |
133 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO2, | ||
120 | }, | 134 | }, |
121 | { | 135 | { |
122 | .name = "LDO3", | 136 | .name = "LDO3", |
123 | .sname = "ldo3-in", | 137 | .sname = "ldo3-in", |
124 | .vsel_addr = PALMAS_LDO3_VOLTAGE, | 138 | .vsel_addr = PALMAS_LDO3_VOLTAGE, |
125 | .ctrl_addr = PALMAS_LDO3_CTRL, | 139 | .ctrl_addr = PALMAS_LDO3_CTRL, |
140 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO3, | ||
126 | }, | 141 | }, |
127 | { | 142 | { |
128 | .name = "LDO4", | 143 | .name = "LDO4", |
129 | .sname = "ldo4-in", | 144 | .sname = "ldo4-in", |
130 | .vsel_addr = PALMAS_LDO4_VOLTAGE, | 145 | .vsel_addr = PALMAS_LDO4_VOLTAGE, |
131 | .ctrl_addr = PALMAS_LDO4_CTRL, | 146 | .ctrl_addr = PALMAS_LDO4_CTRL, |
147 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO4, | ||
132 | }, | 148 | }, |
133 | { | 149 | { |
134 | .name = "LDO5", | 150 | .name = "LDO5", |
135 | .sname = "ldo5-in", | 151 | .sname = "ldo5-in", |
136 | .vsel_addr = PALMAS_LDO5_VOLTAGE, | 152 | .vsel_addr = PALMAS_LDO5_VOLTAGE, |
137 | .ctrl_addr = PALMAS_LDO5_CTRL, | 153 | .ctrl_addr = PALMAS_LDO5_CTRL, |
154 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO5, | ||
138 | }, | 155 | }, |
139 | { | 156 | { |
140 | .name = "LDO6", | 157 | .name = "LDO6", |
141 | .sname = "ldo6-in", | 158 | .sname = "ldo6-in", |
142 | .vsel_addr = PALMAS_LDO6_VOLTAGE, | 159 | .vsel_addr = PALMAS_LDO6_VOLTAGE, |
143 | .ctrl_addr = PALMAS_LDO6_CTRL, | 160 | .ctrl_addr = PALMAS_LDO6_CTRL, |
161 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO6, | ||
144 | }, | 162 | }, |
145 | { | 163 | { |
146 | .name = "LDO7", | 164 | .name = "LDO7", |
147 | .sname = "ldo7-in", | 165 | .sname = "ldo7-in", |
148 | .vsel_addr = PALMAS_LDO7_VOLTAGE, | 166 | .vsel_addr = PALMAS_LDO7_VOLTAGE, |
149 | .ctrl_addr = PALMAS_LDO7_CTRL, | 167 | .ctrl_addr = PALMAS_LDO7_CTRL, |
168 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO7, | ||
150 | }, | 169 | }, |
151 | { | 170 | { |
152 | .name = "LDO8", | 171 | .name = "LDO8", |
153 | .sname = "ldo8-in", | 172 | .sname = "ldo8-in", |
154 | .vsel_addr = PALMAS_LDO8_VOLTAGE, | 173 | .vsel_addr = PALMAS_LDO8_VOLTAGE, |
155 | .ctrl_addr = PALMAS_LDO8_CTRL, | 174 | .ctrl_addr = PALMAS_LDO8_CTRL, |
175 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO8, | ||
156 | }, | 176 | }, |
157 | { | 177 | { |
158 | .name = "LDO9", | 178 | .name = "LDO9", |
159 | .sname = "ldo9-in", | 179 | .sname = "ldo9-in", |
160 | .vsel_addr = PALMAS_LDO9_VOLTAGE, | 180 | .vsel_addr = PALMAS_LDO9_VOLTAGE, |
161 | .ctrl_addr = PALMAS_LDO9_CTRL, | 181 | .ctrl_addr = PALMAS_LDO9_CTRL, |
182 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDO9, | ||
162 | }, | 183 | }, |
163 | { | 184 | { |
164 | .name = "LDOLN", | 185 | .name = "LDOLN", |
165 | .sname = "ldoln-in", | 186 | .sname = "ldoln-in", |
166 | .vsel_addr = PALMAS_LDOLN_VOLTAGE, | 187 | .vsel_addr = PALMAS_LDOLN_VOLTAGE, |
167 | .ctrl_addr = PALMAS_LDOLN_CTRL, | 188 | .ctrl_addr = PALMAS_LDOLN_CTRL, |
189 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDOLN, | ||
168 | }, | 190 | }, |
169 | { | 191 | { |
170 | .name = "LDOUSB", | 192 | .name = "LDOUSB", |
171 | .sname = "ldousb-in", | 193 | .sname = "ldousb-in", |
172 | .vsel_addr = PALMAS_LDOUSB_VOLTAGE, | 194 | .vsel_addr = PALMAS_LDOUSB_VOLTAGE, |
173 | .ctrl_addr = PALMAS_LDOUSB_CTRL, | 195 | .ctrl_addr = PALMAS_LDOUSB_CTRL, |
196 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_LDOUSB, | ||
174 | }, | 197 | }, |
175 | { | 198 | { |
176 | .name = "REGEN1", | 199 | .name = "REGEN1", |
177 | .ctrl_addr = PALMAS_REGEN1_CTRL, | 200 | .ctrl_addr = PALMAS_REGEN1_CTRL, |
201 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN1, | ||
178 | }, | 202 | }, |
179 | { | 203 | { |
180 | .name = "REGEN2", | 204 | .name = "REGEN2", |
181 | .ctrl_addr = PALMAS_REGEN2_CTRL, | 205 | .ctrl_addr = PALMAS_REGEN2_CTRL, |
206 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN2, | ||
182 | }, | 207 | }, |
183 | { | 208 | { |
184 | .name = "REGEN3", | 209 | .name = "REGEN3", |
185 | .ctrl_addr = PALMAS_REGEN3_CTRL, | 210 | .ctrl_addr = PALMAS_REGEN3_CTRL, |
211 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_REGEN3, | ||
186 | }, | 212 | }, |
187 | { | 213 | { |
188 | .name = "SYSEN1", | 214 | .name = "SYSEN1", |
189 | .ctrl_addr = PALMAS_SYSEN1_CTRL, | 215 | .ctrl_addr = PALMAS_SYSEN1_CTRL, |
216 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SYSEN1, | ||
190 | }, | 217 | }, |
191 | { | 218 | { |
192 | .name = "SYSEN2", | 219 | .name = "SYSEN2", |
193 | .ctrl_addr = PALMAS_SYSEN2_CTRL, | 220 | .ctrl_addr = PALMAS_SYSEN2_CTRL, |
221 | .sleep_id = PALMAS_EXTERNAL_REQSTR_ID_SYSEN2, | ||
194 | }, | 222 | }, |
195 | }; | 223 | }; |
196 | 224 | ||
@@ -484,6 +512,17 @@ static struct regulator_ops palmas_ops_smps = { | |||
484 | .set_ramp_delay = palmas_smps_set_ramp_delay, | 512 | .set_ramp_delay = palmas_smps_set_ramp_delay, |
485 | }; | 513 | }; |
486 | 514 | ||
515 | static struct regulator_ops palmas_ops_ext_control_smps = { | ||
516 | .set_mode = palmas_set_mode_smps, | ||
517 | .get_mode = palmas_get_mode_smps, | ||
518 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
519 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
520 | .list_voltage = palmas_list_voltage_smps, | ||
521 | .map_voltage = palmas_map_voltage_smps, | ||
522 | .set_voltage_time_sel = palma_smps_set_voltage_smps_time_sel, | ||
523 | .set_ramp_delay = palmas_smps_set_ramp_delay, | ||
524 | }; | ||
525 | |||
487 | static struct regulator_ops palmas_ops_smps10 = { | 526 | static struct regulator_ops palmas_ops_smps10 = { |
488 | .is_enabled = regulator_is_enabled_regmap, | 527 | .is_enabled = regulator_is_enabled_regmap, |
489 | .enable = regulator_enable_regmap, | 528 | .enable = regulator_enable_regmap, |
@@ -519,12 +558,37 @@ static struct regulator_ops palmas_ops_ldo = { | |||
519 | .map_voltage = regulator_map_voltage_linear, | 558 | .map_voltage = regulator_map_voltage_linear, |
520 | }; | 559 | }; |
521 | 560 | ||
561 | static struct regulator_ops palmas_ops_ext_control_ldo = { | ||
562 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
563 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
564 | .list_voltage = regulator_list_voltage_linear, | ||
565 | .map_voltage = regulator_map_voltage_linear, | ||
566 | }; | ||
567 | |||
522 | static struct regulator_ops palmas_ops_extreg = { | 568 | static struct regulator_ops palmas_ops_extreg = { |
523 | .is_enabled = regulator_is_enabled_regmap, | 569 | .is_enabled = regulator_is_enabled_regmap, |
524 | .enable = regulator_enable_regmap, | 570 | .enable = regulator_enable_regmap, |
525 | .disable = regulator_disable_regmap, | 571 | .disable = regulator_disable_regmap, |
526 | }; | 572 | }; |
527 | 573 | ||
574 | static struct regulator_ops palmas_ops_ext_control_extreg = { | ||
575 | }; | ||
576 | |||
577 | static int palmas_regulator_config_external(struct palmas *palmas, int id, | ||
578 | struct palmas_reg_init *reg_init) | ||
579 | { | ||
580 | int sleep_id = palmas_regs_info[id].sleep_id; | ||
581 | int ret; | ||
582 | |||
583 | ret = palmas_ext_control_req_config(palmas, sleep_id, | ||
584 | reg_init->roof_floor, true); | ||
585 | if (ret < 0) | ||
586 | dev_err(palmas->dev, | ||
587 | "Ext control config for regulator %d failed %d\n", | ||
588 | id, ret); | ||
589 | return ret; | ||
590 | } | ||
591 | |||
528 | /* | 592 | /* |
529 | * setup the hardware based sleep configuration of the SMPS/LDO regulators | 593 | * setup the hardware based sleep configuration of the SMPS/LDO regulators |
530 | * from the platform data. This is different to the software based control | 594 | * from the platform data. This is different to the software based control |
@@ -583,7 +647,22 @@ static int palmas_smps_init(struct palmas *palmas, int id, | |||
583 | return ret; | 647 | return ret; |
584 | } | 648 | } |
585 | 649 | ||
650 | if (reg_init->roof_floor && (id != PALMAS_REG_SMPS10_OUT1) && | ||
651 | (id != PALMAS_REG_SMPS10_OUT2)) { | ||
652 | /* Enable externally controlled regulator */ | ||
653 | addr = palmas_regs_info[id].ctrl_addr; | ||
654 | ret = palmas_smps_read(palmas, addr, ®); | ||
655 | if (ret < 0) | ||
656 | return ret; | ||
586 | 657 | ||
658 | if (!(reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK)) { | ||
659 | reg |= SMPS_CTRL_MODE_ON; | ||
660 | ret = palmas_smps_write(palmas, addr, reg); | ||
661 | if (ret < 0) | ||
662 | return ret; | ||
663 | } | ||
664 | return palmas_regulator_config_external(palmas, id, reg_init); | ||
665 | } | ||
587 | return 0; | 666 | return 0; |
588 | } | 667 | } |
589 | 668 | ||
@@ -614,6 +693,20 @@ static int palmas_ldo_init(struct palmas *palmas, int id, | |||
614 | if (ret) | 693 | if (ret) |
615 | return ret; | 694 | return ret; |
616 | 695 | ||
696 | if (reg_init->roof_floor) { | ||
697 | /* Enable externally controlled regulator */ | ||
698 | addr = palmas_regs_info[id].ctrl_addr; | ||
699 | ret = palmas_update_bits(palmas, PALMAS_LDO_BASE, | ||
700 | addr, PALMAS_LDO1_CTRL_MODE_ACTIVE, | ||
701 | PALMAS_LDO1_CTRL_MODE_ACTIVE); | ||
702 | if (ret < 0) { | ||
703 | dev_err(palmas->dev, | ||
704 | "LDO Register 0x%02x update failed %d\n", | ||
705 | addr, ret); | ||
706 | return ret; | ||
707 | } | ||
708 | return palmas_regulator_config_external(palmas, id, reg_init); | ||
709 | } | ||
617 | return 0; | 710 | return 0; |
618 | } | 711 | } |
619 | 712 | ||
@@ -636,6 +729,21 @@ static int palmas_extreg_init(struct palmas *palmas, int id, | |||
636 | addr, ret); | 729 | addr, ret); |
637 | return ret; | 730 | return ret; |
638 | } | 731 | } |
732 | |||
733 | if (reg_init->roof_floor) { | ||
734 | /* Enable externally controlled regulator */ | ||
735 | addr = palmas_regs_info[id].ctrl_addr; | ||
736 | ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE, | ||
737 | addr, PALMAS_REGEN1_CTRL_MODE_ACTIVE, | ||
738 | PALMAS_REGEN1_CTRL_MODE_ACTIVE); | ||
739 | if (ret < 0) { | ||
740 | dev_err(palmas->dev, | ||
741 | "Resource Register 0x%02x update failed %d\n", | ||
742 | addr, ret); | ||
743 | return ret; | ||
744 | } | ||
745 | return palmas_regulator_config_external(palmas, id, reg_init); | ||
746 | } | ||
639 | return 0; | 747 | return 0; |
640 | } | 748 | } |
641 | 749 | ||
@@ -746,9 +854,35 @@ static void palmas_dt_to_pdata(struct device *dev, | |||
746 | of_property_read_bool(palmas_matches[idx].of_node, | 854 | of_property_read_bool(palmas_matches[idx].of_node, |
747 | "ti,warm-reset"); | 855 | "ti,warm-reset"); |
748 | 856 | ||
749 | pdata->reg_init[idx]->roof_floor = | 857 | ret = of_property_read_u32(palmas_matches[idx].of_node, |
750 | of_property_read_bool(palmas_matches[idx].of_node, | 858 | "ti,roof-floor", &prop); |
751 | "ti,roof-floor"); | 859 | /* EINVAL: Property not found */ |
860 | if (ret != -EINVAL) { | ||
861 | int econtrol; | ||
862 | |||
863 | /* use default value, when no value is specified */ | ||
864 | econtrol = PALMAS_EXT_CONTROL_NSLEEP; | ||
865 | if (!ret) { | ||
866 | switch (prop) { | ||
867 | case 1: | ||
868 | econtrol = PALMAS_EXT_CONTROL_ENABLE1; | ||
869 | break; | ||
870 | case 2: | ||
871 | econtrol = PALMAS_EXT_CONTROL_ENABLE2; | ||
872 | break; | ||
873 | case 3: | ||
874 | econtrol = PALMAS_EXT_CONTROL_NSLEEP; | ||
875 | break; | ||
876 | default: | ||
877 | WARN_ON(1); | ||
878 | dev_warn(dev, | ||
879 | "%s: Invalid roof-floor option: %u\n", | ||
880 | palmas_matches[idx].name, prop); | ||
881 | break; | ||
882 | } | ||
883 | } | ||
884 | pdata->reg_init[idx]->roof_floor = econtrol; | ||
885 | } | ||
752 | 886 | ||
753 | ret = of_property_read_u32(palmas_matches[idx].of_node, | 887 | ret = of_property_read_u32(palmas_matches[idx].of_node, |
754 | "ti,mode-sleep", &prop); | 888 | "ti,mode-sleep", &prop); |
@@ -875,6 +1009,8 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
875 | ret = palmas_smps_init(palmas, id, reg_init); | 1009 | ret = palmas_smps_init(palmas, id, reg_init); |
876 | if (ret) | 1010 | if (ret) |
877 | goto err_unregister_regulator; | 1011 | goto err_unregister_regulator; |
1012 | } else { | ||
1013 | reg_init = NULL; | ||
878 | } | 1014 | } |
879 | 1015 | ||
880 | /* Register the regulators */ | 1016 | /* Register the regulators */ |
@@ -919,7 +1055,11 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
919 | if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) | 1055 | if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) |
920 | pmic->range[id] = 1; | 1056 | pmic->range[id] = 1; |
921 | 1057 | ||
922 | pmic->desc[id].ops = &palmas_ops_smps; | 1058 | if (reg_init && reg_init->roof_floor) |
1059 | pmic->desc[id].ops = | ||
1060 | &palmas_ops_ext_control_smps; | ||
1061 | else | ||
1062 | pmic->desc[id].ops = &palmas_ops_smps; | ||
923 | pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; | 1063 | pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; |
924 | pmic->desc[id].vsel_reg = | 1064 | pmic->desc[id].vsel_reg = |
925 | PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, | 1065 | PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, |
@@ -962,6 +1102,10 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
962 | 1102 | ||
963 | /* Start this loop from the id left from previous loop */ | 1103 | /* Start this loop from the id left from previous loop */ |
964 | for (; id < PALMAS_NUM_REGS; id++) { | 1104 | for (; id < PALMAS_NUM_REGS; id++) { |
1105 | if (pdata && pdata->reg_init[id]) | ||
1106 | reg_init = pdata->reg_init[id]; | ||
1107 | else | ||
1108 | reg_init = NULL; | ||
965 | 1109 | ||
966 | /* Miss out regulators which are not available due | 1110 | /* Miss out regulators which are not available due |
967 | * to alternate functions. | 1111 | * to alternate functions. |
@@ -975,7 +1119,11 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
975 | 1119 | ||
976 | if (id < PALMAS_REG_REGEN1) { | 1120 | if (id < PALMAS_REG_REGEN1) { |
977 | pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; | 1121 | pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; |
978 | pmic->desc[id].ops = &palmas_ops_ldo; | 1122 | if (reg_init && reg_init->roof_floor) |
1123 | pmic->desc[id].ops = | ||
1124 | &palmas_ops_ext_control_ldo; | ||
1125 | else | ||
1126 | pmic->desc[id].ops = &palmas_ops_ldo; | ||
979 | pmic->desc[id].min_uV = 900000; | 1127 | pmic->desc[id].min_uV = 900000; |
980 | pmic->desc[id].uV_step = 50000; | 1128 | pmic->desc[id].uV_step = 50000; |
981 | pmic->desc[id].linear_min_sel = 1; | 1129 | pmic->desc[id].linear_min_sel = 1; |
@@ -999,7 +1147,11 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
999 | } | 1147 | } |
1000 | } else { | 1148 | } else { |
1001 | pmic->desc[id].n_voltages = 1; | 1149 | pmic->desc[id].n_voltages = 1; |
1002 | pmic->desc[id].ops = &palmas_ops_extreg; | 1150 | if (reg_init && reg_init->roof_floor) |
1151 | pmic->desc[id].ops = | ||
1152 | &palmas_ops_ext_control_extreg; | ||
1153 | else | ||
1154 | pmic->desc[id].ops = &palmas_ops_extreg; | ||
1003 | pmic->desc[id].enable_reg = | 1155 | pmic->desc[id].enable_reg = |
1004 | PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE, | 1156 | PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE, |
1005 | palmas_regs_info[id].ctrl_addr); | 1157 | palmas_regs_info[id].ctrl_addr); |