blob: a7f0eac0cd725da1d7519f44bff2f163c6ad2734 [file] [log] [blame]
Michael Bohan037a0f52012-02-29 19:13:09 -08001/*
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 */
24VREG_CONSUMERS(S1B) = {
25 REGULATOR_SUPPLY("8841_s1", NULL),
26};
27VREG_CONSUMERS(S2B) = {
28 REGULATOR_SUPPLY("8841_s2", NULL),
29};
30VREG_CONSUMERS(S3B) = {
31 REGULATOR_SUPPLY("8841_s3", NULL),
32};
33VREG_CONSUMERS(S4B) = {
34 REGULATOR_SUPPLY("8841_s4", NULL),
35};
36VREG_CONSUMERS(S5B) = {
37 REGULATOR_SUPPLY("8841_s5", NULL),
38};
39VREG_CONSUMERS(S6B) = {
40 REGULATOR_SUPPLY("8841_s6", NULL),
41};
42VREG_CONSUMERS(S7B) = {
43 REGULATOR_SUPPLY("8841_s7", NULL),
44};
45VREG_CONSUMERS(S8B) = {
46 REGULATOR_SUPPLY("8841_s8", NULL),
47};
48VREG_CONSUMERS(S1) = {
49 REGULATOR_SUPPLY("8941_s1", NULL),
50};
51VREG_CONSUMERS(S2) = {
52 REGULATOR_SUPPLY("8941_s2", NULL),
53};
54VREG_CONSUMERS(S3) = {
55 REGULATOR_SUPPLY("8941_s3", NULL),
56};
57VREG_CONSUMERS(L1) = {
58 REGULATOR_SUPPLY("8941_l1", NULL),
59};
60VREG_CONSUMERS(L2) = {
61 REGULATOR_SUPPLY("8941_l2", NULL),
62};
63VREG_CONSUMERS(L3) = {
64 REGULATOR_SUPPLY("8941_l3", NULL),
65};
66VREG_CONSUMERS(L4) = {
67 REGULATOR_SUPPLY("8941_l4", NULL),
68};
69VREG_CONSUMERS(L5) = {
70 REGULATOR_SUPPLY("8941_l5", NULL),
71};
72VREG_CONSUMERS(L6) = {
73 REGULATOR_SUPPLY("8941_l6", NULL),
74};
75VREG_CONSUMERS(L7) = {
76 REGULATOR_SUPPLY("8941_l7", NULL),
77};
78VREG_CONSUMERS(L8) = {
79 REGULATOR_SUPPLY("8941_l8", NULL),
80};
81VREG_CONSUMERS(L9) = {
82 REGULATOR_SUPPLY("8941_l9", NULL),
83};
84VREG_CONSUMERS(L10) = {
85 REGULATOR_SUPPLY("8941_l10", NULL),
86};
87VREG_CONSUMERS(L11) = {
88 REGULATOR_SUPPLY("8941_l11", NULL),
89};
90VREG_CONSUMERS(L12) = {
91 REGULATOR_SUPPLY("8941_l12", NULL),
92};
93VREG_CONSUMERS(L13) = {
94 REGULATOR_SUPPLY("8941_l13", NULL),
95};
96VREG_CONSUMERS(L14) = {
97 REGULATOR_SUPPLY("8941_l14", NULL),
98};
99VREG_CONSUMERS(L15) = {
100 REGULATOR_SUPPLY("8941_l15", NULL),
101};
102VREG_CONSUMERS(L16) = {
103 REGULATOR_SUPPLY("8941_l16", NULL),
104};
105VREG_CONSUMERS(L17) = {
106 REGULATOR_SUPPLY("8941_l17", NULL),
107};
108VREG_CONSUMERS(L18) = {
109 REGULATOR_SUPPLY("8941_l18", NULL),
110};
111VREG_CONSUMERS(L19) = {
112 REGULATOR_SUPPLY("8941_l19", NULL),
113};
114VREG_CONSUMERS(L20) = {
115 REGULATOR_SUPPLY("8941_l20", NULL),
116};
117VREG_CONSUMERS(L21) = {
118 REGULATOR_SUPPLY("8941_l21", NULL),
119};
120VREG_CONSUMERS(L22) = {
121 REGULATOR_SUPPLY("8941_l22", NULL),
122};
123VREG_CONSUMERS(L23) = {
124 REGULATOR_SUPPLY("8941_l23", NULL),
125};
126VREG_CONSUMERS(L24) = {
127 REGULATOR_SUPPLY("8941_l24", NULL),
128};
129VREG_CONSUMERS(LVS1) = {
130 REGULATOR_SUPPLY("8941_lvs1", NULL),
131};
132VREG_CONSUMERS(LVS2) = {
133 REGULATOR_SUPPLY("8941_lvs2", NULL),
134};
135VREG_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 */
192PM8X41_SMPS(S1B, "8841_s1", 0, 900000, 1150000, NULL, 100000, 0);
193PM8X41_FTSMPS(S2B, "8841_s2", 0, 900000, 1150000, NULL, 100000, 0);
194PM8X41_SMPS(S3B, "8841_s3", 0, 1150000, 1150000, NULL, 100000, 0);
195PM8X41_FTSMPS(S4B, "8841_s4", 0, 900000, 900000, NULL, 100000, 0);
196PM8X41_FTSMPS(S5B, "8841_s5", 0, 850000, 1100000, NULL, 100000, 0);
197PM8X41_FTSMPS(S6B, "8841_s6", 0, 850000, 1100000, NULL, 100000, 0);
198PM8X41_FTSMPS(S7B, "8841_s7", 0, 850000, 1100000, NULL, 100000, 0);
199PM8X41_FTSMPS(S8B, "8841_s8", 0, 850000, 1100000, NULL, 100000, 0);
200PM8X41_SMPS(S1, "8941_s1", 0, 1300000, 1300000, NULL, 100000, 0);
201PM8X41_SMPS(S2, "8941_s2", 0, 2150000, 2150000, NULL, 100000, 0);
202PM8X41_SMPS(S3, "8941_s3", 0, 1800000, 1800000, NULL, 100000, 0);
203PM8X41_LDO(L1, "8941_l1", 0, 1225000, 1225000, "8941_s1", 100000, 0);
204PM8X41_LDO(L2, "8941_l2", 0, 1200000, 1200000, "8941_s3", 5000, 0);
205PM8X41_LDO(L3, "8941_l3", 0, 1200000, 1200000, "8941_s1", 10000, 0);
206PM8X41_LDO(L4, "8941_l4", 0, 1150000, 1150000, "8941_s1", 10000, 0);
207PM8X41_LDO(L5, "8941_l5", 0, 1800000, 1800000, "8941_s2", 1000, 0);
208PM8X41_LDO(L6, "8941_l6", 0, 1800000, 1800000, "8941_s2", 10000, 0);
209PM8X41_LDO(L7, "8941_l7", 0, 1800000, 1800000, "8941_s2", 1000, 0);
210PM8X41_LDO(L8, "8941_l8", 0, 1800000, 1800000, NULL, 1000, 0);
211PM8X41_LDO(L9, "8941_l9", 0, 1800000, 2950000, NULL, 10000, 0);
212PM8X41_LDO(L10, "8941_l10", 0, 1800000, 2950000, NULL, 10000, 0);
213PM8X41_LDO(L11, "8941_l11", 0, 1250000, 1250000, "8941_s1", 10000, 0);
214PM8X41_LDO(L12, "8941_l12", 0, 1800000, 1800000, "8941_s2", 10000, 0);
215PM8X41_LDO(L13, "8941_l13", 0, 2950000, 2950000, NULL, 10000, 0);
216PM8X41_LDO(L14, "8941_l14", 0, 1800000, 1800000, "8941_s2", 10000, 0);
217PM8X41_LDO(L15, "8941_l15", 0, 2050000, 2050000, "8941_s2", 10000, 0);
218PM8X41_LDO(L16, "8941_l16", 0, 2700000, 2700000, NULL, 10000, 0);
219PM8X41_LDO(L17, "8941_l17", 0, 2850000, 2850000, NULL, 10000, 0);
220PM8X41_LDO(L18, "8941_l18", 0, 2850000, 2850000, NULL, 10000, 0);
221PM8X41_LDO(L19, "8941_l19", 0, 2900000, 2900000, NULL, 10000, 0);
222PM8X41_LDO(L20, "8941_l20", 0, 2950000, 2950000, NULL, 10000, 0);
223PM8X41_LDO(L21, "8941_l21", 0, 2950000, 2950000, NULL, 10000, 0);
224PM8X41_LDO(L22, "8941_l22", 0, 3000000, 3000000, NULL, 10000, 0);
225PM8X41_LDO(L23, "8941_l23", 0, 3000000, 3000000, NULL, 10000, 0);
226PM8X41_LDO(L24, "8941_l24", 0, 3075000, 3075000, NULL, 5000, 0);
227
228/* ID name a_on supply */
229PM8X41_VS(LVS1, "8941_lvs1", 0, "8941_s3");
230PM8X41_VS(LVS2, "8941_lvs2", 0, "8941_s3");
231PM8X41_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
241static struct platform_device VREG_DEVICE(S1B, 0);
242static struct platform_device VREG_DEVICE(S2B, 1);
243static struct platform_device VREG_DEVICE(S3B, 3);
244static struct platform_device VREG_DEVICE(S4B, 4);
245static struct platform_device VREG_DEVICE(S5B, 5);
246static struct platform_device VREG_DEVICE(S6B, 6);
247static struct platform_device VREG_DEVICE(S7B, 7);
248static struct platform_device VREG_DEVICE(S8B, 8);
249static struct platform_device VREG_DEVICE(S1, 9);
250static struct platform_device VREG_DEVICE(S2, 10);
251static struct platform_device VREG_DEVICE(S3, 11);
252static struct platform_device VREG_DEVICE(L1, 12);
253static struct platform_device VREG_DEVICE(L2, 13);
254static struct platform_device VREG_DEVICE(L3, 14);
255static struct platform_device VREG_DEVICE(L4, 15);
256static struct platform_device VREG_DEVICE(L5, 16);
257static struct platform_device VREG_DEVICE(L6, 17);
258static struct platform_device VREG_DEVICE(L7, 18);
259static struct platform_device VREG_DEVICE(L8, 19);
260static struct platform_device VREG_DEVICE(L9, 20);
261static struct platform_device VREG_DEVICE(L10, 21);
262static struct platform_device VREG_DEVICE(L11, 22);
263static struct platform_device VREG_DEVICE(L12, 23);
264static struct platform_device VREG_DEVICE(L13, 24);
265static struct platform_device VREG_DEVICE(L14, 25);
266static struct platform_device VREG_DEVICE(L15, 26);
267static struct platform_device VREG_DEVICE(L16, 27);
268static struct platform_device VREG_DEVICE(L17, 28);
269static struct platform_device VREG_DEVICE(L18, 29);
270static struct platform_device VREG_DEVICE(L19, 30);
271static struct platform_device VREG_DEVICE(L20, 31);
272static struct platform_device VREG_DEVICE(L21, 32);
273static struct platform_device VREG_DEVICE(L22, 33);
274static struct platform_device VREG_DEVICE(L23, 34);
275static struct platform_device VREG_DEVICE(L24, 35);
276static struct platform_device VREG_DEVICE(LVS1, 36);
277static struct platform_device VREG_DEVICE(LVS2, 37);
278static struct platform_device VREG_DEVICE(LVS3, 38);
279
280struct 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
321int msm_copper_stub_regulator_devices_len __devinitdata =
322 ARRAY_SIZE(msm_copper_stub_regulator_devices);