2 * Copyright (c) 2015, Sony Mobile Communications AB.
3 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 and
7 * only version 2 as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <linux/module.h>
17 #include <linux/of_device.h>
18 #include <linux/platform_device.h>
19 #include <linux/regulator/driver.h>
20 #include <linux/soc/qcom/smd-rpm.h>
25 struct qcom_smd_rpm
*rpm
;
30 struct regulator_desc desc
;
36 struct rpm_regulator_req
{
42 #define RPM_KEY_SWEN 0x6e657773 /* "swen" */
43 #define RPM_KEY_UV 0x00007675 /* "uv" */
44 #define RPM_KEY_MA 0x0000616d /* "ma" */
46 static int rpm_reg_write_active(struct qcom_rpm_reg
*vreg
,
47 struct rpm_regulator_req
*req
,
50 return qcom_rpm_smd_write(vreg
->rpm
,
51 QCOM_SMD_RPM_ACTIVE_STATE
,
57 static int rpm_reg_enable(struct regulator_dev
*rdev
)
59 struct qcom_rpm_reg
*vreg
= rdev_get_drvdata(rdev
);
60 struct rpm_regulator_req req
;
63 req
.key
= cpu_to_le32(RPM_KEY_SWEN
);
64 req
.nbytes
= cpu_to_le32(sizeof(u32
));
65 req
.value
= cpu_to_le32(1);
67 ret
= rpm_reg_write_active(vreg
, &req
, sizeof(req
));
74 static int rpm_reg_is_enabled(struct regulator_dev
*rdev
)
76 struct qcom_rpm_reg
*vreg
= rdev_get_drvdata(rdev
);
78 return vreg
->is_enabled
;
81 static int rpm_reg_disable(struct regulator_dev
*rdev
)
83 struct qcom_rpm_reg
*vreg
= rdev_get_drvdata(rdev
);
84 struct rpm_regulator_req req
;
87 req
.key
= cpu_to_le32(RPM_KEY_SWEN
);
88 req
.nbytes
= cpu_to_le32(sizeof(u32
));
91 ret
= rpm_reg_write_active(vreg
, &req
, sizeof(req
));
98 static int rpm_reg_get_voltage(struct regulator_dev
*rdev
)
100 struct qcom_rpm_reg
*vreg
= rdev_get_drvdata(rdev
);
105 static int rpm_reg_set_voltage(struct regulator_dev
*rdev
,
110 struct qcom_rpm_reg
*vreg
= rdev_get_drvdata(rdev
);
111 struct rpm_regulator_req req
;
114 req
.key
= cpu_to_le32(RPM_KEY_UV
);
115 req
.nbytes
= cpu_to_le32(sizeof(u32
));
116 req
.value
= cpu_to_le32(min_uV
);
118 ret
= rpm_reg_write_active(vreg
, &req
, sizeof(req
));
125 static int rpm_reg_set_load(struct regulator_dev
*rdev
, int load_uA
)
127 struct qcom_rpm_reg
*vreg
= rdev_get_drvdata(rdev
);
128 struct rpm_regulator_req req
;
130 req
.key
= cpu_to_le32(RPM_KEY_MA
);
131 req
.nbytes
= cpu_to_le32(sizeof(u32
));
132 req
.value
= cpu_to_le32(load_uA
/ 1000);
134 return rpm_reg_write_active(vreg
, &req
, sizeof(req
));
137 static const struct regulator_ops rpm_smps_ldo_ops
= {
138 .enable
= rpm_reg_enable
,
139 .disable
= rpm_reg_disable
,
140 .is_enabled
= rpm_reg_is_enabled
,
141 .list_voltage
= regulator_list_voltage_linear_range
,
143 .get_voltage
= rpm_reg_get_voltage
,
144 .set_voltage
= rpm_reg_set_voltage
,
146 .set_load
= rpm_reg_set_load
,
149 static const struct regulator_ops rpm_smps_ldo_ops_fixed
= {
150 .enable
= rpm_reg_enable
,
151 .disable
= rpm_reg_disable
,
152 .is_enabled
= rpm_reg_is_enabled
,
154 .get_voltage
= rpm_reg_get_voltage
,
155 .set_voltage
= rpm_reg_set_voltage
,
157 .set_load
= rpm_reg_set_load
,
160 static const struct regulator_ops rpm_switch_ops
= {
161 .enable
= rpm_reg_enable
,
162 .disable
= rpm_reg_disable
,
163 .is_enabled
= rpm_reg_is_enabled
,
166 static const struct regulator_ops rpm_bob_ops
= {
167 .enable
= rpm_reg_enable
,
168 .disable
= rpm_reg_disable
,
169 .is_enabled
= rpm_reg_is_enabled
,
171 .get_voltage
= rpm_reg_get_voltage
,
172 .set_voltage
= rpm_reg_set_voltage
,
175 static const struct regulator_desc pma8084_hfsmps
= {
176 .linear_ranges
= (struct regulator_linear_range
[]) {
177 REGULATOR_LINEAR_RANGE(375000, 0, 95, 12500),
178 REGULATOR_LINEAR_RANGE(1550000, 96, 158, 25000),
180 .n_linear_ranges
= 2,
182 .ops
= &rpm_smps_ldo_ops
,
185 static const struct regulator_desc pma8084_ftsmps
= {
186 .linear_ranges
= (struct regulator_linear_range
[]) {
187 REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000),
188 REGULATOR_LINEAR_RANGE(1280000, 185, 261, 10000),
190 .n_linear_ranges
= 2,
192 .ops
= &rpm_smps_ldo_ops
,
195 static const struct regulator_desc pma8084_pldo
= {
196 .linear_ranges
= (struct regulator_linear_range
[]) {
197 REGULATOR_LINEAR_RANGE( 750000, 0, 63, 12500),
198 REGULATOR_LINEAR_RANGE(1550000, 64, 126, 25000),
199 REGULATOR_LINEAR_RANGE(3100000, 127, 163, 50000),
201 .n_linear_ranges
= 3,
203 .ops
= &rpm_smps_ldo_ops
,
206 static const struct regulator_desc pma8084_nldo
= {
207 .linear_ranges
= (struct regulator_linear_range
[]) {
208 REGULATOR_LINEAR_RANGE(750000, 0, 63, 12500),
210 .n_linear_ranges
= 1,
212 .ops
= &rpm_smps_ldo_ops
,
215 static const struct regulator_desc pma8084_switch
= {
216 .ops
= &rpm_switch_ops
,
219 static const struct regulator_desc pm8x41_hfsmps
= {
220 .linear_ranges
= (struct regulator_linear_range
[]) {
221 REGULATOR_LINEAR_RANGE( 375000, 0, 95, 12500),
222 REGULATOR_LINEAR_RANGE(1575000, 96, 158, 25000),
224 .n_linear_ranges
= 2,
226 .ops
= &rpm_smps_ldo_ops
,
229 static const struct regulator_desc pm8841_ftsmps
= {
230 .linear_ranges
= (struct regulator_linear_range
[]) {
231 REGULATOR_LINEAR_RANGE(350000, 0, 184, 5000),
232 REGULATOR_LINEAR_RANGE(1280000, 185, 261, 10000),
234 .n_linear_ranges
= 2,
236 .ops
= &rpm_smps_ldo_ops
,
239 static const struct regulator_desc pm8941_boost
= {
240 .linear_ranges
= (struct regulator_linear_range
[]) {
241 REGULATOR_LINEAR_RANGE(4000000, 0, 30, 50000),
243 .n_linear_ranges
= 1,
245 .ops
= &rpm_smps_ldo_ops
,
248 static const struct regulator_desc pm8941_pldo
= {
249 .linear_ranges
= (struct regulator_linear_range
[]) {
250 REGULATOR_LINEAR_RANGE( 750000, 0, 63, 12500),
251 REGULATOR_LINEAR_RANGE(1550000, 64, 126, 25000),
252 REGULATOR_LINEAR_RANGE(3100000, 127, 163, 50000),
254 .n_linear_ranges
= 3,
256 .ops
= &rpm_smps_ldo_ops
,
259 static const struct regulator_desc pm8941_nldo
= {
260 .linear_ranges
= (struct regulator_linear_range
[]) {
261 REGULATOR_LINEAR_RANGE(750000, 0, 63, 12500),
263 .n_linear_ranges
= 1,
265 .ops
= &rpm_smps_ldo_ops
,
268 static const struct regulator_desc pm8941_lnldo
= {
271 .ops
= &rpm_smps_ldo_ops_fixed
,
274 static const struct regulator_desc pm8941_switch
= {
275 .ops
= &rpm_switch_ops
,
278 static const struct regulator_desc pm8916_pldo
= {
279 .linear_ranges
= (struct regulator_linear_range
[]) {
280 REGULATOR_LINEAR_RANGE(750000, 0, 208, 12500),
282 .n_linear_ranges
= 1,
284 .ops
= &rpm_smps_ldo_ops
,
287 static const struct regulator_desc pm8916_nldo
= {
288 .linear_ranges
= (struct regulator_linear_range
[]) {
289 REGULATOR_LINEAR_RANGE(375000, 0, 93, 12500),
291 .n_linear_ranges
= 1,
293 .ops
= &rpm_smps_ldo_ops
,
296 static const struct regulator_desc pm8916_buck_lvo_smps
= {
297 .linear_ranges
= (struct regulator_linear_range
[]) {
298 REGULATOR_LINEAR_RANGE(375000, 0, 95, 12500),
299 REGULATOR_LINEAR_RANGE(750000, 96, 127, 25000),
301 .n_linear_ranges
= 2,
303 .ops
= &rpm_smps_ldo_ops
,
306 static const struct regulator_desc pm8916_buck_hvo_smps
= {
307 .linear_ranges
= (struct regulator_linear_range
[]) {
308 REGULATOR_LINEAR_RANGE(1550000, 0, 31, 25000),
310 .n_linear_ranges
= 1,
312 .ops
= &rpm_smps_ldo_ops
,
315 static const struct regulator_desc pm8994_hfsmps
= {
316 .linear_ranges
= (struct regulator_linear_range
[]) {
317 REGULATOR_LINEAR_RANGE( 375000, 0, 95, 12500),
318 REGULATOR_LINEAR_RANGE(1550000, 96, 158, 25000),
320 .n_linear_ranges
= 2,
322 .ops
= &rpm_smps_ldo_ops
,
325 static const struct regulator_desc pm8994_ftsmps
= {
326 .linear_ranges
= (struct regulator_linear_range
[]) {
327 REGULATOR_LINEAR_RANGE(350000, 0, 199, 5000),
328 REGULATOR_LINEAR_RANGE(700000, 200, 349, 10000),
330 .n_linear_ranges
= 2,
332 .ops
= &rpm_smps_ldo_ops
,
335 static const struct regulator_desc pm8994_nldo
= {
336 .linear_ranges
= (struct regulator_linear_range
[]) {
337 REGULATOR_LINEAR_RANGE(750000, 0, 63, 12500),
339 .n_linear_ranges
= 1,
341 .ops
= &rpm_smps_ldo_ops
,
344 static const struct regulator_desc pm8994_pldo
= {
345 .linear_ranges
= (struct regulator_linear_range
[]) {
346 REGULATOR_LINEAR_RANGE( 750000, 0, 63, 12500),
347 REGULATOR_LINEAR_RANGE(1550000, 64, 126, 25000),
348 REGULATOR_LINEAR_RANGE(3100000, 127, 163, 50000),
350 .n_linear_ranges
= 3,
352 .ops
= &rpm_smps_ldo_ops
,
355 static const struct regulator_desc pm8994_switch
= {
356 .ops
= &rpm_switch_ops
,
359 static const struct regulator_desc pm8994_lnldo
= {
362 .ops
= &rpm_smps_ldo_ops_fixed
,
365 static const struct regulator_desc pm8998_ftsmps
= {
366 .linear_ranges
= (struct regulator_linear_range
[]) {
367 REGULATOR_LINEAR_RANGE(320000, 0, 258, 4000),
369 .n_linear_ranges
= 1,
371 .ops
= &rpm_smps_ldo_ops
,
374 static const struct regulator_desc pm8998_hfsmps
= {
375 .linear_ranges
= (struct regulator_linear_range
[]) {
376 REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000),
378 .n_linear_ranges
= 1,
380 .ops
= &rpm_smps_ldo_ops
,
383 static const struct regulator_desc pm8998_nldo
= {
384 .linear_ranges
= (struct regulator_linear_range
[]) {
385 REGULATOR_LINEAR_RANGE(312000, 0, 127, 8000),
387 .n_linear_ranges
= 1,
389 .ops
= &rpm_smps_ldo_ops
,
392 static const struct regulator_desc pm8998_pldo
= {
393 .linear_ranges
= (struct regulator_linear_range
[]) {
394 REGULATOR_LINEAR_RANGE(1664000, 0, 255, 8000),
396 .n_linear_ranges
= 1,
398 .ops
= &rpm_smps_ldo_ops
,
401 static const struct regulator_desc pm8998_pldo_lv
= {
402 .linear_ranges
= (struct regulator_linear_range
[]) {
403 REGULATOR_LINEAR_RANGE(1256000, 0, 127, 8000),
405 .n_linear_ranges
= 1,
407 .ops
= &rpm_smps_ldo_ops
,
410 static const struct regulator_desc pm8998_switch
= {
411 .ops
= &rpm_switch_ops
,
414 static const struct regulator_desc pmi8998_bob
= {
415 .linear_ranges
= (struct regulator_linear_range
[]) {
416 REGULATOR_LINEAR_RANGE(1824000, 0, 83, 32000),
418 .n_linear_ranges
= 1,
423 static const struct regulator_desc pms405_hfsmps3
= {
424 .linear_ranges
= (struct regulator_linear_range
[]) {
425 REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000),
427 .n_linear_ranges
= 1,
429 .ops
= &rpm_smps_ldo_ops
,
432 static const struct regulator_desc pms405_nldo300
= {
433 .linear_ranges
= (struct regulator_linear_range
[]) {
434 REGULATOR_LINEAR_RANGE(312000, 0, 127, 8000),
436 .n_linear_ranges
= 1,
438 .ops
= &rpm_smps_ldo_ops
,
441 static const struct regulator_desc pms405_nldo1200
= {
442 .linear_ranges
= (struct regulator_linear_range
[]) {
443 REGULATOR_LINEAR_RANGE(312000, 0, 127, 8000),
445 .n_linear_ranges
= 1,
447 .ops
= &rpm_smps_ldo_ops
,
450 static const struct regulator_desc pms405_pldo50
= {
451 .linear_ranges
= (struct regulator_linear_range
[]) {
452 REGULATOR_LINEAR_RANGE(1664000, 0, 128, 16000),
454 .n_linear_ranges
= 1,
456 .ops
= &rpm_smps_ldo_ops
,
459 static const struct regulator_desc pms405_pldo150
= {
460 .linear_ranges
= (struct regulator_linear_range
[]) {
461 REGULATOR_LINEAR_RANGE(1664000, 0, 128, 16000),
463 .n_linear_ranges
= 1,
465 .ops
= &rpm_smps_ldo_ops
,
468 static const struct regulator_desc pms405_pldo600
= {
469 .linear_ranges
= (struct regulator_linear_range
[]) {
470 REGULATOR_LINEAR_RANGE(1256000, 0, 98, 8000),
472 .n_linear_ranges
= 1,
474 .ops
= &rpm_smps_ldo_ops
,
477 struct rpm_regulator_data
{
481 const struct regulator_desc
*desc
;
485 static const struct rpm_regulator_data rpm_pm8841_regulators
[] = {
486 { "s1", QCOM_SMD_RPM_SMPB
, 1, &pm8x41_hfsmps
, "vdd_s1" },
487 { "s2", QCOM_SMD_RPM_SMPB
, 2, &pm8841_ftsmps
, "vdd_s2" },
488 { "s3", QCOM_SMD_RPM_SMPB
, 3, &pm8x41_hfsmps
, "vdd_s3" },
489 { "s4", QCOM_SMD_RPM_SMPB
, 4, &pm8841_ftsmps
, "vdd_s4" },
490 { "s5", QCOM_SMD_RPM_SMPB
, 5, &pm8841_ftsmps
, "vdd_s5" },
491 { "s6", QCOM_SMD_RPM_SMPB
, 6, &pm8841_ftsmps
, "vdd_s6" },
492 { "s7", QCOM_SMD_RPM_SMPB
, 7, &pm8841_ftsmps
, "vdd_s7" },
493 { "s8", QCOM_SMD_RPM_SMPB
, 8, &pm8841_ftsmps
, "vdd_s8" },
497 static const struct rpm_regulator_data rpm_pm8916_regulators
[] = {
498 { "s1", QCOM_SMD_RPM_SMPA
, 1, &pm8916_buck_lvo_smps
, "vdd_s1" },
499 { "s2", QCOM_SMD_RPM_SMPA
, 2, &pm8916_buck_lvo_smps
, "vdd_s2" },
500 { "s3", QCOM_SMD_RPM_SMPA
, 3, &pm8916_buck_lvo_smps
, "vdd_s3" },
501 { "s4", QCOM_SMD_RPM_SMPA
, 4, &pm8916_buck_hvo_smps
, "vdd_s4" },
502 { "l1", QCOM_SMD_RPM_LDOA
, 1, &pm8916_nldo
, "vdd_l1_l2_l3" },
503 { "l2", QCOM_SMD_RPM_LDOA
, 2, &pm8916_nldo
, "vdd_l1_l2_l3" },
504 { "l3", QCOM_SMD_RPM_LDOA
, 3, &pm8916_nldo
, "vdd_l1_l2_l3" },
505 { "l4", QCOM_SMD_RPM_LDOA
, 4, &pm8916_pldo
, "vdd_l4_l5_l6" },
506 { "l5", QCOM_SMD_RPM_LDOA
, 5, &pm8916_pldo
, "vdd_l4_l5_l6" },
507 { "l6", QCOM_SMD_RPM_LDOA
, 6, &pm8916_pldo
, "vdd_l4_l5_l6" },
508 { "l7", QCOM_SMD_RPM_LDOA
, 7, &pm8916_pldo
, "vdd_l7" },
509 { "l8", QCOM_SMD_RPM_LDOA
, 8, &pm8916_pldo
, "vdd_l8_l9_l10_l11_l12_l13_l14_l15_l16_l17_l18" },
510 { "l9", QCOM_SMD_RPM_LDOA
, 9, &pm8916_pldo
, "vdd_l8_l9_l10_l11_l12_l13_l14_l15_l16_l17_l18" },
511 { "l10", QCOM_SMD_RPM_LDOA
, 10, &pm8916_pldo
, "vdd_l8_l9_l10_l11_l12_l13_l14_l15_l16_l17_l18"},
512 { "l11", QCOM_SMD_RPM_LDOA
, 11, &pm8916_pldo
, "vdd_l8_l9_l10_l11_l12_l13_l14_l15_l16_l17_l18"},
513 { "l12", QCOM_SMD_RPM_LDOA
, 12, &pm8916_pldo
, "vdd_l8_l9_l10_l11_l12_l13_l14_l15_l16_l17_l18"},
514 { "l13", QCOM_SMD_RPM_LDOA
, 13, &pm8916_pldo
, "vdd_l8_l9_l10_l11_l12_l13_l14_l15_l16_l17_l18"},
515 { "l14", QCOM_SMD_RPM_LDOA
, 14, &pm8916_pldo
, "vdd_l8_l9_l10_l11_l12_l13_l14_l15_l16_l17_l18"},
516 { "l15", QCOM_SMD_RPM_LDOA
, 15, &pm8916_pldo
, "vdd_l8_l9_l10_l11_l12_l13_l14_l15_l16_l17_l18"},
517 { "l16", QCOM_SMD_RPM_LDOA
, 16, &pm8916_pldo
, "vdd_l8_l9_l10_l11_l12_l13_l14_l15_l16_l17_l18"},
518 { "l17", QCOM_SMD_RPM_LDOA
, 17, &pm8916_pldo
, "vdd_l8_l9_l10_l11_l12_l13_l14_l15_l16_l17_l18"},
519 { "l18", QCOM_SMD_RPM_LDOA
, 18, &pm8916_pldo
, "vdd_l8_l9_l10_l11_l12_l13_l14_l15_l16_l17_l18"},
523 static const struct rpm_regulator_data rpm_pm8941_regulators
[] = {
524 { "s1", QCOM_SMD_RPM_SMPA
, 1, &pm8x41_hfsmps
, "vdd_s1" },
525 { "s2", QCOM_SMD_RPM_SMPA
, 2, &pm8x41_hfsmps
, "vdd_s2" },
526 { "s3", QCOM_SMD_RPM_SMPA
, 3, &pm8x41_hfsmps
, "vdd_s3" },
527 { "s4", QCOM_SMD_RPM_BOOST
, 1, &pm8941_boost
},
529 { "l1", QCOM_SMD_RPM_LDOA
, 1, &pm8941_nldo
, "vdd_l1_l3" },
530 { "l2", QCOM_SMD_RPM_LDOA
, 2, &pm8941_nldo
, "vdd_l2_lvs1_2_3" },
531 { "l3", QCOM_SMD_RPM_LDOA
, 3, &pm8941_nldo
, "vdd_l1_l3" },
532 { "l4", QCOM_SMD_RPM_LDOA
, 4, &pm8941_nldo
, "vdd_l4_l11" },
533 { "l5", QCOM_SMD_RPM_LDOA
, 5, &pm8941_lnldo
, "vdd_l5_l7" },
534 { "l6", QCOM_SMD_RPM_LDOA
, 6, &pm8941_pldo
, "vdd_l6_l12_l14_l15" },
535 { "l7", QCOM_SMD_RPM_LDOA
, 7, &pm8941_lnldo
, "vdd_l5_l7" },
536 { "l8", QCOM_SMD_RPM_LDOA
, 8, &pm8941_pldo
, "vdd_l8_l16_l18_l19" },
537 { "l9", QCOM_SMD_RPM_LDOA
, 9, &pm8941_pldo
, "vdd_l9_l10_l17_l22" },
538 { "l10", QCOM_SMD_RPM_LDOA
, 10, &pm8941_pldo
, "vdd_l9_l10_l17_l22" },
539 { "l11", QCOM_SMD_RPM_LDOA
, 11, &pm8941_nldo
, "vdd_l4_l11" },
540 { "l12", QCOM_SMD_RPM_LDOA
, 12, &pm8941_pldo
, "vdd_l6_l12_l14_l15" },
541 { "l13", QCOM_SMD_RPM_LDOA
, 13, &pm8941_pldo
, "vdd_l13_l20_l23_l24" },
542 { "l14", QCOM_SMD_RPM_LDOA
, 14, &pm8941_pldo
, "vdd_l6_l12_l14_l15" },
543 { "l15", QCOM_SMD_RPM_LDOA
, 15, &pm8941_pldo
, "vdd_l6_l12_l14_l15" },
544 { "l16", QCOM_SMD_RPM_LDOA
, 16, &pm8941_pldo
, "vdd_l8_l16_l18_l19" },
545 { "l17", QCOM_SMD_RPM_LDOA
, 17, &pm8941_pldo
, "vdd_l9_l10_l17_l22" },
546 { "l18", QCOM_SMD_RPM_LDOA
, 18, &pm8941_pldo
, "vdd_l8_l16_l18_l19" },
547 { "l19", QCOM_SMD_RPM_LDOA
, 19, &pm8941_pldo
, "vdd_l8_l16_l18_l19" },
548 { "l20", QCOM_SMD_RPM_LDOA
, 20, &pm8941_pldo
, "vdd_l13_l20_l23_l24" },
549 { "l21", QCOM_SMD_RPM_LDOA
, 21, &pm8941_pldo
, "vdd_l21" },
550 { "l22", QCOM_SMD_RPM_LDOA
, 22, &pm8941_pldo
, "vdd_l9_l10_l17_l22" },
551 { "l23", QCOM_SMD_RPM_LDOA
, 23, &pm8941_pldo
, "vdd_l13_l20_l23_l24" },
552 { "l24", QCOM_SMD_RPM_LDOA
, 24, &pm8941_pldo
, "vdd_l13_l20_l23_l24" },
554 { "lvs1", QCOM_SMD_RPM_VSA
, 1, &pm8941_switch
, "vdd_l2_lvs1_2_3" },
555 { "lvs2", QCOM_SMD_RPM_VSA
, 2, &pm8941_switch
, "vdd_l2_lvs1_2_3" },
556 { "lvs3", QCOM_SMD_RPM_VSA
, 3, &pm8941_switch
, "vdd_l2_lvs1_2_3" },
558 { "5vs1", QCOM_SMD_RPM_VSA
, 4, &pm8941_switch
, "vin_5vs" },
559 { "5vs2", QCOM_SMD_RPM_VSA
, 5, &pm8941_switch
, "vin_5vs" },
564 static const struct rpm_regulator_data rpm_pma8084_regulators
[] = {
565 { "s1", QCOM_SMD_RPM_SMPA
, 1, &pma8084_ftsmps
, "vdd_s1" },
566 { "s2", QCOM_SMD_RPM_SMPA
, 2, &pma8084_ftsmps
, "vdd_s2" },
567 { "s3", QCOM_SMD_RPM_SMPA
, 3, &pma8084_hfsmps
, "vdd_s3" },
568 { "s4", QCOM_SMD_RPM_SMPA
, 4, &pma8084_hfsmps
, "vdd_s4" },
569 { "s5", QCOM_SMD_RPM_SMPA
, 5, &pma8084_hfsmps
, "vdd_s5" },
570 { "s6", QCOM_SMD_RPM_SMPA
, 6, &pma8084_ftsmps
, "vdd_s6" },
571 { "s7", QCOM_SMD_RPM_SMPA
, 7, &pma8084_ftsmps
, "vdd_s7" },
572 { "s8", QCOM_SMD_RPM_SMPA
, 8, &pma8084_ftsmps
, "vdd_s8" },
573 { "s9", QCOM_SMD_RPM_SMPA
, 9, &pma8084_ftsmps
, "vdd_s9" },
574 { "s10", QCOM_SMD_RPM_SMPA
, 10, &pma8084_ftsmps
, "vdd_s10" },
575 { "s11", QCOM_SMD_RPM_SMPA
, 11, &pma8084_ftsmps
, "vdd_s11" },
576 { "s12", QCOM_SMD_RPM_SMPA
, 12, &pma8084_ftsmps
, "vdd_s12" },
578 { "l1", QCOM_SMD_RPM_LDOA
, 1, &pma8084_nldo
, "vdd_l1_l11" },
579 { "l2", QCOM_SMD_RPM_LDOA
, 2, &pma8084_nldo
, "vdd_l2_l3_l4_l27" },
580 { "l3", QCOM_SMD_RPM_LDOA
, 3, &pma8084_nldo
, "vdd_l2_l3_l4_l27" },
581 { "l4", QCOM_SMD_RPM_LDOA
, 4, &pma8084_nldo
, "vdd_l2_l3_l4_l27" },
582 { "l5", QCOM_SMD_RPM_LDOA
, 5, &pma8084_pldo
, "vdd_l5_l7" },
583 { "l6", QCOM_SMD_RPM_LDOA
, 6, &pma8084_pldo
, "vdd_l6_l12_l14_l15_l26" },
584 { "l7", QCOM_SMD_RPM_LDOA
, 7, &pma8084_pldo
, "vdd_l5_l7" },
585 { "l8", QCOM_SMD_RPM_LDOA
, 8, &pma8084_pldo
, "vdd_l8" },
586 { "l9", QCOM_SMD_RPM_LDOA
, 9, &pma8084_pldo
, "vdd_l9_l10_l13_l20_l23_l24" },
587 { "l10", QCOM_SMD_RPM_LDOA
, 10, &pma8084_pldo
, "vdd_l9_l10_l13_l20_l23_l24" },
588 { "l11", QCOM_SMD_RPM_LDOA
, 11, &pma8084_nldo
, "vdd_l1_l11" },
589 { "l12", QCOM_SMD_RPM_LDOA
, 12, &pma8084_pldo
, "vdd_l6_l12_l14_l15_l26" },
590 { "l13", QCOM_SMD_RPM_LDOA
, 13, &pma8084_pldo
, "vdd_l9_l10_l13_l20_l23_l24" },
591 { "l14", QCOM_SMD_RPM_LDOA
, 14, &pma8084_pldo
, "vdd_l6_l12_l14_l15_l26" },
592 { "l15", QCOM_SMD_RPM_LDOA
, 15, &pma8084_pldo
, "vdd_l6_l12_l14_l15_l26" },
593 { "l16", QCOM_SMD_RPM_LDOA
, 16, &pma8084_pldo
, "vdd_l16_l25" },
594 { "l17", QCOM_SMD_RPM_LDOA
, 17, &pma8084_pldo
, "vdd_l17" },
595 { "l18", QCOM_SMD_RPM_LDOA
, 18, &pma8084_pldo
, "vdd_l18" },
596 { "l19", QCOM_SMD_RPM_LDOA
, 19, &pma8084_pldo
, "vdd_l19" },
597 { "l20", QCOM_SMD_RPM_LDOA
, 20, &pma8084_pldo
, "vdd_l9_l10_l13_l20_l23_l24" },
598 { "l21", QCOM_SMD_RPM_LDOA
, 21, &pma8084_pldo
, "vdd_l21" },
599 { "l22", QCOM_SMD_RPM_LDOA
, 22, &pma8084_pldo
, "vdd_l22" },
600 { "l23", QCOM_SMD_RPM_LDOA
, 23, &pma8084_pldo
, "vdd_l9_l10_l13_l20_l23_l24" },
601 { "l24", QCOM_SMD_RPM_LDOA
, 24, &pma8084_pldo
, "vdd_l9_l10_l13_l20_l23_l24" },
602 { "l25", QCOM_SMD_RPM_LDOA
, 25, &pma8084_pldo
, "vdd_l16_l25" },
603 { "l26", QCOM_SMD_RPM_LDOA
, 26, &pma8084_pldo
, "vdd_l6_l12_l14_l15_l26" },
604 { "l27", QCOM_SMD_RPM_LDOA
, 27, &pma8084_nldo
, "vdd_l2_l3_l4_l27" },
606 { "lvs1", QCOM_SMD_RPM_VSA
, 1, &pma8084_switch
},
607 { "lvs2", QCOM_SMD_RPM_VSA
, 2, &pma8084_switch
},
608 { "lvs3", QCOM_SMD_RPM_VSA
, 3, &pma8084_switch
},
609 { "lvs4", QCOM_SMD_RPM_VSA
, 4, &pma8084_switch
},
610 { "5vs1", QCOM_SMD_RPM_VSA
, 5, &pma8084_switch
},
615 static const struct rpm_regulator_data rpm_pm8994_regulators
[] = {
616 { "s1", QCOM_SMD_RPM_SMPA
, 1, &pm8994_ftsmps
, "vdd_s1" },
617 { "s2", QCOM_SMD_RPM_SMPA
, 2, &pm8994_ftsmps
, "vdd_s2" },
618 { "s3", QCOM_SMD_RPM_SMPA
, 3, &pm8994_hfsmps
, "vdd_s3" },
619 { "s4", QCOM_SMD_RPM_SMPA
, 4, &pm8994_hfsmps
, "vdd_s4" },
620 { "s5", QCOM_SMD_RPM_SMPA
, 5, &pm8994_hfsmps
, "vdd_s5" },
621 { "s6", QCOM_SMD_RPM_SMPA
, 6, &pm8994_ftsmps
, "vdd_s6" },
622 { "s7", QCOM_SMD_RPM_SMPA
, 7, &pm8994_hfsmps
, "vdd_s7" },
623 { "s8", QCOM_SMD_RPM_SMPA
, 8, &pm8994_ftsmps
, "vdd_s8" },
624 { "s9", QCOM_SMD_RPM_SMPA
, 9, &pm8994_ftsmps
, "vdd_s9" },
625 { "s10", QCOM_SMD_RPM_SMPA
, 10, &pm8994_ftsmps
, "vdd_s10" },
626 { "s11", QCOM_SMD_RPM_SMPA
, 11, &pm8994_ftsmps
, "vdd_s11" },
627 { "s12", QCOM_SMD_RPM_SMPA
, 12, &pm8994_ftsmps
, "vdd_s12" },
628 { "l1", QCOM_SMD_RPM_LDOA
, 1, &pm8994_nldo
, "vdd_l1" },
629 { "l2", QCOM_SMD_RPM_LDOA
, 2, &pm8994_nldo
, "vdd_l2_l26_l28" },
630 { "l3", QCOM_SMD_RPM_LDOA
, 3, &pm8994_nldo
, "vdd_l3_l11" },
631 { "l4", QCOM_SMD_RPM_LDOA
, 4, &pm8994_nldo
, "vdd_l4_l27_l31" },
632 { "l5", QCOM_SMD_RPM_LDOA
, 5, &pm8994_lnldo
, "vdd_l5_l7" },
633 { "l6", QCOM_SMD_RPM_LDOA
, 6, &pm8994_pldo
, "vdd_l6_l12_l32" },
634 { "l7", QCOM_SMD_RPM_LDOA
, 7, &pm8994_lnldo
, "vdd_l5_l7" },
635 { "l8", QCOM_SMD_RPM_LDOA
, 8, &pm8994_pldo
, "vdd_l8_l16_l30" },
636 { "l9", QCOM_SMD_RPM_LDOA
, 9, &pm8994_pldo
, "vdd_l9_l10_l18_l22" },
637 { "l10", QCOM_SMD_RPM_LDOA
, 10, &pm8994_pldo
, "vdd_l9_l10_l18_l22" },
638 { "l11", QCOM_SMD_RPM_LDOA
, 11, &pm8994_nldo
, "vdd_l3_l11" },
639 { "l12", QCOM_SMD_RPM_LDOA
, 12, &pm8994_pldo
, "vdd_l6_l12_l32" },
640 { "l13", QCOM_SMD_RPM_LDOA
, 13, &pm8994_pldo
, "vdd_l13_l19_l23_l24" },
641 { "l14", QCOM_SMD_RPM_LDOA
, 14, &pm8994_pldo
, "vdd_l14_l15" },
642 { "l15", QCOM_SMD_RPM_LDOA
, 15, &pm8994_pldo
, "vdd_l14_l15" },
643 { "l16", QCOM_SMD_RPM_LDOA
, 16, &pm8994_pldo
, "vdd_l8_l16_l30" },
644 { "l17", QCOM_SMD_RPM_LDOA
, 17, &pm8994_pldo
, "vdd_l17_l29" },
645 { "l18", QCOM_SMD_RPM_LDOA
, 18, &pm8994_pldo
, "vdd_l9_l10_l18_l22" },
646 { "l19", QCOM_SMD_RPM_LDOA
, 19, &pm8994_pldo
, "vdd_l13_l19_l23_l24" },
647 { "l20", QCOM_SMD_RPM_LDOA
, 20, &pm8994_pldo
, "vdd_l20_l21" },
648 { "l21", QCOM_SMD_RPM_LDOA
, 21, &pm8994_pldo
, "vdd_l20_l21" },
649 { "l22", QCOM_SMD_RPM_LDOA
, 22, &pm8994_pldo
, "vdd_l9_l10_l18_l22" },
650 { "l23", QCOM_SMD_RPM_LDOA
, 23, &pm8994_pldo
, "vdd_l13_l19_l23_l24" },
651 { "l24", QCOM_SMD_RPM_LDOA
, 24, &pm8994_pldo
, "vdd_l13_l19_l23_l24" },
652 { "l25", QCOM_SMD_RPM_LDOA
, 25, &pm8994_pldo
, "vdd_l25" },
653 { "l26", QCOM_SMD_RPM_LDOA
, 26, &pm8994_nldo
, "vdd_l2_l26_l28" },
654 { "l27", QCOM_SMD_RPM_LDOA
, 27, &pm8994_nldo
, "vdd_l4_l27_l31" },
655 { "l28", QCOM_SMD_RPM_LDOA
, 28, &pm8994_nldo
, "vdd_l2_l26_l28" },
656 { "l29", QCOM_SMD_RPM_LDOA
, 29, &pm8994_pldo
, "vdd_l17_l29" },
657 { "l30", QCOM_SMD_RPM_LDOA
, 30, &pm8994_pldo
, "vdd_l8_l16_l30" },
658 { "l31", QCOM_SMD_RPM_LDOA
, 31, &pm8994_nldo
, "vdd_l4_l27_l31" },
659 { "l32", QCOM_SMD_RPM_LDOA
, 32, &pm8994_pldo
, "vdd_l6_l12_l32" },
660 { "lvs1", QCOM_SMD_RPM_VSA
, 1, &pm8994_switch
, "vdd_lvs1_2" },
661 { "lvs2", QCOM_SMD_RPM_VSA
, 2, &pm8994_switch
, "vdd_lvs1_2" },
666 static const struct rpm_regulator_data rpm_pm8998_regulators
[] = {
667 { "s1", QCOM_SMD_RPM_SMPA
, 1, &pm8998_ftsmps
, "vdd_s1" },
668 { "s2", QCOM_SMD_RPM_SMPA
, 2, &pm8998_ftsmps
, "vdd_s2" },
669 { "s3", QCOM_SMD_RPM_SMPA
, 3, &pm8998_hfsmps
, "vdd_s3" },
670 { "s4", QCOM_SMD_RPM_SMPA
, 4, &pm8998_hfsmps
, "vdd_s4" },
671 { "s5", QCOM_SMD_RPM_SMPA
, 5, &pm8998_hfsmps
, "vdd_s5" },
672 { "s6", QCOM_SMD_RPM_SMPA
, 6, &pm8998_ftsmps
, "vdd_s6" },
673 { "s7", QCOM_SMD_RPM_SMPA
, 7, &pm8998_ftsmps
, "vdd_s7" },
674 { "s8", QCOM_SMD_RPM_SMPA
, 8, &pm8998_ftsmps
, "vdd_s8" },
675 { "s9", QCOM_SMD_RPM_SMPA
, 9, &pm8998_ftsmps
, "vdd_s9" },
676 { "s10", QCOM_SMD_RPM_SMPA
, 10, &pm8998_ftsmps
, "vdd_s10" },
677 { "s11", QCOM_SMD_RPM_SMPA
, 11, &pm8998_ftsmps
, "vdd_s11" },
678 { "s12", QCOM_SMD_RPM_SMPA
, 12, &pm8998_ftsmps
, "vdd_s12" },
679 { "s13", QCOM_SMD_RPM_SMPA
, 13, &pm8998_ftsmps
, "vdd_s13" },
680 { "l1", QCOM_SMD_RPM_LDOA
, 1, &pm8998_nldo
, "vdd_l1_l27" },
681 { "l2", QCOM_SMD_RPM_LDOA
, 2, &pm8998_nldo
, "vdd_l2_l8_l17" },
682 { "l3", QCOM_SMD_RPM_LDOA
, 3, &pm8998_nldo
, "vdd_l3_l11" },
683 { "l4", QCOM_SMD_RPM_LDOA
, 4, &pm8998_nldo
, "vdd_l4_l5" },
684 { "l5", QCOM_SMD_RPM_LDOA
, 5, &pm8998_nldo
, "vdd_l4_l5" },
685 { "l6", QCOM_SMD_RPM_LDOA
, 6, &pm8998_pldo
, "vdd_l6" },
686 { "l7", QCOM_SMD_RPM_LDOA
, 7, &pm8998_pldo_lv
, "vdd_l7_l12_l14_l15" },
687 { "l8", QCOM_SMD_RPM_LDOA
, 8, &pm8998_nldo
, "vdd_l2_l8_l17" },
688 { "l9", QCOM_SMD_RPM_LDOA
, 9, &pm8998_pldo
, "vdd_l9" },
689 { "l10", QCOM_SMD_RPM_LDOA
, 10, &pm8998_pldo
, "vdd_l10_l23_l25" },
690 { "l11", QCOM_SMD_RPM_LDOA
, 11, &pm8998_nldo
, "vdd_l3_l11" },
691 { "l12", QCOM_SMD_RPM_LDOA
, 12, &pm8998_pldo_lv
, "vdd_l7_l12_l14_l15" },
692 { "l13", QCOM_SMD_RPM_LDOA
, 13, &pm8998_pldo
, "vdd_l13_l19_l21" },
693 { "l14", QCOM_SMD_RPM_LDOA
, 14, &pm8998_pldo_lv
, "vdd_l7_l12_l14_l15" },
694 { "l15", QCOM_SMD_RPM_LDOA
, 15, &pm8998_pldo_lv
, "vdd_l7_l12_l14_l15" },
695 { "l16", QCOM_SMD_RPM_LDOA
, 16, &pm8998_pldo
, "vdd_l16_l28" },
696 { "l17", QCOM_SMD_RPM_LDOA
, 17, &pm8998_nldo
, "vdd_l2_l8_l17" },
697 { "l18", QCOM_SMD_RPM_LDOA
, 18, &pm8998_pldo
, "vdd_l18_l22" },
698 { "l19", QCOM_SMD_RPM_LDOA
, 19, &pm8998_pldo
, "vdd_l13_l19_l21" },
699 { "l20", QCOM_SMD_RPM_LDOA
, 20, &pm8998_pldo
, "vdd_l20_l24" },
700 { "l21", QCOM_SMD_RPM_LDOA
, 21, &pm8998_pldo
, "vdd_l13_l19_l21" },
701 { "l22", QCOM_SMD_RPM_LDOA
, 22, &pm8998_pldo
, "vdd_l18_l22" },
702 { "l23", QCOM_SMD_RPM_LDOA
, 23, &pm8998_pldo
, "vdd_l10_l23_l25" },
703 { "l24", QCOM_SMD_RPM_LDOA
, 24, &pm8998_pldo
, "vdd_l20_l24" },
704 { "l25", QCOM_SMD_RPM_LDOA
, 25, &pm8998_pldo
, "vdd_l10_l23_l25" },
705 { "l26", QCOM_SMD_RPM_LDOA
, 26, &pm8998_nldo
, "vdd_l26" },
706 { "l27", QCOM_SMD_RPM_LDOA
, 27, &pm8998_nldo
, "vdd_l1_l27" },
707 { "l28", QCOM_SMD_RPM_LDOA
, 28, &pm8998_pldo
, "vdd_l16_l28" },
708 { "lvs1", QCOM_SMD_RPM_VSA
, 1, &pm8998_switch
, "vdd_lvs1_lvs2" },
709 { "lvs2", QCOM_SMD_RPM_VSA
, 2, &pm8998_switch
, "vdd_lvs1_lvs2" },
713 static const struct rpm_regulator_data rpm_pmi8998_regulators
[] = {
714 { "bob", QCOM_SMD_RPM_BOBB
, 1, &pmi8998_bob
, "vdd_bob" },
718 static const struct rpm_regulator_data rpm_pms405_regulators
[] = {
719 { "s1", QCOM_SMD_RPM_SMPA
, 1, &pms405_hfsmps3
, "vdd_s1" },
720 { "s2", QCOM_SMD_RPM_SMPA
, 2, &pms405_hfsmps3
, "vdd_s2" },
721 { "s3", QCOM_SMD_RPM_SMPA
, 3, &pms405_hfsmps3
, "vdd_s3" },
722 { "s4", QCOM_SMD_RPM_SMPA
, 4, &pms405_hfsmps3
, "vdd_s4" },
723 { "s5", QCOM_SMD_RPM_SMPA
, 5, &pms405_hfsmps3
, "vdd_s5" },
724 { "l1", QCOM_SMD_RPM_LDOA
, 1, &pms405_nldo1200
, "vdd_l1_l2" },
725 { "l2", QCOM_SMD_RPM_LDOA
, 2, &pms405_nldo1200
, "vdd_l1_l2" },
726 { "l3", QCOM_SMD_RPM_LDOA
, 3, &pms405_nldo1200
, "vdd_l3_l8" },
727 { "l4", QCOM_SMD_RPM_LDOA
, 4, &pms405_nldo300
, "vdd_l4" },
728 { "l5", QCOM_SMD_RPM_LDOA
, 5, &pms405_pldo600
, "vdd_l5_l6" },
729 { "l6", QCOM_SMD_RPM_LDOA
, 6, &pms405_pldo600
, "vdd_l5_l6" },
730 { "l7", QCOM_SMD_RPM_LDOA
, 7, &pms405_pldo150
, "vdd_l7" },
731 { "l8", QCOM_SMD_RPM_LDOA
, 8, &pms405_nldo1200
, "vdd_l3_l8" },
732 { "l9", QCOM_SMD_RPM_LDOA
, 9, &pms405_nldo1200
, "vdd_l9" },
733 { "l10", QCOM_SMD_RPM_LDOA
, 10, &pms405_pldo50
, "vdd_l10_l11_l12_l13" },
734 { "l11", QCOM_SMD_RPM_LDOA
, 11, &pms405_pldo150
, "vdd_l10_l11_l12_l13" },
735 { "l12", QCOM_SMD_RPM_LDOA
, 12, &pms405_pldo150
, "vdd_l10_l11_l12_l13" },
736 { "l13", QCOM_SMD_RPM_LDOA
, 13, &pms405_pldo150
, "vdd_l10_l11_l12_l13" },
740 static const struct of_device_id rpm_of_match
[] = {
741 { .compatible
= "qcom,rpm-pm8841-regulators", .data
= &rpm_pm8841_regulators
},
742 { .compatible
= "qcom,rpm-pm8916-regulators", .data
= &rpm_pm8916_regulators
},
743 { .compatible
= "qcom,rpm-pm8941-regulators", .data
= &rpm_pm8941_regulators
},
744 { .compatible
= "qcom,rpm-pm8994-regulators", .data
= &rpm_pm8994_regulators
},
745 { .compatible
= "qcom,rpm-pm8998-regulators", .data
= &rpm_pm8998_regulators
},
746 { .compatible
= "qcom,rpm-pma8084-regulators", .data
= &rpm_pma8084_regulators
},
747 { .compatible
= "qcom,rpm-pmi8998-regulators", .data
= &rpm_pmi8998_regulators
},
748 { .compatible
= "qcom,rpm-pms405-regulators", .data
= &rpm_pms405_regulators
},
751 MODULE_DEVICE_TABLE(of
, rpm_of_match
);
753 static int rpm_reg_probe(struct platform_device
*pdev
)
755 const struct rpm_regulator_data
*reg
;
756 const struct of_device_id
*match
;
757 struct regulator_config config
= { };
758 struct regulator_dev
*rdev
;
759 struct qcom_rpm_reg
*vreg
;
760 struct qcom_smd_rpm
*rpm
;
762 rpm
= dev_get_drvdata(pdev
->dev
.parent
);
764 dev_err(&pdev
->dev
, "unable to retrieve handle to rpm\n");
768 match
= of_match_device(rpm_of_match
, &pdev
->dev
);
770 dev_err(&pdev
->dev
, "failed to match device\n");
774 for (reg
= match
->data
; reg
->name
; reg
++) {
775 vreg
= devm_kzalloc(&pdev
->dev
, sizeof(*vreg
), GFP_KERNEL
);
779 vreg
->dev
= &pdev
->dev
;
780 vreg
->type
= reg
->type
;
784 memcpy(&vreg
->desc
, reg
->desc
, sizeof(vreg
->desc
));
787 vreg
->desc
.owner
= THIS_MODULE
;
788 vreg
->desc
.type
= REGULATOR_VOLTAGE
;
789 vreg
->desc
.name
= reg
->name
;
790 vreg
->desc
.supply_name
= reg
->supply
;
791 vreg
->desc
.of_match
= reg
->name
;
793 config
.dev
= &pdev
->dev
;
794 config
.driver_data
= vreg
;
795 rdev
= devm_regulator_register(&pdev
->dev
, &vreg
->desc
, &config
);
797 dev_err(&pdev
->dev
, "failed to register %s\n", reg
->name
);
798 return PTR_ERR(rdev
);
805 static struct platform_driver rpm_reg_driver
= {
806 .probe
= rpm_reg_probe
,
808 .name
= "qcom_rpm_smd_regulator",
809 .of_match_table
= rpm_of_match
,
813 static int __init
rpm_reg_init(void)
815 return platform_driver_register(&rpm_reg_driver
);
817 subsys_initcall(rpm_reg_init
);
819 static void __exit
rpm_reg_exit(void)
821 platform_driver_unregister(&rpm_reg_driver
);
823 module_exit(rpm_reg_exit
)
825 MODULE_DESCRIPTION("Qualcomm RPM regulator driver");
826 MODULE_LICENSE("GPL v2");