blob: 6568bef7641b4dca3900d3940f53619f627f2430 [file] [log] [blame]
David Collins00b31e62011-08-31 20:00:10 -07001/*
2 * Copyright (c) 2011, 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/regulator/pm8018-regulator.h>
David Collins0f9942a2011-10-31 09:47:34 -070015#include <linux/regulator/gpio-regulator.h>
David Collinsbea297a2011-09-28 13:11:14 -070016#include <mach/rpm-regulator.h>
David Collins00b31e62011-08-31 20:00:10 -070017
18#include "board-9615.h"
19
20#define VREG_CONSUMERS(_id) \
21 static struct regulator_consumer_supply vreg_consumers_##_id[]
22
23/*
24 * Consumer specific regulator names:
25 * regulator name consumer dev_name
26 */
27VREG_CONSUMERS(L2) = {
28 REGULATOR_SUPPLY("8018_l2", NULL),
Amit Blayf8b609e2011-09-02 20:42:53 +030029 REGULATOR_SUPPLY("HSUSB_1p8", "msm_otg"),
David Collins00b31e62011-08-31 20:00:10 -070030};
31VREG_CONSUMERS(L3) = {
32 REGULATOR_SUPPLY("8018_l3", NULL),
33};
34VREG_CONSUMERS(L4) = {
35 REGULATOR_SUPPLY("8018_l4", NULL),
Amit Blayf8b609e2011-09-02 20:42:53 +030036 REGULATOR_SUPPLY("HSUSB_3p3", "msm_otg"),
David Collins00b31e62011-08-31 20:00:10 -070037};
38VREG_CONSUMERS(L5) = {
39 REGULATOR_SUPPLY("8018_l5", NULL),
40};
41VREG_CONSUMERS(L6) = {
42 REGULATOR_SUPPLY("8018_l6", NULL),
43};
44VREG_CONSUMERS(L7) = {
45 REGULATOR_SUPPLY("8018_l7", NULL),
46};
47VREG_CONSUMERS(L8) = {
48 REGULATOR_SUPPLY("8018_l8", NULL),
49};
50VREG_CONSUMERS(L9) = {
51 REGULATOR_SUPPLY("8018_l9", NULL),
52};
53VREG_CONSUMERS(L10) = {
54 REGULATOR_SUPPLY("8018_l10", NULL),
55};
56VREG_CONSUMERS(L11) = {
57 REGULATOR_SUPPLY("8018_l11", NULL),
58};
59VREG_CONSUMERS(L12) = {
60 REGULATOR_SUPPLY("8018_l12", NULL),
61};
62VREG_CONSUMERS(L13) = {
63 REGULATOR_SUPPLY("8018_l13", NULL),
64};
65VREG_CONSUMERS(L14) = {
66 REGULATOR_SUPPLY("8018_l14", NULL),
67};
68VREG_CONSUMERS(S1) = {
69 REGULATOR_SUPPLY("8018_s1", NULL),
Amit Blayf8b609e2011-09-02 20:42:53 +030070 REGULATOR_SUPPLY("HSUSB_VDDCX", "msm_otg"),
David Collins00b31e62011-08-31 20:00:10 -070071};
72VREG_CONSUMERS(S2) = {
73 REGULATOR_SUPPLY("8018_s2", NULL),
74};
75VREG_CONSUMERS(S3) = {
76 REGULATOR_SUPPLY("8018_s3", NULL),
77};
78VREG_CONSUMERS(S4) = {
79 REGULATOR_SUPPLY("8018_s4", NULL),
80};
81VREG_CONSUMERS(S5) = {
82 REGULATOR_SUPPLY("8018_s5", NULL),
83};
84VREG_CONSUMERS(LVS1) = {
85 REGULATOR_SUPPLY("8018_lvs1", NULL),
86};
David Collins0f9942a2011-10-31 09:47:34 -070087VREG_CONSUMERS(EXT_2P95V) = {
88 REGULATOR_SUPPLY("ext_2p95v", NULL),
89};
David Collins00b31e62011-08-31 20:00:10 -070090
91#define PM8018_VREG_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, \
92 _pull_down, _always_on, _supply_regulator, \
93 _system_uA, _enable_time) \
94 { \
95 .init_data = { \
96 .constraints = { \
97 .valid_modes_mask = _modes, \
98 .valid_ops_mask = _ops, \
99 .min_uV = _min_uV, \
100 .max_uV = _max_uV, \
101 .input_uV = _max_uV, \
102 .apply_uV = _apply_uV, \
103 .always_on = _always_on, \
104 }, \
105 .num_consumer_supplies = \
106 ARRAY_SIZE(vreg_consumers_##_id), \
107 .consumer_supplies = vreg_consumers_##_id, \
108 .supply_regulator = _supply_regulator, \
109 }, \
110 .id = PM8018_VREG_ID_##_id, \
111 .pull_down_enable = _pull_down, \
112 .system_uA = _system_uA, \
113 .enable_time = _enable_time, \
114 }
115
116#define PM8018_VREG_INIT_LDO(_id, _always_on, _pull_down, _min_uV, _max_uV, \
117 _enable_time, _supply_regulator, _system_uA) \
118 PM8018_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \
119 | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \
120 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
121 REGULATOR_CHANGE_DRMS, 0, _pull_down, _always_on, \
122 _supply_regulator, _system_uA, _enable_time)
123
124#define PM8018_VREG_INIT_NLDO1200(_id, _always_on, _pull_down, _min_uV, \
125 _max_uV, _enable_time, _supply_regulator, _system_uA) \
126 PM8018_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \
127 | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \
128 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
129 REGULATOR_CHANGE_DRMS, 0, _pull_down, _always_on, \
130 _supply_regulator, _system_uA, _enable_time)
131
132#define PM8018_VREG_INIT_SMPS(_id, _always_on, _pull_down, _min_uV, _max_uV, \
133 _enable_time, _supply_regulator, _system_uA) \
134 PM8018_VREG_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \
135 | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE | \
136 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE | \
137 REGULATOR_CHANGE_DRMS, 0, _pull_down, _always_on, \
138 _supply_regulator, _system_uA, _enable_time)
139
140#define PM8018_VREG_INIT_VS(_id, _always_on, _pull_down, _enable_time, \
141 _supply_regulator) \
142 PM8018_VREG_INIT(_id, 0, 0, 0, REGULATOR_CHANGE_STATUS, 0, _pull_down, \
143 _always_on, _supply_regulator, 0, _enable_time)
144
145/* Pin control initialization */
146#define PM8018_PC_INIT(_id, _always_on, _pin_fn, _pin_ctrl, _supply_regulator) \
147 { \
148 .init_data = { \
149 .constraints = { \
150 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
151 .always_on = _always_on, \
152 }, \
153 .num_consumer_supplies = \
154 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
155 .consumer_supplies = vreg_consumers_##_id##_PC, \
156 .supply_regulator = _supply_regulator, \
157 }, \
158 .id = PM8018_VREG_ID_##_id##_PC, \
159 .pin_fn = PM8018_VREG_PIN_FN_##_pin_fn, \
160 .pin_ctrl = _pin_ctrl, \
161 }
162
David Collinsbea297a2011-09-28 13:11:14 -0700163#define RPM_INIT(_id, _min_uV, _max_uV, _modes, _ops, _apply_uV, _default_uV, \
164 _peak_uA, _avg_uA, _pull_down, _pin_ctrl, _freq, _pin_fn, \
165 _force_mode, _power_mode, _state, _sleep_selectable, \
166 _always_on, _supply_regulator, _system_uA) \
167 { \
168 .init_data = { \
169 .constraints = { \
170 .valid_modes_mask = _modes, \
171 .valid_ops_mask = _ops, \
172 .min_uV = _min_uV, \
173 .max_uV = _max_uV, \
174 .input_uV = _min_uV, \
175 .apply_uV = _apply_uV, \
176 .always_on = _always_on, \
177 }, \
178 .num_consumer_supplies = \
179 ARRAY_SIZE(vreg_consumers_##_id), \
180 .consumer_supplies = vreg_consumers_##_id, \
181 .supply_regulator = _supply_regulator, \
182 }, \
183 .id = RPM_VREG_ID_PM8018_##_id, \
184 .default_uV = _default_uV, \
185 .peak_uA = _peak_uA, \
186 .avg_uA = _avg_uA, \
187 .pull_down_enable = _pull_down, \
188 .pin_ctrl = _pin_ctrl, \
189 .freq = RPM_VREG_FREQ_##_freq, \
190 .pin_fn = _pin_fn, \
191 .force_mode = _force_mode, \
192 .power_mode = _power_mode, \
193 .state = _state, \
194 .sleep_selectable = _sleep_selectable, \
195 .system_uA = _system_uA, \
196 }
197
198#define RPM_LDO(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
199 _supply_regulator, _system_uA, _init_peak_uA) \
200 RPM_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \
201 | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE \
202 | REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE \
203 | REGULATOR_CHANGE_DRMS, 0, _max_uV, _init_peak_uA, 0, _pd, \
204 RPM_VREG_PIN_CTRL_NONE, NONE, RPM_VREG_PIN_FN_9615_NONE, \
205 RPM_VREG_FORCE_MODE_9615_NONE, RPM_VREG_POWER_MODE_9615_PWM, \
206 RPM_VREG_STATE_OFF, _sleep_selectable, _always_on, \
207 _supply_regulator, _system_uA)
208
209#define RPM_SMPS(_id, _always_on, _pd, _sleep_selectable, _min_uV, _max_uV, \
210 _supply_regulator, _system_uA, _freq) \
211 RPM_INIT(_id, _min_uV, _max_uV, REGULATOR_MODE_NORMAL \
212 | REGULATOR_MODE_IDLE, REGULATOR_CHANGE_VOLTAGE \
213 | REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_MODE \
214 | REGULATOR_CHANGE_DRMS, 0, _max_uV, _system_uA, 0, _pd, \
215 RPM_VREG_PIN_CTRL_NONE, _freq, RPM_VREG_PIN_FN_9615_NONE, \
216 RPM_VREG_FORCE_MODE_9615_NONE, RPM_VREG_POWER_MODE_9615_PWM, \
217 RPM_VREG_STATE_OFF, _sleep_selectable, _always_on, \
218 _supply_regulator, _system_uA)
219
220#define RPM_VS(_id, _always_on, _pd, _sleep_selectable, _supply_regulator) \
221 RPM_INIT(_id, 0, 0, 0, REGULATOR_CHANGE_STATUS, 0, 0, 1000, 1000, _pd, \
222 RPM_VREG_PIN_CTRL_NONE, NONE, RPM_VREG_PIN_FN_9615_NONE, \
223 RPM_VREG_FORCE_MODE_9615_NONE, RPM_VREG_POWER_MODE_9615_PWM, \
224 RPM_VREG_STATE_OFF, _sleep_selectable, _always_on, \
225 _supply_regulator, 0)
226
227/* Pin control initialization */
228#define RPM_PC_INIT(_id, _always_on, _pin_fn, _pin_ctrl, _supply_regulator) \
229 { \
230 .init_data = { \
231 .constraints = { \
232 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
233 .always_on = _always_on, \
234 }, \
235 .num_consumer_supplies = \
236 ARRAY_SIZE(vreg_consumers_##_id##_PC), \
237 .consumer_supplies = vreg_consumers_##_id##_PC, \
238 .supply_regulator = _supply_regulator, \
239 }, \
240 .id = RPM_VREG_ID_PM8018_##_id##_PC, \
241 .pin_fn = RPM_VREG_PIN_FN_9615_##_pin_fn, \
242 .pin_ctrl = _pin_ctrl, \
243 }
244
David Collins0f9942a2011-10-31 09:47:34 -0700245#define GPIO_VREG_INIT(_id, _reg_name, _gpio_label, _gpio) \
246 [GPIO_VREG_ID_##_id] = { \
247 .init_data = { \
248 .constraints = { \
249 .valid_ops_mask = REGULATOR_CHANGE_STATUS, \
250 }, \
251 .num_consumer_supplies = \
252 ARRAY_SIZE(vreg_consumers_##_id), \
253 .consumer_supplies = vreg_consumers_##_id, \
254 }, \
255 .regulator_name = _reg_name, \
256 .gpio_label = _gpio_label, \
257 .gpio = _gpio, \
258 }
259
260/* GPIO regulator constraints */
261struct gpio_regulator_platform_data msm_gpio_regulator_pdata[] = {
262 GPIO_VREG_INIT(EXT_2P95V, "ext_2p95v", "ext_2p95_en", 18),
263};
David Collinsbea297a2011-09-28 13:11:14 -0700264
David Collins00b31e62011-08-31 20:00:10 -0700265/* PM8018 regulator constraints */
266struct pm8018_regulator_platform_data
267msm_pm8018_regulator_pdata[] __devinitdata = {
David Collinsbea297a2011-09-28 13:11:14 -0700268};
David Collins00b31e62011-08-31 20:00:10 -0700269
David Collinsbea297a2011-09-28 13:11:14 -0700270static struct rpm_regulator_init_data
271msm_rpm_regulator_init_data[] __devinitdata = {
272 /* ID a_on pd ss min_uV max_uV supply sys_uA freq */
Matt Wagantallb1be5662011-10-18 13:28:58 -0700273 RPM_SMPS(S1, 1, 1, 1, 950000, 1150000, NULL, 100000, 1p60),
David Collinsbea297a2011-09-28 13:11:14 -0700274 RPM_SMPS(S2, 0, 1, 0, 1225000, 1300000, NULL, 0, 1p60),
275 RPM_SMPS(S3, 1, 1, 0, 1800000, 1800000, NULL, 100000, 1p60),
276 RPM_SMPS(S4, 0, 1, 0, 2100000, 2200000, NULL, 0, 1p60),
277 RPM_SMPS(S5, 1, 1, 0, 1350000, 1350000, NULL, 100000, 1p60),
David Collins00b31e62011-08-31 20:00:10 -0700278
David Collinsbea297a2011-09-28 13:11:14 -0700279 /* ID a_on pd ss min_uV max_uV supply sys_uA init_ip */
280 RPM_LDO(L2, 1, 1, 0, 1800000, 1800000, NULL, 0, 10000),
281 RPM_LDO(L3, 0, 1, 0, 1800000, 1800000, NULL, 0, 0),
282 RPM_LDO(L4, 0, 1, 0, 3075000, 3075000, NULL, 0, 0),
283 RPM_LDO(L5, 0, 1, 0, 2850000, 2850000, NULL, 0, 0),
284 RPM_LDO(L6, 0, 1, 0, 1800000, 2850000, NULL, 0, 0),
285 RPM_LDO(L7, 0, 1, 0, 1850000, 1900000, "8018_s4", 0, 0),
286 RPM_LDO(L8, 0, 1, 0, 1200000, 1200000, "8018_s3", 0, 0),
Matt Wagantallb1be5662011-10-18 13:28:58 -0700287 RPM_LDO(L9, 1, 1, 1, 1050000, 1150000, "8018_s5", 10000, 10000),
David Collinsbea297a2011-09-28 13:11:14 -0700288 RPM_LDO(L10, 0, 1, 0, 1050000, 1050000, "8018_s5", 0, 0),
289 RPM_LDO(L11, 0, 1, 0, 1050000, 1050000, "8018_s5", 0, 0),
290 RPM_LDO(L12, 0, 1, 0, 1050000, 1050000, "8018_s5", 0, 0),
291 RPM_LDO(L13, 0, 1, 0, 2950000, 2950000, NULL, 0, 0),
292 RPM_LDO(L14, 0, 1, 0, 2850000, 2850000, NULL, 0, 0),
293
294 /* ID a_on pd ss supply */
295 RPM_VS(LVS1, 0, 1, 0, "8018_s3"),
David Collins00b31e62011-08-31 20:00:10 -0700296};
297
298int msm_pm8018_regulator_pdata_len __devinitdata =
299 ARRAY_SIZE(msm_pm8018_regulator_pdata);
David Collinsbea297a2011-09-28 13:11:14 -0700300
301struct rpm_regulator_platform_data
302msm_rpm_regulator_9615_pdata __devinitdata = {
303 .init_data = msm_rpm_regulator_init_data,
304 .num_regulators = ARRAY_SIZE(msm_rpm_regulator_init_data),
305 .version = RPM_VREG_VERSION_9615,
306 .vreg_id_vdd_mem = RPM_VREG_ID_PM8018_L9,
307 .vreg_id_vdd_dig = RPM_VREG_ID_PM8018_S1,
308};