diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/regulator/anatop-regulator.c | 28 | ||||
-rw-r--r-- | drivers/regulator/core.c | 6 | ||||
-rw-r--r-- | drivers/regulator/da9055-regulator.c | 55 | ||||
-rw-r--r-- | drivers/regulator/palmas-regulator.c | 37 | ||||
-rw-r--r-- | drivers/regulator/pcf50633-regulator.c | 176 | ||||
-rw-r--r-- | drivers/regulator/tps51632-regulator.c | 15 |
6 files changed, 61 insertions, 256 deletions
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 1aa5246c79d9..0199eeea63b1 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c | |||
@@ -48,36 +48,21 @@ static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg, | |||
48 | unsigned selector) | 48 | unsigned selector) |
49 | { | 49 | { |
50 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); | 50 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
51 | u32 val, mask; | ||
52 | 51 | ||
53 | if (!anatop_reg->control_reg) | 52 | if (!anatop_reg->control_reg) |
54 | return -ENOTSUPP; | 53 | return -ENOTSUPP; |
55 | 54 | ||
56 | val = anatop_reg->min_bit_val + selector; | 55 | return regulator_set_voltage_sel_regmap(reg, selector); |
57 | dev_dbg(®->dev, "%s: calculated val %d\n", __func__, val); | ||
58 | mask = ((1 << anatop_reg->vol_bit_width) - 1) << | ||
59 | anatop_reg->vol_bit_shift; | ||
60 | val <<= anatop_reg->vol_bit_shift; | ||
61 | regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg, | ||
62 | mask, val); | ||
63 | |||
64 | return 0; | ||
65 | } | 56 | } |
66 | 57 | ||
67 | static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) | 58 | static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) |
68 | { | 59 | { |
69 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); | 60 | struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); |
70 | u32 val, mask; | ||
71 | 61 | ||
72 | if (!anatop_reg->control_reg) | 62 | if (!anatop_reg->control_reg) |
73 | return -ENOTSUPP; | 63 | return -ENOTSUPP; |
74 | 64 | ||
75 | regmap_read(anatop_reg->anatop, anatop_reg->control_reg, &val); | 65 | return regulator_get_voltage_sel_regmap(reg); |
76 | mask = ((1 << anatop_reg->vol_bit_width) - 1) << | ||
77 | anatop_reg->vol_bit_shift; | ||
78 | val = (val & mask) >> anatop_reg->vol_bit_shift; | ||
79 | |||
80 | return val - anatop_reg->min_bit_val; | ||
81 | } | 66 | } |
82 | 67 | ||
83 | static struct regulator_ops anatop_rops = { | 68 | static struct regulator_ops anatop_rops = { |
@@ -158,15 +143,20 @@ static int anatop_regulator_probe(struct platform_device *pdev) | |||
158 | goto anatop_probe_end; | 143 | goto anatop_probe_end; |
159 | } | 144 | } |
160 | 145 | ||
161 | rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) | 146 | rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1 |
162 | / 25000 + 1; | 147 | + sreg->min_bit_val; |
163 | rdesc->min_uV = sreg->min_voltage; | 148 | rdesc->min_uV = sreg->min_voltage; |
164 | rdesc->uV_step = 25000; | 149 | rdesc->uV_step = 25000; |
150 | rdesc->linear_min_sel = sreg->min_bit_val; | ||
151 | rdesc->vsel_reg = sreg->control_reg; | ||
152 | rdesc->vsel_mask = ((1 << sreg->vol_bit_width) - 1) << | ||
153 | sreg->vol_bit_shift; | ||
165 | 154 | ||
166 | config.dev = &pdev->dev; | 155 | config.dev = &pdev->dev; |
167 | config.init_data = initdata; | 156 | config.init_data = initdata; |
168 | config.driver_data = sreg; | 157 | config.driver_data = sreg; |
169 | config.of_node = pdev->dev.of_node; | 158 | config.of_node = pdev->dev.of_node; |
159 | config.regmap = sreg->anatop; | ||
170 | 160 | ||
171 | /* register regulator */ | 161 | /* register regulator */ |
172 | rdev = regulator_register(rdesc, &config); | 162 | rdev = regulator_register(rdesc, &config); |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 35c149bb2ad3..cd1b201c91e2 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1924,6 +1924,10 @@ int regulator_list_voltage_linear(struct regulator_dev *rdev, | |||
1924 | { | 1924 | { |
1925 | if (selector >= rdev->desc->n_voltages) | 1925 | if (selector >= rdev->desc->n_voltages) |
1926 | return -EINVAL; | 1926 | return -EINVAL; |
1927 | if (selector < rdev->desc->linear_min_sel) | ||
1928 | return 0; | ||
1929 | |||
1930 | selector -= rdev->desc->linear_min_sel; | ||
1927 | 1931 | ||
1928 | return rdev->desc->min_uV + (rdev->desc->uV_step * selector); | 1932 | return rdev->desc->min_uV + (rdev->desc->uV_step * selector); |
1929 | } | 1933 | } |
@@ -2152,6 +2156,8 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev, | |||
2152 | if (ret < 0) | 2156 | if (ret < 0) |
2153 | return ret; | 2157 | return ret; |
2154 | 2158 | ||
2159 | ret += rdev->desc->linear_min_sel; | ||
2160 | |||
2155 | /* Map back into a voltage to verify we're still in bounds */ | 2161 | /* Map back into a voltage to verify we're still in bounds */ |
2156 | voltage = rdev->desc->ops->list_voltage(rdev, ret); | 2162 | voltage = rdev->desc->ops->list_voltage(rdev, ret); |
2157 | if (voltage < min_uV || voltage > max_uV) | 2163 | if (voltage < min_uV || voltage > max_uV) |
diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c index db59ce7534cd..a4b9cb8c4317 100644 --- a/drivers/regulator/da9055-regulator.c +++ b/drivers/regulator/da9055-regulator.c | |||
@@ -57,7 +57,6 @@ struct da9055_volt_reg { | |||
57 | int reg_a; | 57 | int reg_a; |
58 | int reg_b; | 58 | int reg_b; |
59 | int sl_shift; | 59 | int sl_shift; |
60 | int v_offset; | ||
61 | int v_mask; | 60 | int v_mask; |
62 | int v_shift; | 61 | int v_shift; |
63 | }; | 62 | }; |
@@ -201,41 +200,6 @@ static int da9055_buck_set_current_limit(struct regulator_dev *rdev, int min_uA, | |||
201 | return -EINVAL; | 200 | return -EINVAL; |
202 | } | 201 | } |
203 | 202 | ||
204 | static int da9055_list_voltage(struct regulator_dev *rdev, unsigned selector) | ||
205 | { | ||
206 | struct da9055_regulator *regulator = rdev_get_drvdata(rdev); | ||
207 | struct da9055_regulator_info *info = regulator->info; | ||
208 | |||
209 | if (selector >= rdev->desc->n_voltages) | ||
210 | return -EINVAL; | ||
211 | |||
212 | if (selector < info->volt.v_offset) | ||
213 | return 0; | ||
214 | |||
215 | selector -= info->volt.v_offset; | ||
216 | return rdev->desc->min_uV + (rdev->desc->uV_step * selector); | ||
217 | } | ||
218 | |||
219 | static int da9055_map_voltage(struct regulator_dev *rdev, int min_uV, | ||
220 | int max_uV) | ||
221 | { | ||
222 | struct da9055_regulator *regulator = rdev_get_drvdata(rdev); | ||
223 | struct da9055_regulator_info *info = regulator->info; | ||
224 | int sel, voltage; | ||
225 | |||
226 | if (min_uV < rdev->desc->min_uV) | ||
227 | min_uV = rdev->desc->min_uV; | ||
228 | |||
229 | sel = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step); | ||
230 | sel += info->volt.v_offset; | ||
231 | |||
232 | voltage = da9055_list_voltage(rdev, sel); | ||
233 | if (voltage < min_uV || voltage > max_uV) | ||
234 | return -EINVAL; | ||
235 | |||
236 | return sel; | ||
237 | } | ||
238 | |||
239 | static int da9055_regulator_get_voltage_sel(struct regulator_dev *rdev) | 203 | static int da9055_regulator_get_voltage_sel(struct regulator_dev *rdev) |
240 | { | 204 | { |
241 | struct da9055_regulator *regulator = rdev_get_drvdata(rdev); | 205 | struct da9055_regulator *regulator = rdev_get_drvdata(rdev); |
@@ -264,10 +228,7 @@ static int da9055_regulator_get_voltage_sel(struct regulator_dev *rdev) | |||
264 | return ret; | 228 | return ret; |
265 | 229 | ||
266 | sel = (ret & volt.v_mask); | 230 | sel = (ret & volt.v_mask); |
267 | if (sel <= volt.v_offset) | 231 | return sel; |
268 | return 0; | ||
269 | else | ||
270 | return sel; | ||
271 | } | 232 | } |
272 | 233 | ||
273 | static int da9055_regulator_set_voltage_sel(struct regulator_dev *rdev, | 234 | static int da9055_regulator_set_voltage_sel(struct regulator_dev *rdev, |
@@ -328,7 +289,7 @@ static int da9055_regulator_set_suspend_voltage(struct regulator_dev *rdev, | |||
328 | return ret; | 289 | return ret; |
329 | } | 290 | } |
330 | 291 | ||
331 | ret = da9055_map_voltage(rdev, uV, uV); | 292 | ret = regulator_map_voltage_linear(rdev, uV, uV); |
332 | if (ret < 0) | 293 | if (ret < 0) |
333 | return ret; | 294 | return ret; |
334 | 295 | ||
@@ -371,8 +332,8 @@ static struct regulator_ops da9055_buck_ops = { | |||
371 | 332 | ||
372 | .get_voltage_sel = da9055_regulator_get_voltage_sel, | 333 | .get_voltage_sel = da9055_regulator_get_voltage_sel, |
373 | .set_voltage_sel = da9055_regulator_set_voltage_sel, | 334 | .set_voltage_sel = da9055_regulator_set_voltage_sel, |
374 | .list_voltage = da9055_list_voltage, | 335 | .list_voltage = regulator_list_voltage_linear, |
375 | .map_voltage = da9055_map_voltage, | 336 | .map_voltage = regulator_map_voltage_linear, |
376 | .is_enabled = regulator_is_enabled_regmap, | 337 | .is_enabled = regulator_is_enabled_regmap, |
377 | .enable = regulator_enable_regmap, | 338 | .enable = regulator_enable_regmap, |
378 | .disable = regulator_disable_regmap, | 339 | .disable = regulator_disable_regmap, |
@@ -389,8 +350,8 @@ static struct regulator_ops da9055_ldo_ops = { | |||
389 | 350 | ||
390 | .get_voltage_sel = da9055_regulator_get_voltage_sel, | 351 | .get_voltage_sel = da9055_regulator_get_voltage_sel, |
391 | .set_voltage_sel = da9055_regulator_set_voltage_sel, | 352 | .set_voltage_sel = da9055_regulator_set_voltage_sel, |
392 | .list_voltage = da9055_list_voltage, | 353 | .list_voltage = regulator_list_voltage_linear, |
393 | .map_voltage = da9055_map_voltage, | 354 | .map_voltage = regulator_map_voltage_linear, |
394 | .is_enabled = regulator_is_enabled_regmap, | 355 | .is_enabled = regulator_is_enabled_regmap, |
395 | .enable = regulator_enable_regmap, | 356 | .enable = regulator_enable_regmap, |
396 | .disable = regulator_disable_regmap, | 357 | .disable = regulator_disable_regmap, |
@@ -414,6 +375,7 @@ static struct regulator_ops da9055_ldo_ops = { | |||
414 | .enable_mask = 1, \ | 375 | .enable_mask = 1, \ |
415 | .min_uV = (min) * 1000,\ | 376 | .min_uV = (min) * 1000,\ |
416 | .uV_step = (step) * 1000,\ | 377 | .uV_step = (step) * 1000,\ |
378 | .linear_min_sel = (voffset),\ | ||
417 | .owner = THIS_MODULE,\ | 379 | .owner = THIS_MODULE,\ |
418 | },\ | 380 | },\ |
419 | .conf = {\ | 381 | .conf = {\ |
@@ -425,7 +387,6 @@ static struct regulator_ops da9055_ldo_ops = { | |||
425 | .reg_a = DA9055_REG_VBCORE_A + DA9055_ID_##_id, \ | 387 | .reg_a = DA9055_REG_VBCORE_A + DA9055_ID_##_id, \ |
426 | .reg_b = DA9055_REG_VBCORE_B + DA9055_ID_##_id, \ | 388 | .reg_b = DA9055_REG_VBCORE_B + DA9055_ID_##_id, \ |
427 | .sl_shift = 7,\ | 389 | .sl_shift = 7,\ |
428 | .v_offset = (voffset),\ | ||
429 | .v_mask = (1 << (vbits)) - 1,\ | 390 | .v_mask = (1 << (vbits)) - 1,\ |
430 | .v_shift = (vbits),\ | 391 | .v_shift = (vbits),\ |
431 | },\ | 392 | },\ |
@@ -443,6 +404,7 @@ static struct regulator_ops da9055_ldo_ops = { | |||
443 | .enable_mask = 1,\ | 404 | .enable_mask = 1,\ |
444 | .min_uV = (min) * 1000,\ | 405 | .min_uV = (min) * 1000,\ |
445 | .uV_step = (step) * 1000,\ | 406 | .uV_step = (step) * 1000,\ |
407 | .linear_min_sel = (voffset),\ | ||
446 | .owner = THIS_MODULE,\ | 408 | .owner = THIS_MODULE,\ |
447 | },\ | 409 | },\ |
448 | .conf = {\ | 410 | .conf = {\ |
@@ -454,7 +416,6 @@ static struct regulator_ops da9055_ldo_ops = { | |||
454 | .reg_a = DA9055_REG_VBCORE_A + DA9055_ID_##_id, \ | 416 | .reg_a = DA9055_REG_VBCORE_A + DA9055_ID_##_id, \ |
455 | .reg_b = DA9055_REG_VBCORE_B + DA9055_ID_##_id, \ | 417 | .reg_b = DA9055_REG_VBCORE_B + DA9055_ID_##_id, \ |
456 | .sl_shift = 7,\ | 418 | .sl_shift = 7,\ |
457 | .v_offset = (voffset),\ | ||
458 | .v_mask = (1 << (vbits)) - 1,\ | 419 | .v_mask = (1 << (vbits)) - 1,\ |
459 | .v_shift = (vbits),\ | 420 | .v_shift = (vbits),\ |
460 | },\ | 421 | },\ |
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 3d445929cc80..fd27a43a9fbc 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c | |||
@@ -436,44 +436,14 @@ static int palmas_is_enabled_ldo(struct regulator_dev *dev) | |||
436 | return !!(reg); | 436 | return !!(reg); |
437 | } | 437 | } |
438 | 438 | ||
439 | static int palmas_list_voltage_ldo(struct regulator_dev *dev, | ||
440 | unsigned selector) | ||
441 | { | ||
442 | if (!selector) | ||
443 | return 0; | ||
444 | |||
445 | /* voltage is 0.85V + (selector * 0.05v) */ | ||
446 | return 850000 + (selector * 50000); | ||
447 | } | ||
448 | |||
449 | static int palmas_map_voltage_ldo(struct regulator_dev *rdev, | ||
450 | int min_uV, int max_uV) | ||
451 | { | ||
452 | int ret, voltage; | ||
453 | |||
454 | if (min_uV == 0) | ||
455 | return 0; | ||
456 | |||
457 | if (min_uV < 900000) | ||
458 | min_uV = 900000; | ||
459 | ret = DIV_ROUND_UP(min_uV - 900000, 50000) + 1; | ||
460 | |||
461 | /* Map back into a voltage to verify we're still in bounds */ | ||
462 | voltage = palmas_list_voltage_ldo(rdev, ret); | ||
463 | if (voltage < min_uV || voltage > max_uV) | ||
464 | return -EINVAL; | ||
465 | |||
466 | return ret; | ||
467 | } | ||
468 | |||
469 | static struct regulator_ops palmas_ops_ldo = { | 439 | static struct regulator_ops palmas_ops_ldo = { |
470 | .is_enabled = palmas_is_enabled_ldo, | 440 | .is_enabled = palmas_is_enabled_ldo, |
471 | .enable = regulator_enable_regmap, | 441 | .enable = regulator_enable_regmap, |
472 | .disable = regulator_disable_regmap, | 442 | .disable = regulator_disable_regmap, |
473 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 443 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
474 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | 444 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
475 | .list_voltage = palmas_list_voltage_ldo, | 445 | .list_voltage = regulator_list_voltage_linear, |
476 | .map_voltage = palmas_map_voltage_ldo, | 446 | .map_voltage = regulator_map_voltage_linear, |
477 | }; | 447 | }; |
478 | 448 | ||
479 | /* | 449 | /* |
@@ -821,6 +791,9 @@ static int palmas_probe(struct platform_device *pdev) | |||
821 | 791 | ||
822 | pmic->desc[id].type = REGULATOR_VOLTAGE; | 792 | pmic->desc[id].type = REGULATOR_VOLTAGE; |
823 | pmic->desc[id].owner = THIS_MODULE; | 793 | pmic->desc[id].owner = THIS_MODULE; |
794 | pmic->desc[id].min_uV = 900000; | ||
795 | pmic->desc[id].uV_step = 50000; | ||
796 | pmic->desc[id].linear_min_sel = 1; | ||
824 | pmic->desc[id].vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, | 797 | pmic->desc[id].vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, |
825 | palmas_regs_info[id].vsel_addr); | 798 | palmas_regs_info[id].vsel_addr); |
826 | pmic->desc[id].vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK; | 799 | pmic->desc[id].vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK; |
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c index d776f518aa0d..534075e13d6d 100644 --- a/drivers/regulator/pcf50633-regulator.c +++ b/drivers/regulator/pcf50633-regulator.c | |||
@@ -24,12 +24,15 @@ | |||
24 | #include <linux/mfd/pcf50633/core.h> | 24 | #include <linux/mfd/pcf50633/core.h> |
25 | #include <linux/mfd/pcf50633/pmic.h> | 25 | #include <linux/mfd/pcf50633/pmic.h> |
26 | 26 | ||
27 | #define PCF50633_REGULATOR(_name, _id, _n) \ | 27 | #define PCF50633_REGULATOR(_name, _id, _min_uV, _uV_step, _min_sel, _n) \ |
28 | { \ | 28 | { \ |
29 | .name = _name, \ | 29 | .name = _name, \ |
30 | .id = PCF50633_REGULATOR_##_id, \ | 30 | .id = PCF50633_REGULATOR_##_id, \ |
31 | .ops = &pcf50633_regulator_ops, \ | 31 | .ops = &pcf50633_regulator_ops, \ |
32 | .n_voltages = _n, \ | 32 | .n_voltages = _n, \ |
33 | .min_uV = _min_uV, \ | ||
34 | .uV_step = _uV_step, \ | ||
35 | .linear_min_sel = _min_sel, \ | ||
33 | .type = REGULATOR_VOLTAGE, \ | 36 | .type = REGULATOR_VOLTAGE, \ |
34 | .owner = THIS_MODULE, \ | 37 | .owner = THIS_MODULE, \ |
35 | .vsel_reg = PCF50633_REG_##_id##OUT, \ | 38 | .vsel_reg = PCF50633_REG_##_id##OUT, \ |
@@ -38,162 +41,39 @@ | |||
38 | .enable_mask = PCF50633_REGULATOR_ON, \ | 41 | .enable_mask = PCF50633_REGULATOR_ON, \ |
39 | } | 42 | } |
40 | 43 | ||
41 | /* Bits from voltage value */ | ||
42 | static u8 auto_voltage_bits(unsigned int millivolts) | ||
43 | { | ||
44 | if (millivolts < 1800) | ||
45 | return 0x2f; | ||
46 | if (millivolts > 3800) | ||
47 | return 0xff; | ||
48 | |||
49 | millivolts -= 625; | ||
50 | |||
51 | return millivolts / 25; | ||
52 | } | ||
53 | |||
54 | static u8 down_voltage_bits(unsigned int millivolts) | ||
55 | { | ||
56 | if (millivolts < 625) | ||
57 | return 0; | ||
58 | else if (millivolts > 3000) | ||
59 | return 0xff; | ||
60 | |||
61 | millivolts -= 625; | ||
62 | |||
63 | return millivolts / 25; | ||
64 | } | ||
65 | |||
66 | static u8 ldo_voltage_bits(unsigned int millivolts) | ||
67 | { | ||
68 | if (millivolts < 900) | ||
69 | return 0; | ||
70 | else if (millivolts > 3600) | ||
71 | return 0x1f; | ||
72 | |||
73 | millivolts -= 900; | ||
74 | return millivolts / 100; | ||
75 | } | ||
76 | |||
77 | /* Obtain voltage value from bits */ | ||
78 | static unsigned int auto_voltage_value(u8 bits) | ||
79 | { | ||
80 | /* AUTOOUT: 00000000 to 00101110 are reserved. | ||
81 | * Return 0 for bits in reserved range, which means this selector code | ||
82 | * can't be used on this system */ | ||
83 | if (bits < 0x2f) | ||
84 | return 0; | ||
85 | |||
86 | return 625 + (bits * 25); | ||
87 | } | ||
88 | |||
89 | |||
90 | static unsigned int down_voltage_value(u8 bits) | ||
91 | { | ||
92 | return 625 + (bits * 25); | ||
93 | } | ||
94 | |||
95 | |||
96 | static unsigned int ldo_voltage_value(u8 bits) | ||
97 | { | ||
98 | bits &= 0x1f; | ||
99 | |||
100 | return 900 + (bits * 100); | ||
101 | } | ||
102 | |||
103 | static int pcf50633_regulator_map_voltage(struct regulator_dev *rdev, | ||
104 | int min_uV, int max_uV) | ||
105 | { | ||
106 | struct pcf50633 *pcf; | ||
107 | int regulator_id, millivolts; | ||
108 | u8 volt_bits; | ||
109 | |||
110 | pcf = rdev_get_drvdata(rdev); | ||
111 | |||
112 | regulator_id = rdev_get_id(rdev); | ||
113 | if (regulator_id >= PCF50633_NUM_REGULATORS) | ||
114 | return -EINVAL; | ||
115 | |||
116 | millivolts = min_uV / 1000; | ||
117 | |||
118 | switch (regulator_id) { | ||
119 | case PCF50633_REGULATOR_AUTO: | ||
120 | volt_bits = auto_voltage_bits(millivolts); | ||
121 | break; | ||
122 | case PCF50633_REGULATOR_DOWN1: | ||
123 | case PCF50633_REGULATOR_DOWN2: | ||
124 | volt_bits = down_voltage_bits(millivolts); | ||
125 | break; | ||
126 | case PCF50633_REGULATOR_LDO1: | ||
127 | case PCF50633_REGULATOR_LDO2: | ||
128 | case PCF50633_REGULATOR_LDO3: | ||
129 | case PCF50633_REGULATOR_LDO4: | ||
130 | case PCF50633_REGULATOR_LDO5: | ||
131 | case PCF50633_REGULATOR_LDO6: | ||
132 | case PCF50633_REGULATOR_HCLDO: | ||
133 | case PCF50633_REGULATOR_MEMLDO: | ||
134 | volt_bits = ldo_voltage_bits(millivolts); | ||
135 | break; | ||
136 | default: | ||
137 | return -EINVAL; | ||
138 | } | ||
139 | |||
140 | return volt_bits; | ||
141 | } | ||
142 | |||
143 | static int pcf50633_regulator_list_voltage(struct regulator_dev *rdev, | ||
144 | unsigned int index) | ||
145 | { | ||
146 | int regulator_id = rdev_get_id(rdev); | ||
147 | |||
148 | int millivolts; | ||
149 | |||
150 | switch (regulator_id) { | ||
151 | case PCF50633_REGULATOR_AUTO: | ||
152 | millivolts = auto_voltage_value(index); | ||
153 | break; | ||
154 | case PCF50633_REGULATOR_DOWN1: | ||
155 | case PCF50633_REGULATOR_DOWN2: | ||
156 | millivolts = down_voltage_value(index); | ||
157 | break; | ||
158 | case PCF50633_REGULATOR_LDO1: | ||
159 | case PCF50633_REGULATOR_LDO2: | ||
160 | case PCF50633_REGULATOR_LDO3: | ||
161 | case PCF50633_REGULATOR_LDO4: | ||
162 | case PCF50633_REGULATOR_LDO5: | ||
163 | case PCF50633_REGULATOR_LDO6: | ||
164 | case PCF50633_REGULATOR_HCLDO: | ||
165 | case PCF50633_REGULATOR_MEMLDO: | ||
166 | millivolts = ldo_voltage_value(index); | ||
167 | break; | ||
168 | default: | ||
169 | return -EINVAL; | ||
170 | } | ||
171 | |||
172 | return millivolts * 1000; | ||
173 | } | ||
174 | |||
175 | static struct regulator_ops pcf50633_regulator_ops = { | 44 | static struct regulator_ops pcf50633_regulator_ops = { |
176 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | 45 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
177 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 46 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
178 | .list_voltage = pcf50633_regulator_list_voltage, | 47 | .list_voltage = regulator_list_voltage_linear, |
179 | .map_voltage = pcf50633_regulator_map_voltage, | 48 | .map_voltage = regulator_map_voltage_linear, |
180 | .enable = regulator_enable_regmap, | 49 | .enable = regulator_enable_regmap, |
181 | .disable = regulator_disable_regmap, | 50 | .disable = regulator_disable_regmap, |
182 | .is_enabled = regulator_is_enabled_regmap, | 51 | .is_enabled = regulator_is_enabled_regmap, |
183 | }; | 52 | }; |
184 | 53 | ||
185 | static const struct regulator_desc regulators[] = { | 54 | static const struct regulator_desc regulators[] = { |
186 | [PCF50633_REGULATOR_AUTO] = PCF50633_REGULATOR("auto", AUTO, 128), | 55 | [PCF50633_REGULATOR_AUTO] = |
187 | [PCF50633_REGULATOR_DOWN1] = PCF50633_REGULATOR("down1", DOWN1, 96), | 56 | PCF50633_REGULATOR("auto", AUTO, 1800000, 25000, 0x2f, 128), |
188 | [PCF50633_REGULATOR_DOWN2] = PCF50633_REGULATOR("down2", DOWN2, 96), | 57 | [PCF50633_REGULATOR_DOWN1] = |
189 | [PCF50633_REGULATOR_LDO1] = PCF50633_REGULATOR("ldo1", LDO1, 28), | 58 | PCF50633_REGULATOR("down1", DOWN1, 625000, 25000, 0, 96), |
190 | [PCF50633_REGULATOR_LDO2] = PCF50633_REGULATOR("ldo2", LDO2, 28), | 59 | [PCF50633_REGULATOR_DOWN2] = |
191 | [PCF50633_REGULATOR_LDO3] = PCF50633_REGULATOR("ldo3", LDO3, 28), | 60 | PCF50633_REGULATOR("down2", DOWN2, 625000, 25000, 0, 96), |
192 | [PCF50633_REGULATOR_LDO4] = PCF50633_REGULATOR("ldo4", LDO4, 28), | 61 | [PCF50633_REGULATOR_LDO1] = |
193 | [PCF50633_REGULATOR_LDO5] = PCF50633_REGULATOR("ldo5", LDO5, 28), | 62 | PCF50633_REGULATOR("ldo1", LDO1, 900000, 100000, 0, 28), |
194 | [PCF50633_REGULATOR_LDO6] = PCF50633_REGULATOR("ldo6", LDO6, 28), | 63 | [PCF50633_REGULATOR_LDO2] = |
195 | [PCF50633_REGULATOR_HCLDO] = PCF50633_REGULATOR("hcldo", HCLDO, 28), | 64 | PCF50633_REGULATOR("ldo2", LDO2, 900000, 100000, 0, 28), |
196 | [PCF50633_REGULATOR_MEMLDO] = PCF50633_REGULATOR("memldo", MEMLDO, 28), | 65 | [PCF50633_REGULATOR_LDO3] = |
66 | PCF50633_REGULATOR("ldo3", LDO3, 900000, 100000, 0, 28), | ||
67 | [PCF50633_REGULATOR_LDO4] = | ||
68 | PCF50633_REGULATOR("ldo4", LDO4, 900000, 100000, 0, 28), | ||
69 | [PCF50633_REGULATOR_LDO5] = | ||
70 | PCF50633_REGULATOR("ldo5", LDO5, 900000, 100000, 0, 28), | ||
71 | [PCF50633_REGULATOR_LDO6] = | ||
72 | PCF50633_REGULATOR("ldo6", LDO6, 900000, 100000, 0, 28), | ||
73 | [PCF50633_REGULATOR_HCLDO] = | ||
74 | PCF50633_REGULATOR("hcldo", HCLDO, 900000, 100000, 0, 28), | ||
75 | [PCF50633_REGULATOR_MEMLDO] = | ||
76 | PCF50633_REGULATOR("memldo", MEMLDO, 900000, 100000, 0, 28), | ||
197 | }; | 77 | }; |
198 | 78 | ||
199 | static int pcf50633_regulator_probe(struct platform_device *pdev) | 79 | static int pcf50633_regulator_probe(struct platform_device *pdev) |
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c index a9c3a4a6cca0..523b1e5e0b4c 100644 --- a/drivers/regulator/tps51632-regulator.c +++ b/drivers/regulator/tps51632-regulator.c | |||
@@ -106,29 +106,23 @@ static int tps51632_dcdc_get_voltage_sel(struct regulator_dev *rdev) | |||
106 | } | 106 | } |
107 | 107 | ||
108 | vsel = data & TPS51632_VOUT_MASK; | 108 | vsel = data & TPS51632_VOUT_MASK; |
109 | 109 | return vsel; | |
110 | if (vsel < TPS51632_MIN_VSEL) | ||
111 | return 0; | ||
112 | else | ||
113 | return vsel - TPS51632_MIN_VSEL; | ||
114 | } | 110 | } |
115 | 111 | ||
116 | static int tps51632_dcdc_set_voltage_sel(struct regulator_dev *rdev, | 112 | static int tps51632_dcdc_set_voltage_sel(struct regulator_dev *rdev, |
117 | unsigned selector) | 113 | unsigned selector) |
118 | { | 114 | { |
119 | struct tps51632_chip *tps = rdev_get_drvdata(rdev); | 115 | struct tps51632_chip *tps = rdev_get_drvdata(rdev); |
120 | int vsel; | ||
121 | int ret; | 116 | int ret; |
122 | unsigned int reg = TPS51632_VOLTAGE_SELECT_REG; | 117 | unsigned int reg = TPS51632_VOLTAGE_SELECT_REG; |
123 | 118 | ||
124 | if (tps->enable_pwm_dvfs) | 119 | if (tps->enable_pwm_dvfs) |
125 | reg = TPS51632_VOLTAGE_BASE_REG; | 120 | reg = TPS51632_VOLTAGE_BASE_REG; |
126 | 121 | ||
127 | vsel = selector + TPS51632_MIN_VSEL; | 122 | if (selector > TPS51632_MAX_VSEL) |
128 | if (vsel > TPS51632_MAX_VSEL) | ||
129 | return -EINVAL; | 123 | return -EINVAL; |
130 | 124 | ||
131 | ret = regmap_write(tps->regmap, TPS51632_VOLTAGE_SELECT_REG, vsel); | 125 | ret = regmap_write(tps->regmap, reg, selector); |
132 | if (ret < 0) | 126 | if (ret < 0) |
133 | dev_err(tps->dev, "reg write failed, err %d\n", ret); | 127 | dev_err(tps->dev, "reg write failed, err %d\n", ret); |
134 | return ret; | 128 | return ret; |
@@ -254,7 +248,8 @@ static int tps51632_probe(struct i2c_client *client, | |||
254 | tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; | 248 | tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; |
255 | tps->desc.min_uV = TPS51632_MIN_VOLATGE; | 249 | tps->desc.min_uV = TPS51632_MIN_VOLATGE; |
256 | tps->desc.uV_step = TPS51632_VOLATGE_STEP_10mV; | 250 | tps->desc.uV_step = TPS51632_VOLATGE_STEP_10mV; |
257 | tps->desc.n_voltages = (TPS51632_MAX_VSEL - TPS51632_MIN_VSEL) + 1; | 251 | tps->desc.linear_min_sel = TPS51632_MIN_VSEL; |
252 | tps->desc.n_voltages = TPS51632_MAX_VSEL + 1; | ||
258 | tps->desc.ops = &tps51632_dcdc_ops; | 253 | tps->desc.ops = &tps51632_dcdc_ops; |
259 | tps->desc.type = REGULATOR_VOLTAGE; | 254 | tps->desc.type = REGULATOR_VOLTAGE; |
260 | tps->desc.owner = THIS_MODULE; | 255 | tps->desc.owner = THIS_MODULE; |