David Collins | 1d4061b | 2011-12-06 15:36:40 -0800 | [diff] [blame] | 1 | /* |
David Collins | b455842 | 2012-01-05 10:50:49 -0800 | [diff] [blame^] | 2 | * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
David Collins | 1d4061b | 2011-12-06 15:36:40 -0800 | [diff] [blame] | 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 | */ |
| 13 | |
| 14 | #include <linux/regulator/pm8xxx-regulator.h> |
| 15 | |
| 16 | #include "board-8930.h" |
| 17 | |
| 18 | #define VREG_CONSUMERS(_id) \ |
| 19 | static struct regulator_consumer_supply vreg_consumers_##_id[] |
| 20 | |
| 21 | /* |
| 22 | * Consumer specific regulator names: |
| 23 | * regulator name consumer dev_name |
| 24 | */ |
| 25 | VREG_CONSUMERS(L1) = { |
| 26 | REGULATOR_SUPPLY("8038_l1", NULL), |
| 27 | }; |
| 28 | VREG_CONSUMERS(L2) = { |
| 29 | REGULATOR_SUPPLY("8038_l2", NULL), |
| 30 | }; |
| 31 | VREG_CONSUMERS(L3) = { |
| 32 | REGULATOR_SUPPLY("8038_l3", NULL), |
Mayank Rana | bf5084a | 2011-12-12 17:06:54 +0530 | [diff] [blame] | 33 | REGULATOR_SUPPLY("HSUSB_3p3", "msm_otg"), |
David Collins | 1d4061b | 2011-12-06 15:36:40 -0800 | [diff] [blame] | 34 | }; |
| 35 | VREG_CONSUMERS(L4) = { |
| 36 | REGULATOR_SUPPLY("8038_l4", NULL), |
Mayank Rana | bf5084a | 2011-12-12 17:06:54 +0530 | [diff] [blame] | 37 | REGULATOR_SUPPLY("HSUSB_1p8", "msm_otg"), |
David Collins | 1d4061b | 2011-12-06 15:36:40 -0800 | [diff] [blame] | 38 | }; |
| 39 | VREG_CONSUMERS(L5) = { |
| 40 | REGULATOR_SUPPLY("8038_l5", NULL), |
| 41 | }; |
| 42 | VREG_CONSUMERS(L6) = { |
| 43 | REGULATOR_SUPPLY("8038_l6", NULL), |
| 44 | }; |
| 45 | VREG_CONSUMERS(L7) = { |
| 46 | REGULATOR_SUPPLY("8038_l7", NULL), |
| 47 | }; |
| 48 | VREG_CONSUMERS(L8) = { |
| 49 | REGULATOR_SUPPLY("8038_l8", NULL), |
| 50 | }; |
| 51 | VREG_CONSUMERS(L9) = { |
| 52 | REGULATOR_SUPPLY("8038_l9", NULL), |
| 53 | }; |
| 54 | VREG_CONSUMERS(L10) = { |
| 55 | REGULATOR_SUPPLY("8038_l10", NULL), |
| 56 | }; |
| 57 | VREG_CONSUMERS(L11) = { |
| 58 | REGULATOR_SUPPLY("8038_l11", NULL), |
| 59 | }; |
| 60 | VREG_CONSUMERS(L12) = { |
| 61 | REGULATOR_SUPPLY("8038_l12", NULL), |
| 62 | }; |
| 63 | VREG_CONSUMERS(L14) = { |
| 64 | REGULATOR_SUPPLY("8038_l14", NULL), |
| 65 | }; |
| 66 | VREG_CONSUMERS(L15) = { |
| 67 | REGULATOR_SUPPLY("8038_l15", NULL), |
| 68 | }; |
| 69 | VREG_CONSUMERS(L16) = { |
| 70 | REGULATOR_SUPPLY("8038_l16", NULL), |
| 71 | }; |
| 72 | VREG_CONSUMERS(L17) = { |
| 73 | REGULATOR_SUPPLY("8038_l17", NULL), |
| 74 | }; |
| 75 | VREG_CONSUMERS(L18) = { |
| 76 | REGULATOR_SUPPLY("8038_l18", NULL), |
| 77 | }; |
| 78 | VREG_CONSUMERS(L19) = { |
| 79 | REGULATOR_SUPPLY("8038_l19", NULL), |
| 80 | }; |
| 81 | VREG_CONSUMERS(L20) = { |
| 82 | REGULATOR_SUPPLY("8038_l20", NULL), |
| 83 | }; |
| 84 | VREG_CONSUMERS(L21) = { |
| 85 | REGULATOR_SUPPLY("8038_l21", NULL), |
| 86 | }; |
| 87 | VREG_CONSUMERS(L22) = { |
| 88 | REGULATOR_SUPPLY("8038_l22", NULL), |
| 89 | }; |
| 90 | VREG_CONSUMERS(L23) = { |
| 91 | REGULATOR_SUPPLY("8038_l23", NULL), |
| 92 | }; |
| 93 | VREG_CONSUMERS(L24) = { |
| 94 | REGULATOR_SUPPLY("8038_l24", NULL), |
| 95 | }; |
| 96 | VREG_CONSUMERS(L26) = { |
| 97 | REGULATOR_SUPPLY("8038_l26", NULL), |
| 98 | }; |
| 99 | VREG_CONSUMERS(L27) = { |
| 100 | REGULATOR_SUPPLY("8038_l27", NULL), |
| 101 | }; |
| 102 | VREG_CONSUMERS(S1) = { |
| 103 | REGULATOR_SUPPLY("8038_s1", NULL), |
Mayank Rana | bf5084a | 2011-12-12 17:06:54 +0530 | [diff] [blame] | 104 | REGULATOR_SUPPLY("HSUSB_VDDCX", "msm_otg"), |
David Collins | 1d4061b | 2011-12-06 15:36:40 -0800 | [diff] [blame] | 105 | }; |
| 106 | VREG_CONSUMERS(S2) = { |
| 107 | REGULATOR_SUPPLY("8038_s2", NULL), |
| 108 | }; |
| 109 | VREG_CONSUMERS(S3) = { |
| 110 | REGULATOR_SUPPLY("8038_s3", NULL), |
| 111 | }; |
| 112 | VREG_CONSUMERS(S4) = { |
| 113 | REGULATOR_SUPPLY("8038_s4", NULL), |
| 114 | }; |
| 115 | VREG_CONSUMERS(S5) = { |
| 116 | REGULATOR_SUPPLY("8038_s5", NULL), |
David Collins | b455842 | 2012-01-05 10:50:49 -0800 | [diff] [blame^] | 117 | REGULATOR_SUPPLY("krait0", NULL), |
David Collins | 1d4061b | 2011-12-06 15:36:40 -0800 | [diff] [blame] | 118 | }; |
| 119 | VREG_CONSUMERS(S6) = { |
| 120 | REGULATOR_SUPPLY("8038_s6", NULL), |
David Collins | b455842 | 2012-01-05 10:50:49 -0800 | [diff] [blame^] | 121 | REGULATOR_SUPPLY("krait1", NULL), |
David Collins | 1d4061b | 2011-12-06 15:36:40 -0800 | [diff] [blame] | 122 | }; |
| 123 | VREG_CONSUMERS(LVS1) = { |
| 124 | REGULATOR_SUPPLY("8038_lvs1", NULL), |
| 125 | }; |
| 126 | VREG_CONSUMERS(LVS2) = { |
| 127 | REGULATOR_SUPPLY("8038_lvs2", NULL), |
| 128 | }; |
| 129 | VREG_CONSUMERS(EXT_5V) = { |
| 130 | REGULATOR_SUPPLY("ext_5v", NULL), |
| 131 | }; |
| 132 | VREG_CONSUMERS(EXT_OTG_SW) = { |
| 133 | REGULATOR_SUPPLY("ext_otg_sw", NULL), |
Mayank Rana | bf5084a | 2011-12-12 17:06:54 +0530 | [diff] [blame] | 134 | REGULATOR_SUPPLY("vbus_otg", "msm_otg"), |
David Collins | 1d4061b | 2011-12-06 15:36:40 -0800 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | #define PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, _modes, _ops, \ |
| 138 | _apply_uV, _pull_down, _always_on, _supply_regulator, \ |
| 139 | _system_uA, _enable_time, _reg_id) \ |
| 140 | { \ |
| 141 | .init_data = { \ |
| 142 | .constraints = { \ |
| 143 | .valid_modes_mask = _modes, \ |
| 144 | .valid_ops_mask = _ops, \ |
| 145 | .min_uV = _min_uV, \ |
| 146 | .max_uV = _max_uV, \ |
| 147 | .input_uV = _max_uV, \ |
| 148 | .apply_uV = _apply_uV, \ |
| 149 | .always_on = _always_on, \ |
| 150 | .name = _name, \ |
| 151 | }, \ |
| 152 | .num_consumer_supplies = \ |
| 153 | ARRAY_SIZE(vreg_consumers_##_id), \ |
| 154 | .consumer_supplies = vreg_consumers_##_id, \ |
| 155 | .supply_regulator = _supply_regulator, \ |
| 156 | }, \ |
| 157 | .id = _reg_id, \ |
| 158 | .pull_down_enable = _pull_down, \ |
| 159 | .system_uA = _system_uA, \ |
| 160 | .enable_time = _enable_time, \ |
| 161 | } |
| 162 | |
| 163 | #define PM8XXX_LDO(_id, _name, _always_on, _pull_down, _min_uV, _max_uV, \ |
| 164 | _enable_time, _supply_regulator, _system_uA, _reg_id) \ |
| 165 | PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \ |
| 166 | | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \ |
| 167 | REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \ |
| 168 | REGULATOR_CHANGE_DRMS, 0, _pull_down, _always_on, \ |
| 169 | _supply_regulator, _system_uA, _enable_time, _reg_id) |
| 170 | |
| 171 | #define PM8XXX_NLDO1200(_id, _name, _always_on, _pull_down, _min_uV, \ |
| 172 | _max_uV, _enable_time, _supply_regulator, _system_uA, _reg_id) \ |
| 173 | PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \ |
| 174 | | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \ |
| 175 | REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \ |
| 176 | REGULATOR_CHANGE_DRMS, 0, _pull_down, _always_on, \ |
| 177 | _supply_regulator, _system_uA, _enable_time, _reg_id) |
| 178 | |
| 179 | #define PM8XXX_SMPS(_id, _name, _always_on, _pull_down, _min_uV, _max_uV, \ |
| 180 | _enable_time, _supply_regulator, _system_uA, _reg_id) \ |
| 181 | PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \ |
| 182 | | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \ |
| 183 | REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \ |
| 184 | REGULATOR_CHANGE_DRMS, 0, _pull_down, _always_on, \ |
| 185 | _supply_regulator, _system_uA, _enable_time, _reg_id) |
| 186 | |
| 187 | #define PM8XXX_FTSMPS(_id, _name, _always_on, _pull_down, _min_uV, _max_uV, \ |
| 188 | _enable_time, _supply_regulator, _system_uA, _reg_id) \ |
| 189 | PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \ |
| 190 | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS \ |
| 191 | | REGULATOR_CHANGE_MODE, 0, _pull_down, _always_on, \ |
| 192 | _supply_regulator, _system_uA, _enable_time, _reg_id) |
| 193 | |
| 194 | #define PM8XXX_VS(_id, _name, _always_on, _pull_down, _enable_time, \ |
| 195 | _supply_regulator, _reg_id) \ |
| 196 | PM8XXX_VREG_INIT(_id, _name, 0, 0, 0, REGULATOR_CHANGE_STATUS, 0, \ |
| 197 | _pull_down, _always_on, _supply_regulator, 0, _enable_time, \ |
| 198 | _reg_id) |
| 199 | |
| 200 | #define PM8XXX_VS300(_id, _name, _always_on, _pull_down, _enable_time, \ |
| 201 | _supply_regulator, _reg_id) \ |
| 202 | PM8XXX_VREG_INIT(_id, _name, 0, 0, 0, REGULATOR_CHANGE_STATUS, 0, \ |
| 203 | _pull_down, _always_on, _supply_regulator, 0, _enable_time, \ |
| 204 | _reg_id) |
| 205 | |
| 206 | #define PM8XXX_NCP(_id, _name, _always_on, _min_uV, _max_uV, _enable_time, \ |
| 207 | _supply_regulator, _reg_id) \ |
| 208 | PM8XXX_VREG_INIT(_id, _name, _min_uV, _max_uV, 0, \ |
| 209 | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS, 0, 0, \ |
| 210 | _always_on, _supply_regulator, 0, _enable_time, _reg_id) |
| 211 | |
| 212 | /* Pin control initialization */ |
| 213 | #define PM8XXX_PC(_id, _name, _always_on, _pin_fn, _pin_ctrl, \ |
| 214 | _supply_regulator, _reg_id) \ |
| 215 | { \ |
| 216 | .init_data = { \ |
| 217 | .constraints = { \ |
| 218 | .valid_ops_mask = REGULATOR_CHANGE_STATUS, \ |
| 219 | .always_on = _always_on, \ |
| 220 | .name = _name, \ |
| 221 | }, \ |
| 222 | .num_consumer_supplies = \ |
| 223 | ARRAY_SIZE(vreg_consumers_##_id##_PC), \ |
| 224 | .consumer_supplies = vreg_consumers_##_id##_PC, \ |
| 225 | .supply_regulator = _supply_regulator, \ |
| 226 | }, \ |
| 227 | .id = _reg_id, \ |
| 228 | .pin_fn = PM8XXX_VREG_PIN_FN_##_pin_fn, \ |
| 229 | .pin_ctrl = _pin_ctrl, \ |
| 230 | } |
| 231 | |
| 232 | #define GPIO_VREG(_id, _reg_name, _gpio_label, _gpio, _supply_regulator) \ |
| 233 | [MSM8930_GPIO_VREG_ID_##_id] = { \ |
| 234 | .init_data = { \ |
| 235 | .constraints = { \ |
| 236 | .valid_ops_mask = REGULATOR_CHANGE_STATUS, \ |
| 237 | }, \ |
| 238 | .num_consumer_supplies = \ |
| 239 | ARRAY_SIZE(vreg_consumers_##_id), \ |
| 240 | .consumer_supplies = vreg_consumers_##_id, \ |
| 241 | .supply_regulator = _supply_regulator, \ |
| 242 | }, \ |
| 243 | .regulator_name = _reg_name, \ |
| 244 | .gpio_label = _gpio_label, \ |
| 245 | .gpio = _gpio, \ |
| 246 | } |
| 247 | |
David Collins | b455842 | 2012-01-05 10:50:49 -0800 | [diff] [blame^] | 248 | #define SAW_VREG_INIT(_id, _name, _min_uV, _max_uV) \ |
| 249 | { \ |
| 250 | .constraints = { \ |
| 251 | .name = _name, \ |
| 252 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, \ |
| 253 | .min_uV = _min_uV, \ |
| 254 | .max_uV = _max_uV, \ |
| 255 | }, \ |
| 256 | .num_consumer_supplies = ARRAY_SIZE(vreg_consumers_##_id), \ |
| 257 | .consumer_supplies = vreg_consumers_##_id, \ |
| 258 | } |
| 259 | |
David Collins | 1d4061b | 2011-12-06 15:36:40 -0800 | [diff] [blame] | 260 | /* GPIO regulator constraints */ |
| 261 | struct gpio_regulator_platform_data |
| 262 | msm8930_gpio_regulator_pdata[] __devinitdata = { |
| 263 | /* ID vreg_name gpio_label gpio supply */ |
| 264 | GPIO_VREG(EXT_5V, "ext_5v", "ext_5v_en", 63, NULL), |
| 265 | GPIO_VREG(EXT_OTG_SW, "ext_otg_sw", "ext_otg_sw_en", 97, "ext_5v"), |
| 266 | }; |
| 267 | |
David Collins | b455842 | 2012-01-05 10:50:49 -0800 | [diff] [blame^] | 268 | /* SAW regulator constraints */ |
| 269 | struct regulator_init_data msm8930_saw_regulator_core0_pdata = |
| 270 | /* ID vreg_name min_uV max_uV */ |
| 271 | SAW_VREG_INIT(S5, "8038_s5", 850000, 1300000); |
| 272 | struct regulator_init_data msm8930_saw_regulator_core1_pdata = |
| 273 | SAW_VREG_INIT(S6, "8038_s6", 850000, 1300000); |
| 274 | |
David Collins | 1d4061b | 2011-12-06 15:36:40 -0800 | [diff] [blame] | 275 | /* PM8038 regulator constraints */ |
| 276 | struct pm8xxx_regulator_platform_data |
| 277 | msm8930_pm8038_regulator_pdata[] __devinitdata = { |
| 278 | /* |
| 279 | * ID name always_on pd min_uV max_uV en_t supply |
| 280 | * system_uA reg_ID |
| 281 | */ |
| 282 | PM8XXX_SMPS(S1, "8038_s1", 1, 1, 1150000, 1150000, 500, NULL, 100000, |
| 283 | 26), |
| 284 | PM8XXX_SMPS(S2, "8038_s2", 1, 1, 1400000, 1400000, 500, NULL, 100000, |
| 285 | 27), |
| 286 | PM8XXX_SMPS(S3, "8038_s3", 0, 1, 1150000, 1150000, 500, NULL, 0, 28), |
| 287 | PM8XXX_SMPS(S4, "8038_s4", 1, 1, 2200000, 2200000, 500, NULL, 100000, |
| 288 | 29), |
| 289 | |
David Collins | 1d4061b | 2011-12-06 15:36:40 -0800 | [diff] [blame] | 290 | PM8XXX_NLDO1200(L1, "8038_l1", 0, 1, 1300000, 1300000, 200, "8038_s2", |
| 291 | 0, 1), |
| 292 | PM8XXX_LDO(L2, "8038_l2", 0, 1, 1200000, 1200000, 200, "8038_s2", 0, |
| 293 | 2), |
| 294 | PM8XXX_LDO(L3, "8038_l3", 0, 1, 3075000, 3075000, 200, NULL, 0, 3), |
| 295 | PM8XXX_LDO(L4, "8038_l4", 1, 1, 1800000, 1800000, 200, NULL, 10000, |
| 296 | 4), |
| 297 | PM8XXX_LDO(L5, "8038_l5", 0, 1, 2950000, 2950000, 200, NULL, 0, 5), |
| 298 | PM8XXX_LDO(L6, "8038_l6", 0, 1, 2950000, 2950000, 200, NULL, 0, 6), |
| 299 | PM8XXX_LDO(L7, "8038_l7", 0, 1, 2050000, 2050000, 200, "8038_s4", 0, |
| 300 | 7), |
| 301 | PM8XXX_LDO(L8, "8038_l8", 0, 1, 2800000, 2800000, 200, NULL, 0, 8), |
| 302 | PM8XXX_LDO(L9, "8038_l9", 0, 1, 2850000, 2850000, 200, NULL, 0, 9), |
| 303 | PM8XXX_LDO(L10, "8038_l10", 0, 1, 2900000, 2900000, 200, NULL, 0, 10), |
| 304 | PM8XXX_LDO(L11, "8038_l11", 1, 1, 1800000, 1800000, 200, "8038_s4", |
| 305 | 10000, 11), |
| 306 | PM8XXX_LDO(L12, "8038_l12", 0, 1, 1200000, 1200000, 200, "8038_s2", 0, |
| 307 | 12), |
| 308 | PM8XXX_LDO(L14, "8038_l14", 0, 1, 1800000, 1800000, 200, NULL, 0, 13), |
| 309 | PM8XXX_LDO(L15, "8038_l15", 0, 1, 1800000, 2950000, 200, NULL, 0, 14), |
| 310 | PM8XXX_NLDO1200(L16, "8038_l16", 0, 1, 1050000, 1050000, 200, "8038_s3", |
| 311 | 0, 15), |
| 312 | PM8XXX_LDO(L17, "8038_l17", 0, 1, 1800000, 2950000, 200, NULL, 0, 16), |
| 313 | PM8XXX_LDO(L18, "8038_l18", 0, 1, 1800000, 1800000, 200, NULL, 0, 17), |
| 314 | PM8XXX_NLDO1200(L19, "8038_l19", 0, 1, 1050000, 1050000, 200, "8038_s3", |
| 315 | 0, 18), |
| 316 | PM8XXX_NLDO1200(L20, "8038_l20", 1, 1, 1200000, 1200000, 200, "8038_s2", |
| 317 | 10000, 19), |
| 318 | PM8XXX_LDO(L21, "8038_l21", 0, 1, 1900000, 1900000, 200, "8038_s4", 0, |
| 319 | 20), |
| 320 | PM8XXX_LDO(L22, "8038_l22", 1, 1, 2950000, 2950000, 200, NULL, 10000, |
| 321 | 21), |
| 322 | PM8XXX_LDO(L23, "8038_l23", 0, 1, 1800000, 1800000, 200, "8038_s4", 0, |
| 323 | 22), |
| 324 | PM8XXX_NLDO1200(L24, "8038_l24", 1, 1, 1150000, 1150000, 200, "8038_s2", |
| 325 | 10000, 23), |
| 326 | PM8XXX_LDO(L26, "8038_l26", 1, 1, 1050000, 1050000, 200, "8038_s2", |
| 327 | 10000, 24), |
| 328 | PM8XXX_NLDO1200(L27, "8038_l27", 0, 1, 1050000, 1050000, 200, "8038_s3", |
| 329 | 0, 25), |
| 330 | |
| 331 | /* ID name always_on pd en_t supply reg_ID */ |
| 332 | PM8XXX_VS(LVS1, "8038_lvs1", 0, 1, 0, "8038_l11", 32), |
| 333 | PM8XXX_VS(LVS2, "8038_lvs2", 0, 1, 0, "8038_l11", 33), |
| 334 | |
| 335 | }; |
| 336 | |
| 337 | int msm8930_pm8038_regulator_pdata_len __devinitdata = |
| 338 | ARRAY_SIZE(msm8930_pm8038_regulator_pdata); |