diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-05-19 22:33:35 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-03 08:25:01 -0400 |
commit | ec1cc4d9da39b58764fdb6f3d1aebcfe709a688f (patch) | |
tree | 731c9e12677ebfba540c1321960a4488dce59b97 /drivers/regulator/ab8500.c | |
parent | a3beb74261f26142019847128b2441b0301797ac (diff) |
regulator: ab8500: Use regulator_list_voltage_table()
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/ab8500.c')
-rw-r--r-- | drivers/regulator/ab8500.c | 64 |
1 files changed, 24 insertions, 40 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index e1b8c54ace5a..da883e661b38 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c | |||
@@ -40,8 +40,6 @@ | |||
40 | * @voltage_bank: bank to control regulator voltage | 40 | * @voltage_bank: bank to control regulator voltage |
41 | * @voltage_reg: register to control regulator voltage | 41 | * @voltage_reg: register to control regulator voltage |
42 | * @voltage_mask: mask to control regulator voltage | 42 | * @voltage_mask: mask to control regulator voltage |
43 | * @voltages: supported voltage table | ||
44 | * @voltages_len: number of supported voltages for the regulator | ||
45 | * @delay: startup/set voltage delay in us | 43 | * @delay: startup/set voltage delay in us |
46 | */ | 44 | */ |
47 | struct ab8500_regulator_info { | 45 | struct ab8500_regulator_info { |
@@ -58,13 +56,11 @@ struct ab8500_regulator_info { | |||
58 | u8 voltage_bank; | 56 | u8 voltage_bank; |
59 | u8 voltage_reg; | 57 | u8 voltage_reg; |
60 | u8 voltage_mask; | 58 | u8 voltage_mask; |
61 | int const *voltages; | ||
62 | int voltages_len; | ||
63 | unsigned int delay; | 59 | unsigned int delay; |
64 | }; | 60 | }; |
65 | 61 | ||
66 | /* voltage tables for the vauxn/vintcore supplies */ | 62 | /* voltage tables for the vauxn/vintcore supplies */ |
67 | static const int ldo_vauxn_voltages[] = { | 63 | static const unsigned int ldo_vauxn_voltages[] = { |
68 | 1100000, | 64 | 1100000, |
69 | 1200000, | 65 | 1200000, |
70 | 1300000, | 66 | 1300000, |
@@ -83,7 +79,7 @@ static const int ldo_vauxn_voltages[] = { | |||
83 | 3300000, | 79 | 3300000, |
84 | }; | 80 | }; |
85 | 81 | ||
86 | static const int ldo_vaux3_voltages[] = { | 82 | static const unsigned int ldo_vaux3_voltages[] = { |
87 | 1200000, | 83 | 1200000, |
88 | 1500000, | 84 | 1500000, |
89 | 1800000, | 85 | 1800000, |
@@ -94,7 +90,7 @@ static const int ldo_vaux3_voltages[] = { | |||
94 | 2910000, | 90 | 2910000, |
95 | }; | 91 | }; |
96 | 92 | ||
97 | static const int ldo_vintcore_voltages[] = { | 93 | static const unsigned int ldo_vintcore_voltages[] = { |
98 | 1200000, | 94 | 1200000, |
99 | 1225000, | 95 | 1225000, |
100 | 1250000, | 96 | 1250000, |
@@ -185,25 +181,6 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) | |||
185 | return false; | 181 | return false; |
186 | } | 182 | } |
187 | 183 | ||
188 | static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector) | ||
189 | { | ||
190 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | ||
191 | |||
192 | if (info == NULL) { | ||
193 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); | ||
194 | return -EINVAL; | ||
195 | } | ||
196 | |||
197 | /* return the uV for the fixed regulators */ | ||
198 | if (info->fixed_uV) | ||
199 | return info->fixed_uV; | ||
200 | |||
201 | if (selector >= info->voltages_len) | ||
202 | return -EINVAL; | ||
203 | |||
204 | return info->voltages[selector]; | ||
205 | } | ||
206 | |||
207 | static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev) | 184 | static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev) |
208 | { | 185 | { |
209 | int ret, val; | 186 | int ret, val; |
@@ -296,11 +273,24 @@ static struct regulator_ops ab8500_regulator_ops = { | |||
296 | .is_enabled = ab8500_regulator_is_enabled, | 273 | .is_enabled = ab8500_regulator_is_enabled, |
297 | .get_voltage_sel = ab8500_regulator_get_voltage_sel, | 274 | .get_voltage_sel = ab8500_regulator_get_voltage_sel, |
298 | .set_voltage_sel = ab8500_regulator_set_voltage_sel, | 275 | .set_voltage_sel = ab8500_regulator_set_voltage_sel, |
299 | .list_voltage = ab8500_list_voltage, | 276 | .list_voltage = regulator_list_voltage_table, |
300 | .enable_time = ab8500_regulator_enable_time, | 277 | .enable_time = ab8500_regulator_enable_time, |
301 | .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel, | 278 | .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel, |
302 | }; | 279 | }; |
303 | 280 | ||
281 | static int ab8500_fixed_list_voltage(struct regulator_dev *rdev, | ||
282 | unsigned selector) | ||
283 | { | ||
284 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | ||
285 | |||
286 | if (info == NULL) { | ||
287 | dev_err(rdev_get_dev(rdev), "regulator info null pointer\n"); | ||
288 | return -EINVAL; | ||
289 | } | ||
290 | |||
291 | return info->fixed_uV; | ||
292 | } | ||
293 | |||
304 | static int ab8500_fixed_get_voltage(struct regulator_dev *rdev) | 294 | static int ab8500_fixed_get_voltage(struct regulator_dev *rdev) |
305 | { | 295 | { |
306 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); | 296 | struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); |
@@ -318,7 +308,7 @@ static struct regulator_ops ab8500_regulator_fixed_ops = { | |||
318 | .disable = ab8500_regulator_disable, | 308 | .disable = ab8500_regulator_disable, |
319 | .is_enabled = ab8500_regulator_is_enabled, | 309 | .is_enabled = ab8500_regulator_is_enabled, |
320 | .get_voltage = ab8500_fixed_get_voltage, | 310 | .get_voltage = ab8500_fixed_get_voltage, |
321 | .list_voltage = ab8500_list_voltage, | 311 | .list_voltage = ab8500_fixed_list_voltage, |
322 | .enable_time = ab8500_regulator_enable_time, | 312 | .enable_time = ab8500_regulator_enable_time, |
323 | .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel, | 313 | .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel, |
324 | }; | 314 | }; |
@@ -329,7 +319,7 @@ static struct ab8500_regulator_info | |||
329 | * Variable Voltage Regulators | 319 | * Variable Voltage Regulators |
330 | * name, min mV, max mV, | 320 | * name, min mV, max mV, |
331 | * update bank, reg, mask, enable val | 321 | * update bank, reg, mask, enable val |
332 | * volt bank, reg, mask, table, table length | 322 | * volt bank, reg, mask |
333 | */ | 323 | */ |
334 | [AB8500_LDO_AUX1] = { | 324 | [AB8500_LDO_AUX1] = { |
335 | .desc = { | 325 | .desc = { |
@@ -339,6 +329,7 @@ static struct ab8500_regulator_info | |||
339 | .id = AB8500_LDO_AUX1, | 329 | .id = AB8500_LDO_AUX1, |
340 | .owner = THIS_MODULE, | 330 | .owner = THIS_MODULE, |
341 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), | 331 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), |
332 | .volt_table = ldo_vauxn_voltages, | ||
342 | }, | 333 | }, |
343 | .min_uV = 1100000, | 334 | .min_uV = 1100000, |
344 | .max_uV = 3300000, | 335 | .max_uV = 3300000, |
@@ -349,8 +340,6 @@ static struct ab8500_regulator_info | |||
349 | .voltage_bank = 0x04, | 340 | .voltage_bank = 0x04, |
350 | .voltage_reg = 0x1f, | 341 | .voltage_reg = 0x1f, |
351 | .voltage_mask = 0x0f, | 342 | .voltage_mask = 0x0f, |
352 | .voltages = ldo_vauxn_voltages, | ||
353 | .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages), | ||
354 | }, | 343 | }, |
355 | [AB8500_LDO_AUX2] = { | 344 | [AB8500_LDO_AUX2] = { |
356 | .desc = { | 345 | .desc = { |
@@ -360,6 +349,7 @@ static struct ab8500_regulator_info | |||
360 | .id = AB8500_LDO_AUX2, | 349 | .id = AB8500_LDO_AUX2, |
361 | .owner = THIS_MODULE, | 350 | .owner = THIS_MODULE, |
362 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), | 351 | .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), |
352 | .volt_table = ldo_vauxn_voltages, | ||
363 | }, | 353 | }, |
364 | .min_uV = 1100000, | 354 | .min_uV = 1100000, |
365 | .max_uV = 3300000, | 355 | .max_uV = 3300000, |
@@ -370,8 +360,6 @@ static struct ab8500_regulator_info | |||
370 | .voltage_bank = 0x04, | 360 | .voltage_bank = 0x04, |
371 | .voltage_reg = 0x20, | 361 | .voltage_reg = 0x20, |
372 | .voltage_mask = 0x0f, | 362 | .voltage_mask = 0x0f, |
373 | .voltages = ldo_vauxn_voltages, | ||
374 | .voltages_len = ARRAY_SIZE(ldo_vauxn_voltages), | ||
375 | }, | 363 | }, |
376 | [AB8500_LDO_AUX3] = { | 364 | [AB8500_LDO_AUX3] = { |
377 | .desc = { | 365 | .desc = { |
@@ -381,6 +369,7 @@ static struct ab8500_regulator_info | |||
381 | .id = AB8500_LDO_AUX3, | 369 | .id = AB8500_LDO_AUX3, |
382 | .owner = THIS_MODULE, | 370 | .owner = THIS_MODULE, |
383 | .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages), | 371 | .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages), |
372 | .volt_table = ldo_vaux3_voltages, | ||
384 | }, | 373 | }, |
385 | .min_uV = 1100000, | 374 | .min_uV = 1100000, |
386 | .max_uV = 3300000, | 375 | .max_uV = 3300000, |
@@ -391,8 +380,6 @@ static struct ab8500_regulator_info | |||
391 | .voltage_bank = 0x04, | 380 | .voltage_bank = 0x04, |
392 | .voltage_reg = 0x21, | 381 | .voltage_reg = 0x21, |
393 | .voltage_mask = 0x07, | 382 | .voltage_mask = 0x07, |
394 | .voltages = ldo_vaux3_voltages, | ||
395 | .voltages_len = ARRAY_SIZE(ldo_vaux3_voltages), | ||
396 | }, | 383 | }, |
397 | [AB8500_LDO_INTCORE] = { | 384 | [AB8500_LDO_INTCORE] = { |
398 | .desc = { | 385 | .desc = { |
@@ -402,6 +389,7 @@ static struct ab8500_regulator_info | |||
402 | .id = AB8500_LDO_INTCORE, | 389 | .id = AB8500_LDO_INTCORE, |
403 | .owner = THIS_MODULE, | 390 | .owner = THIS_MODULE, |
404 | .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages), | 391 | .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages), |
392 | .volt_table = ldo_vintcore_voltages, | ||
405 | }, | 393 | }, |
406 | .min_uV = 1100000, | 394 | .min_uV = 1100000, |
407 | .max_uV = 3300000, | 395 | .max_uV = 3300000, |
@@ -412,8 +400,6 @@ static struct ab8500_regulator_info | |||
412 | .voltage_bank = 0x03, | 400 | .voltage_bank = 0x03, |
413 | .voltage_reg = 0x80, | 401 | .voltage_reg = 0x80, |
414 | .voltage_mask = 0x38, | 402 | .voltage_mask = 0x38, |
415 | .voltages = ldo_vintcore_voltages, | ||
416 | .voltages_len = ARRAY_SIZE(ldo_vintcore_voltages), | ||
417 | }, | 403 | }, |
418 | 404 | ||
419 | /* | 405 | /* |
@@ -769,9 +755,7 @@ static __devinit int ab8500_regulator_register(struct platform_device *pdev, | |||
769 | if (info->desc.id == AB8500_LDO_AUX3) { | 755 | if (info->desc.id == AB8500_LDO_AUX3) { |
770 | info->desc.n_voltages = | 756 | info->desc.n_voltages = |
771 | ARRAY_SIZE(ldo_vauxn_voltages); | 757 | ARRAY_SIZE(ldo_vauxn_voltages); |
772 | info->voltages = ldo_vauxn_voltages; | 758 | info->desc.volt_table = ldo_vauxn_voltages; |
773 | info->voltages_len = | ||
774 | ARRAY_SIZE(ldo_vauxn_voltages); | ||
775 | info->voltage_mask = 0xf; | 759 | info->voltage_mask = 0xf; |
776 | } | 760 | } |
777 | } | 761 | } |