diff options
author | Axel Lin <axel.lin@ingics.com> | 2014-05-21 21:26:47 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-05-26 12:03:06 -0400 |
commit | 5ab9be4274a12ef56fbf8cd965516f7d1f7868c6 (patch) | |
tree | 523c513875b04b8c9d58751322967ec261f299ca /drivers/regulator | |
parent | c9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff) |
regulator: tps65218: Convert to use regulator_set_voltage_time_sel
Use regulator_set_voltage_time_sel() instead of open-coded.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/tps65218-regulator.c | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/drivers/regulator/tps65218-regulator.c b/drivers/regulator/tps65218-regulator.c index cec72fa71d1d..69b4b7750410 100644 --- a/drivers/regulator/tps65218-regulator.c +++ b/drivers/regulator/tps65218-regulator.c | |||
@@ -27,12 +27,10 @@ | |||
27 | #include <linux/regulator/machine.h> | 27 | #include <linux/regulator/machine.h> |
28 | #include <linux/mfd/tps65218.h> | 28 | #include <linux/mfd/tps65218.h> |
29 | 29 | ||
30 | static unsigned int tps65218_ramp_delay = 4000; | ||
31 | |||
32 | enum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4, DCDC5, DCDC6, LDO1 }; | 30 | enum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4, DCDC5, DCDC6, LDO1 }; |
33 | 31 | ||
34 | #define TPS65218_REGULATOR(_name, _id, _ops, _n, _vr, _vm, _er, _em, _t, \ | 32 | #define TPS65218_REGULATOR(_name, _id, _ops, _n, _vr, _vm, _er, _em, _t, \ |
35 | _lr, _nlr) \ | 33 | _lr, _nlr, _delay) \ |
36 | { \ | 34 | { \ |
37 | .name = _name, \ | 35 | .name = _name, \ |
38 | .id = _id, \ | 36 | .id = _id, \ |
@@ -47,6 +45,7 @@ enum tps65218_regulators { DCDC1, DCDC2, DCDC3, DCDC4, DCDC5, DCDC6, LDO1 }; | |||
47 | .volt_table = _t, \ | 45 | .volt_table = _t, \ |
48 | .linear_ranges = _lr, \ | 46 | .linear_ranges = _lr, \ |
49 | .n_linear_ranges = _nlr, \ | 47 | .n_linear_ranges = _nlr, \ |
48 | .ramp_delay = _delay, \ | ||
50 | } \ | 49 | } \ |
51 | 50 | ||
52 | #define TPS65218_INFO(_id, _nm, _min, _max) \ | 51 | #define TPS65218_INFO(_id, _nm, _min, _max) \ |
@@ -152,22 +151,6 @@ static int tps65218_pmic_disable(struct regulator_dev *dev) | |||
152 | dev->desc->enable_mask, TPS65218_PROTECT_L1); | 151 | dev->desc->enable_mask, TPS65218_PROTECT_L1); |
153 | } | 152 | } |
154 | 153 | ||
155 | static int tps65218_set_voltage_time_sel(struct regulator_dev *rdev, | ||
156 | unsigned int old_selector, unsigned int new_selector) | ||
157 | { | ||
158 | int old_uv, new_uv; | ||
159 | |||
160 | old_uv = regulator_list_voltage_linear_range(rdev, old_selector); | ||
161 | if (old_uv < 0) | ||
162 | return old_uv; | ||
163 | |||
164 | new_uv = regulator_list_voltage_linear_range(rdev, new_selector); | ||
165 | if (new_uv < 0) | ||
166 | return new_uv; | ||
167 | |||
168 | return DIV_ROUND_UP(abs(old_uv - new_uv), tps65218_ramp_delay); | ||
169 | } | ||
170 | |||
171 | /* Operations permitted on DCDC1, DCDC2 */ | 154 | /* Operations permitted on DCDC1, DCDC2 */ |
172 | static struct regulator_ops tps65218_dcdc12_ops = { | 155 | static struct regulator_ops tps65218_dcdc12_ops = { |
173 | .is_enabled = regulator_is_enabled_regmap, | 156 | .is_enabled = regulator_is_enabled_regmap, |
@@ -177,7 +160,7 @@ static struct regulator_ops tps65218_dcdc12_ops = { | |||
177 | .set_voltage_sel = tps65218_pmic_set_voltage_sel, | 160 | .set_voltage_sel = tps65218_pmic_set_voltage_sel, |
178 | .list_voltage = regulator_list_voltage_linear_range, | 161 | .list_voltage = regulator_list_voltage_linear_range, |
179 | .map_voltage = regulator_map_voltage_linear_range, | 162 | .map_voltage = regulator_map_voltage_linear_range, |
180 | .set_voltage_time_sel = tps65218_set_voltage_time_sel, | 163 | .set_voltage_time_sel = regulator_set_voltage_time_sel, |
181 | }; | 164 | }; |
182 | 165 | ||
183 | /* Operations permitted on DCDC3, DCDC4 and LDO1 */ | 166 | /* Operations permitted on DCDC3, DCDC4 and LDO1 */ |
@@ -203,33 +186,33 @@ static const struct regulator_desc regulators[] = { | |||
203 | TPS65218_REG_CONTROL_DCDC1, | 186 | TPS65218_REG_CONTROL_DCDC1, |
204 | TPS65218_CONTROL_DCDC1_MASK, | 187 | TPS65218_CONTROL_DCDC1_MASK, |
205 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC1_EN, NULL, | 188 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC1_EN, NULL, |
206 | dcdc1_dcdc2_ranges, 2), | 189 | dcdc1_dcdc2_ranges, 2, 4000), |
207 | TPS65218_REGULATOR("DCDC2", TPS65218_DCDC_2, tps65218_dcdc12_ops, 64, | 190 | TPS65218_REGULATOR("DCDC2", TPS65218_DCDC_2, tps65218_dcdc12_ops, 64, |
208 | TPS65218_REG_CONTROL_DCDC2, | 191 | TPS65218_REG_CONTROL_DCDC2, |
209 | TPS65218_CONTROL_DCDC2_MASK, | 192 | TPS65218_CONTROL_DCDC2_MASK, |
210 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC2_EN, NULL, | 193 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC2_EN, NULL, |
211 | dcdc1_dcdc2_ranges, 2), | 194 | dcdc1_dcdc2_ranges, 2, 4000), |
212 | TPS65218_REGULATOR("DCDC3", TPS65218_DCDC_3, tps65218_ldo1_dcdc34_ops, | 195 | TPS65218_REGULATOR("DCDC3", TPS65218_DCDC_3, tps65218_ldo1_dcdc34_ops, |
213 | 64, TPS65218_REG_CONTROL_DCDC3, | 196 | 64, TPS65218_REG_CONTROL_DCDC3, |
214 | TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1, | 197 | TPS65218_CONTROL_DCDC3_MASK, TPS65218_REG_ENABLE1, |
215 | TPS65218_ENABLE1_DC3_EN, NULL, | 198 | TPS65218_ENABLE1_DC3_EN, NULL, |
216 | ldo1_dcdc3_ranges, 2), | 199 | ldo1_dcdc3_ranges, 2, 0), |
217 | TPS65218_REGULATOR("DCDC4", TPS65218_DCDC_4, tps65218_ldo1_dcdc34_ops, | 200 | TPS65218_REGULATOR("DCDC4", TPS65218_DCDC_4, tps65218_ldo1_dcdc34_ops, |
218 | 53, TPS65218_REG_CONTROL_DCDC4, | 201 | 53, TPS65218_REG_CONTROL_DCDC4, |
219 | TPS65218_CONTROL_DCDC4_MASK, | 202 | TPS65218_CONTROL_DCDC4_MASK, |
220 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC4_EN, NULL, | 203 | TPS65218_REG_ENABLE1, TPS65218_ENABLE1_DC4_EN, NULL, |
221 | dcdc4_ranges, 2), | 204 | dcdc4_ranges, 2, 0), |
222 | TPS65218_REGULATOR("DCDC5", TPS65218_DCDC_5, tps65218_dcdc56_pmic_ops, | 205 | TPS65218_REGULATOR("DCDC5", TPS65218_DCDC_5, tps65218_dcdc56_pmic_ops, |
223 | 1, -1, -1, TPS65218_REG_ENABLE1, | 206 | 1, -1, -1, TPS65218_REG_ENABLE1, |
224 | TPS65218_ENABLE1_DC5_EN, NULL, NULL, 0), | 207 | TPS65218_ENABLE1_DC5_EN, NULL, NULL, 0, 0), |
225 | TPS65218_REGULATOR("DCDC6", TPS65218_DCDC_6, tps65218_dcdc56_pmic_ops, | 208 | TPS65218_REGULATOR("DCDC6", TPS65218_DCDC_6, tps65218_dcdc56_pmic_ops, |
226 | 1, -1, -1, TPS65218_REG_ENABLE1, | 209 | 1, -1, -1, TPS65218_REG_ENABLE1, |
227 | TPS65218_ENABLE1_DC6_EN, NULL, NULL, 0), | 210 | TPS65218_ENABLE1_DC6_EN, NULL, NULL, 0, 0), |
228 | TPS65218_REGULATOR("LDO1", TPS65218_LDO_1, tps65218_ldo1_dcdc34_ops, 64, | 211 | TPS65218_REGULATOR("LDO1", TPS65218_LDO_1, tps65218_ldo1_dcdc34_ops, 64, |
229 | TPS65218_REG_CONTROL_DCDC4, | 212 | TPS65218_REG_CONTROL_DCDC4, |
230 | TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2, | 213 | TPS65218_CONTROL_LDO1_MASK, TPS65218_REG_ENABLE2, |
231 | TPS65218_ENABLE2_LDO1_EN, NULL, ldo1_dcdc3_ranges, | 214 | TPS65218_ENABLE2_LDO1_EN, NULL, ldo1_dcdc3_ranges, |
232 | 2), | 215 | 2, 0), |
233 | }; | 216 | }; |
234 | 217 | ||
235 | static int tps65218_regulator_probe(struct platform_device *pdev) | 218 | static int tps65218_regulator_probe(struct platform_device *pdev) |