| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 5 | | - * it under the terms of the GNU General Public License version 2 and |
|---|
| 6 | | - * only version 2 as published by the Free Software Foundation. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | | - * GNU General Public License for more details. |
|---|
| 12 | 4 | */ |
|---|
| 13 | 5 | |
|---|
| 14 | 6 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 104 | 96 | SPMI_REGULATOR_LOGICAL_TYPE_ULT_LO_SMPS, |
|---|
| 105 | 97 | SPMI_REGULATOR_LOGICAL_TYPE_ULT_HO_SMPS, |
|---|
| 106 | 98 | SPMI_REGULATOR_LOGICAL_TYPE_ULT_LDO, |
|---|
| 99 | + SPMI_REGULATOR_LOGICAL_TYPE_FTSMPS426, |
|---|
| 100 | + SPMI_REGULATOR_LOGICAL_TYPE_HFS430, |
|---|
| 107 | 101 | }; |
|---|
| 108 | 102 | |
|---|
| 109 | 103 | enum spmi_regulator_type { |
|---|
| .. | .. |
|---|
| 141 | 135 | SPMI_REGULATOR_SUBTYPE_LV_P600 = 0x2b, |
|---|
| 142 | 136 | SPMI_REGULATOR_SUBTYPE_LV_P1200 = 0x2c, |
|---|
| 143 | 137 | SPMI_REGULATOR_SUBTYPE_LV_P450 = 0x2d, |
|---|
| 138 | + SPMI_REGULATOR_SUBTYPE_HT_N300_ST = 0x30, |
|---|
| 139 | + SPMI_REGULATOR_SUBTYPE_HT_N600_ST = 0x31, |
|---|
| 140 | + SPMI_REGULATOR_SUBTYPE_HT_N1200_ST = 0x32, |
|---|
| 141 | + SPMI_REGULATOR_SUBTYPE_HT_LVP150 = 0x3b, |
|---|
| 142 | + SPMI_REGULATOR_SUBTYPE_HT_LVP300 = 0x3c, |
|---|
| 143 | + SPMI_REGULATOR_SUBTYPE_L660_N300_ST = 0x42, |
|---|
| 144 | + SPMI_REGULATOR_SUBTYPE_L660_N600_ST = 0x43, |
|---|
| 145 | + SPMI_REGULATOR_SUBTYPE_L660_P50 = 0x46, |
|---|
| 146 | + SPMI_REGULATOR_SUBTYPE_L660_P150 = 0x47, |
|---|
| 147 | + SPMI_REGULATOR_SUBTYPE_L660_P600 = 0x49, |
|---|
| 148 | + SPMI_REGULATOR_SUBTYPE_L660_LVP150 = 0x4d, |
|---|
| 149 | + SPMI_REGULATOR_SUBTYPE_L660_LVP600 = 0x4f, |
|---|
| 144 | 150 | SPMI_REGULATOR_SUBTYPE_LV100 = 0x01, |
|---|
| 145 | 151 | SPMI_REGULATOR_SUBTYPE_LV300 = 0x02, |
|---|
| 146 | 152 | SPMI_REGULATOR_SUBTYPE_MV300 = 0x08, |
|---|
| .. | .. |
|---|
| 150 | 156 | SPMI_REGULATOR_SUBTYPE_5V_BOOST = 0x01, |
|---|
| 151 | 157 | SPMI_REGULATOR_SUBTYPE_FTS_CTL = 0x08, |
|---|
| 152 | 158 | SPMI_REGULATOR_SUBTYPE_FTS2p5_CTL = 0x09, |
|---|
| 159 | + SPMI_REGULATOR_SUBTYPE_FTS426_CTL = 0x0a, |
|---|
| 153 | 160 | SPMI_REGULATOR_SUBTYPE_BB_2A = 0x01, |
|---|
| 154 | 161 | SPMI_REGULATOR_SUBTYPE_ULT_HF_CTL1 = 0x0d, |
|---|
| 155 | 162 | SPMI_REGULATOR_SUBTYPE_ULT_HF_CTL2 = 0x0e, |
|---|
| 156 | 163 | SPMI_REGULATOR_SUBTYPE_ULT_HF_CTL3 = 0x0f, |
|---|
| 157 | 164 | SPMI_REGULATOR_SUBTYPE_ULT_HF_CTL4 = 0x10, |
|---|
| 165 | + SPMI_REGULATOR_SUBTYPE_HFS430 = 0x0a, |
|---|
| 158 | 166 | }; |
|---|
| 159 | 167 | |
|---|
| 160 | 168 | enum spmi_common_regulator_registers { |
|---|
| .. | .. |
|---|
| 168 | 176 | SPMI_COMMON_REG_PULL_DOWN = 0x48, |
|---|
| 169 | 177 | SPMI_COMMON_REG_SOFT_START = 0x4c, |
|---|
| 170 | 178 | SPMI_COMMON_REG_STEP_CTRL = 0x61, |
|---|
| 179 | +}; |
|---|
| 180 | + |
|---|
| 181 | +/* |
|---|
| 182 | + * Second common register layout used by newer devices starting with ftsmps426 |
|---|
| 183 | + * Note that some of the registers from the first common layout remain |
|---|
| 184 | + * unchanged and their definition is not duplicated. |
|---|
| 185 | + */ |
|---|
| 186 | +enum spmi_ftsmps426_regulator_registers { |
|---|
| 187 | + SPMI_FTSMPS426_REG_VOLTAGE_LSB = 0x40, |
|---|
| 188 | + SPMI_FTSMPS426_REG_VOLTAGE_MSB = 0x41, |
|---|
| 189 | + SPMI_FTSMPS426_REG_VOLTAGE_ULS_LSB = 0x68, |
|---|
| 190 | + SPMI_FTSMPS426_REG_VOLTAGE_ULS_MSB = 0x69, |
|---|
| 171 | 191 | }; |
|---|
| 172 | 192 | |
|---|
| 173 | 193 | enum spmi_vs_registers { |
|---|
| .. | .. |
|---|
| 229 | 249 | #define SPMI_COMMON_MODE_FOLLOW_HW_EN0_MASK 0x01 |
|---|
| 230 | 250 | #define SPMI_COMMON_MODE_FOLLOW_ALL_MASK 0x1f |
|---|
| 231 | 251 | |
|---|
| 252 | +#define SPMI_FTSMPS426_MODE_BYPASS_MASK 3 |
|---|
| 253 | +#define SPMI_FTSMPS426_MODE_RETENTION_MASK 4 |
|---|
| 254 | +#define SPMI_FTSMPS426_MODE_LPM_MASK 5 |
|---|
| 255 | +#define SPMI_FTSMPS426_MODE_AUTO_MASK 6 |
|---|
| 256 | +#define SPMI_FTSMPS426_MODE_HPM_MASK 7 |
|---|
| 257 | + |
|---|
| 258 | +#define SPMI_FTSMPS426_MODE_MASK 0x07 |
|---|
| 259 | + |
|---|
| 232 | 260 | /* Common regulator pull down control register layout */ |
|---|
| 233 | 261 | #define SPMI_COMMON_PULL_DOWN_ENABLE_MASK 0x80 |
|---|
| 234 | 262 | |
|---|
| .. | .. |
|---|
| 273 | 301 | */ |
|---|
| 274 | 302 | #define SPMI_FTSMPS_STEP_MARGIN_NUM 4 |
|---|
| 275 | 303 | #define SPMI_FTSMPS_STEP_MARGIN_DEN 5 |
|---|
| 304 | + |
|---|
| 305 | +#define SPMI_FTSMPS426_STEP_CTRL_DELAY_MASK 0x03 |
|---|
| 306 | +#define SPMI_FTSMPS426_STEP_CTRL_DELAY_SHIFT 0 |
|---|
| 307 | + |
|---|
| 308 | +/* Clock rate in kHz of the FTSMPS426 regulator reference clock. */ |
|---|
| 309 | +#define SPMI_FTSMPS426_CLOCK_RATE 4800 |
|---|
| 310 | + |
|---|
| 311 | +#define SPMI_HFS430_CLOCK_RATE 1600 |
|---|
| 312 | + |
|---|
| 313 | +/* Minimum voltage stepper delay for each step. */ |
|---|
| 314 | +#define SPMI_FTSMPS426_STEP_DELAY 2 |
|---|
| 315 | + |
|---|
| 316 | +/* |
|---|
| 317 | + * The ratio SPMI_FTSMPS426_STEP_MARGIN_NUM/SPMI_FTSMPS426_STEP_MARGIN_DEN is |
|---|
| 318 | + * used to adjust the step rate in order to account for oscillator variance. |
|---|
| 319 | + */ |
|---|
| 320 | +#define SPMI_FTSMPS426_STEP_MARGIN_NUM 10 |
|---|
| 321 | +#define SPMI_FTSMPS426_STEP_MARGIN_DEN 11 |
|---|
| 322 | + |
|---|
| 276 | 323 | |
|---|
| 277 | 324 | /* VSET value to decide the range of ULT SMPS */ |
|---|
| 278 | 325 | #define ULT_SMPS_RANGE_SPLIT 0x60 |
|---|
| .. | .. |
|---|
| 345 | 392 | enum spmi_regulator_logical_type logical_type; |
|---|
| 346 | 393 | u32 revision_min; |
|---|
| 347 | 394 | u32 revision_max; |
|---|
| 348 | | - struct regulator_ops *ops; |
|---|
| 395 | + const struct regulator_ops *ops; |
|---|
| 349 | 396 | struct spmi_voltage_set_points *set_points; |
|---|
| 350 | 397 | int hpm_min_load; |
|---|
| 351 | 398 | }; |
|---|
| .. | .. |
|---|
| 447 | 494 | SPMI_VOLTAGE_RANGE(1, 160000, 1360000, 2200000, 2200000, 10000), |
|---|
| 448 | 495 | }; |
|---|
| 449 | 496 | |
|---|
| 497 | +static struct spmi_voltage_range ftsmps426_ranges[] = { |
|---|
| 498 | + SPMI_VOLTAGE_RANGE(0, 0, 320000, 1352000, 1352000, 4000), |
|---|
| 499 | +}; |
|---|
| 500 | + |
|---|
| 450 | 501 | static struct spmi_voltage_range boost_ranges[] = { |
|---|
| 451 | 502 | SPMI_VOLTAGE_RANGE(0, 4000000, 4000000, 5550000, 5550000, 50000), |
|---|
| 452 | 503 | }; |
|---|
| .. | .. |
|---|
| 472 | 523 | SPMI_VOLTAGE_RANGE(0, 1750000, 1750000, 3337500, 3337500, 12500), |
|---|
| 473 | 524 | }; |
|---|
| 474 | 525 | |
|---|
| 526 | +static struct spmi_voltage_range pldo660_ranges[] = { |
|---|
| 527 | + SPMI_VOLTAGE_RANGE(0, 1504000, 1504000, 3544000, 3544000, 8000), |
|---|
| 528 | +}; |
|---|
| 529 | + |
|---|
| 530 | +static struct spmi_voltage_range nldo660_ranges[] = { |
|---|
| 531 | + SPMI_VOLTAGE_RANGE(0, 320000, 320000, 1304000, 1304000, 8000), |
|---|
| 532 | +}; |
|---|
| 533 | + |
|---|
| 534 | +static struct spmi_voltage_range ht_lvpldo_ranges[] = { |
|---|
| 535 | + SPMI_VOLTAGE_RANGE(0, 1504000, 1504000, 2000000, 2000000, 8000), |
|---|
| 536 | +}; |
|---|
| 537 | + |
|---|
| 538 | +static struct spmi_voltage_range ht_nldo_ranges[] = { |
|---|
| 539 | + SPMI_VOLTAGE_RANGE(0, 312000, 312000, 1304000, 1304000, 8000), |
|---|
| 540 | +}; |
|---|
| 541 | + |
|---|
| 542 | +static struct spmi_voltage_range hfs430_ranges[] = { |
|---|
| 543 | + SPMI_VOLTAGE_RANGE(0, 320000, 320000, 2040000, 2040000, 8000), |
|---|
| 544 | +}; |
|---|
| 545 | + |
|---|
| 475 | 546 | static DEFINE_SPMI_SET_POINTS(pldo); |
|---|
| 476 | 547 | static DEFINE_SPMI_SET_POINTS(nldo1); |
|---|
| 477 | 548 | static DEFINE_SPMI_SET_POINTS(nldo2); |
|---|
| .. | .. |
|---|
| 480 | 551 | static DEFINE_SPMI_SET_POINTS(smps); |
|---|
| 481 | 552 | static DEFINE_SPMI_SET_POINTS(ftsmps); |
|---|
| 482 | 553 | static DEFINE_SPMI_SET_POINTS(ftsmps2p5); |
|---|
| 554 | +static DEFINE_SPMI_SET_POINTS(ftsmps426); |
|---|
| 483 | 555 | static DEFINE_SPMI_SET_POINTS(boost); |
|---|
| 484 | 556 | static DEFINE_SPMI_SET_POINTS(boost_byp); |
|---|
| 485 | 557 | static DEFINE_SPMI_SET_POINTS(ult_lo_smps); |
|---|
| 486 | 558 | static DEFINE_SPMI_SET_POINTS(ult_ho_smps); |
|---|
| 487 | 559 | static DEFINE_SPMI_SET_POINTS(ult_nldo); |
|---|
| 488 | 560 | static DEFINE_SPMI_SET_POINTS(ult_pldo); |
|---|
| 561 | +static DEFINE_SPMI_SET_POINTS(pldo660); |
|---|
| 562 | +static DEFINE_SPMI_SET_POINTS(nldo660); |
|---|
| 563 | +static DEFINE_SPMI_SET_POINTS(ht_lvpldo); |
|---|
| 564 | +static DEFINE_SPMI_SET_POINTS(ht_nldo); |
|---|
| 565 | +static DEFINE_SPMI_SET_POINTS(hfs430); |
|---|
| 489 | 566 | |
|---|
| 490 | 567 | static inline int spmi_vreg_read(struct spmi_regulator *vreg, u16 addr, u8 *buf, |
|---|
| 491 | 568 | int len) |
|---|
| .. | .. |
|---|
| 747 | 824 | return spmi_vreg_write(vreg, SPMI_COMMON_REG_VOLTAGE_RANGE, buf, 2); |
|---|
| 748 | 825 | } |
|---|
| 749 | 826 | |
|---|
| 827 | +static int spmi_regulator_common_list_voltage(struct regulator_dev *rdev, |
|---|
| 828 | + unsigned selector); |
|---|
| 829 | + |
|---|
| 830 | +static int spmi_regulator_ftsmps426_set_voltage(struct regulator_dev *rdev, |
|---|
| 831 | + unsigned selector) |
|---|
| 832 | +{ |
|---|
| 833 | + struct spmi_regulator *vreg = rdev_get_drvdata(rdev); |
|---|
| 834 | + u8 buf[2]; |
|---|
| 835 | + int mV; |
|---|
| 836 | + |
|---|
| 837 | + mV = spmi_regulator_common_list_voltage(rdev, selector) / 1000; |
|---|
| 838 | + |
|---|
| 839 | + buf[0] = mV & 0xff; |
|---|
| 840 | + buf[1] = mV >> 8; |
|---|
| 841 | + return spmi_vreg_write(vreg, SPMI_FTSMPS426_REG_VOLTAGE_LSB, buf, 2); |
|---|
| 842 | +} |
|---|
| 843 | + |
|---|
| 750 | 844 | static int spmi_regulator_set_voltage_time_sel(struct regulator_dev *rdev, |
|---|
| 751 | 845 | unsigned int old_selector, unsigned int new_selector) |
|---|
| 752 | 846 | { |
|---|
| 753 | 847 | struct spmi_regulator *vreg = rdev_get_drvdata(rdev); |
|---|
| 754 | | - const struct spmi_voltage_range *range; |
|---|
| 755 | 848 | int diff_uV; |
|---|
| 756 | 849 | |
|---|
| 757 | | - range = spmi_regulator_find_range(vreg); |
|---|
| 758 | | - if (!range) |
|---|
| 759 | | - return -EINVAL; |
|---|
| 760 | | - |
|---|
| 761 | | - diff_uV = abs(new_selector - old_selector) * range->step_uV; |
|---|
| 850 | + diff_uV = abs(spmi_regulator_common_list_voltage(rdev, new_selector) - |
|---|
| 851 | + spmi_regulator_common_list_voltage(rdev, old_selector)); |
|---|
| 762 | 852 | |
|---|
| 763 | 853 | return DIV_ROUND_UP(diff_uV, vreg->slew_rate); |
|---|
| 764 | 854 | } |
|---|
| .. | .. |
|---|
| 776 | 866 | return -EINVAL; |
|---|
| 777 | 867 | |
|---|
| 778 | 868 | return spmi_hw_selector_to_sw(vreg, voltage_sel, range); |
|---|
| 869 | +} |
|---|
| 870 | + |
|---|
| 871 | +static int spmi_regulator_ftsmps426_get_voltage(struct regulator_dev *rdev) |
|---|
| 872 | +{ |
|---|
| 873 | + struct spmi_regulator *vreg = rdev_get_drvdata(rdev); |
|---|
| 874 | + const struct spmi_voltage_range *range; |
|---|
| 875 | + u8 buf[2]; |
|---|
| 876 | + int uV; |
|---|
| 877 | + |
|---|
| 878 | + spmi_vreg_read(vreg, SPMI_FTSMPS426_REG_VOLTAGE_LSB, buf, 2); |
|---|
| 879 | + |
|---|
| 880 | + uV = (((unsigned int)buf[1] << 8) | (unsigned int)buf[0]) * 1000; |
|---|
| 881 | + range = vreg->set_points->range; |
|---|
| 882 | + |
|---|
| 883 | + return (uV - range->set_point_min_uV) / range->step_uV; |
|---|
| 779 | 884 | } |
|---|
| 780 | 885 | |
|---|
| 781 | 886 | static int spmi_regulator_single_map_voltage(struct regulator_dev *rdev, |
|---|
| .. | .. |
|---|
| 911 | 1016 | |
|---|
| 912 | 1017 | spmi_vreg_read(vreg, SPMI_COMMON_REG_MODE, ®, 1); |
|---|
| 913 | 1018 | |
|---|
| 914 | | - if (reg & SPMI_COMMON_MODE_HPM_MASK) |
|---|
| 1019 | + reg &= SPMI_COMMON_MODE_HPM_MASK | SPMI_COMMON_MODE_AUTO_MASK; |
|---|
| 1020 | + |
|---|
| 1021 | + switch (reg) { |
|---|
| 1022 | + case SPMI_COMMON_MODE_HPM_MASK: |
|---|
| 915 | 1023 | return REGULATOR_MODE_NORMAL; |
|---|
| 916 | | - |
|---|
| 917 | | - if (reg & SPMI_COMMON_MODE_AUTO_MASK) |
|---|
| 1024 | + case SPMI_COMMON_MODE_AUTO_MASK: |
|---|
| 918 | 1025 | return REGULATOR_MODE_FAST; |
|---|
| 1026 | + default: |
|---|
| 1027 | + return REGULATOR_MODE_IDLE; |
|---|
| 1028 | + } |
|---|
| 1029 | +} |
|---|
| 919 | 1030 | |
|---|
| 920 | | - return REGULATOR_MODE_IDLE; |
|---|
| 1031 | +static unsigned int spmi_regulator_ftsmps426_get_mode(struct regulator_dev *rdev) |
|---|
| 1032 | +{ |
|---|
| 1033 | + struct spmi_regulator *vreg = rdev_get_drvdata(rdev); |
|---|
| 1034 | + u8 reg; |
|---|
| 1035 | + |
|---|
| 1036 | + spmi_vreg_read(vreg, SPMI_COMMON_REG_MODE, ®, 1); |
|---|
| 1037 | + |
|---|
| 1038 | + switch (reg) { |
|---|
| 1039 | + case SPMI_FTSMPS426_MODE_HPM_MASK: |
|---|
| 1040 | + return REGULATOR_MODE_NORMAL; |
|---|
| 1041 | + case SPMI_FTSMPS426_MODE_AUTO_MASK: |
|---|
| 1042 | + return REGULATOR_MODE_FAST; |
|---|
| 1043 | + default: |
|---|
| 1044 | + return REGULATOR_MODE_IDLE; |
|---|
| 1045 | + } |
|---|
| 921 | 1046 | } |
|---|
| 922 | 1047 | |
|---|
| 923 | 1048 | static int |
|---|
| .. | .. |
|---|
| 925 | 1050 | { |
|---|
| 926 | 1051 | struct spmi_regulator *vreg = rdev_get_drvdata(rdev); |
|---|
| 927 | 1052 | u8 mask = SPMI_COMMON_MODE_HPM_MASK | SPMI_COMMON_MODE_AUTO_MASK; |
|---|
| 928 | | - u8 val = 0; |
|---|
| 1053 | + u8 val; |
|---|
| 929 | 1054 | |
|---|
| 930 | | - if (mode == REGULATOR_MODE_NORMAL) |
|---|
| 1055 | + switch (mode) { |
|---|
| 1056 | + case REGULATOR_MODE_NORMAL: |
|---|
| 931 | 1057 | val = SPMI_COMMON_MODE_HPM_MASK; |
|---|
| 932 | | - else if (mode == REGULATOR_MODE_FAST) |
|---|
| 1058 | + break; |
|---|
| 1059 | + case REGULATOR_MODE_FAST: |
|---|
| 933 | 1060 | val = SPMI_COMMON_MODE_AUTO_MASK; |
|---|
| 1061 | + break; |
|---|
| 1062 | + default: |
|---|
| 1063 | + val = 0; |
|---|
| 1064 | + break; |
|---|
| 1065 | + } |
|---|
| 1066 | + |
|---|
| 1067 | + return spmi_vreg_update_bits(vreg, SPMI_COMMON_REG_MODE, val, mask); |
|---|
| 1068 | +} |
|---|
| 1069 | + |
|---|
| 1070 | +static int |
|---|
| 1071 | +spmi_regulator_ftsmps426_set_mode(struct regulator_dev *rdev, unsigned int mode) |
|---|
| 1072 | +{ |
|---|
| 1073 | + struct spmi_regulator *vreg = rdev_get_drvdata(rdev); |
|---|
| 1074 | + u8 mask = SPMI_FTSMPS426_MODE_MASK; |
|---|
| 1075 | + u8 val; |
|---|
| 1076 | + |
|---|
| 1077 | + switch (mode) { |
|---|
| 1078 | + case REGULATOR_MODE_NORMAL: |
|---|
| 1079 | + val = SPMI_FTSMPS426_MODE_HPM_MASK; |
|---|
| 1080 | + break; |
|---|
| 1081 | + case REGULATOR_MODE_FAST: |
|---|
| 1082 | + val = SPMI_FTSMPS426_MODE_AUTO_MASK; |
|---|
| 1083 | + break; |
|---|
| 1084 | + case REGULATOR_MODE_IDLE: |
|---|
| 1085 | + val = SPMI_FTSMPS426_MODE_LPM_MASK; |
|---|
| 1086 | + break; |
|---|
| 1087 | + default: |
|---|
| 1088 | + return -EINVAL; |
|---|
| 1089 | + } |
|---|
| 934 | 1090 | |
|---|
| 935 | 1091 | return spmi_vreg_update_bits(vreg, SPMI_COMMON_REG_MODE, val, mask); |
|---|
| 936 | 1092 | } |
|---|
| .. | .. |
|---|
| 1137 | 1293 | |
|---|
| 1138 | 1294 | static struct regulator_ops spmi_saw_ops = {}; |
|---|
| 1139 | 1295 | |
|---|
| 1140 | | -static struct regulator_ops spmi_smps_ops = { |
|---|
| 1296 | +static const struct regulator_ops spmi_smps_ops = { |
|---|
| 1141 | 1297 | .enable = regulator_enable_regmap, |
|---|
| 1142 | 1298 | .disable = regulator_disable_regmap, |
|---|
| 1143 | 1299 | .is_enabled = regulator_is_enabled_regmap, |
|---|
| .. | .. |
|---|
| 1152 | 1308 | .set_pull_down = spmi_regulator_common_set_pull_down, |
|---|
| 1153 | 1309 | }; |
|---|
| 1154 | 1310 | |
|---|
| 1155 | | -static struct regulator_ops spmi_ldo_ops = { |
|---|
| 1311 | +static const struct regulator_ops spmi_ldo_ops = { |
|---|
| 1156 | 1312 | .enable = regulator_enable_regmap, |
|---|
| 1157 | 1313 | .disable = regulator_disable_regmap, |
|---|
| 1158 | 1314 | .is_enabled = regulator_is_enabled_regmap, |
|---|
| .. | .. |
|---|
| 1169 | 1325 | .set_soft_start = spmi_regulator_common_set_soft_start, |
|---|
| 1170 | 1326 | }; |
|---|
| 1171 | 1327 | |
|---|
| 1172 | | -static struct regulator_ops spmi_ln_ldo_ops = { |
|---|
| 1328 | +static const struct regulator_ops spmi_ln_ldo_ops = { |
|---|
| 1173 | 1329 | .enable = regulator_enable_regmap, |
|---|
| 1174 | 1330 | .disable = regulator_disable_regmap, |
|---|
| 1175 | 1331 | .is_enabled = regulator_is_enabled_regmap, |
|---|
| .. | .. |
|---|
| 1181 | 1337 | .get_bypass = spmi_regulator_common_get_bypass, |
|---|
| 1182 | 1338 | }; |
|---|
| 1183 | 1339 | |
|---|
| 1184 | | -static struct regulator_ops spmi_vs_ops = { |
|---|
| 1340 | +static const struct regulator_ops spmi_vs_ops = { |
|---|
| 1185 | 1341 | .enable = spmi_regulator_vs_enable, |
|---|
| 1186 | 1342 | .disable = regulator_disable_regmap, |
|---|
| 1187 | 1343 | .is_enabled = regulator_is_enabled_regmap, |
|---|
| .. | .. |
|---|
| 1192 | 1348 | .get_mode = spmi_regulator_common_get_mode, |
|---|
| 1193 | 1349 | }; |
|---|
| 1194 | 1350 | |
|---|
| 1195 | | -static struct regulator_ops spmi_boost_ops = { |
|---|
| 1351 | +static const struct regulator_ops spmi_boost_ops = { |
|---|
| 1196 | 1352 | .enable = regulator_enable_regmap, |
|---|
| 1197 | 1353 | .disable = regulator_disable_regmap, |
|---|
| 1198 | 1354 | .is_enabled = regulator_is_enabled_regmap, |
|---|
| .. | .. |
|---|
| 1203 | 1359 | .set_input_current_limit = spmi_regulator_set_ilim, |
|---|
| 1204 | 1360 | }; |
|---|
| 1205 | 1361 | |
|---|
| 1206 | | -static struct regulator_ops spmi_ftsmps_ops = { |
|---|
| 1362 | +static const struct regulator_ops spmi_ftsmps_ops = { |
|---|
| 1207 | 1363 | .enable = regulator_enable_regmap, |
|---|
| 1208 | 1364 | .disable = regulator_disable_regmap, |
|---|
| 1209 | 1365 | .is_enabled = regulator_is_enabled_regmap, |
|---|
| .. | .. |
|---|
| 1218 | 1374 | .set_pull_down = spmi_regulator_common_set_pull_down, |
|---|
| 1219 | 1375 | }; |
|---|
| 1220 | 1376 | |
|---|
| 1221 | | -static struct regulator_ops spmi_ult_lo_smps_ops = { |
|---|
| 1377 | +static const struct regulator_ops spmi_ult_lo_smps_ops = { |
|---|
| 1222 | 1378 | .enable = regulator_enable_regmap, |
|---|
| 1223 | 1379 | .disable = regulator_disable_regmap, |
|---|
| 1224 | 1380 | .is_enabled = regulator_is_enabled_regmap, |
|---|
| .. | .. |
|---|
| 1232 | 1388 | .set_pull_down = spmi_regulator_common_set_pull_down, |
|---|
| 1233 | 1389 | }; |
|---|
| 1234 | 1390 | |
|---|
| 1235 | | -static struct regulator_ops spmi_ult_ho_smps_ops = { |
|---|
| 1391 | +static const struct regulator_ops spmi_ult_ho_smps_ops = { |
|---|
| 1236 | 1392 | .enable = regulator_enable_regmap, |
|---|
| 1237 | 1393 | .disable = regulator_disable_regmap, |
|---|
| 1238 | 1394 | .is_enabled = regulator_is_enabled_regmap, |
|---|
| .. | .. |
|---|
| 1247 | 1403 | .set_pull_down = spmi_regulator_common_set_pull_down, |
|---|
| 1248 | 1404 | }; |
|---|
| 1249 | 1405 | |
|---|
| 1250 | | -static struct regulator_ops spmi_ult_ldo_ops = { |
|---|
| 1406 | +static const struct regulator_ops spmi_ult_ldo_ops = { |
|---|
| 1251 | 1407 | .enable = regulator_enable_regmap, |
|---|
| 1252 | 1408 | .disable = regulator_disable_regmap, |
|---|
| 1253 | 1409 | .is_enabled = regulator_is_enabled_regmap, |
|---|
| .. | .. |
|---|
| 1264 | 1420 | .set_soft_start = spmi_regulator_common_set_soft_start, |
|---|
| 1265 | 1421 | }; |
|---|
| 1266 | 1422 | |
|---|
| 1423 | +static const struct regulator_ops spmi_ftsmps426_ops = { |
|---|
| 1424 | + .enable = regulator_enable_regmap, |
|---|
| 1425 | + .disable = regulator_disable_regmap, |
|---|
| 1426 | + .is_enabled = regulator_is_enabled_regmap, |
|---|
| 1427 | + .set_voltage_sel = spmi_regulator_ftsmps426_set_voltage, |
|---|
| 1428 | + .set_voltage_time_sel = spmi_regulator_set_voltage_time_sel, |
|---|
| 1429 | + .get_voltage_sel = spmi_regulator_ftsmps426_get_voltage, |
|---|
| 1430 | + .map_voltage = spmi_regulator_single_map_voltage, |
|---|
| 1431 | + .list_voltage = spmi_regulator_common_list_voltage, |
|---|
| 1432 | + .set_mode = spmi_regulator_ftsmps426_set_mode, |
|---|
| 1433 | + .get_mode = spmi_regulator_ftsmps426_get_mode, |
|---|
| 1434 | + .set_load = spmi_regulator_common_set_load, |
|---|
| 1435 | + .set_pull_down = spmi_regulator_common_set_pull_down, |
|---|
| 1436 | +}; |
|---|
| 1437 | + |
|---|
| 1438 | +static const struct regulator_ops spmi_hfs430_ops = { |
|---|
| 1439 | + .enable = regulator_enable_regmap, |
|---|
| 1440 | + .disable = regulator_disable_regmap, |
|---|
| 1441 | + .is_enabled = regulator_is_enabled_regmap, |
|---|
| 1442 | + .set_voltage_sel = spmi_regulator_ftsmps426_set_voltage, |
|---|
| 1443 | + .set_voltage_time_sel = spmi_regulator_set_voltage_time_sel, |
|---|
| 1444 | + .get_voltage_sel = spmi_regulator_ftsmps426_get_voltage, |
|---|
| 1445 | + .map_voltage = spmi_regulator_single_map_voltage, |
|---|
| 1446 | + .list_voltage = spmi_regulator_common_list_voltage, |
|---|
| 1447 | + .set_mode = spmi_regulator_ftsmps426_set_mode, |
|---|
| 1448 | + .get_mode = spmi_regulator_ftsmps426_get_mode, |
|---|
| 1449 | +}; |
|---|
| 1450 | + |
|---|
| 1267 | 1451 | /* Maximum possible digital major revision value */ |
|---|
| 1268 | 1452 | #define INF 0xFF |
|---|
| 1269 | 1453 | |
|---|
| 1270 | 1454 | static const struct spmi_regulator_mapping supported_regulators[] = { |
|---|
| 1271 | 1455 | /* type subtype dig_min dig_max ltype ops setpoints hpm_min */ |
|---|
| 1272 | 1456 | SPMI_VREG(BUCK, GP_CTL, 0, INF, SMPS, smps, smps, 100000), |
|---|
| 1457 | + SPMI_VREG(BUCK, HFS430, 0, INF, HFS430, hfs430, hfs430, 10000), |
|---|
| 1273 | 1458 | SPMI_VREG(LDO, N300, 0, INF, LDO, ldo, nldo1, 10000), |
|---|
| 1274 | 1459 | SPMI_VREG(LDO, N600, 0, 0, LDO, ldo, nldo2, 10000), |
|---|
| 1275 | 1460 | SPMI_VREG(LDO, N1200, 0, 0, LDO, ldo, nldo2, 10000), |
|---|
| .. | .. |
|---|
| 1290 | 1475 | SPMI_VREG(LDO, LV_P300, 0, INF, LDO, ldo, pldo, 10000), |
|---|
| 1291 | 1476 | SPMI_VREG(LDO, LV_P600, 0, INF, LDO, ldo, pldo, 10000), |
|---|
| 1292 | 1477 | SPMI_VREG(LDO, LV_P1200, 0, INF, LDO, ldo, pldo, 10000), |
|---|
| 1478 | + SPMI_VREG(LDO, HT_N300_ST, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1479 | + ht_nldo, 30000), |
|---|
| 1480 | + SPMI_VREG(LDO, HT_N600_ST, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1481 | + ht_nldo, 30000), |
|---|
| 1482 | + SPMI_VREG(LDO, HT_N1200_ST, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1483 | + ht_nldo, 30000), |
|---|
| 1484 | + SPMI_VREG(LDO, HT_LVP150, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1485 | + ht_lvpldo, 10000), |
|---|
| 1486 | + SPMI_VREG(LDO, HT_LVP300, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1487 | + ht_lvpldo, 10000), |
|---|
| 1488 | + SPMI_VREG(LDO, L660_N300_ST, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1489 | + nldo660, 10000), |
|---|
| 1490 | + SPMI_VREG(LDO, L660_N600_ST, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1491 | + nldo660, 10000), |
|---|
| 1492 | + SPMI_VREG(LDO, L660_P50, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1493 | + pldo660, 10000), |
|---|
| 1494 | + SPMI_VREG(LDO, L660_P150, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1495 | + pldo660, 10000), |
|---|
| 1496 | + SPMI_VREG(LDO, L660_P600, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1497 | + pldo660, 10000), |
|---|
| 1498 | + SPMI_VREG(LDO, L660_LVP150, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1499 | + ht_lvpldo, 10000), |
|---|
| 1500 | + SPMI_VREG(LDO, L660_LVP600, 0, INF, FTSMPS426, ftsmps426, |
|---|
| 1501 | + ht_lvpldo, 10000), |
|---|
| 1293 | 1502 | SPMI_VREG_VS(LV100, 0, INF), |
|---|
| 1294 | 1503 | SPMI_VREG_VS(LV300, 0, INF), |
|---|
| 1295 | 1504 | SPMI_VREG_VS(MV300, 0, INF), |
|---|
| .. | .. |
|---|
| 1299 | 1508 | SPMI_VREG(BOOST, 5V_BOOST, 0, INF, BOOST, boost, boost, 0), |
|---|
| 1300 | 1509 | SPMI_VREG(FTS, FTS_CTL, 0, INF, FTSMPS, ftsmps, ftsmps, 100000), |
|---|
| 1301 | 1510 | SPMI_VREG(FTS, FTS2p5_CTL, 0, INF, FTSMPS, ftsmps, ftsmps2p5, 100000), |
|---|
| 1511 | + SPMI_VREG(FTS, FTS426_CTL, 0, INF, FTSMPS426, ftsmps426, ftsmps426, 100000), |
|---|
| 1302 | 1512 | SPMI_VREG(BOOST_BYP, BB_2A, 0, INF, BOOST_BYP, boost, boost_byp, 0), |
|---|
| 1303 | 1513 | SPMI_VREG(ULT_BUCK, ULT_HF_CTL1, 0, INF, ULT_LO_SMPS, ult_lo_smps, |
|---|
| 1304 | 1514 | ult_lo_smps, 100000), |
|---|
| .. | .. |
|---|
| 1436 | 1646 | return ret; |
|---|
| 1437 | 1647 | } |
|---|
| 1438 | 1648 | |
|---|
| 1649 | +static int spmi_regulator_init_slew_rate_ftsmps426(struct spmi_regulator *vreg, |
|---|
| 1650 | + int clock_rate) |
|---|
| 1651 | +{ |
|---|
| 1652 | + int ret; |
|---|
| 1653 | + u8 reg = 0; |
|---|
| 1654 | + int delay, slew_rate; |
|---|
| 1655 | + const struct spmi_voltage_range *range = &vreg->set_points->range[0]; |
|---|
| 1656 | + |
|---|
| 1657 | + ret = spmi_vreg_read(vreg, SPMI_COMMON_REG_STEP_CTRL, ®, 1); |
|---|
| 1658 | + if (ret) { |
|---|
| 1659 | + dev_err(vreg->dev, "spmi read failed, ret=%d\n", ret); |
|---|
| 1660 | + return ret; |
|---|
| 1661 | + } |
|---|
| 1662 | + |
|---|
| 1663 | + delay = reg & SPMI_FTSMPS426_STEP_CTRL_DELAY_MASK; |
|---|
| 1664 | + delay >>= SPMI_FTSMPS426_STEP_CTRL_DELAY_SHIFT; |
|---|
| 1665 | + |
|---|
| 1666 | + /* slew_rate has units of uV/us */ |
|---|
| 1667 | + slew_rate = clock_rate * range->step_uV; |
|---|
| 1668 | + slew_rate /= 1000 * (SPMI_FTSMPS426_STEP_DELAY << delay); |
|---|
| 1669 | + slew_rate *= SPMI_FTSMPS426_STEP_MARGIN_NUM; |
|---|
| 1670 | + slew_rate /= SPMI_FTSMPS426_STEP_MARGIN_DEN; |
|---|
| 1671 | + |
|---|
| 1672 | + /* Ensure that the slew rate is greater than 0 */ |
|---|
| 1673 | + vreg->slew_rate = max(slew_rate, 1); |
|---|
| 1674 | + |
|---|
| 1675 | + return ret; |
|---|
| 1676 | +} |
|---|
| 1677 | + |
|---|
| 1439 | 1678 | static int spmi_regulator_init_registers(struct spmi_regulator *vreg, |
|---|
| 1440 | 1679 | const struct spmi_regulator_init_data *data) |
|---|
| 1441 | 1680 | { |
|---|
| .. | .. |
|---|
| 1450 | 1689 | return ret; |
|---|
| 1451 | 1690 | |
|---|
| 1452 | 1691 | /* Set up enable pin control. */ |
|---|
| 1453 | | - if ((type == SPMI_REGULATOR_LOGICAL_TYPE_SMPS |
|---|
| 1454 | | - || type == SPMI_REGULATOR_LOGICAL_TYPE_LDO |
|---|
| 1455 | | - || type == SPMI_REGULATOR_LOGICAL_TYPE_VS) |
|---|
| 1456 | | - && !(data->pin_ctrl_enable |
|---|
| 1457 | | - & SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT)) { |
|---|
| 1458 | | - ctrl_reg[SPMI_COMMON_IDX_ENABLE] &= |
|---|
| 1459 | | - ~SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK; |
|---|
| 1460 | | - ctrl_reg[SPMI_COMMON_IDX_ENABLE] |= |
|---|
| 1461 | | - data->pin_ctrl_enable & SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK; |
|---|
| 1692 | + if (!(data->pin_ctrl_enable & SPMI_REGULATOR_PIN_CTRL_ENABLE_HW_DEFAULT)) { |
|---|
| 1693 | + switch (type) { |
|---|
| 1694 | + case SPMI_REGULATOR_LOGICAL_TYPE_SMPS: |
|---|
| 1695 | + case SPMI_REGULATOR_LOGICAL_TYPE_LDO: |
|---|
| 1696 | + case SPMI_REGULATOR_LOGICAL_TYPE_VS: |
|---|
| 1697 | + ctrl_reg[SPMI_COMMON_IDX_ENABLE] &= |
|---|
| 1698 | + ~SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK; |
|---|
| 1699 | + ctrl_reg[SPMI_COMMON_IDX_ENABLE] |= |
|---|
| 1700 | + data->pin_ctrl_enable & SPMI_COMMON_ENABLE_FOLLOW_ALL_MASK; |
|---|
| 1701 | + break; |
|---|
| 1702 | + default: |
|---|
| 1703 | + break; |
|---|
| 1704 | + } |
|---|
| 1462 | 1705 | } |
|---|
| 1463 | 1706 | |
|---|
| 1464 | 1707 | /* Set up mode pin control. */ |
|---|
| 1465 | | - if ((type == SPMI_REGULATOR_LOGICAL_TYPE_SMPS |
|---|
| 1466 | | - || type == SPMI_REGULATOR_LOGICAL_TYPE_LDO) |
|---|
| 1467 | | - && !(data->pin_ctrl_hpm |
|---|
| 1468 | | - & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) { |
|---|
| 1469 | | - ctrl_reg[SPMI_COMMON_IDX_MODE] &= |
|---|
| 1470 | | - ~SPMI_COMMON_MODE_FOLLOW_ALL_MASK; |
|---|
| 1471 | | - ctrl_reg[SPMI_COMMON_IDX_MODE] |= |
|---|
| 1472 | | - data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_ALL_MASK; |
|---|
| 1473 | | - } |
|---|
| 1474 | | - |
|---|
| 1475 | | - if (type == SPMI_REGULATOR_LOGICAL_TYPE_VS |
|---|
| 1476 | | - && !(data->pin_ctrl_hpm & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) { |
|---|
| 1477 | | - ctrl_reg[SPMI_COMMON_IDX_MODE] &= |
|---|
| 1478 | | - ~SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK; |
|---|
| 1479 | | - ctrl_reg[SPMI_COMMON_IDX_MODE] |= |
|---|
| 1480 | | - data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK; |
|---|
| 1481 | | - } |
|---|
| 1482 | | - |
|---|
| 1483 | | - if ((type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_LO_SMPS |
|---|
| 1484 | | - || type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_HO_SMPS |
|---|
| 1485 | | - || type == SPMI_REGULATOR_LOGICAL_TYPE_ULT_LDO) |
|---|
| 1486 | | - && !(data->pin_ctrl_hpm |
|---|
| 1487 | | - & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) { |
|---|
| 1488 | | - ctrl_reg[SPMI_COMMON_IDX_MODE] &= |
|---|
| 1489 | | - ~SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK; |
|---|
| 1490 | | - ctrl_reg[SPMI_COMMON_IDX_MODE] |= |
|---|
| 1491 | | - data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK; |
|---|
| 1708 | + if (!(data->pin_ctrl_hpm & SPMI_REGULATOR_PIN_CTRL_HPM_HW_DEFAULT)) { |
|---|
| 1709 | + switch (type) { |
|---|
| 1710 | + case SPMI_REGULATOR_LOGICAL_TYPE_SMPS: |
|---|
| 1711 | + case SPMI_REGULATOR_LOGICAL_TYPE_LDO: |
|---|
| 1712 | + ctrl_reg[SPMI_COMMON_IDX_MODE] &= |
|---|
| 1713 | + ~SPMI_COMMON_MODE_FOLLOW_ALL_MASK; |
|---|
| 1714 | + ctrl_reg[SPMI_COMMON_IDX_MODE] |= |
|---|
| 1715 | + data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_ALL_MASK; |
|---|
| 1716 | + break; |
|---|
| 1717 | + case SPMI_REGULATOR_LOGICAL_TYPE_VS: |
|---|
| 1718 | + case SPMI_REGULATOR_LOGICAL_TYPE_ULT_LO_SMPS: |
|---|
| 1719 | + case SPMI_REGULATOR_LOGICAL_TYPE_ULT_HO_SMPS: |
|---|
| 1720 | + case SPMI_REGULATOR_LOGICAL_TYPE_ULT_LDO: |
|---|
| 1721 | + ctrl_reg[SPMI_COMMON_IDX_MODE] &= |
|---|
| 1722 | + ~SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK; |
|---|
| 1723 | + ctrl_reg[SPMI_COMMON_IDX_MODE] |= |
|---|
| 1724 | + data->pin_ctrl_hpm & SPMI_COMMON_MODE_FOLLOW_AWAKE_MASK; |
|---|
| 1725 | + break; |
|---|
| 1726 | + default: |
|---|
| 1727 | + break; |
|---|
| 1728 | + } |
|---|
| 1492 | 1729 | } |
|---|
| 1493 | 1730 | |
|---|
| 1494 | 1731 | /* Write back any control register values that were modified. */ |
|---|
| .. | .. |
|---|
| 1575 | 1812 | ret = spmi_regulator_init_slew_rate(vreg); |
|---|
| 1576 | 1813 | if (ret) |
|---|
| 1577 | 1814 | return ret; |
|---|
| 1815 | + break; |
|---|
| 1816 | + case SPMI_REGULATOR_LOGICAL_TYPE_FTSMPS426: |
|---|
| 1817 | + ret = spmi_regulator_init_slew_rate_ftsmps426(vreg, |
|---|
| 1818 | + SPMI_FTSMPS426_CLOCK_RATE); |
|---|
| 1819 | + if (ret) |
|---|
| 1820 | + return ret; |
|---|
| 1821 | + break; |
|---|
| 1822 | + case SPMI_REGULATOR_LOGICAL_TYPE_HFS430: |
|---|
| 1823 | + ret = spmi_regulator_init_slew_rate_ftsmps426(vreg, |
|---|
| 1824 | + SPMI_HFS430_CLOCK_RATE); |
|---|
| 1825 | + if (ret) |
|---|
| 1826 | + return ret; |
|---|
| 1827 | + break; |
|---|
| 1578 | 1828 | default: |
|---|
| 1579 | 1829 | break; |
|---|
| 1580 | 1830 | } |
|---|
| .. | .. |
|---|
| 1673 | 1923 | { } |
|---|
| 1674 | 1924 | }; |
|---|
| 1675 | 1925 | |
|---|
| 1926 | +static const struct spmi_regulator_data pm8950_regulators[] = { |
|---|
| 1927 | + { "s1", 0x1400, "vdd_s1", }, |
|---|
| 1928 | + { "s2", 0x1700, "vdd_s2", }, |
|---|
| 1929 | + { "s3", 0x1a00, "vdd_s3", }, |
|---|
| 1930 | + { "s4", 0x1d00, "vdd_s4", }, |
|---|
| 1931 | + { "s5", 0x2000, "vdd_s5", }, |
|---|
| 1932 | + { "s6", 0x2300, "vdd_s6", }, |
|---|
| 1933 | + { "l1", 0x4000, "vdd_l1_l19", }, |
|---|
| 1934 | + { "l2", 0x4100, "vdd_l2_l23", }, |
|---|
| 1935 | + { "l3", 0x4200, "vdd_l3", }, |
|---|
| 1936 | + { "l4", 0x4300, "vdd_l4_l5_l6_l7_l16", }, |
|---|
| 1937 | + { "l5", 0x4400, "vdd_l4_l5_l6_l7_l16", }, |
|---|
| 1938 | + { "l6", 0x4500, "vdd_l4_l5_l6_l7_l16", }, |
|---|
| 1939 | + { "l7", 0x4600, "vdd_l4_l5_l6_l7_l16", }, |
|---|
| 1940 | + { "l8", 0x4700, "vdd_l8_l11_l12_l17_l22", }, |
|---|
| 1941 | + { "l9", 0x4800, "vdd_l9_l10_l13_l14_l15_l18", }, |
|---|
| 1942 | + { "l10", 0x4900, "vdd_l9_l10_l13_l14_l15_l18", }, |
|---|
| 1943 | + { "l11", 0x4a00, "vdd_l8_l11_l12_l17_l22", }, |
|---|
| 1944 | + { "l12", 0x4b00, "vdd_l8_l11_l12_l17_l22", }, |
|---|
| 1945 | + { "l13", 0x4c00, "vdd_l9_l10_l13_l14_l15_l18", }, |
|---|
| 1946 | + { "l14", 0x4d00, "vdd_l9_l10_l13_l14_l15_l18", }, |
|---|
| 1947 | + { "l15", 0x4e00, "vdd_l9_l10_l13_l14_l15_l18", }, |
|---|
| 1948 | + { "l16", 0x4f00, "vdd_l4_l5_l6_l7_l16", }, |
|---|
| 1949 | + { "l17", 0x5000, "vdd_l8_l11_l12_l17_l22", }, |
|---|
| 1950 | + { "l18", 0x5100, "vdd_l9_l10_l13_l14_l15_l18", }, |
|---|
| 1951 | + { "l19", 0x5200, "vdd_l1_l19", }, |
|---|
| 1952 | + { "l20", 0x5300, "vdd_l20", }, |
|---|
| 1953 | + { "l21", 0x5400, "vdd_l21", }, |
|---|
| 1954 | + { "l22", 0x5500, "vdd_l8_l11_l12_l17_l22", }, |
|---|
| 1955 | + { "l23", 0x5600, "vdd_l2_l23", }, |
|---|
| 1956 | + { } |
|---|
| 1957 | +}; |
|---|
| 1958 | + |
|---|
| 1676 | 1959 | static const struct spmi_regulator_data pm8994_regulators[] = { |
|---|
| 1677 | 1960 | { "s1", 0x1400, "vdd_s1", }, |
|---|
| 1678 | 1961 | { "s2", 0x1700, "vdd_s2", }, |
|---|
| .. | .. |
|---|
| 1731 | 2014 | { } |
|---|
| 1732 | 2015 | }; |
|---|
| 1733 | 2016 | |
|---|
| 2017 | +static const struct spmi_regulator_data pm660_regulators[] = { |
|---|
| 2018 | + { "s1", 0x1400, "vdd_s1", }, |
|---|
| 2019 | + { "s2", 0x1700, "vdd_s2", }, |
|---|
| 2020 | + { "s3", 0x1a00, "vdd_s3", }, |
|---|
| 2021 | + { "s4", 0x1d00, "vdd_s3", }, |
|---|
| 2022 | + { "s5", 0x2000, "vdd_s5", }, |
|---|
| 2023 | + { "s6", 0x2300, "vdd_s6", }, |
|---|
| 2024 | + { "l1", 0x4000, "vdd_l1_l6_l7", }, |
|---|
| 2025 | + { "l2", 0x4100, "vdd_l2_l3", }, |
|---|
| 2026 | + { "l3", 0x4200, "vdd_l2_l3", }, |
|---|
| 2027 | + /* l4 is unaccessible on PM660 */ |
|---|
| 2028 | + { "l5", 0x4400, "vdd_l5", }, |
|---|
| 2029 | + { "l6", 0x4500, "vdd_l1_l6_l7", }, |
|---|
| 2030 | + { "l7", 0x4600, "vdd_l1_l6_l7", }, |
|---|
| 2031 | + { "l8", 0x4700, "vdd_l8_l9_l10_l11_l12_l13_l14", }, |
|---|
| 2032 | + { "l9", 0x4800, "vdd_l8_l9_l10_l11_l12_l13_l14", }, |
|---|
| 2033 | + { "l10", 0x4900, "vdd_l8_l9_l10_l11_l12_l13_l14", }, |
|---|
| 2034 | + { "l11", 0x4a00, "vdd_l8_l9_l10_l11_l12_l13_l14", }, |
|---|
| 2035 | + { "l12", 0x4b00, "vdd_l8_l9_l10_l11_l12_l13_l14", }, |
|---|
| 2036 | + { "l13", 0x4c00, "vdd_l8_l9_l10_l11_l12_l13_l14", }, |
|---|
| 2037 | + { "l14", 0x4d00, "vdd_l8_l9_l10_l11_l12_l13_l14", }, |
|---|
| 2038 | + { "l15", 0x4e00, "vdd_l15_l16_l17_l18_l19", }, |
|---|
| 2039 | + { "l16", 0x4f00, "vdd_l15_l16_l17_l18_l19", }, |
|---|
| 2040 | + { "l17", 0x5000, "vdd_l15_l16_l17_l18_l19", }, |
|---|
| 2041 | + { "l18", 0x5100, "vdd_l15_l16_l17_l18_l19", }, |
|---|
| 2042 | + { "l19", 0x5200, "vdd_l15_l16_l17_l18_l19", }, |
|---|
| 2043 | + { } |
|---|
| 2044 | +}; |
|---|
| 2045 | + |
|---|
| 2046 | +static const struct spmi_regulator_data pm660l_regulators[] = { |
|---|
| 2047 | + { "s1", 0x1400, "vdd_s1", }, |
|---|
| 2048 | + { "s2", 0x1700, "vdd_s2", }, |
|---|
| 2049 | + { "s3", 0x1a00, "vdd_s3", }, |
|---|
| 2050 | + { "s4", 0x1d00, "vdd_s4", }, |
|---|
| 2051 | + { "s5", 0x2000, "vdd_s5", }, |
|---|
| 2052 | + { "l1", 0x4000, "vdd_l1_l9_l10", }, |
|---|
| 2053 | + { "l2", 0x4100, "vdd_l2", }, |
|---|
| 2054 | + { "l3", 0x4200, "vdd_l3_l5_l7_l8", }, |
|---|
| 2055 | + { "l4", 0x4300, "vdd_l4_l6", }, |
|---|
| 2056 | + { "l5", 0x4400, "vdd_l3_l5_l7_l8", }, |
|---|
| 2057 | + { "l6", 0x4500, "vdd_l4_l6", }, |
|---|
| 2058 | + { "l7", 0x4600, "vdd_l3_l5_l7_l8", }, |
|---|
| 2059 | + { "l8", 0x4700, "vdd_l3_l5_l7_l8", }, |
|---|
| 2060 | + { "l9", 0x4800, "vdd_l1_l9_l10", }, |
|---|
| 2061 | + { "l10", 0x4900, "vdd_l1_l9_l10", }, |
|---|
| 2062 | + { } |
|---|
| 2063 | +}; |
|---|
| 2064 | + |
|---|
| 2065 | + |
|---|
| 2066 | +static const struct spmi_regulator_data pm8004_regulators[] = { |
|---|
| 2067 | + { "s2", 0x1700, "vdd_s2", }, |
|---|
| 2068 | + { "s5", 0x2000, "vdd_s5", }, |
|---|
| 2069 | + { } |
|---|
| 2070 | +}; |
|---|
| 2071 | + |
|---|
| 2072 | +static const struct spmi_regulator_data pm8005_regulators[] = { |
|---|
| 2073 | + { "s1", 0x1400, "vdd_s1", }, |
|---|
| 2074 | + { "s2", 0x1700, "vdd_s2", }, |
|---|
| 2075 | + { "s3", 0x1a00, "vdd_s3", }, |
|---|
| 2076 | + { "s4", 0x1d00, "vdd_s4", }, |
|---|
| 2077 | + { } |
|---|
| 2078 | +}; |
|---|
| 2079 | + |
|---|
| 2080 | +static const struct spmi_regulator_data pms405_regulators[] = { |
|---|
| 2081 | + { "s3", 0x1a00, "vdd_s3"}, |
|---|
| 2082 | + { } |
|---|
| 2083 | +}; |
|---|
| 2084 | + |
|---|
| 1734 | 2085 | static const struct of_device_id qcom_spmi_regulator_match[] = { |
|---|
| 2086 | + { .compatible = "qcom,pm8004-regulators", .data = &pm8004_regulators }, |
|---|
| 2087 | + { .compatible = "qcom,pm8005-regulators", .data = &pm8005_regulators }, |
|---|
| 1735 | 2088 | { .compatible = "qcom,pm8841-regulators", .data = &pm8841_regulators }, |
|---|
| 1736 | 2089 | { .compatible = "qcom,pm8916-regulators", .data = &pm8916_regulators }, |
|---|
| 1737 | 2090 | { .compatible = "qcom,pm8941-regulators", .data = &pm8941_regulators }, |
|---|
| 2091 | + { .compatible = "qcom,pm8950-regulators", .data = &pm8950_regulators }, |
|---|
| 1738 | 2092 | { .compatible = "qcom,pm8994-regulators", .data = &pm8994_regulators }, |
|---|
| 1739 | 2093 | { .compatible = "qcom,pmi8994-regulators", .data = &pmi8994_regulators }, |
|---|
| 2094 | + { .compatible = "qcom,pm660-regulators", .data = &pm660_regulators }, |
|---|
| 2095 | + { .compatible = "qcom,pm660l-regulators", .data = &pm660l_regulators }, |
|---|
| 2096 | + { .compatible = "qcom,pms405-regulators", .data = &pms405_regulators }, |
|---|
| 1740 | 2097 | { } |
|---|
| 1741 | 2098 | }; |
|---|
| 1742 | 2099 | MODULE_DEVICE_TABLE(of, qcom_spmi_regulator_match); |
|---|
| .. | .. |
|---|
| 1744 | 2101 | static int qcom_spmi_regulator_probe(struct platform_device *pdev) |
|---|
| 1745 | 2102 | { |
|---|
| 1746 | 2103 | const struct spmi_regulator_data *reg; |
|---|
| 2104 | + const struct spmi_voltage_range *range; |
|---|
| 1747 | 2105 | const struct of_device_id *match; |
|---|
| 1748 | 2106 | struct regulator_config config = { }; |
|---|
| 1749 | 2107 | struct regulator_dev *rdev; |
|---|
| .. | .. |
|---|
| 1833 | 2191 | } |
|---|
| 1834 | 2192 | } |
|---|
| 1835 | 2193 | |
|---|
| 2194 | + if (vreg->set_points && vreg->set_points->count == 1) { |
|---|
| 2195 | + /* since there is only one range */ |
|---|
| 2196 | + range = vreg->set_points->range; |
|---|
| 2197 | + vreg->desc.uV_step = range->step_uV; |
|---|
| 2198 | + } |
|---|
| 2199 | + |
|---|
| 1836 | 2200 | config.dev = dev; |
|---|
| 1837 | 2201 | config.driver_data = vreg; |
|---|
| 1838 | 2202 | config.regmap = regmap; |
|---|