| @@ -24,7 +24,7 @@ · 23 unmodified lines |
| 24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
| 25 | | 25 | |
| 26 | /* | 26 | /* |
| 27 | * The TWL4030/TW5030/TPS659x0/TWL6030 family chips include power management, a | 27 | * The TWL4030/TW5030/TPS659x0 family chips include power management, a |
| 28 | * USB OTG transceiver, an RTC, ADC, PWM, and lots more. Some versions | 28 | * USB OTG transceiver, an RTC, ADC, PWM, and lots more. Some versions |
| 29 | * include an audio codec, battery charger, and more voltage regulators. | 29 | * include an audio codec, battery charger, and more voltage regulators. |
| 30 | * These chips are often used in OMAP-based systems. | 30 | * These chips are often used in OMAP-based systems. |
| @@ -48,25 +48,12 @@ struct twlreg_info { · 17 unmodified lines |
| 48 | /* State REMAP default configuration */ | 48 | /* State REMAP default configuration */ |
| 49 | u8 remap; | 49 | u8 remap; |
| 50 | | 50 | |
| 51 | /* chip constraints on regulator behavior */ | | |
| 52 | u16 min_mV; | | |
| 53 | u16 max_mV; | | |
| 54 | | | |
| 55 | u8 flags; | | |
| 56 | | | |
| 57 | /* used by regulator core */ | 51 | /* used by regulator core */ |
| 58 | struct regulator_desc desc; | 52 | struct regulator_desc desc; |
| 59 | | 53 | |
| 60 | /* chip specific features */ | 54 | /* chip specific features */ |
| 61 | unsigned long features; | 55 | unsigned long features; |
| 62 | | 56 | |
| 63 | /* | | |
| 64 | * optional override functions for voltage set/get | | |
| 65 | * these are currently only used for SMPS regulators | | |
| 66 | */ | | |
| 67 | int (*get_voltage)(void *data); | | |
| 68 | int (*set_voltage)(void *data, int target_uV); | | |
| 69 | | | |
| 70 | /* data passed from board for external get/set voltage */ | 57 | /* data passed from board for external get/set voltage */ |
| 71 | void *data; | 58 | void *data; |
| 72 | }; | 59 | }; |
| @@ -88,33 +75,6 @@ struct twlreg_info { · 15 unmodified lines |
| 88 | #define VREG_STATE 2 | 75 | #define VREG_STATE 2 |
| 89 | #define VREG_VOLTAGE 3 | 76 | #define VREG_VOLTAGE 3 |
| 90 | #define VREG_VOLTAGE_SMPS 4 | 77 | #define VREG_VOLTAGE_SMPS 4 |
| 91 | /* TWL6030 Misc register offsets */ | | |
| 92 | #define VREG_BC_ALL 1 | | |
| 93 | #define VREG_BC_REF 2 | | |
| 94 | #define VREG_BC_PROC 3 | | |
| 95 | #define VREG_BC_CLK_RST 4 | | |
| 96 | | | |
| 97 | /* TWL6030 LDO register values for CFG_STATE */ | | |
| 98 | #define TWL6030_CFG_STATE_OFF 0x00 | | |
| 99 | #define TWL6030_CFG_STATE_ON 0x01 | | |
| 100 | #define TWL6030_CFG_STATE_OFF2 0x02 | | |
| 101 | #define TWL6030_CFG_STATE_SLEEP 0x03 | | |
| 102 | #define TWL6030_CFG_STATE_GRP_SHIFT 5 | | |
| 103 | #define TWL6030_CFG_STATE_APP_SHIFT 2 | | |
| 104 | #define TWL6030_CFG_STATE_APP_MASK (0x03 << TWL6030_CFG_STATE_APP_SHIFT) | | |
| 105 | #define TWL6030_CFG_STATE_APP(v) (((v) & TWL6030_CFG_STATE_APP_MASK) >>\ | | |
| 106 | TWL6030_CFG_STATE_APP_SHIFT) | | |
| 107 | | | |
| 108 | /* Flags for SMPS Voltage reading */ | | |
| 109 | #define SMPS_OFFSET_EN BIT(0) | | |
| 110 | #define SMPS_EXTENDED_EN BIT(1) | | |
| 111 | | | |
| 112 | /* twl6032 SMPS EPROM values */ | | |
| 113 | #define TWL6030_SMPS_OFFSET 0xB0 | | |
| 114 | #define TWL6030_SMPS_MULT 0xB3 | | |
| 115 | #define SMPS_MULTOFFSET_SMPS4 BIT(0) | | |
| 116 | #define SMPS_MULTOFFSET_VIO BIT(1) | | |
| 117 | #define SMPS_MULTOFFSET_SMPS3 BIT(6) | | |
| 118 | | 78 | |
| 119 | static inline int | 79 | static inline int |
| 120 | twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset) | 80 | twlreg_read(struct twlreg_info *info, unsigned slave_subgp, unsigned offset) |
| @@ -168,26 +128,6 @@ static int twl4030reg_is_enabled(struct regulator_dev *rdev) · 47 unmodified lines |
| 168 | return state & P1_GRP_4030; | 128 | return state & P1_GRP_4030; |
| 169 | } | 129 | } |
| 170 | | 130 | |
| 171 | static int twl6030reg_is_enabled(struct regulator_dev *rdev) | | |
| 172 | { | | |
| 173 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 174 | int grp = 0, val; | | |
| 175 | | | |
| 176 | if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) { | | |
| 177 | grp = twlreg_grp(rdev); | | |
| 178 | if (grp < 0) | | |
| 179 | return grp; | | |
| 180 | grp &= P1_GRP_6030; | | |
| 181 | } else { | | |
| 182 | grp = 1; | | |
| 183 | } | | |
| 184 | | | |
| 185 | val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); | | |
| 186 | val = TWL6030_CFG_STATE_APP(val); | | |
| 187 | | | |
| 188 | return grp && (val == TWL6030_CFG_STATE_ON); | | |
| 189 | } | | |
| 190 | | | |
| 191 | #define PB_I2C_BUSY BIT(0) | 131 | #define PB_I2C_BUSY BIT(0) |
| 192 | #define PB_I2C_BWEN BIT(1) | 132 | #define PB_I2C_BWEN BIT(1) |
| 193 | | 133 | |
| @@ -273,23 +213,6 @@ static int twl4030reg_enable(struct regulator_dev *rdev) · 79 unmodified lines |
| 273 | return ret; | 213 | return ret; |
| 274 | } | 214 | } |
| 275 | | 215 | |
| 276 | static int twl6030reg_enable(struct regulator_dev *rdev) | | |
| 277 | { | | |
| 278 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 279 | int grp = 0; | | |
| 280 | int ret; | | |
| 281 | | | |
| 282 | if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) | | |
| 283 | grp = twlreg_grp(rdev); | | |
| 284 | if (grp < 0) | | |
| 285 | return grp; | | |
| 286 | | | |
| 287 | ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, | | |
| 288 | grp << TWL6030_CFG_STATE_GRP_SHIFT | | | |
| 289 | TWL6030_CFG_STATE_ON); | | |
| 290 | return ret; | | |
| 291 | } | | |
| 292 | | | |
| 293 | static int twl4030reg_disable(struct regulator_dev *rdev) | 216 | static int twl4030reg_disable(struct regulator_dev *rdev) |
| 294 | { | 217 | { |
| 295 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 218 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| @@ -307,23 +230,6 @@ static int twl4030reg_disable(struct regulator_dev *rdev) · 11 unmodified lines |
| 307 | return ret; | 230 | return ret; |
| 308 | } | 231 | } |
| 309 | | 232 | |
| 310 | static int twl6030reg_disable(struct regulator_dev *rdev) | | |
| 311 | { | | |
| 312 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 313 | int grp = 0; | | |
| 314 | int ret; | | |
| 315 | | | |
| 316 | if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) | | |
| 317 | grp = P1_GRP_6030 | P2_GRP_6030 | P3_GRP_6030; | | |
| 318 | | | |
| 319 | /* For 6030, set the off state for all grps enabled */ | | |
| 320 | ret = twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, | | |
| 321 | (grp) << TWL6030_CFG_STATE_GRP_SHIFT | | | |
| 322 | TWL6030_CFG_STATE_OFF); | | |
| 323 | | | |
| 324 | return ret; | | |
| 325 | } | | |
| 326 | | | |
| 327 | static int twl4030reg_get_status(struct regulator_dev *rdev) | 233 | static int twl4030reg_get_status(struct regulator_dev *rdev) |
| 328 | { | 234 | { |
| 329 | int state = twlreg_grp(rdev); | 235 | int state = twlreg_grp(rdev); |
| @@ -340,33 +246,6 @@ static int twl4030reg_get_status(struct regulator_dev *rdev) · 10 unmodified lines |
| 340 | : REGULATOR_STATUS_STANDBY; | 246 | : REGULATOR_STATUS_STANDBY; |
| 341 | } | 247 | } |
| 342 | | 248 | |
| 343 | static int twl6030reg_get_status(struct regulator_dev *rdev) | | |
| 344 | { | | |
| 345 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 346 | int val; | | |
| 347 | | | |
| 348 | val = twlreg_grp(rdev); | | |
| 349 | if (val < 0) | | |
| 350 | return val; | | |
| 351 | | | |
| 352 | val = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_STATE); | | |
| 353 | | | |
| 354 | switch (TWL6030_CFG_STATE_APP(val)) { | | |
| 355 | case TWL6030_CFG_STATE_ON: | | |
| 356 | return REGULATOR_STATUS_NORMAL; | | |
| 357 | | | |
| 358 | case TWL6030_CFG_STATE_SLEEP: | | |
| 359 | return REGULATOR_STATUS_STANDBY; | | |
| 360 | | | |
| 361 | case TWL6030_CFG_STATE_OFF: | | |
| 362 | case TWL6030_CFG_STATE_OFF2: | | |
| 363 | default: | | |
| 364 | break; | | |
| 365 | } | | |
| 366 | | | |
| 367 | return REGULATOR_STATUS_OFF; | | |
| 368 | } | | |
| 369 | | | |
| 370 | static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode) | 249 | static int twl4030reg_set_mode(struct regulator_dev *rdev, unsigned mode) |
| 371 | { | 250 | { |
| 372 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 251 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| @@ -399,36 +278,6 @@ static inline unsigned int twl4030reg_map_mode(unsigned int mode) · 26 unmodified lines |
| 399 | } | 278 | } |
| 400 | } | 279 | } |
| 401 | | 280 | |
| 402 | static int twl6030reg_set_mode(struct regulator_dev *rdev, unsigned mode) | | |
| 403 | { | | |
| 404 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 405 | int grp = 0; | | |
| 406 | int val; | | |
| 407 | | | |
| 408 | if (!(twl_class_is_6030() && (info->features & TWL6032_SUBCLASS))) | | |
| 409 | grp = twlreg_grp(rdev); | | |
| 410 | | | |
| 411 | if (grp < 0) | | |
| 412 | return grp; | | |
| 413 | | | |
| 414 | /* Compose the state register settings */ | | |
| 415 | val = grp << TWL6030_CFG_STATE_GRP_SHIFT; | | |
| 416 | /* We can only set the mode through state machine commands... */ | | |
| 417 | switch (mode) { | | |
| 418 | case REGULATOR_MODE_NORMAL: | | |
| 419 | val |= TWL6030_CFG_STATE_ON; | | |
| 420 | break; | | |
| 421 | case REGULATOR_MODE_STANDBY: | | |
| 422 | val |= TWL6030_CFG_STATE_SLEEP; | | |
| 423 | break; | | |
| 424 | | | |
| 425 | default: | | |
| 426 | return -EINVAL; | | |
| 427 | } | | |
| 428 | | | |
| 429 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_STATE, val); | | |
| 430 | } | | |
| 431 | | | |
| 432 | /*----------------------------------------------------------------------*/ | 281 | /*----------------------------------------------------------------------*/ |
| 433 | | 282 | |
| 434 | /* | 283 | /* |
| @@ -565,12 +414,7 @@ twl4030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, · 130 unmodified lines |
| 565 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 414 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 566 | int vsel = DIV_ROUND_UP(min_uV - 600000, 12500); | 415 | int vsel = DIV_ROUND_UP(min_uV - 600000, 12500); |
| 567 | | 416 | |
| 568 | if (info->set_voltage) { | 417 | twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS_4030, vsel); |
| 569 | return info->set_voltage(info->data, min_uV); | | |
| 570 | } else { | | |
| 571 | twlreg_write(info, TWL_MODULE_PM_RECEIVER, | | |
| 572 | VREG_VOLTAGE_SMPS_4030, vsel); | | |
| 573 | } | | |
| 574 | | 418 | |
| 575 | return 0; | 419 | return 0; |
| 576 | } | 420 | } |
| @@ -580,9 +424,6 @@ static int twl4030smps_get_voltage(struct regulator_dev *rdev) · 3 unmodified lines |
| 580 | struct twlreg_info *info = rdev_get_drvdata(rdev); | 424 | struct twlreg_info *info = rdev_get_drvdata(rdev); |
| 581 | int vsel; | 425 | int vsel; |
| 582 | | 426 | |
| 583 | if (info->get_voltage) | | |
| 584 | return info->get_voltage(info->data); | | |
| 585 | | | |
| 586 | vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, | 427 | vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, |
| 587 | VREG_VOLTAGE_SMPS_4030); | 428 | VREG_VOLTAGE_SMPS_4030); |
| 588 | | 429 | |
| @@ -594,85 +435,6 @@ static struct regulator_ops twl4030smps_ops = { · 5 unmodified lines |
| 594 | .get_voltage = twl4030smps_get_voltage, | 435 | .get_voltage = twl4030smps_get_voltage, |
| 595 | }; | 436 | }; |
| 596 | | 437 | |
| 597 | static int twl6030coresmps_set_voltage(struct regulator_dev *rdev, int min_uV, | | |
| 598 | int max_uV, unsigned *selector) | | |
| 599 | { | | |
| 600 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 601 | | | |
| 602 | if (info->set_voltage) | | |
| 603 | return info->set_voltage(info->data, min_uV); | | |
| 604 | | | |
| 605 | return -ENODEV; | | |
| 606 | } | | |
| 607 | | | |
| 608 | static int twl6030coresmps_get_voltage(struct regulator_dev *rdev) | | |
| 609 | { | | |
| 610 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 611 | | | |
| 612 | if (info->get_voltage) | | |
| 613 | return info->get_voltage(info->data); | | |
| 614 | | | |
| 615 | return -ENODEV; | | |
| 616 | } | | |
| 617 | | | |
| 618 | static struct regulator_ops twl6030coresmps_ops = { | | |
| 619 | .set_voltage = twl6030coresmps_set_voltage, | | |
| 620 | .get_voltage = twl6030coresmps_get_voltage, | | |
| 621 | }; | | |
| 622 | | | |
| 623 | static int twl6030ldo_list_voltage(struct regulator_dev *rdev, unsigned sel) | | |
| 624 | { | | |
| 625 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 626 | | | |
| 627 | switch (sel) { | | |
| 628 | case 0: | | |
| 629 | return 0; | | |
| 630 | case 1 ... 24: | | |
| 631 | /* Linear mapping from 00000001 to 00011000: | | |
| 632 | * Absolute voltage value = 1.0 V + 0.1 V × (sel – 00000001) | | |
| 633 | */ | | |
| 634 | return (info->min_mV + 100 * (sel - 1)) * 1000; | | |
| 635 | case 25 ... 30: | | |
| 636 | return -EINVAL; | | |
| 637 | case 31: | | |
| 638 | return 2750000; | | |
| 639 | default: | | |
| 640 | return -EINVAL; | | |
| 641 | } | | |
| 642 | } | | |
| 643 | | | |
| 644 | static int | | |
| 645 | twl6030ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) | | |
| 646 | { | | |
| 647 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 648 | | | |
| 649 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE, | | |
| 650 | selector); | | |
| 651 | } | | |
| 652 | | | |
| 653 | static int twl6030ldo_get_voltage_sel(struct regulator_dev *rdev) | | |
| 654 | { | | |
| 655 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 656 | int vsel = twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE); | | |
| 657 | | | |
| 658 | return vsel; | | |
| 659 | } | | |
| 660 | | | |
| 661 | static struct regulator_ops twl6030ldo_ops = { | | |
| 662 | .list_voltage = twl6030ldo_list_voltage, | | |
| 663 | | | |
| 664 | .set_voltage_sel = twl6030ldo_set_voltage_sel, | | |
| 665 | .get_voltage_sel = twl6030ldo_get_voltage_sel, | | |
| 666 | | | |
| 667 | .enable = twl6030reg_enable, | | |
| 668 | .disable = twl6030reg_disable, | | |
| 669 | .is_enabled = twl6030reg_is_enabled, | | |
| 670 | | | |
| 671 | .set_mode = twl6030reg_set_mode, | | |
| 672 | | | |
| 673 | .get_status = twl6030reg_get_status, | | |
| 674 | }; | | |
| 675 | | | |
| 676 | /*----------------------------------------------------------------------*/ | 438 | /*----------------------------------------------------------------------*/ |
| 677 | | 439 | |
| 678 | static struct regulator_ops twl4030fixed_ops = { | 440 | static struct regulator_ops twl4030fixed_ops = { |
| @@ -687,226 +449,8 @@ static struct regulator_ops twl4030fixed_ops = { · 8 unmodified lines |
| 687 | .get_status = twl4030reg_get_status, | 449 | .get_status = twl4030reg_get_status, |
| 688 | }; | 450 | }; |
| 689 | | 451 | |
| 690 | static struct regulator_ops twl6030fixed_ops = { | | |
| 691 | .list_voltage = regulator_list_voltage_linear, | | |
| 692 | | | |
| 693 | .enable = twl6030reg_enable, | | |
| 694 | .disable = twl6030reg_disable, | | |
| 695 | .is_enabled = twl6030reg_is_enabled, | | |
| 696 | | | |
| 697 | .set_mode = twl6030reg_set_mode, | | |
| 698 | | | |
| 699 | .get_status = twl6030reg_get_status, | | |
| 700 | }; | | |
| 701 | | | |
| 702 | /* | | |
| 703 | * SMPS status and control | | |
| 704 | */ | | |
| 705 | | | |
| 706 | static int twl6030smps_list_voltage(struct regulator_dev *rdev, unsigned index) | | |
| 707 | { | | |
| 708 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 709 | | | |
| 710 | int voltage = 0; | | |
| 711 | | | |
| 712 | switch (info->flags) { | | |
| 713 | case SMPS_OFFSET_EN: | | |
| 714 | voltage = 100000; | | |
| 715 | /* fall through */ | | |
| 716 | case 0: | | |
| 717 | switch (index) { | | |
| 718 | case 0: | | |
| 719 | voltage = 0; | | |
| 720 | break; | | |
| 721 | case 58: | | |
| 722 | voltage = 1350 * 1000; | | |
| 723 | break; | | |
| 724 | case 59: | | |
| 725 | voltage = 1500 * 1000; | | |
| 726 | break; | | |
| 727 | case 60: | | |
| 728 | voltage = 1800 * 1000; | | |
| 729 | break; | | |
| 730 | case 61: | | |
| 731 | voltage = 1900 * 1000; | | |
| 732 | break; | | |
| 733 | case 62: | | |
| 734 | voltage = 2100 * 1000; | | |
| 735 | break; | | |
| 736 | default: | | |
| 737 | voltage += (600000 + (12500 * (index - 1))); | | |
| 738 | } | | |
| 739 | break; | | |
| 740 | case SMPS_EXTENDED_EN: | | |
| 741 | switch (index) { | | |
| 742 | case 0: | | |
| 743 | voltage = 0; | | |
| 744 | break; | | |
| 745 | case 58: | | |
| 746 | voltage = 2084 * 1000; | | |
| 747 | break; | | |
| 748 | case 59: | | |
| 749 | voltage = 2315 * 1000; | | |
| 750 | break; | | |
| 751 | case 60: | | |
| 752 | voltage = 2778 * 1000; | | |
| 753 | break; | | |
| 754 | case 61: | | |
| 755 | voltage = 2932 * 1000; | | |
| 756 | break; | | |
| 757 | case 62: | | |
| 758 | voltage = 3241 * 1000; | | |
| 759 | break; | | |
| 760 | default: | | |
| 761 | voltage = (1852000 + (38600 * (index - 1))); | | |
| 762 | } | | |
| 763 | break; | | |
| 764 | case SMPS_OFFSET_EN | SMPS_EXTENDED_EN: | | |
| 765 | switch (index) { | | |
| 766 | case 0: | | |
| 767 | voltage = 0; | | |
| 768 | break; | | |
| 769 | case 58: | | |
| 770 | voltage = 4167 * 1000; | | |
| 771 | break; | | |
| 772 | case 59: | | |
| 773 | voltage = 2315 * 1000; | | |
| 774 | break; | | |
| 775 | case 60: | | |
| 776 | voltage = 2778 * 1000; | | |
| 777 | break; | | |
| 778 | case 61: | | |
| 779 | voltage = 2932 * 1000; | | |
| 780 | break; | | |
| 781 | case 62: | | |
| 782 | voltage = 3241 * 1000; | | |
| 783 | break; | | |
| 784 | default: | | |
| 785 | voltage = (2161000 + (38600 * (index - 1))); | | |
| 786 | } | | |
| 787 | break; | | |
| 788 | } | | |
| 789 | | | |
| 790 | return voltage; | | |
| 791 | } | | |
| 792 | | | |
| 793 | static int twl6030smps_map_voltage(struct regulator_dev *rdev, int min_uV, | | |
| 794 | int max_uV) | | |
| 795 | { | | |
| 796 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 797 | int vsel = 0; | | |
| 798 | | | |
| 799 | switch (info->flags) { | | |
| 800 | case 0: | | |
| 801 | if (min_uV == 0) | | |
| 802 | vsel = 0; | | |
| 803 | else if ((min_uV >= 600000) && (min_uV <= 1300000)) { | | |
| 804 | vsel = DIV_ROUND_UP(min_uV - 600000, 12500); | | |
| 805 | vsel++; | | |
| 806 | } | | |
| 807 | /* Values 1..57 for vsel are linear and can be calculated | | |
| 808 | * values 58..62 are non linear. | | |
| 809 | */ | | |
| 810 | else if ((min_uV > 1900000) && (min_uV <= 2100000)) | | |
| 811 | vsel = 62; | | |
| 812 | else if ((min_uV > 1800000) && (min_uV <= 1900000)) | | |
| 813 | vsel = 61; | | |
| 814 | else if ((min_uV > 1500000) && (min_uV <= 1800000)) | | |
| 815 | vsel = 60; | | |
| 816 | else if ((min_uV > 1350000) && (min_uV <= 1500000)) | | |
| 817 | vsel = 59; | | |
| 818 | else if ((min_uV > 1300000) && (min_uV <= 1350000)) | | |
| 819 | vsel = 58; | | |
| 820 | else | | |
| 821 | return -EINVAL; | | |
| 822 | break; | | |
| 823 | case SMPS_OFFSET_EN: | | |
| 824 | if (min_uV == 0) | | |
| 825 | vsel = 0; | | |
| 826 | else if ((min_uV >= 700000) && (min_uV <= 1420000)) { | | |
| 827 | vsel = DIV_ROUND_UP(min_uV - 700000, 12500); | | |
| 828 | vsel++; | | |
| 829 | } | | |
| 830 | /* Values 1..57 for vsel are linear and can be calculated | | |
| 831 | * values 58..62 are non linear. | | |
| 832 | */ | | |
| 833 | else if ((min_uV > 1900000) && (min_uV <= 2100000)) | | |
| 834 | vsel = 62; | | |
| 835 | else if ((min_uV > 1800000) && (min_uV <= 1900000)) | | |
| 836 | vsel = 61; | | |
| 837 | else if ((min_uV > 1350000) && (min_uV <= 1800000)) | | |
| 838 | vsel = 60; | | |
| 839 | else if ((min_uV > 1350000) && (min_uV <= 1500000)) | | |
| 840 | vsel = 59; | | |
| 841 | else if ((min_uV > 1300000) && (min_uV <= 1350000)) | | |
| 842 | vsel = 58; | | |
| 843 | else | | |
| 844 | return -EINVAL; | | |
| 845 | break; | | |
| 846 | case SMPS_EXTENDED_EN: | | |
| 847 | if (min_uV == 0) { | | |
| 848 | vsel = 0; | | |
| 849 | } else if ((min_uV >= 1852000) && (max_uV <= 4013600)) { | | |
| 850 | vsel = DIV_ROUND_UP(min_uV - 1852000, 38600); | | |
| 851 | vsel++; | | |
| 852 | } | | |
| 853 | break; | | |
| 854 | case SMPS_OFFSET_EN|SMPS_EXTENDED_EN: | | |
| 855 | if (min_uV == 0) { | | |
| 856 | vsel = 0; | | |
| 857 | } else if ((min_uV >= 2161000) && (min_uV <= 4321000)) { | | |
| 858 | vsel = DIV_ROUND_UP(min_uV - 2161000, 38600); | | |
| 859 | vsel++; | | |
| 860 | } | | |
| 861 | break; | | |
| 862 | } | | |
| 863 | | | |
| 864 | return vsel; | | |
| 865 | } | | |
| 866 | | | |
| 867 | static int twl6030smps_set_voltage_sel(struct regulator_dev *rdev, | | |
| 868 | unsigned int selector) | | |
| 869 | { | | |
| 870 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 871 | | | |
| 872 | return twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS, | | |
| 873 | selector); | | |
| 874 | } | | |
| 875 | | | |
| 876 | static int twl6030smps_get_voltage_sel(struct regulator_dev *rdev) | | |
| 877 | { | | |
| 878 | struct twlreg_info *info = rdev_get_drvdata(rdev); | | |
| 879 | | | |
| 880 | return twlreg_read(info, TWL_MODULE_PM_RECEIVER, VREG_VOLTAGE_SMPS); | | |
| 881 | } | | |
| 882 | | | |
| 883 | static struct regulator_ops twlsmps_ops = { | | |
| 884 | .list_voltage = twl6030smps_list_voltage, | | |
| 885 | .map_voltage = twl6030smps_map_voltage, | | |
| 886 | | | |
| 887 | .set_voltage_sel = twl6030smps_set_voltage_sel, | | |
| 888 | .get_voltage_sel = twl6030smps_get_voltage_sel, | | |
| 889 | | | |
| 890 | .enable = twl6030reg_enable, | | |
| 891 | .disable = twl6030reg_disable, | | |
| 892 | .is_enabled = twl6030reg_is_enabled, | | |
| 893 | | | |
| 894 | .set_mode = twl6030reg_set_mode, | | |
| 895 | | | |
| 896 | .get_status = twl6030reg_get_status, | | |
| 897 | }; | | |
| 898 | | | |
| 899 | /*----------------------------------------------------------------------*/ | 452 | /*----------------------------------------------------------------------*/ |
| 900 | | 453 | |
| 901 | #define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | | |
| 902 | remap_conf) \ | | |
| 903 | TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ | | |
| 904 | remap_conf, TWL4030, twl4030fixed_ops, \ | | |
| 905 | twl4030reg_map_mode) | | |
| 906 | #define TWL6030_FIXED_LDO(label, offset, mVolts, turnon_delay) \ | | |
| 907 | TWL_FIXED_LDO(label, offset, mVolts, 0x0, turnon_delay, \ | | |
| 908 | 0x0, TWL6030, twl6030fixed_ops, NULL) | | |
| 909 | | | |
| 910 | #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \ | 454 | #define TWL4030_ADJUSTABLE_LDO(label, offset, num, turnon_delay, remap_conf) \ |
| 911 | static const struct twlreg_info TWL4030_INFO_##label = { \ | 455 | static const struct twlreg_info TWL4030_INFO_##label = { \ |
| 912 | .base = offset, \ | 456 | .base = offset, \ |
| @@ -942,79 +486,22 @@ static const struct twlreg_info TWL4030_INFO_##label = { \ · 29 unmodified lines |
| 942 | }, \ | 486 | }, \ |
| 943 | } | 487 | } |
| 944 | | 488 | |
| 945 | #define TWL6030_ADJUSTABLE_SMPS(label) \ | 489 | #define TWL4030_FIXED_LDO(label, offset, mVolts, num, turnon_delay, \ |
| 946 | static const struct twlreg_info TWL6030_INFO_##label = { \ | 490 | remap_conf) \ |
| 947 | .desc = { \ | | |
| 948 | .name = #label, \ | | |
| 949 | .id = TWL6030_REG_##label, \ | | |
| 950 | .ops = &twl6030coresmps_ops, \ | | |
| 951 | .type = REGULATOR_VOLTAGE, \ | | |
| 952 | .owner = THIS_MODULE, \ | | |
| 953 | }, \ | | |
| 954 | } | | |
| 955 | | | |
| 956 | #define TWL6030_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \ | | |
| 957 | static const struct twlreg_info TWL6030_INFO_##label = { \ | | |
| 958 | .base = offset, \ | | |
| 959 | .min_mV = min_mVolts, \ | | |
| 960 | .max_mV = max_mVolts, \ | | |
| 961 | .desc = { \ | | |
| 962 | .name = #label, \ | | |
| 963 | .id = TWL6030_REG_##label, \ | | |
| 964 | .n_voltages = 32, \ | | |
| 965 | .ops = &twl6030ldo_ops, \ | | |
| 966 | .type = REGULATOR_VOLTAGE, \ | | |
| 967 | .owner = THIS_MODULE, \ | | |
| 968 | }, \ | | |
| 969 | } | | |
| 970 | | | |
| 971 | #define TWL6032_ADJUSTABLE_LDO(label, offset, min_mVolts, max_mVolts) \ | | |
| 972 | static const struct twlreg_info TWL6032_INFO_##label = { \ | | |
| 973 | .base = offset, \ | | |
| 974 | .min_mV = min_mVolts, \ | | |
| 975 | .max_mV = max_mVolts, \ | | |
| 976 | .desc = { \ | | |
| 977 | .name = #label, \ | | |
| 978 | .id = TWL6032_REG_##label, \ | | |
| 979 | .n_voltages = 32, \ | | |
| 980 | .ops = &twl6030ldo_ops, \ | | |
| 981 | .type = REGULATOR_VOLTAGE, \ | | |
| 982 | .owner = THIS_MODULE, \ | | |
| 983 | }, \ | | |
| 984 | } | | |
| 985 | | | |
| 986 | #define TWL_FIXED_LDO(label, offset, mVolts, num, turnon_delay, remap_conf, \ | | |
| 987 | family, operations, map_mode) \ | | |
| 988 | static const struct twlreg_info TWLFIXED_INFO_##label = { \ | 491 | static const struct twlreg_info TWLFIXED_INFO_##label = { \ |
| 989 | .base = offset, \ | 492 | .base = offset, \ |
| 990 | .id = num, \ | 493 | .id = num, \ |
| 991 | .min_mV = mVolts, \ | | |
| 992 | .remap = remap_conf, \ | 494 | .remap = remap_conf, \ |
| 993 | .desc = { \ | 495 | .desc = { \ |
| 994 | .name = #label, \ | 496 | .name = #label, \ |
| 995 | .id = family##_REG_##label, \ | 497 | .id = TWL4030##_REG_##label, \ |
| 996 | .n_voltages = 1, \ | 498 | .n_voltages = 1, \ |
| 997 | .ops = &operations, \ | 499 | .ops = &twl4030fixed_ops, \ |
| 998 | .type = REGULATOR_VOLTAGE, \ | 500 | .type = REGULATOR_VOLTAGE, \ |
| 999 | .owner = THIS_MODULE, \ | 501 | .owner = THIS_MODULE, \ |
| 1000 | .min_uV = mVolts * 1000, \ | 502 | .min_uV = mVolts * 1000, \ |
| 1001 | .enable_time = turnon_delay, \ | 503 | .enable_time = turnon_delay, \ |
| 1002 | .of_map_mode = map_mode, \ | 504 | .of_map_mode = twl4030reg_map_mode, \ |
| 1003 | }, \ | | |
| 1004 | } | | |
| 1005 | | | |
| 1006 | #define TWL6032_ADJUSTABLE_SMPS(label, offset) \ | | |
| 1007 | static const struct twlreg_info TWLSMPS_INFO_##label = { \ | | |
| 1008 | .base = offset, \ | | |
| 1009 | .min_mV = 600, \ | | |
| 1010 | .max_mV = 2100, \ | | |
| 1011 | .desc = { \ | | |
| 1012 | .name = #label, \ | | |
| 1013 | .id = TWL6032_REG_##label, \ | | |
| 1014 | .n_voltages = 63, \ | | |
| 1015 | .ops = &twlsmps_ops, \ | | |
| 1016 | .type = REGULATOR_VOLTAGE, \ | | |
| 1017 | .owner = THIS_MODULE, \ | | |
| 1018 | }, \ | 505 | }, \ |
| 1019 | } | 506 | } |
| 1020 | | 507 | |
| @@ -1038,60 +525,11 @@ TWL4030_ADJUSTABLE_LDO(VIO, 0x4b, 14, 1000, 0x08); · 17 unmodified lines |
| 1038 | TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08); | 525 | TWL4030_ADJUSTABLE_SMPS(VDD1, 0x55, 15, 1000, 0x08); |
| 1039 | TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08); | 526 | TWL4030_ADJUSTABLE_SMPS(VDD2, 0x63, 16, 1000, 0x08); |
| 1040 | /* VUSBCP is managed *only* by the USB subchip */ | 527 | /* VUSBCP is managed *only* by the USB subchip */ |
| 1041 | /* 6030 REG with base as PMC Slave Misc : 0x0030 */ | | |
| 1042 | /* Turnon-delay and remap configuration values for 6030 are not | | |
| 1043 | verified since the specification is not public */ | | |
| 1044 | TWL6030_ADJUSTABLE_SMPS(VDD1); | | |
| 1045 | TWL6030_ADJUSTABLE_SMPS(VDD2); | | |
| 1046 | TWL6030_ADJUSTABLE_SMPS(VDD3); | | |
| 1047 | TWL6030_ADJUSTABLE_LDO(VAUX1_6030, 0x54, 1000, 3300); | | |
| 1048 | TWL6030_ADJUSTABLE_LDO(VAUX2_6030, 0x58, 1000, 3300); | | |
| 1049 | TWL6030_ADJUSTABLE_LDO(VAUX3_6030, 0x5c, 1000, 3300); | | |
| 1050 | TWL6030_ADJUSTABLE_LDO(VMMC, 0x68, 1000, 3300); | | |
| 1051 | TWL6030_ADJUSTABLE_LDO(VPP, 0x6c, 1000, 3300); | | |
| 1052 | TWL6030_ADJUSTABLE_LDO(VUSIM, 0x74, 1000, 3300); | | |
| 1053 | /* 6025 are renamed compared to 6030 versions */ | | |
| 1054 | TWL6032_ADJUSTABLE_LDO(LDO2, 0x54, 1000, 3300); | | |
| 1055 | TWL6032_ADJUSTABLE_LDO(LDO4, 0x58, 1000, 3300); | | |
| 1056 | TWL6032_ADJUSTABLE_LDO(LDO3, 0x5c, 1000, 3300); | | |
| 1057 | TWL6032_ADJUSTABLE_LDO(LDO5, 0x68, 1000, 3300); | | |
| 1058 | TWL6032_ADJUSTABLE_LDO(LDO1, 0x6c, 1000, 3300); | | |
| 1059 | TWL6032_ADJUSTABLE_LDO(LDO7, 0x74, 1000, 3300); | | |
| 1060 | TWL6032_ADJUSTABLE_LDO(LDO6, 0x60, 1000, 3300); | | |
| 1061 | TWL6032_ADJUSTABLE_LDO(LDOLN, 0x64, 1000, 3300); | | |
| 1062 | TWL6032_ADJUSTABLE_LDO(LDOUSB, 0x70, 1000, 3300); | | |
| 1063 | TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08); | 528 | TWL4030_FIXED_LDO(VINTANA1, 0x3f, 1500, 11, 100, 0x08); |
| 1064 | TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08); | 529 | TWL4030_FIXED_LDO(VINTDIG, 0x47, 1500, 13, 100, 0x08); |
| 1065 | TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08); | 530 | TWL4030_FIXED_LDO(VUSB1V5, 0x71, 1500, 17, 100, 0x08); |
| 1066 | TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08); | 531 | TWL4030_FIXED_LDO(VUSB1V8, 0x74, 1800, 18, 100, 0x08); |
| 1067 | TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08); | 532 | TWL4030_FIXED_LDO(VUSB3V1, 0x77, 3100, 19, 150, 0x08); |
| 1068 | TWL6030_FIXED_LDO(VANA, 0x50, 2100, 0); | | |
| 1069 | TWL6030_FIXED_LDO(VCXIO, 0x60, 1800, 0); | | |
| 1070 | TWL6030_FIXED_LDO(VDAC, 0x64, 1800, 0); | | |
| 1071 | TWL6030_FIXED_LDO(VUSB, 0x70, 3300, 0); | | |
| 1072 | TWL6030_FIXED_LDO(V1V8, 0x16, 1800, 0); | | |
| 1073 | TWL6030_FIXED_LDO(V2V1, 0x1c, 2100, 0); | | |
| 1074 | TWL6032_ADJUSTABLE_SMPS(SMPS3, 0x34); | | |
| 1075 | TWL6032_ADJUSTABLE_SMPS(SMPS4, 0x10); | | |
| 1076 | TWL6032_ADJUSTABLE_SMPS(VIO, 0x16); | | |
| 1077 | | | |
| 1078 | static u8 twl_get_smps_offset(void) | | |
| 1079 | { | | |
| 1080 | u8 value; | | |
| 1081 | | | |
| 1082 | twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value, | | |
| 1083 | TWL6030_SMPS_OFFSET); | | |
| 1084 | return value; | | |
| 1085 | } | | |
| 1086 | | | |
| 1087 | static u8 twl_get_smps_mult(void) | | |
| 1088 | { | | |
| 1089 | u8 value; | | |
| 1090 | | | |
| 1091 | twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &value, | | |
| 1092 | TWL6030_SMPS_MULT); | | |
| 1093 | return value; | | |
| 1094 | } | | |
| 1095 | | 533 | |
| 1096 | #define TWL_OF_MATCH(comp, family, label) \ | 534 | #define TWL_OF_MATCH(comp, family, label) \ |
| 1097 | { \ | 535 | { \ |
| @@ -1121,81 +559,37 @@ static const struct of_device_id twl_of_match[] = { · 23 unmodified lines |
| 1121 | TWL4030_OF_MATCH("ti,twl4030-vio", VIO), | 559 | TWL4030_OF_MATCH("ti,twl4030-vio", VIO), |
| 1122 | TWL4030_OF_MATCH("ti,twl4030-vdd1", VDD1), | 560 | TWL4030_OF_MATCH("ti,twl4030-vdd1", VDD1), |
| 1123 | TWL4030_OF_MATCH("ti,twl4030-vdd2", VDD2), | 561 | TWL4030_OF_MATCH("ti,twl4030-vdd2", VDD2), |
| 1124 | TWL6030_OF_MATCH("ti,twl6030-vdd1", VDD1), | | |
| 1125 | TWL6030_OF_MATCH("ti,twl6030-vdd2", VDD2), | | |
| 1126 | TWL6030_OF_MATCH("ti,twl6030-vdd3", VDD3), | | |
| 1127 | TWL6030_OF_MATCH("ti,twl6030-vaux1", VAUX1_6030), | | |
| 1128 | TWL6030_OF_MATCH("ti,twl6030-vaux2", VAUX2_6030), | | |
| 1129 | TWL6030_OF_MATCH("ti,twl6030-vaux3", VAUX3_6030), | | |
| 1130 | TWL6030_OF_MATCH("ti,twl6030-vmmc", VMMC), | | |
| 1131 | TWL6030_OF_MATCH("ti,twl6030-vpp", VPP), | | |
| 1132 | TWL6030_OF_MATCH("ti,twl6030-vusim", VUSIM), | | |
| 1133 | TWL6032_OF_MATCH("ti,twl6032-ldo2", LDO2), | | |
| 1134 | TWL6032_OF_MATCH("ti,twl6032-ldo4", LDO4), | | |
| 1135 | TWL6032_OF_MATCH("ti,twl6032-ldo3", LDO3), | | |
| 1136 | TWL6032_OF_MATCH("ti,twl6032-ldo5", LDO5), | | |
| 1137 | TWL6032_OF_MATCH("ti,twl6032-ldo1", LDO1), | | |
| 1138 | TWL6032_OF_MATCH("ti,twl6032-ldo7", LDO7), | | |
| 1139 | TWL6032_OF_MATCH("ti,twl6032-ldo6", LDO6), | | |
| 1140 | TWL6032_OF_MATCH("ti,twl6032-ldoln", LDOLN), | | |
| 1141 | TWL6032_OF_MATCH("ti,twl6032-ldousb", LDOUSB), | | |
| 1142 | TWLFIXED_OF_MATCH("ti,twl4030-vintana1", VINTANA1), | 562 | TWLFIXED_OF_MATCH("ti,twl4030-vintana1", VINTANA1), |
| 1143 | TWLFIXED_OF_MATCH("ti,twl4030-vintdig", VINTDIG), | 563 | TWLFIXED_OF_MATCH("ti,twl4030-vintdig", VINTDIG), |
| 1144 | TWLFIXED_OF_MATCH("ti,twl4030-vusb1v5", VUSB1V5), | 564 | TWLFIXED_OF_MATCH("ti,twl4030-vusb1v5", VUSB1V5), |
| 1145 | TWLFIXED_OF_MATCH("ti,twl4030-vusb1v8", VUSB1V8), | 565 | TWLFIXED_OF_MATCH("ti,twl4030-vusb1v8", VUSB1V8), |
| 1146 | TWLFIXED_OF_MATCH("ti,twl4030-vusb3v1", VUSB3V1), | 566 | TWLFIXED_OF_MATCH("ti,twl4030-vusb3v1", VUSB3V1), |
| 1147 | TWLFIXED_OF_MATCH("ti,twl6030-vana", VANA), | | |
| 1148 | TWLFIXED_OF_MATCH("ti,twl6030-vcxio", VCXIO), | | |
| 1149 | TWLFIXED_OF_MATCH("ti,twl6030-vdac", VDAC), | | |
| 1150 | TWLFIXED_OF_MATCH("ti,twl6030-vusb", VUSB), | | |
| 1151 | TWLFIXED_OF_MATCH("ti,twl6030-v1v8", V1V8), | | |
| 1152 | TWLFIXED_OF_MATCH("ti,twl6030-v2v1", V2V1), | | |
| 1153 | TWLSMPS_OF_MATCH("ti,twl6032-smps3", SMPS3), | | |
| 1154 | TWLSMPS_OF_MATCH("ti,twl6032-smps4", SMPS4), | | |
| 1155 | TWLSMPS_OF_MATCH("ti,twl6032-vio", VIO), | | |
| 1156 | {}, | 567 | {}, |
| 1157 | }; | 568 | }; |
| 1158 | MODULE_DEVICE_TABLE(of, twl_of_match); | 569 | MODULE_DEVICE_TABLE(of, twl_of_match); |
| 1159 | | 570 | |
| 1160 | static int twlreg_probe(struct platform_device *pdev) | 571 | static int twlreg_probe(struct platform_device *pdev) |
| 1161 | { | 572 | { |
| 1162 | int i, id; | 573 | int id; |
| 1163 | struct twlreg_info *info; | 574 | struct twlreg_info *info; |
| 1164 | const struct twlreg_info *template; | 575 | const struct twlreg_info *template; |
| 1165 | struct regulator_init_data *initdata; | 576 | struct regulator_init_data *initdata; |
| 1166 | struct regulation_constraints *c; | 577 | struct regulation_constraints *c; |
| 1167 | struct regulator_dev *rdev; | 578 | struct regulator_dev *rdev; |
| 1168 | struct twl_regulator_driver_data *drvdata; | | |
| 1169 | const struct of_device_id *match; | 579 | const struct of_device_id *match; |
| 1170 | struct regulator_config config = { }; | 580 | struct regulator_config config = { }; |
| 1171 | | 581 | |
| 1172 | match = of_match_device(twl_of_match, &pdev->dev); | 582 | match = of_match_device(twl_of_match, &pdev->dev); |
| 1173 | if (match) { | 583 | if (!match) |
| 1174 | template = match->data; | 584 | return -ENODEV; |
| 1175 | id = template->desc.id; | | |
| 1176 | initdata = of_get_regulator_init_data(&pdev->dev, | | |
| 1177 | pdev->dev.of_node, | | |
| 1178 | &template->desc); | | |
| 1179 | drvdata = NULL; | | |
| 1180 | } else { | | |
| 1181 | id = pdev->id; | | |
| 1182 | initdata = dev_get_platdata(&pdev->dev); | | |
| 1183 | for (i = 0, template = NULL; i < ARRAY_SIZE(twl_of_match); i++) { | | |
| 1184 | template = twl_of_match[i].data; | | |
| 1185 | if (template && template->desc.id == id) | | |
| 1186 | break; | | |
| 1187 | } | | |
| 1188 | if (i == ARRAY_SIZE(twl_of_match)) | | |
| 1189 | return -ENODEV; | | |
| 1190 | | | |
| 1191 | drvdata = initdata->driver_data; | | |
| 1192 | if (!drvdata) | | |
| 1193 | return -EINVAL; | | |
| 1194 | } | | |
| 1195 | | 585 | |
| | 586 | template = match->data; |
| 1196 | if (!template) | 587 | if (!template) |
| 1197 | return -ENODEV; | 588 | return -ENODEV; |
| 1198 | | 589 | |
| | 590 | id = template->desc.id; |
| | 591 | initdata = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node, |
| | 592 | &template->desc); |
| 1199 | if (!initdata) | 593 | if (!initdata) |
| 1200 | return -EINVAL; | 594 | return -EINVAL; |
| 1201 | | 595 | |
| @@ -1203,14 +597,6 @@ static int twlreg_probe(struct platform_device *pdev) · 1 unmodified line |
| 1203 | if (!info) | 597 | if (!info) |
| 1204 | return -ENOMEM; | 598 | return -ENOMEM; |
| 1205 | | 599 | |
| 1206 | if (drvdata) { | | |
| 1207 | /* copy the driver data into regulator data */ | | |
| 1208 | info->features = drvdata->features; | | |
| 1209 | info->data = drvdata->data; | | |
| 1210 | info->set_voltage = drvdata->set_voltage; | | |
| 1211 | info->get_voltage = drvdata->get_voltage; | | |
| 1212 | } | | |
| 1213 | | | |
| 1214 | /* Constrain board-specific capabilities according to what | 600 | /* Constrain board-specific capabilities according to what |
| 1215 | * this driver and the chip itself can actually do. | 601 | * this driver and the chip itself can actually do. |
| 1216 | */ | 602 | */ |
| @@ -1233,27 +619,6 @@ static int twlreg_probe(struct platform_device *pdev) · 16 unmodified lines |
| 1233 | break; | 619 | break; |
| 1234 | } | 620 | } |
| 1235 | | 621 | |
| 1236 | switch (id) { | | |
| 1237 | case TWL6032_REG_SMPS3: | | |
| 1238 | if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS3) | | |
| 1239 | info->flags |= SMPS_EXTENDED_EN; | | |
| 1240 | if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS3) | | |
| 1241 | info->flags |= SMPS_OFFSET_EN; | | |
| 1242 | break; | | |
| 1243 | case TWL6032_REG_SMPS4: | | |
| 1244 | if (twl_get_smps_mult() & SMPS_MULTOFFSET_SMPS4) | | |
| 1245 | info->flags |= SMPS_EXTENDED_EN; | | |
| 1246 | if (twl_get_smps_offset() & SMPS_MULTOFFSET_SMPS4) | | |
| 1247 | info->flags |= SMPS_OFFSET_EN; | | |
| 1248 | break; | | |
| 1249 | case TWL6032_REG_VIO: | | |
| 1250 | if (twl_get_smps_mult() & SMPS_MULTOFFSET_VIO) | | |
| 1251 | info->flags |= SMPS_EXTENDED_EN; | | |
| 1252 | if (twl_get_smps_offset() & SMPS_MULTOFFSET_VIO) | | |
| 1253 | info->flags |= SMPS_OFFSET_EN; | | |
| 1254 | break; | | |
| 1255 | } | | |
| 1256 | | | |
| 1257 | config.dev = &pdev->dev; | 622 | config.dev = &pdev->dev; |
| 1258 | config.init_data = initdata; | 623 | config.init_data = initdata; |
| 1259 | config.driver_data = info; | 624 | config.driver_data = info; |
| @@ -1267,9 +632,7 @@ static int twlreg_probe(struct platform_device *pdev) · 7 unmodified lines |
| 1267 | } | 632 | } |
| 1268 | platform_set_drvdata(pdev, rdev); | 633 | platform_set_drvdata(pdev, rdev); |
| 1269 | | 634 | |
| 1270 | if (twl_class_is_4030()) | 635 | twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP, info->remap); |
| 1271 | twlreg_write(info, TWL_MODULE_PM_RECEIVER, VREG_REMAP, | | |
| 1272 | info->remap); | | |
| 1273 | | 636 | |
| 1274 | /* NOTE: many regulators support short-circuit IRQs (presentable | 637 | /* NOTE: many regulators support short-circuit IRQs (presentable |
| 1275 | * as REGULATOR_OVER_CURRENT notifications?) configured via: | 638 | * as REGULATOR_OVER_CURRENT notifications?) configured via: |
| @@ -1282,7 +645,7 @@ static int twlreg_probe(struct platform_device *pdev) · 6 unmodified lines |
| 1282 | return 0; | 645 | return 0; |
| 1283 | } | 646 | } |
| 1284 | | 647 | |
| 1285 | MODULE_ALIAS("platform:twl_reg"); | 648 | MODULE_ALIAS("platform:twl4030_reg"); |
| 1286 | | 649 | |
| 1287 | static struct platform_driver twlreg_driver = { | 650 | static struct platform_driver twlreg_driver = { |
| 1288 | .probe = twlreg_probe, | 651 | .probe = twlreg_probe, |
| @@ -1290,7 +653,7 @@ static struct platform_driver twlreg_driver = { · 1 unmodified line |
| 1290 | * "twl_regulator.12" (and friends) to "twl_regulator.1". | 653 | * "twl_regulator.12" (and friends) to "twl_regulator.1". |
| 1291 | */ | 654 | */ |
| 1292 | .driver = { | 655 | .driver = { |
| 1293 | .name = "twl_reg", | 656 | .name = "twl4030_reg", |
| 1294 | .of_match_table = of_match_ptr(twl_of_match), | 657 | .of_match_table = of_match_ptr(twl_of_match), |
| 1295 | }, | 658 | }, |
| 1296 | }; | 659 | }; |
| @@ -1307,5 +670,5 @@ static void __exit twlreg_exit(void) · 10 unmodified lines |
| 1307 | } | 670 | } |
| 1308 | module_exit(twlreg_exit) | 671 | module_exit(twlreg_exit) |
| 1309 | | 672 | |
| 1310 | MODULE_DESCRIPTION("TWL regulator driver"); | 673 | MODULE_DESCRIPTION("TWL4030 regulator driver"); |
| 1311 | MODULE_LICENSE("GPL"); | 674 | MODULE_LICENSE("GPL"); |