diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-06-20 10:30:15 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-07-02 13:26:02 -0400 |
commit | cac87fd34ebd79a954321f78acf38abcc69e1308 (patch) | |
tree | 189a8a85f7856a618c5b1a670dbdab99c6b28fd7 | |
parent | 744c62eb65a1c3bb2196ded1a1d2922cf6f2ce80 (diff) |
regulator: tps6524x: Convert to regulator_list_voltage_table()
This patch adds fixed_5000000_voltage table for fixed voltage,
so we can convert regulator_ops to regulator_list_voltage_table.
We can differentiate fixed voltage by checking rdev->desc->n_voltages == 1,
thus remove the FIXED_VOLTAGE flag usage.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | drivers/regulator/tps6524x-regulator.c | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c index 1b299aacf22f..48e37bd95a27 100644 --- a/drivers/regulator/tps6524x-regulator.c +++ b/drivers/regulator/tps6524x-regulator.c | |||
@@ -111,7 +111,6 @@ | |||
111 | #define N_REGULATORS (N_DCDC + N_LDO + N_SWITCH) | 111 | #define N_REGULATORS (N_DCDC + N_LDO + N_SWITCH) |
112 | 112 | ||
113 | #define FIXED_ILIMSEL BIT(0) | 113 | #define FIXED_ILIMSEL BIT(0) |
114 | #define FIXED_VOLTAGE BIT(1) | ||
115 | 114 | ||
116 | #define CMD_READ(reg) ((reg) << 6) | 115 | #define CMD_READ(reg) ((reg) << 6) |
117 | #define CMD_WRITE(reg) (BIT(5) | (reg) << 6) | 116 | #define CMD_WRITE(reg) (BIT(5) | (reg) << 6) |
@@ -129,8 +128,7 @@ struct field { | |||
129 | struct supply_info { | 128 | struct supply_info { |
130 | const char *name; | 129 | const char *name; |
131 | int n_voltages; | 130 | int n_voltages; |
132 | const int *voltages; | 131 | const unsigned int *voltages; |
133 | int fixed_voltage; | ||
134 | int n_ilimsels; | 132 | int n_ilimsels; |
135 | const int *ilimsels; | 133 | const int *ilimsels; |
136 | int fixed_ilimsel; | 134 | int fixed_ilimsel; |
@@ -307,7 +305,7 @@ static int write_field(struct tps6524x *hw, const struct field *field, | |||
307 | val << field->shift); | 305 | val << field->shift); |
308 | } | 306 | } |
309 | 307 | ||
310 | static const int dcdc1_voltages[] = { | 308 | static const unsigned int dcdc1_voltages[] = { |
311 | 800000, 825000, 850000, 875000, | 309 | 800000, 825000, 850000, 875000, |
312 | 900000, 925000, 950000, 975000, | 310 | 900000, 925000, 950000, 975000, |
313 | 1000000, 1025000, 1050000, 1075000, | 311 | 1000000, 1025000, 1050000, 1075000, |
@@ -318,7 +316,7 @@ static const int dcdc1_voltages[] = { | |||
318 | 1500000, 1525000, 1550000, 1575000, | 316 | 1500000, 1525000, 1550000, 1575000, |
319 | }; | 317 | }; |
320 | 318 | ||
321 | static const int dcdc2_voltages[] = { | 319 | static const unsigned int dcdc2_voltages[] = { |
322 | 1400000, 1450000, 1500000, 1550000, | 320 | 1400000, 1450000, 1500000, 1550000, |
323 | 1600000, 1650000, 1700000, 1750000, | 321 | 1600000, 1650000, 1700000, 1750000, |
324 | 1800000, 1850000, 1900000, 1950000, | 322 | 1800000, 1850000, 1900000, 1950000, |
@@ -329,7 +327,7 @@ static const int dcdc2_voltages[] = { | |||
329 | 2800000, 2850000, 2900000, 2950000, | 327 | 2800000, 2850000, 2900000, 2950000, |
330 | }; | 328 | }; |
331 | 329 | ||
332 | static const int dcdc3_voltages[] = { | 330 | static const unsigned int dcdc3_voltages[] = { |
333 | 2400000, 2450000, 2500000, 2550000, 2600000, | 331 | 2400000, 2450000, 2500000, 2550000, 2600000, |
334 | 2650000, 2700000, 2750000, 2800000, 2850000, | 332 | 2650000, 2700000, 2750000, 2800000, 2850000, |
335 | 2900000, 2950000, 3000000, 3050000, 3100000, | 333 | 2900000, 2950000, 3000000, 3050000, 3100000, |
@@ -337,20 +335,24 @@ static const int dcdc3_voltages[] = { | |||
337 | 3400000, 3450000, 3500000, 3550000, 3600000, | 335 | 3400000, 3450000, 3500000, 3550000, 3600000, |
338 | }; | 336 | }; |
339 | 337 | ||
340 | static const int ldo1_voltages[] = { | 338 | static const unsigned int ldo1_voltages[] = { |
341 | 4300000, 4350000, 4400000, 4450000, | 339 | 4300000, 4350000, 4400000, 4450000, |
342 | 4500000, 4550000, 4600000, 4650000, | 340 | 4500000, 4550000, 4600000, 4650000, |
343 | 4700000, 4750000, 4800000, 4850000, | 341 | 4700000, 4750000, 4800000, 4850000, |
344 | 4900000, 4950000, 5000000, 5050000, | 342 | 4900000, 4950000, 5000000, 5050000, |
345 | }; | 343 | }; |
346 | 344 | ||
347 | static const int ldo2_voltages[] = { | 345 | static const unsigned int ldo2_voltages[] = { |
348 | 1100000, 1150000, 1200000, 1250000, | 346 | 1100000, 1150000, 1200000, 1250000, |
349 | 1300000, 1700000, 1750000, 1800000, | 347 | 1300000, 1700000, 1750000, 1800000, |
350 | 1850000, 1900000, 3150000, 3200000, | 348 | 1850000, 1900000, 3150000, 3200000, |
351 | 3250000, 3300000, 3350000, 3400000, | 349 | 3250000, 3300000, 3350000, 3400000, |
352 | }; | 350 | }; |
353 | 351 | ||
352 | static const unsigned int fixed_5000000_voltage[] = { | ||
353 | 5000000 | ||
354 | }; | ||
355 | |||
354 | static const int ldo_ilimsel[] = { | 356 | static const int ldo_ilimsel[] = { |
355 | 400000, 1500000 | 357 | 400000, 1500000 |
356 | }; | 358 | }; |
@@ -424,8 +426,8 @@ static const struct supply_info supply_info[N_REGULATORS] = { | |||
424 | }, | 426 | }, |
425 | { | 427 | { |
426 | .name = "USB", | 428 | .name = "USB", |
427 | .flags = FIXED_VOLTAGE, | 429 | .n_voltages = ARRAY_SIZE(fixed_5000000_voltage), |
428 | .fixed_voltage = 5000000, | 430 | .voltages = fixed_5000000_voltage, |
429 | .n_ilimsels = ARRAY_SIZE(usb_ilimsel), | 431 | .n_ilimsels = ARRAY_SIZE(usb_ilimsel), |
430 | .ilimsels = usb_ilimsel, | 432 | .ilimsels = usb_ilimsel, |
431 | .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK, | 433 | .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK, |
@@ -435,29 +437,15 @@ static const struct supply_info supply_info[N_REGULATORS] = { | |||
435 | }, | 437 | }, |
436 | { | 438 | { |
437 | .name = "LCD", | 439 | .name = "LCD", |
438 | .flags = FIXED_VOLTAGE | FIXED_ILIMSEL, | 440 | .n_voltages = ARRAY_SIZE(fixed_5000000_voltage), |
439 | .fixed_voltage = 5000000, | 441 | .voltages = fixed_5000000_voltage, |
442 | .flags = FIXED_ILIMSEL, | ||
440 | .fixed_ilimsel = 400000, | 443 | .fixed_ilimsel = 400000, |
441 | .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK, | 444 | .enable = __MK_FIELD(REG_BLOCK_EN, BLOCK_MASK, |
442 | BLOCK_LCD_SHIFT), | 445 | BLOCK_LCD_SHIFT), |
443 | }, | 446 | }, |
444 | }; | 447 | }; |
445 | 448 | ||
446 | static int list_voltage(struct regulator_dev *rdev, unsigned selector) | ||
447 | { | ||
448 | const struct supply_info *info; | ||
449 | struct tps6524x *hw; | ||
450 | |||
451 | hw = rdev_get_drvdata(rdev); | ||
452 | info = &supply_info[rdev_get_id(rdev)]; | ||
453 | |||
454 | if (info->flags & FIXED_VOLTAGE) | ||
455 | return selector ? -EINVAL : info->fixed_voltage; | ||
456 | |||
457 | return ((selector < info->n_voltages) ? | ||
458 | info->voltages[selector] : -EINVAL); | ||
459 | } | ||
460 | |||
461 | static int set_voltage_sel(struct regulator_dev *rdev, unsigned selector) | 449 | static int set_voltage_sel(struct regulator_dev *rdev, unsigned selector) |
462 | { | 450 | { |
463 | const struct supply_info *info; | 451 | const struct supply_info *info; |
@@ -466,7 +454,7 @@ static int set_voltage_sel(struct regulator_dev *rdev, unsigned selector) | |||
466 | hw = rdev_get_drvdata(rdev); | 454 | hw = rdev_get_drvdata(rdev); |
467 | info = &supply_info[rdev_get_id(rdev)]; | 455 | info = &supply_info[rdev_get_id(rdev)]; |
468 | 456 | ||
469 | if (info->flags & FIXED_VOLTAGE) | 457 | if (rdev->desc->n_voltages == 1) |
470 | return -EINVAL; | 458 | return -EINVAL; |
471 | 459 | ||
472 | return write_field(hw, &info->voltage, selector); | 460 | return write_field(hw, &info->voltage, selector); |
@@ -481,7 +469,7 @@ static int get_voltage_sel(struct regulator_dev *rdev) | |||
481 | hw = rdev_get_drvdata(rdev); | 469 | hw = rdev_get_drvdata(rdev); |
482 | info = &supply_info[rdev_get_id(rdev)]; | 470 | info = &supply_info[rdev_get_id(rdev)]; |
483 | 471 | ||
484 | if (info->flags & FIXED_VOLTAGE) | 472 | if (rdev->desc->n_voltages == 1) |
485 | return 0; | 473 | return 0; |
486 | 474 | ||
487 | ret = read_field(hw, &info->voltage); | 475 | ret = read_field(hw, &info->voltage); |
@@ -577,7 +565,7 @@ static struct regulator_ops regulator_ops = { | |||
577 | .disable = disable_supply, | 565 | .disable = disable_supply, |
578 | .get_voltage_sel = get_voltage_sel, | 566 | .get_voltage_sel = get_voltage_sel, |
579 | .set_voltage_sel = set_voltage_sel, | 567 | .set_voltage_sel = set_voltage_sel, |
580 | .list_voltage = list_voltage, | 568 | .list_voltage = regulator_list_voltage_table, |
581 | .set_current_limit = set_current_limit, | 569 | .set_current_limit = set_current_limit, |
582 | .get_current_limit = get_current_limit, | 570 | .get_current_limit = get_current_limit, |
583 | }; | 571 | }; |
@@ -629,13 +617,11 @@ static int __devinit pmic_probe(struct spi_device *spi) | |||
629 | hw->desc[i].name = info->name; | 617 | hw->desc[i].name = info->name; |
630 | hw->desc[i].id = i; | 618 | hw->desc[i].id = i; |
631 | hw->desc[i].n_voltages = info->n_voltages; | 619 | hw->desc[i].n_voltages = info->n_voltages; |
620 | hw->desc[i].volt_table = info->voltages; | ||
632 | hw->desc[i].ops = ®ulator_ops; | 621 | hw->desc[i].ops = ®ulator_ops; |
633 | hw->desc[i].type = REGULATOR_VOLTAGE; | 622 | hw->desc[i].type = REGULATOR_VOLTAGE; |
634 | hw->desc[i].owner = THIS_MODULE; | 623 | hw->desc[i].owner = THIS_MODULE; |
635 | 624 | ||
636 | if (info->flags & FIXED_VOLTAGE) | ||
637 | hw->desc[i].n_voltages = 1; | ||
638 | |||
639 | config.dev = dev; | 625 | config.dev = dev; |
640 | config.init_data = init_data; | 626 | config.init_data = init_data; |
641 | config.driver_data = hw; | 627 | config.driver_data = hw; |