diff options
-rw-r--r-- | drivers/regulator/tps65910-regulator.c | 357 | ||||
-rw-r--r-- | include/linux/mfd/tps65910.h | 10 |
2 files changed, 332 insertions, 35 deletions
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 048ba47e058..55dd4e6650d 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
@@ -39,8 +39,17 @@ | |||
39 | #define TPS65910_REG_VAUX33 11 | 39 | #define TPS65910_REG_VAUX33 11 |
40 | #define TPS65910_REG_VMMC 12 | 40 | #define TPS65910_REG_VMMC 12 |
41 | 41 | ||
42 | #define TPS65910_NUM_REGULATOR 13 | 42 | #define TPS65911_REG_VDDCTRL 4 |
43 | #define TPS65911_REG_LDO1 5 | ||
44 | #define TPS65911_REG_LDO2 6 | ||
45 | #define TPS65911_REG_LDO3 7 | ||
46 | #define TPS65911_REG_LDO4 8 | ||
47 | #define TPS65911_REG_LDO5 9 | ||
48 | #define TPS65911_REG_LDO6 10 | ||
49 | #define TPS65911_REG_LDO7 11 | ||
50 | #define TPS65911_REG_LDO8 12 | ||
43 | 51 | ||
52 | #define TPS65910_NUM_REGULATOR 13 | ||
44 | #define TPS65910_SUPPLY_STATE_ENABLED 0x1 | 53 | #define TPS65910_SUPPLY_STATE_ENABLED 0x1 |
45 | 54 | ||
46 | /* supported VIO voltages in milivolts */ | 55 | /* supported VIO voltages in milivolts */ |
@@ -48,7 +57,9 @@ static const u16 VIO_VSEL_table[] = { | |||
48 | 1500, 1800, 2500, 3300, | 57 | 1500, 1800, 2500, 3300, |
49 | }; | 58 | }; |
50 | 59 | ||
51 | /* supported VIO voltages in milivolts */ | 60 | /* VSEL tables for TPS65910 specific LDOs and dcdc's */ |
61 | |||
62 | /* supported VDD3 voltages in milivolts */ | ||
52 | static const u16 VDD3_VSEL_table[] = { | 63 | static const u16 VDD3_VSEL_table[] = { |
53 | 5000, | 64 | 5000, |
54 | }; | 65 | }; |
@@ -187,6 +198,71 @@ static struct tps_info tps65910_regs[] = { | |||
187 | }, | 198 | }, |
188 | }; | 199 | }; |
189 | 200 | ||
201 | static struct tps_info tps65911_regs[] = { | ||
202 | { | ||
203 | .name = "VIO", | ||
204 | .min_uV = 1500000, | ||
205 | .max_uV = 3300000, | ||
206 | .table_len = ARRAY_SIZE(VIO_VSEL_table), | ||
207 | .table = VIO_VSEL_table, | ||
208 | }, | ||
209 | { | ||
210 | .name = "VDD1", | ||
211 | .min_uV = 600000, | ||
212 | .max_uV = 4500000, | ||
213 | }, | ||
214 | { | ||
215 | .name = "VDD2", | ||
216 | .min_uV = 600000, | ||
217 | .max_uV = 4500000, | ||
218 | }, | ||
219 | { | ||
220 | .name = "VDDCTRL", | ||
221 | .min_uV = 600000, | ||
222 | .max_uV = 1400000, | ||
223 | }, | ||
224 | { | ||
225 | .name = "LDO1", | ||
226 | .min_uV = 1000000, | ||
227 | .max_uV = 3300000, | ||
228 | }, | ||
229 | { | ||
230 | .name = "LDO2", | ||
231 | .min_uV = 1000000, | ||
232 | .max_uV = 3300000, | ||
233 | }, | ||
234 | { | ||
235 | .name = "LDO3", | ||
236 | .min_uV = 1000000, | ||
237 | .max_uV = 3300000, | ||
238 | }, | ||
239 | { | ||
240 | .name = "LDO4", | ||
241 | .min_uV = 1000000, | ||
242 | .max_uV = 3300000, | ||
243 | }, | ||
244 | { | ||
245 | .name = "LDO5", | ||
246 | .min_uV = 1000000, | ||
247 | .max_uV = 3300000, | ||
248 | }, | ||
249 | { | ||
250 | .name = "LDO6", | ||
251 | .min_uV = 1000000, | ||
252 | .max_uV = 3300000, | ||
253 | }, | ||
254 | { | ||
255 | .name = "LDO7", | ||
256 | .min_uV = 1000000, | ||
257 | .max_uV = 3300000, | ||
258 | }, | ||
259 | { | ||
260 | .name = "LDO8", | ||
261 | .min_uV = 1000000, | ||
262 | .max_uV = 3300000, | ||
263 | }, | ||
264 | }; | ||
265 | |||
190 | struct tps65910_reg { | 266 | struct tps65910_reg { |
191 | struct regulator_desc desc[TPS65910_NUM_REGULATOR]; | 267 | struct regulator_desc desc[TPS65910_NUM_REGULATOR]; |
192 | struct tps65910 *mfd; | 268 | struct tps65910 *mfd; |
@@ -194,6 +270,7 @@ struct tps65910_reg { | |||
194 | struct tps_info *info[TPS65910_NUM_REGULATOR]; | 270 | struct tps_info *info[TPS65910_NUM_REGULATOR]; |
195 | struct mutex mutex; | 271 | struct mutex mutex; |
196 | int mode; | 272 | int mode; |
273 | int (*get_ctrl_reg)(int); | ||
197 | }; | 274 | }; |
198 | 275 | ||
199 | static inline int tps65910_read(struct tps65910_reg *pmic, u8 reg) | 276 | static inline int tps65910_read(struct tps65910_reg *pmic, u8 reg) |
@@ -300,12 +377,46 @@ static int tps65910_get_ctrl_register(int id) | |||
300 | } | 377 | } |
301 | } | 378 | } |
302 | 379 | ||
380 | static int tps65911_get_ctrl_register(int id) | ||
381 | { | ||
382 | switch (id) { | ||
383 | case TPS65910_REG_VRTC: | ||
384 | return TPS65910_VRTC; | ||
385 | case TPS65910_REG_VIO: | ||
386 | return TPS65910_VIO; | ||
387 | case TPS65910_REG_VDD1: | ||
388 | return TPS65910_VDD1; | ||
389 | case TPS65910_REG_VDD2: | ||
390 | return TPS65910_VDD2; | ||
391 | case TPS65911_REG_VDDCTRL: | ||
392 | return TPS65911_VDDCTRL; | ||
393 | case TPS65911_REG_LDO1: | ||
394 | return TPS65911_LDO1; | ||
395 | case TPS65911_REG_LDO2: | ||
396 | return TPS65911_LDO2; | ||
397 | case TPS65911_REG_LDO3: | ||
398 | return TPS65911_LDO3; | ||
399 | case TPS65911_REG_LDO4: | ||
400 | return TPS65911_LDO4; | ||
401 | case TPS65911_REG_LDO5: | ||
402 | return TPS65911_LDO5; | ||
403 | case TPS65911_REG_LDO6: | ||
404 | return TPS65911_LDO6; | ||
405 | case TPS65911_REG_LDO7: | ||
406 | return TPS65911_LDO7; | ||
407 | case TPS65911_REG_LDO8: | ||
408 | return TPS65911_LDO8; | ||
409 | default: | ||
410 | return -EINVAL; | ||
411 | } | ||
412 | } | ||
413 | |||
303 | static int tps65910_is_enabled(struct regulator_dev *dev) | 414 | static int tps65910_is_enabled(struct regulator_dev *dev) |
304 | { | 415 | { |
305 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | 416 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); |
306 | int reg, value, id = rdev_get_id(dev); | 417 | int reg, value, id = rdev_get_id(dev); |
307 | 418 | ||
308 | reg = tps65910_get_ctrl_register(id); | 419 | reg = pmic->get_ctrl_reg(id); |
309 | if (reg < 0) | 420 | if (reg < 0) |
310 | return reg; | 421 | return reg; |
311 | 422 | ||
@@ -322,7 +433,7 @@ static int tps65910_enable(struct regulator_dev *dev) | |||
322 | struct tps65910 *mfd = pmic->mfd; | 433 | struct tps65910 *mfd = pmic->mfd; |
323 | int reg, id = rdev_get_id(dev); | 434 | int reg, id = rdev_get_id(dev); |
324 | 435 | ||
325 | reg = tps65910_get_ctrl_register(id); | 436 | reg = pmic->get_ctrl_reg(id); |
326 | if (reg < 0) | 437 | if (reg < 0) |
327 | return reg; | 438 | return reg; |
328 | 439 | ||
@@ -335,7 +446,7 @@ static int tps65910_disable(struct regulator_dev *dev) | |||
335 | struct tps65910 *mfd = pmic->mfd; | 446 | struct tps65910 *mfd = pmic->mfd; |
336 | int reg, id = rdev_get_id(dev); | 447 | int reg, id = rdev_get_id(dev); |
337 | 448 | ||
338 | reg = tps65910_get_ctrl_register(id); | 449 | reg = pmic->get_ctrl_reg(id); |
339 | if (reg < 0) | 450 | if (reg < 0) |
340 | return reg; | 451 | return reg; |
341 | 452 | ||
@@ -348,7 +459,8 @@ static int tps65910_set_mode(struct regulator_dev *dev, unsigned int mode) | |||
348 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | 459 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); |
349 | struct tps65910 *mfd = pmic->mfd; | 460 | struct tps65910 *mfd = pmic->mfd; |
350 | int reg, value, id = rdev_get_id(dev); | 461 | int reg, value, id = rdev_get_id(dev); |
351 | reg = tps65910_get_ctrl_register(id); | 462 | |
463 | reg = pmic->get_ctrl_reg(id); | ||
352 | if (reg < 0) | 464 | if (reg < 0) |
353 | return reg; | 465 | return reg; |
354 | 466 | ||
@@ -371,7 +483,7 @@ static unsigned int tps65910_get_mode(struct regulator_dev *dev) | |||
371 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | 483 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); |
372 | int reg, value, id = rdev_get_id(dev); | 484 | int reg, value, id = rdev_get_id(dev); |
373 | 485 | ||
374 | reg = tps65910_get_ctrl_register(id); | 486 | reg = pmic->get_ctrl_reg(id); |
375 | if (reg < 0) | 487 | if (reg < 0) |
376 | return reg; | 488 | return reg; |
377 | 489 | ||
@@ -391,7 +503,7 @@ static int tps65910_get_voltage_dcdc(struct regulator_dev *dev) | |||
391 | { | 503 | { |
392 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | 504 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); |
393 | int id = rdev_get_id(dev), voltage = 0; | 505 | int id = rdev_get_id(dev), voltage = 0; |
394 | int opvsel = 0, srvsel = 0, mult = 0, sr = 0; | 506 | int opvsel = 0, srvsel = 0, vselmax = 0, mult = 0, sr = 0; |
395 | 507 | ||
396 | switch (id) { | 508 | switch (id) { |
397 | case TPS65910_REG_VDD1: | 509 | case TPS65910_REG_VDD1: |
@@ -402,6 +514,7 @@ static int tps65910_get_voltage_dcdc(struct regulator_dev *dev) | |||
402 | sr = opvsel & VDD1_OP_CMD_MASK; | 514 | sr = opvsel & VDD1_OP_CMD_MASK; |
403 | opvsel &= VDD1_OP_SEL_MASK; | 515 | opvsel &= VDD1_OP_SEL_MASK; |
404 | srvsel &= VDD1_SR_SEL_MASK; | 516 | srvsel &= VDD1_SR_SEL_MASK; |
517 | vselmax = 75; | ||
405 | break; | 518 | break; |
406 | case TPS65910_REG_VDD2: | 519 | case TPS65910_REG_VDD2: |
407 | opvsel = tps65910_reg_read(pmic, TPS65910_VDD2_OP); | 520 | opvsel = tps65910_reg_read(pmic, TPS65910_VDD2_OP); |
@@ -411,6 +524,15 @@ static int tps65910_get_voltage_dcdc(struct regulator_dev *dev) | |||
411 | sr = opvsel & VDD2_OP_CMD_MASK; | 524 | sr = opvsel & VDD2_OP_CMD_MASK; |
412 | opvsel &= VDD2_OP_SEL_MASK; | 525 | opvsel &= VDD2_OP_SEL_MASK; |
413 | srvsel &= VDD2_SR_SEL_MASK; | 526 | srvsel &= VDD2_SR_SEL_MASK; |
527 | vselmax = 75; | ||
528 | break; | ||
529 | case TPS65911_REG_VDDCTRL: | ||
530 | opvsel = tps65910_reg_read(pmic, TPS65911_VDDCTRL_OP); | ||
531 | srvsel = tps65910_reg_read(pmic, TPS65911_VDDCTRL_SR); | ||
532 | sr = opvsel & VDDCTRL_OP_CMD_MASK; | ||
533 | opvsel &= VDDCTRL_OP_SEL_MASK; | ||
534 | srvsel &= VDDCTRL_SR_SEL_MASK; | ||
535 | vselmax = 64; | ||
414 | break; | 536 | break; |
415 | } | 537 | } |
416 | 538 | ||
@@ -419,17 +541,21 @@ static int tps65910_get_voltage_dcdc(struct regulator_dev *dev) | |||
419 | mult=1; | 541 | mult=1; |
420 | 542 | ||
421 | if (sr) { | 543 | if (sr) { |
422 | /* Valid range is 3-75 so normalise */ | 544 | /* normalise to valid range */ |
423 | if (srvsel < 3) srvsel = 3; | 545 | if (srvsel < 3) |
424 | if (srvsel > 75) srvsel = 75; | 546 | srvsel = 3; |
547 | if (srvsel > vselmax) | ||
548 | srvsel = vselmax; | ||
425 | srvsel -= 3; | 549 | srvsel -= 3; |
426 | 550 | ||
427 | voltage = (srvsel * VDD1_2_OFFSET + VDD1_2_MIN_VOLT) * 100; | 551 | voltage = (srvsel * VDD1_2_OFFSET + VDD1_2_MIN_VOLT) * 100; |
428 | } else { | 552 | } else { |
429 | 553 | ||
430 | /* Valid range is 3-75 so normalise */ | 554 | /* normalise to valid range*/ |
431 | if (opvsel < 3) opvsel = 3; | 555 | if (opvsel < 3) |
432 | if (opvsel > 75) opvsel = 75; | 556 | opvsel = 3; |
557 | if (opvsel > vselmax) | ||
558 | opvsel = vselmax; | ||
433 | opvsel -= 3; | 559 | opvsel -= 3; |
434 | 560 | ||
435 | voltage = (opvsel * VDD1_2_OFFSET + VDD1_2_MIN_VOLT) * 100; | 561 | voltage = (opvsel * VDD1_2_OFFSET + VDD1_2_MIN_VOLT) * 100; |
@@ -445,7 +571,7 @@ static int tps65910_get_voltage(struct regulator_dev *dev) | |||
445 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | 571 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); |
446 | int reg, value, id = rdev_get_id(dev), voltage = 0; | 572 | int reg, value, id = rdev_get_id(dev), voltage = 0; |
447 | 573 | ||
448 | reg = tps65910_get_ctrl_register(id); | 574 | reg = pmic->get_ctrl_reg(id); |
449 | if (reg < 0) | 575 | if (reg < 0) |
450 | return reg; | 576 | return reg; |
451 | 577 | ||
@@ -480,29 +606,88 @@ static int tps65910_get_voltage_vdd3(struct regulator_dev *dev) | |||
480 | return 5 * 1000 * 1000; | 606 | return 5 * 1000 * 1000; |
481 | } | 607 | } |
482 | 608 | ||
609 | static int tps65911_get_voltage(struct regulator_dev *dev) | ||
610 | { | ||
611 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
612 | int step_mv, id = rdev_get_id(dev); | ||
613 | u8 value, reg; | ||
614 | |||
615 | reg = pmic->get_ctrl_reg(id); | ||
616 | |||
617 | value = tps65910_reg_read(pmic, reg); | ||
618 | |||
619 | switch (id) { | ||
620 | case TPS65911_REG_LDO1: | ||
621 | case TPS65911_REG_LDO2: | ||
622 | case TPS65911_REG_LDO4: | ||
623 | value &= LDO1_SEL_MASK; | ||
624 | value >>= LDO_SEL_SHIFT; | ||
625 | /* The first 5 values of the selector correspond to 1V */ | ||
626 | if (value < 5) | ||
627 | value = 0; | ||
628 | else | ||
629 | value -= 4; | ||
630 | |||
631 | step_mv = 50; | ||
632 | break; | ||
633 | case TPS65911_REG_LDO3: | ||
634 | case TPS65911_REG_LDO5: | ||
635 | case TPS65911_REG_LDO6: | ||
636 | case TPS65911_REG_LDO7: | ||
637 | case TPS65911_REG_LDO8: | ||
638 | value &= LDO3_SEL_MASK; | ||
639 | value >>= LDO_SEL_SHIFT; | ||
640 | /* The first 3 values of the selector correspond to 1V */ | ||
641 | if (value < 3) | ||
642 | value = 0; | ||
643 | else | ||
644 | value -= 2; | ||
645 | |||
646 | step_mv = 100; | ||
647 | break; | ||
648 | case TPS65910_REG_VIO: | ||
649 | return pmic->info[id]->table[value] * 1000; | ||
650 | break; | ||
651 | default: | ||
652 | return -EINVAL; | ||
653 | } | ||
654 | |||
655 | return (LDO_MIN_VOLT + value * step_mv) * 1000; | ||
656 | } | ||
657 | |||
483 | static int tps65910_set_voltage_dcdc(struct regulator_dev *dev, | 658 | static int tps65910_set_voltage_dcdc(struct regulator_dev *dev, |
484 | unsigned selector) | 659 | unsigned selector) |
485 | { | 660 | { |
486 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | 661 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); |
487 | int id = rdev_get_id(dev), vsel; | 662 | int id = rdev_get_id(dev), vsel; |
488 | int dcdc_mult; | 663 | int dcdc_mult = 0; |
489 | 664 | ||
490 | /* Split vsel into appropriate registers */ | 665 | switch (id) { |
491 | dcdc_mult = (selector / VDD1_2_NUM_VOLTS) + 1; | 666 | case TPS65910_REG_VDD1: |
492 | if (dcdc_mult == 1) dcdc_mult--; | 667 | dcdc_mult = (selector / VDD1_2_NUM_VOLTS) + 1; |
493 | 668 | if (dcdc_mult == 1) | |
494 | vsel = (selector % VDD1_2_NUM_VOLTS) + 3; | 669 | dcdc_mult--; |
670 | vsel = (selector % VDD1_2_NUM_VOLTS) + 3; | ||
495 | 671 | ||
496 | if (id == TPS65910_REG_VDD1) { | ||
497 | tps65910_modify_bits(pmic, TPS65910_VDD1, | 672 | tps65910_modify_bits(pmic, TPS65910_VDD1, |
498 | (dcdc_mult << VDD1_VGAIN_SEL_SHIFT), | 673 | (dcdc_mult << VDD1_VGAIN_SEL_SHIFT), |
499 | VDD1_VGAIN_SEL_MASK); | 674 | VDD1_VGAIN_SEL_MASK); |
500 | tps65910_reg_write(pmic, TPS65910_VDD1_OP, vsel); | 675 | tps65910_reg_write(pmic, TPS65910_VDD1_OP, vsel); |
501 | } else { | 676 | break; |
677 | case TPS65910_REG_VDD2: | ||
678 | dcdc_mult = (selector / VDD1_2_NUM_VOLTS) + 1; | ||
679 | if (dcdc_mult == 1) | ||
680 | dcdc_mult--; | ||
681 | vsel = (selector % VDD1_2_NUM_VOLTS) + 3; | ||
682 | |||
502 | tps65910_modify_bits(pmic, TPS65910_VDD2, | 683 | tps65910_modify_bits(pmic, TPS65910_VDD2, |
503 | (dcdc_mult << VDD2_VGAIN_SEL_SHIFT), | 684 | (dcdc_mult << VDD2_VGAIN_SEL_SHIFT), |
504 | VDD1_VGAIN_SEL_MASK); | 685 | VDD1_VGAIN_SEL_MASK); |
505 | tps65910_reg_write(pmic, TPS65910_VDD2_OP, vsel); | 686 | tps65910_reg_write(pmic, TPS65910_VDD2_OP, vsel); |
687 | break; | ||
688 | case TPS65911_REG_VDDCTRL: | ||
689 | vsel = selector; | ||
690 | tps65910_reg_write(pmic, TPS65911_VDDCTRL_OP, vsel); | ||
506 | } | 691 | } |
507 | 692 | ||
508 | return 0; | 693 | return 0; |
@@ -513,7 +698,7 @@ static int tps65910_set_voltage(struct regulator_dev *dev, unsigned selector) | |||
513 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | 698 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); |
514 | int reg, id = rdev_get_id(dev); | 699 | int reg, id = rdev_get_id(dev); |
515 | 700 | ||
516 | reg = tps65910_get_ctrl_register(id); | 701 | reg = pmic->get_ctrl_reg(id); |
517 | if (reg < 0) | 702 | if (reg < 0) |
518 | return reg; | 703 | return reg; |
519 | 704 | ||
@@ -534,14 +719,49 @@ static int tps65910_set_voltage(struct regulator_dev *dev, unsigned selector) | |||
534 | return -EINVAL; | 719 | return -EINVAL; |
535 | } | 720 | } |
536 | 721 | ||
722 | static int tps65911_set_voltage(struct regulator_dev *dev, unsigned selector) | ||
723 | { | ||
724 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
725 | int reg, id = rdev_get_id(dev); | ||
726 | |||
727 | reg = pmic->get_ctrl_reg(id); | ||
728 | if (reg < 0) | ||
729 | return reg; | ||
730 | |||
731 | switch (id) { | ||
732 | case TPS65911_REG_LDO1: | ||
733 | case TPS65911_REG_LDO2: | ||
734 | case TPS65911_REG_LDO4: | ||
735 | return tps65910_modify_bits(pmic, reg, | ||
736 | (selector << LDO_SEL_SHIFT), LDO1_SEL_MASK); | ||
737 | case TPS65911_REG_LDO3: | ||
738 | case TPS65911_REG_LDO5: | ||
739 | case TPS65911_REG_LDO6: | ||
740 | case TPS65911_REG_LDO7: | ||
741 | case TPS65911_REG_LDO8: | ||
742 | case TPS65910_REG_VIO: | ||
743 | return tps65910_modify_bits(pmic, reg, | ||
744 | (selector << LDO_SEL_SHIFT), LDO3_SEL_MASK); | ||
745 | } | ||
746 | |||
747 | return -EINVAL; | ||
748 | } | ||
749 | |||
750 | |||
537 | static int tps65910_list_voltage_dcdc(struct regulator_dev *dev, | 751 | static int tps65910_list_voltage_dcdc(struct regulator_dev *dev, |
538 | unsigned selector) | 752 | unsigned selector) |
539 | { | 753 | { |
540 | int mult, volt; | 754 | int volt, mult = 1, id = rdev_get_id(dev); |
541 | |||
542 | mult = (selector / VDD1_2_NUM_VOLTS) + 1; | ||
543 | 755 | ||
544 | volt = VDD1_2_MIN_VOLT + (selector % VDD1_2_NUM_VOLTS) * VDD1_2_OFFSET; | 756 | switch (id) { |
757 | case TPS65910_REG_VDD1: | ||
758 | case TPS65910_REG_VDD2: | ||
759 | mult = (selector / VDD1_2_NUM_VOLTS) + 1; | ||
760 | volt = VDD1_2_MIN_VOLT + | ||
761 | (selector % VDD1_2_NUM_VOLTS) * VDD1_2_OFFSET; | ||
762 | case TPS65911_REG_VDDCTRL: | ||
763 | volt = VDDCTRL_MIN_VOLT + (selector * VDDCTRL_OFFSET); | ||
764 | } | ||
545 | 765 | ||
546 | return volt * 100 * mult; | 766 | return volt * 100 * mult; |
547 | } | 767 | } |
@@ -563,6 +783,45 @@ static int tps65910_list_voltage(struct regulator_dev *dev, | |||
563 | return voltage; | 783 | return voltage; |
564 | } | 784 | } |
565 | 785 | ||
786 | static int tps65911_list_voltage(struct regulator_dev *dev, unsigned selector) | ||
787 | { | ||
788 | struct tps65910_reg *pmic = rdev_get_drvdata(dev); | ||
789 | int step_mv = 0, id = rdev_get_id(dev); | ||
790 | |||
791 | switch(id) { | ||
792 | case TPS65911_REG_LDO1: | ||
793 | case TPS65911_REG_LDO2: | ||
794 | case TPS65911_REG_LDO4: | ||
795 | /* The first 5 values of the selector correspond to 1V */ | ||
796 | if (selector < 5) | ||
797 | selector = 0; | ||
798 | else | ||
799 | selector -= 4; | ||
800 | |||
801 | step_mv = 50; | ||
802 | break; | ||
803 | case TPS65911_REG_LDO3: | ||
804 | case TPS65911_REG_LDO5: | ||
805 | case TPS65911_REG_LDO6: | ||
806 | case TPS65911_REG_LDO7: | ||
807 | case TPS65911_REG_LDO8: | ||
808 | /* The first 3 values of the selector correspond to 1V */ | ||
809 | if (selector < 3) | ||
810 | selector = 0; | ||
811 | else | ||
812 | selector -= 2; | ||
813 | |||
814 | step_mv = 100; | ||
815 | break; | ||
816 | case TPS65910_REG_VIO: | ||
817 | return pmic->info[id]->table[selector] * 1000; | ||
818 | default: | ||
819 | return -EINVAL; | ||
820 | } | ||
821 | |||
822 | return (LDO_MIN_VOLT + selector * step_mv) * 1000; | ||
823 | } | ||
824 | |||
566 | /* Regulator ops (except VRTC) */ | 825 | /* Regulator ops (except VRTC) */ |
567 | static struct regulator_ops tps65910_ops_dcdc = { | 826 | static struct regulator_ops tps65910_ops_dcdc = { |
568 | .is_enabled = tps65910_is_enabled, | 827 | .is_enabled = tps65910_is_enabled, |
@@ -596,10 +855,21 @@ static struct regulator_ops tps65910_ops = { | |||
596 | .list_voltage = tps65910_list_voltage, | 855 | .list_voltage = tps65910_list_voltage, |
597 | }; | 856 | }; |
598 | 857 | ||
858 | static struct regulator_ops tps65911_ops = { | ||
859 | .is_enabled = tps65910_is_enabled, | ||
860 | .enable = tps65910_enable, | ||
861 | .disable = tps65910_disable, | ||
862 | .set_mode = tps65910_set_mode, | ||
863 | .get_mode = tps65910_get_mode, | ||
864 | .get_voltage = tps65911_get_voltage, | ||
865 | .set_voltage_sel = tps65911_set_voltage, | ||
866 | .list_voltage = tps65911_list_voltage, | ||
867 | }; | ||
868 | |||
599 | static __devinit int tps65910_probe(struct platform_device *pdev) | 869 | static __devinit int tps65910_probe(struct platform_device *pdev) |
600 | { | 870 | { |
601 | struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); | 871 | struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); |
602 | struct tps_info *info = tps65910_regs; | 872 | struct tps_info *info; |
603 | struct regulator_init_data *reg_data; | 873 | struct regulator_init_data *reg_data; |
604 | struct regulator_dev *rdev; | 874 | struct regulator_dev *rdev; |
605 | struct tps65910_reg *pmic; | 875 | struct tps65910_reg *pmic; |
@@ -624,6 +894,18 @@ static __devinit int tps65910_probe(struct platform_device *pdev) | |||
624 | tps65910_set_bits(pmic->mfd, TPS65910_DEVCTRL, | 894 | tps65910_set_bits(pmic->mfd, TPS65910_DEVCTRL, |
625 | DEVCTRL_SR_CTL_I2C_SEL_MASK); | 895 | DEVCTRL_SR_CTL_I2C_SEL_MASK); |
626 | 896 | ||
897 | switch(tps65910_chip_id(tps65910)) { | ||
898 | case TPS65910: | ||
899 | pmic->get_ctrl_reg = &tps65910_get_ctrl_register; | ||
900 | info = tps65910_regs; | ||
901 | case TPS65911: | ||
902 | pmic->get_ctrl_reg = &tps65911_get_ctrl_register; | ||
903 | info = tps65911_regs; | ||
904 | default: | ||
905 | pr_err("Invalid tps chip version\n"); | ||
906 | return -ENODEV; | ||
907 | } | ||
908 | |||
627 | for (i = 0; i < TPS65910_NUM_REGULATOR; i++, info++, reg_data++) { | 909 | for (i = 0; i < TPS65910_NUM_REGULATOR; i++, info++, reg_data++) { |
628 | /* Register the regulators */ | 910 | /* Register the regulators */ |
629 | pmic->info[i] = info; | 911 | pmic->info[i] = info; |
@@ -632,12 +914,19 @@ static __devinit int tps65910_probe(struct platform_device *pdev) | |||
632 | pmic->desc[i].id = i; | 914 | pmic->desc[i].id = i; |
633 | pmic->desc[i].n_voltages = info->table_len; | 915 | pmic->desc[i].n_voltages = info->table_len; |
634 | 916 | ||
635 | if ((i == TPS65910_REG_VDD1) || (i == TPS65910_REG_VDD2)) | 917 | if (i == TPS65910_REG_VDD1 || i == TPS65910_REG_VDD2) { |
636 | pmic->desc[i].ops = &tps65910_ops_dcdc; | 918 | pmic->desc[i].ops = &tps65910_ops_dcdc; |
637 | else if (i == TPS65910_REG_VDD3) | 919 | } else if (i == TPS65910_REG_VDD3) { |
638 | pmic->desc[i].ops = &tps65910_ops_vdd3; | 920 | if (tps65910_chip_id(tps65910) == TPS65910) |
639 | else | 921 | pmic->desc[i].ops = &tps65910_ops_vdd3; |
640 | pmic->desc[i].ops = &tps65910_ops; | 922 | else |
923 | pmic->desc[i].ops = &tps65910_ops_dcdc; | ||
924 | } else { | ||
925 | if (tps65910_chip_id(tps65910) == TPS65910) | ||
926 | pmic->desc[i].ops = &tps65910_ops; | ||
927 | else | ||
928 | pmic->desc[i].ops = &tps65911_ops; | ||
929 | } | ||
641 | 930 | ||
642 | pmic->desc[i].type = REGULATOR_VOLTAGE; | 931 | pmic->desc[i].type = REGULATOR_VOLTAGE; |
643 | pmic->desc[i].owner = THIS_MODULE; | 932 | pmic->desc[i].owner = THIS_MODULE; |
diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h index 6ceea0dab8d..20359e669ae 100644 --- a/include/linux/mfd/tps65910.h +++ b/include/linux/mfd/tps65910.h | |||
@@ -232,7 +232,6 @@ | |||
232 | #define VDD2_OP_SEL_MASK 0x7F | 232 | #define VDD2_OP_SEL_MASK 0x7F |
233 | #define VDD2_OP_SEL_SHIFT 0 | 233 | #define VDD2_OP_SEL_SHIFT 0 |
234 | 234 | ||
235 | |||
236 | /*Register VDD2_SR (0x80) register.RegisterDescription */ | 235 | /*Register VDD2_SR (0x80) register.RegisterDescription */ |
237 | #define VDD2_SR_SEL_MASK 0x7F | 236 | #define VDD2_SR_SEL_MASK 0x7F |
238 | #define VDD2_SR_SEL_SHIFT 0 | 237 | #define VDD2_SR_SEL_SHIFT 0 |
@@ -249,6 +248,8 @@ | |||
249 | #define VDD3_CKINEN_SHIFT 2 | 248 | #define VDD3_CKINEN_SHIFT 2 |
250 | #define VDD3_ST_MASK 0x03 | 249 | #define VDD3_ST_MASK 0x03 |
251 | #define VDD3_ST_SHIFT 0 | 250 | #define VDD3_ST_SHIFT 0 |
251 | #define VDDCTRL_MIN_VOLT 6000 | ||
252 | #define VDDCTRL_OFFSET 125 | ||
252 | 253 | ||
253 | /*Registers VDIG (0x80) to VDAC register.RegisterDescription */ | 254 | /*Registers VDIG (0x80) to VDAC register.RegisterDescription */ |
254 | #define LDO_SEL_MASK 0x0C | 255 | #define LDO_SEL_MASK 0x0C |
@@ -259,6 +260,13 @@ | |||
259 | #define LDO_ST_MODE_BIT 0x02 | 260 | #define LDO_ST_MODE_BIT 0x02 |
260 | 261 | ||
261 | 262 | ||
263 | /* Registers LDO1 to LDO8 in tps65910 */ | ||
264 | #define LDO1_SEL_MASK 0xFC | ||
265 | #define LDO3_SEL_MASK 0x7C | ||
266 | #define LDO_MIN_VOLT 1000 | ||
267 | #define LDO_MAX_VOLT 3300; | ||
268 | |||
269 | |||
262 | /*Register VDIG1 (0x80) register.RegisterDescription */ | 270 | /*Register VDIG1 (0x80) register.RegisterDescription */ |
263 | #define VDIG1_SEL_MASK 0x0C | 271 | #define VDIG1_SEL_MASK 0x0C |
264 | #define VDIG1_SEL_SHIFT 2 | 272 | #define VDIG1_SEL_SHIFT 2 |