Michael Bohan | 037a0f5 | 2012-02-29 19:13:09 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2012, Code Aurora Forum. 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 | */ |
| 13 | |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/regulator/stub-regulator.h> |
| 16 | |
| 17 | #define VREG_CONSUMERS(_name) \ |
| 18 | static struct regulator_consumer_supply vreg_consumers_##_name[] |
| 19 | |
| 20 | /* |
| 21 | * Consumer specific regulator names: |
| 22 | * regulator name consumer dev_name |
| 23 | */ |
| 24 | VREG_CONSUMERS(S1B) = { |
| 25 | REGULATOR_SUPPLY("8841_s1", NULL), |
| 26 | }; |
| 27 | VREG_CONSUMERS(S2B) = { |
| 28 | REGULATOR_SUPPLY("8841_s2", NULL), |
| 29 | }; |
| 30 | VREG_CONSUMERS(S3B) = { |
| 31 | REGULATOR_SUPPLY("8841_s3", NULL), |
| 32 | }; |
| 33 | VREG_CONSUMERS(S4B) = { |
| 34 | REGULATOR_SUPPLY("8841_s4", NULL), |
| 35 | }; |
| 36 | VREG_CONSUMERS(S5B) = { |
| 37 | REGULATOR_SUPPLY("8841_s5", NULL), |
| 38 | }; |
| 39 | VREG_CONSUMERS(S6B) = { |
| 40 | REGULATOR_SUPPLY("8841_s6", NULL), |
| 41 | }; |
| 42 | VREG_CONSUMERS(S7B) = { |
| 43 | REGULATOR_SUPPLY("8841_s7", NULL), |
| 44 | }; |
| 45 | VREG_CONSUMERS(S8B) = { |
| 46 | REGULATOR_SUPPLY("8841_s8", NULL), |
| 47 | }; |
| 48 | VREG_CONSUMERS(S1) = { |
| 49 | REGULATOR_SUPPLY("8941_s1", NULL), |
| 50 | }; |
| 51 | VREG_CONSUMERS(S2) = { |
| 52 | REGULATOR_SUPPLY("8941_s2", NULL), |
| 53 | }; |
| 54 | VREG_CONSUMERS(S3) = { |
| 55 | REGULATOR_SUPPLY("8941_s3", NULL), |
| 56 | }; |
| 57 | VREG_CONSUMERS(L1) = { |
| 58 | REGULATOR_SUPPLY("8941_l1", NULL), |
| 59 | }; |
| 60 | VREG_CONSUMERS(L2) = { |
| 61 | REGULATOR_SUPPLY("8941_l2", NULL), |
| 62 | }; |
| 63 | VREG_CONSUMERS(L3) = { |
| 64 | REGULATOR_SUPPLY("8941_l3", NULL), |
| 65 | }; |
| 66 | VREG_CONSUMERS(L4) = { |
| 67 | REGULATOR_SUPPLY("8941_l4", NULL), |
| 68 | }; |
| 69 | VREG_CONSUMERS(L5) = { |
| 70 | REGULATOR_SUPPLY("8941_l5", NULL), |
| 71 | }; |
| 72 | VREG_CONSUMERS(L6) = { |
| 73 | REGULATOR_SUPPLY("8941_l6", NULL), |
| 74 | }; |
| 75 | VREG_CONSUMERS(L7) = { |
| 76 | REGULATOR_SUPPLY("8941_l7", NULL), |
| 77 | }; |
| 78 | VREG_CONSUMERS(L8) = { |
| 79 | REGULATOR_SUPPLY("8941_l8", NULL), |
| 80 | }; |
| 81 | VREG_CONSUMERS(L9) = { |
| 82 | REGULATOR_SUPPLY("8941_l9", NULL), |
| 83 | }; |
| 84 | VREG_CONSUMERS(L10) = { |
| 85 | REGULATOR_SUPPLY("8941_l10", NULL), |
| 86 | }; |
| 87 | VREG_CONSUMERS(L11) = { |
| 88 | REGULATOR_SUPPLY("8941_l11", NULL), |
| 89 | }; |
| 90 | VREG_CONSUMERS(L12) = { |
| 91 | REGULATOR_SUPPLY("8941_l12", NULL), |
| 92 | }; |
| 93 | VREG_CONSUMERS(L13) = { |
| 94 | REGULATOR_SUPPLY("8941_l13", NULL), |
| 95 | }; |
| 96 | VREG_CONSUMERS(L14) = { |
| 97 | REGULATOR_SUPPLY("8941_l14", NULL), |
| 98 | }; |
| 99 | VREG_CONSUMERS(L15) = { |
| 100 | REGULATOR_SUPPLY("8941_l15", NULL), |
| 101 | }; |
| 102 | VREG_CONSUMERS(L16) = { |
| 103 | REGULATOR_SUPPLY("8941_l16", NULL), |
| 104 | }; |
| 105 | VREG_CONSUMERS(L17) = { |
| 106 | REGULATOR_SUPPLY("8941_l17", NULL), |
| 107 | }; |
| 108 | VREG_CONSUMERS(L18) = { |
| 109 | REGULATOR_SUPPLY("8941_l18", NULL), |
| 110 | }; |
| 111 | VREG_CONSUMERS(L19) = { |
| 112 | REGULATOR_SUPPLY("8941_l19", NULL), |
| 113 | }; |
| 114 | VREG_CONSUMERS(L20) = { |
| 115 | REGULATOR_SUPPLY("8941_l20", NULL), |
| 116 | }; |
| 117 | VREG_CONSUMERS(L21) = { |
| 118 | REGULATOR_SUPPLY("8941_l21", NULL), |
| 119 | }; |
| 120 | VREG_CONSUMERS(L22) = { |
| 121 | REGULATOR_SUPPLY("8941_l22", NULL), |
| 122 | }; |
| 123 | VREG_CONSUMERS(L23) = { |
| 124 | REGULATOR_SUPPLY("8941_l23", NULL), |
| 125 | }; |
| 126 | VREG_CONSUMERS(L24) = { |
| 127 | REGULATOR_SUPPLY("8941_l24", NULL), |
| 128 | }; |
| 129 | VREG_CONSUMERS(LVS1) = { |
| 130 | REGULATOR_SUPPLY("8941_lvs1", NULL), |
| 131 | }; |
| 132 | VREG_CONSUMERS(LVS2) = { |
| 133 | REGULATOR_SUPPLY("8941_lvs2", NULL), |
| 134 | }; |
| 135 | VREG_CONSUMERS(LVS3) = { |
| 136 | REGULATOR_SUPPLY("8941_lvs3", NULL), |
| 137 | }; |
| 138 | |
| 139 | #define PM8X41_VREG_INIT(_id, _name, _min_uV, _max_uV, _modes, _ops, \ |
| 140 | _always_on, _supply_regulator, _hpm_min, _system_uA) \ |
| 141 | struct stub_regulator_pdata vreg_dev_##_id##_pdata __devinitdata = { \ |
| 142 | .init_data = { \ |
| 143 | .constraints = { \ |
| 144 | .valid_modes_mask = _modes, \ |
| 145 | .valid_ops_mask = _ops, \ |
| 146 | .min_uV = _min_uV, \ |
| 147 | .max_uV = _max_uV, \ |
| 148 | .input_uV = _max_uV, \ |
| 149 | .apply_uV = 0, \ |
| 150 | .always_on = _always_on, \ |
| 151 | .name = _name, \ |
| 152 | }, \ |
| 153 | .num_consumer_supplies = \ |
| 154 | ARRAY_SIZE(vreg_consumers_##_id), \ |
| 155 | .consumer_supplies = vreg_consumers_##_id, \ |
| 156 | .supply_regulator = _supply_regulator, \ |
| 157 | }, \ |
| 158 | .hpm_min_load = _hpm_min, \ |
| 159 | .system_uA = _system_uA, \ |
| 160 | } |
| 161 | |
| 162 | #define PM8X41_LDO(_id, _name, _always_on, _min_uV, _max_uV, \ |
| 163 | _supply_regulator, _hpm_min, _system_uA) \ |
| 164 | PM8X41_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \ |
| 165 | | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \ |
| 166 | REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \ |
| 167 | REGULATOR_CHANGE_DRMS, _always_on, \ |
| 168 | _supply_regulator, _hpm_min, _system_uA) |
| 169 | |
| 170 | #define PM8X41_SMPS(_id, _name, _always_on, _min_uV, _max_uV, \ |
| 171 | _supply_regulator, _hpm_min, _system_uA) \ |
| 172 | PM8X41_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \ |
| 173 | | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \ |
| 174 | REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \ |
| 175 | REGULATOR_CHANGE_DRMS, _always_on, \ |
| 176 | _supply_regulator, _hpm_min, _system_uA) |
| 177 | |
| 178 | #define PM8X41_FTSMPS(_id, _name, _always_on, _min_uV, _max_uV, \ |
| 179 | _supply_regulator, _hpm_min, _system_uA) \ |
| 180 | PM8X41_VREG_INIT(_id, _name, _min_uV, _max_uV, REGULATOR_MODE_NORMAL, \ |
| 181 | REGULATOR_CHANGE_VOLTAGE | REGULATOR_CHANGE_STATUS \ |
| 182 | | REGULATOR_CHANGE_MODE, _always_on, \ |
| 183 | _supply_regulator, _hpm_min, _system_uA) |
| 184 | |
| 185 | #define PM8X41_VS(_id, _name, _always_on, _supply_regulator) \ |
| 186 | PM8X41_VREG_INIT(_id, _name, 0, 0, 0, REGULATOR_CHANGE_STATUS, \ |
| 187 | _always_on, _supply_regulator, 0, 0) |
| 188 | |
| 189 | /* PM8x41 regulator constraints */ |
| 190 | |
| 191 | /* ID name a_on min_uV max_uV supply hpm_min sys_uA */ |
| 192 | PM8X41_SMPS(S1B, "8841_s1", 0, 900000, 1150000, NULL, 100000, 0); |
| 193 | PM8X41_FTSMPS(S2B, "8841_s2", 0, 900000, 1150000, NULL, 100000, 0); |
| 194 | PM8X41_SMPS(S3B, "8841_s3", 0, 1150000, 1150000, NULL, 100000, 0); |
| 195 | PM8X41_FTSMPS(S4B, "8841_s4", 0, 900000, 900000, NULL, 100000, 0); |
| 196 | PM8X41_FTSMPS(S5B, "8841_s5", 0, 850000, 1100000, NULL, 100000, 0); |
| 197 | PM8X41_FTSMPS(S6B, "8841_s6", 0, 850000, 1100000, NULL, 100000, 0); |
| 198 | PM8X41_FTSMPS(S7B, "8841_s7", 0, 850000, 1100000, NULL, 100000, 0); |
| 199 | PM8X41_FTSMPS(S8B, "8841_s8", 0, 850000, 1100000, NULL, 100000, 0); |
| 200 | PM8X41_SMPS(S1, "8941_s1", 0, 1300000, 1300000, NULL, 100000, 0); |
| 201 | PM8X41_SMPS(S2, "8941_s2", 0, 2150000, 2150000, NULL, 100000, 0); |
| 202 | PM8X41_SMPS(S3, "8941_s3", 0, 1800000, 1800000, NULL, 100000, 0); |
| 203 | PM8X41_LDO(L1, "8941_l1", 0, 1225000, 1225000, "8941_s1", 100000, 0); |
| 204 | PM8X41_LDO(L2, "8941_l2", 0, 1200000, 1200000, "8941_s3", 5000, 0); |
| 205 | PM8X41_LDO(L3, "8941_l3", 0, 1200000, 1200000, "8941_s1", 10000, 0); |
| 206 | PM8X41_LDO(L4, "8941_l4", 0, 1150000, 1150000, "8941_s1", 10000, 0); |
| 207 | PM8X41_LDO(L5, "8941_l5", 0, 1800000, 1800000, "8941_s2", 1000, 0); |
| 208 | PM8X41_LDO(L6, "8941_l6", 0, 1800000, 1800000, "8941_s2", 10000, 0); |
| 209 | PM8X41_LDO(L7, "8941_l7", 0, 1800000, 1800000, "8941_s2", 1000, 0); |
| 210 | PM8X41_LDO(L8, "8941_l8", 0, 1800000, 1800000, NULL, 1000, 0); |
| 211 | PM8X41_LDO(L9, "8941_l9", 0, 1800000, 2950000, NULL, 10000, 0); |
| 212 | PM8X41_LDO(L10, "8941_l10", 0, 1800000, 2950000, NULL, 10000, 0); |
| 213 | PM8X41_LDO(L11, "8941_l11", 0, 1250000, 1250000, "8941_s1", 10000, 0); |
| 214 | PM8X41_LDO(L12, "8941_l12", 0, 1800000, 1800000, "8941_s2", 10000, 0); |
| 215 | PM8X41_LDO(L13, "8941_l13", 0, 2950000, 2950000, NULL, 10000, 0); |
| 216 | PM8X41_LDO(L14, "8941_l14", 0, 1800000, 1800000, "8941_s2", 10000, 0); |
| 217 | PM8X41_LDO(L15, "8941_l15", 0, 2050000, 2050000, "8941_s2", 10000, 0); |
| 218 | PM8X41_LDO(L16, "8941_l16", 0, 2700000, 2700000, NULL, 10000, 0); |
| 219 | PM8X41_LDO(L17, "8941_l17", 0, 2850000, 2850000, NULL, 10000, 0); |
| 220 | PM8X41_LDO(L18, "8941_l18", 0, 2850000, 2850000, NULL, 10000, 0); |
| 221 | PM8X41_LDO(L19, "8941_l19", 0, 2900000, 2900000, NULL, 10000, 0); |
| 222 | PM8X41_LDO(L20, "8941_l20", 0, 2950000, 2950000, NULL, 10000, 0); |
| 223 | PM8X41_LDO(L21, "8941_l21", 0, 2950000, 2950000, NULL, 10000, 0); |
| 224 | PM8X41_LDO(L22, "8941_l22", 0, 3000000, 3000000, NULL, 10000, 0); |
| 225 | PM8X41_LDO(L23, "8941_l23", 0, 3000000, 3000000, NULL, 10000, 0); |
| 226 | PM8X41_LDO(L24, "8941_l24", 0, 3075000, 3075000, NULL, 5000, 0); |
| 227 | |
| 228 | /* ID name a_on supply */ |
| 229 | PM8X41_VS(LVS1, "8941_lvs1", 0, "8941_s3"); |
| 230 | PM8X41_VS(LVS2, "8941_lvs2", 0, "8941_s3"); |
| 231 | PM8X41_VS(LVS3, "8941_lvs3", 0, "8941_s3"); |
| 232 | |
| 233 | #define VREG_DEVICE(_name, _devid) \ |
| 234 | vreg_device_##_name __devinitdata = \ |
| 235 | { \ |
| 236 | .name = STUB_REGULATOR_DRIVER_NAME, \ |
| 237 | .id = _devid, \ |
| 238 | .dev = { .platform_data = &vreg_dev_##_name##_pdata }, \ |
| 239 | } |
| 240 | |
| 241 | static struct platform_device VREG_DEVICE(S1B, 0); |
| 242 | static struct platform_device VREG_DEVICE(S2B, 1); |
| 243 | static struct platform_device VREG_DEVICE(S3B, 3); |
| 244 | static struct platform_device VREG_DEVICE(S4B, 4); |
| 245 | static struct platform_device VREG_DEVICE(S5B, 5); |
| 246 | static struct platform_device VREG_DEVICE(S6B, 6); |
| 247 | static struct platform_device VREG_DEVICE(S7B, 7); |
| 248 | static struct platform_device VREG_DEVICE(S8B, 8); |
| 249 | static struct platform_device VREG_DEVICE(S1, 9); |
| 250 | static struct platform_device VREG_DEVICE(S2, 10); |
| 251 | static struct platform_device VREG_DEVICE(S3, 11); |
| 252 | static struct platform_device VREG_DEVICE(L1, 12); |
| 253 | static struct platform_device VREG_DEVICE(L2, 13); |
| 254 | static struct platform_device VREG_DEVICE(L3, 14); |
| 255 | static struct platform_device VREG_DEVICE(L4, 15); |
| 256 | static struct platform_device VREG_DEVICE(L5, 16); |
| 257 | static struct platform_device VREG_DEVICE(L6, 17); |
| 258 | static struct platform_device VREG_DEVICE(L7, 18); |
| 259 | static struct platform_device VREG_DEVICE(L8, 19); |
| 260 | static struct platform_device VREG_DEVICE(L9, 20); |
| 261 | static struct platform_device VREG_DEVICE(L10, 21); |
| 262 | static struct platform_device VREG_DEVICE(L11, 22); |
| 263 | static struct platform_device VREG_DEVICE(L12, 23); |
| 264 | static struct platform_device VREG_DEVICE(L13, 24); |
| 265 | static struct platform_device VREG_DEVICE(L14, 25); |
| 266 | static struct platform_device VREG_DEVICE(L15, 26); |
| 267 | static struct platform_device VREG_DEVICE(L16, 27); |
| 268 | static struct platform_device VREG_DEVICE(L17, 28); |
| 269 | static struct platform_device VREG_DEVICE(L18, 29); |
| 270 | static struct platform_device VREG_DEVICE(L19, 30); |
| 271 | static struct platform_device VREG_DEVICE(L20, 31); |
| 272 | static struct platform_device VREG_DEVICE(L21, 32); |
| 273 | static struct platform_device VREG_DEVICE(L22, 33); |
| 274 | static struct platform_device VREG_DEVICE(L23, 34); |
| 275 | static struct platform_device VREG_DEVICE(L24, 35); |
| 276 | static struct platform_device VREG_DEVICE(LVS1, 36); |
| 277 | static struct platform_device VREG_DEVICE(LVS2, 37); |
| 278 | static struct platform_device VREG_DEVICE(LVS3, 38); |
| 279 | |
| 280 | struct platform_device *msm_copper_stub_regulator_devices[] __devinitdata = { |
| 281 | &vreg_device_S1B, |
| 282 | &vreg_device_S2B, |
| 283 | &vreg_device_S3B, |
| 284 | &vreg_device_S4B, |
| 285 | &vreg_device_S5B, |
| 286 | &vreg_device_S6B, |
| 287 | &vreg_device_S7B, |
| 288 | &vreg_device_S8B, |
| 289 | &vreg_device_S1, |
| 290 | &vreg_device_S2, |
| 291 | &vreg_device_S3, |
| 292 | &vreg_device_L1, |
| 293 | &vreg_device_L2, |
| 294 | &vreg_device_L3, |
| 295 | &vreg_device_L4, |
| 296 | &vreg_device_L5, |
| 297 | &vreg_device_L6, |
| 298 | &vreg_device_L7, |
| 299 | &vreg_device_L8, |
| 300 | &vreg_device_L9, |
| 301 | &vreg_device_L10, |
| 302 | &vreg_device_L11, |
| 303 | &vreg_device_L12, |
| 304 | &vreg_device_L13, |
| 305 | &vreg_device_L14, |
| 306 | &vreg_device_L15, |
| 307 | &vreg_device_L16, |
| 308 | &vreg_device_L17, |
| 309 | &vreg_device_L18, |
| 310 | &vreg_device_L19, |
| 311 | &vreg_device_L20, |
| 312 | &vreg_device_L21, |
| 313 | &vreg_device_L22, |
| 314 | &vreg_device_L23, |
| 315 | &vreg_device_L24, |
| 316 | &vreg_device_LVS1, |
| 317 | &vreg_device_LVS2, |
| 318 | &vreg_device_LVS3, |
| 319 | }; |
| 320 | |
| 321 | int msm_copper_stub_regulator_devices_len __devinitdata = |
| 322 | ARRAY_SIZE(msm_copper_stub_regulator_devices); |