1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson SA 2010
5 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
6 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
7 * Daniel Willerud <daniel.willerud@stericsson.com> for ST-Ericsson
9 * AB8500 peripheral regulators
11 * AB8500 supports the following regulators:
12 * VAUX1/2/3, VINTCORE, VTVOUT, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA
14 * AB8505 supports the following regulators:
15 * VAUX1/2/3/4/5/6, VINTCORE, VADC, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA
17 #include <linux/init.h>
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/err.h>
21 #include <linux/platform_device.h>
22 #include <linux/mfd/abx500.h>
23 #include <linux/mfd/abx500/ab8500.h>
25 #include <linux/regulator/of_regulator.h>
26 #include <linux/regulator/driver.h>
27 #include <linux/regulator/machine.h>
28 #include <linux/regulator/ab8500.h>
29 #include <linux/slab.h>
32 * struct ab8500_shared_mode - is used when mode is shared between
34 * @shared_regulator: pointer to the other sharing regulator
35 * @lp_mode_req: low power mode requested by this regulator
37 struct ab8500_shared_mode
{
38 struct ab8500_regulator_info
*shared_regulator
;
43 * struct ab8500_regulator_info - ab8500 regulator information
44 * @dev: device pointer
45 * @desc: regulator description
46 * @shared_mode: used when mode is shared between two regulators
47 * @load_lp_uA: maximum load in idle (low power) mode
48 * @update_bank: bank to control on/off
49 * @update_reg: register to control on/off
50 * @update_mask: mask to enable/disable and set mode of regulator
51 * @update_val: bits holding the regulator current mode
52 * @update_val_idle: bits to enable the regulator in idle (low power) mode
53 * @update_val_normal: bits to enable the regulator in normal (high power) mode
54 * @mode_bank: bank with location of mode register
55 * @mode_reg: mode register
56 * @mode_mask: mask for setting mode
57 * @mode_val_idle: mode setting for low power
58 * @mode_val_normal: mode setting for normal power
59 * @voltage_bank: bank to control regulator voltage
60 * @voltage_reg: register to control regulator voltage
61 * @voltage_mask: mask to control regulator voltage
63 struct ab8500_regulator_info
{
65 struct regulator_desc desc
;
66 struct ab8500_shared_mode
*shared_mode
;
90 /* voltage tables for the vauxn/vintcore supplies */
91 static const unsigned int ldo_vauxn_voltages
[] = {
110 static const unsigned int ldo_vaux3_voltages
[] = {
121 static const unsigned int ldo_vaux56_voltages
[] = {
132 static const unsigned int ldo_vintcore_voltages
[] = {
142 static const unsigned int ldo_sdio_voltages
[] = {
153 static const unsigned int fixed_1200000_voltage
[] = {
157 static const unsigned int fixed_1800000_voltage
[] = {
161 static const unsigned int fixed_2000000_voltage
[] = {
165 static const unsigned int fixed_2050000_voltage
[] = {
169 static const unsigned int fixed_3300000_voltage
[] = {
173 static const unsigned int ldo_vana_voltages
[] = {
184 static const unsigned int ldo_vaudio_voltages
[] = {
192 2600000, /* Duplicated in Vaudio and IsoUicc Control register. */
195 static const unsigned int ldo_vdmic_voltages
[] = {
202 static DEFINE_MUTEX(shared_mode_mutex
);
203 static struct ab8500_shared_mode ldo_anamic1_shared
;
204 static struct ab8500_shared_mode ldo_anamic2_shared
;
206 static int ab8500_regulator_enable(struct regulator_dev
*rdev
)
209 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
212 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
216 ret
= abx500_mask_and_set_register_interruptible(info
->dev
,
217 info
->update_bank
, info
->update_reg
,
218 info
->update_mask
, info
->update_val
);
220 dev_err(rdev_get_dev(rdev
),
221 "couldn't set enable bits for regulator\n");
225 dev_vdbg(rdev_get_dev(rdev
),
226 "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
227 info
->desc
.name
, info
->update_bank
, info
->update_reg
,
228 info
->update_mask
, info
->update_val
);
233 static int ab8500_regulator_disable(struct regulator_dev
*rdev
)
236 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
239 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
243 ret
= abx500_mask_and_set_register_interruptible(info
->dev
,
244 info
->update_bank
, info
->update_reg
,
245 info
->update_mask
, 0x0);
247 dev_err(rdev_get_dev(rdev
),
248 "couldn't set disable bits for regulator\n");
252 dev_vdbg(rdev_get_dev(rdev
),
253 "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
254 info
->desc
.name
, info
->update_bank
, info
->update_reg
,
255 info
->update_mask
, 0x0);
260 static int ab8500_regulator_is_enabled(struct regulator_dev
*rdev
)
263 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
267 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
271 ret
= abx500_get_register_interruptible(info
->dev
,
272 info
->update_bank
, info
->update_reg
, ®val
);
274 dev_err(rdev_get_dev(rdev
),
275 "couldn't read 0x%x register\n", info
->update_reg
);
279 dev_vdbg(rdev_get_dev(rdev
),
280 "%s-is_enabled (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
282 info
->desc
.name
, info
->update_bank
, info
->update_reg
,
283 info
->update_mask
, regval
);
285 if (regval
& info
->update_mask
)
291 static unsigned int ab8500_regulator_get_optimum_mode(
292 struct regulator_dev
*rdev
, int input_uV
,
293 int output_uV
, int load_uA
)
297 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
300 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
304 if (load_uA
<= info
->load_lp_uA
)
305 mode
= REGULATOR_MODE_IDLE
;
307 mode
= REGULATOR_MODE_NORMAL
;
312 static int ab8500_regulator_set_mode(struct regulator_dev
*rdev
,
316 u8 bank
, reg
, mask
, val
;
317 bool lp_mode_req
= false;
318 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
321 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
325 if (info
->mode_mask
) {
326 bank
= info
->mode_bank
;
327 reg
= info
->mode_reg
;
328 mask
= info
->mode_mask
;
330 bank
= info
->update_bank
;
331 reg
= info
->update_reg
;
332 mask
= info
->update_mask
;
335 if (info
->shared_mode
)
336 mutex_lock(&shared_mode_mutex
);
339 case REGULATOR_MODE_NORMAL
:
340 if (info
->shared_mode
)
344 val
= info
->mode_val_normal
;
346 val
= info
->update_val_normal
;
348 case REGULATOR_MODE_IDLE
:
349 if (info
->shared_mode
) {
350 struct ab8500_regulator_info
*shared_regulator
;
352 shared_regulator
= info
->shared_mode
->shared_regulator
;
353 if (!shared_regulator
->shared_mode
->lp_mode_req
) {
354 /* Other regulator prevent LP mode */
355 info
->shared_mode
->lp_mode_req
= true;
363 val
= info
->mode_val_idle
;
365 val
= info
->update_val_idle
;
372 if (info
->mode_mask
|| ab8500_regulator_is_enabled(rdev
)) {
373 ret
= abx500_mask_and_set_register_interruptible(info
->dev
,
374 bank
, reg
, mask
, val
);
376 dev_err(rdev_get_dev(rdev
),
377 "couldn't set regulator mode\n");
381 dev_vdbg(rdev_get_dev(rdev
),
382 "%s-set_mode (bank, reg, mask, value): "
383 "0x%x, 0x%x, 0x%x, 0x%x\n",
384 info
->desc
.name
, bank
, reg
,
388 if (!info
->mode_mask
)
389 info
->update_val
= val
;
391 if (info
->shared_mode
)
392 info
->shared_mode
->lp_mode_req
= lp_mode_req
;
395 if (info
->shared_mode
)
396 mutex_unlock(&shared_mode_mutex
);
401 static unsigned int ab8500_regulator_get_mode(struct regulator_dev
*rdev
)
403 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
410 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
414 /* Need special handling for shared mode */
415 if (info
->shared_mode
) {
416 if (info
->shared_mode
->lp_mode_req
)
417 return REGULATOR_MODE_IDLE
;
419 return REGULATOR_MODE_NORMAL
;
422 if (info
->mode_mask
) {
423 /* Dedicated register for handling mode */
424 ret
= abx500_get_register_interruptible(info
->dev
,
425 info
->mode_bank
, info
->mode_reg
, &val
);
426 val
= val
& info
->mode_mask
;
428 val_normal
= info
->mode_val_normal
;
429 val_idle
= info
->mode_val_idle
;
431 /* Mode register same as enable register */
432 val
= info
->update_val
;
433 val_normal
= info
->update_val_normal
;
434 val_idle
= info
->update_val_idle
;
437 if (val
== val_normal
)
438 ret
= REGULATOR_MODE_NORMAL
;
439 else if (val
== val_idle
)
440 ret
= REGULATOR_MODE_IDLE
;
447 static int ab8500_regulator_get_voltage_sel(struct regulator_dev
*rdev
)
449 int ret
, voltage_shift
;
450 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
454 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
458 voltage_shift
= ffs(info
->voltage_mask
) - 1;
460 ret
= abx500_get_register_interruptible(info
->dev
,
461 info
->voltage_bank
, info
->voltage_reg
, ®val
);
463 dev_err(rdev_get_dev(rdev
),
464 "couldn't read voltage reg for regulator\n");
468 dev_vdbg(rdev_get_dev(rdev
),
469 "%s-get_voltage (bank, reg, mask, shift, value): "
470 "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
471 info
->desc
.name
, info
->voltage_bank
,
472 info
->voltage_reg
, info
->voltage_mask
,
473 voltage_shift
, regval
);
475 return (regval
& info
->voltage_mask
) >> voltage_shift
;
478 static int ab8500_regulator_set_voltage_sel(struct regulator_dev
*rdev
,
481 int ret
, voltage_shift
;
482 struct ab8500_regulator_info
*info
= rdev_get_drvdata(rdev
);
486 dev_err(rdev_get_dev(rdev
), "regulator info null pointer\n");
490 voltage_shift
= ffs(info
->voltage_mask
) - 1;
492 /* set the registers for the request */
493 regval
= (u8
)selector
<< voltage_shift
;
494 ret
= abx500_mask_and_set_register_interruptible(info
->dev
,
495 info
->voltage_bank
, info
->voltage_reg
,
496 info
->voltage_mask
, regval
);
498 dev_err(rdev_get_dev(rdev
),
499 "couldn't set voltage reg for regulator\n");
501 dev_vdbg(rdev_get_dev(rdev
),
502 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
504 info
->desc
.name
, info
->voltage_bank
, info
->voltage_reg
,
505 info
->voltage_mask
, regval
);
510 static const struct regulator_ops ab8500_regulator_volt_mode_ops
= {
511 .enable
= ab8500_regulator_enable
,
512 .disable
= ab8500_regulator_disable
,
513 .is_enabled
= ab8500_regulator_is_enabled
,
514 .get_optimum_mode
= ab8500_regulator_get_optimum_mode
,
515 .set_mode
= ab8500_regulator_set_mode
,
516 .get_mode
= ab8500_regulator_get_mode
,
517 .get_voltage_sel
= ab8500_regulator_get_voltage_sel
,
518 .set_voltage_sel
= ab8500_regulator_set_voltage_sel
,
519 .list_voltage
= regulator_list_voltage_table
,
522 static const struct regulator_ops ab8500_regulator_volt_ops
= {
523 .enable
= ab8500_regulator_enable
,
524 .disable
= ab8500_regulator_disable
,
525 .is_enabled
= ab8500_regulator_is_enabled
,
526 .get_voltage_sel
= ab8500_regulator_get_voltage_sel
,
527 .set_voltage_sel
= ab8500_regulator_set_voltage_sel
,
528 .list_voltage
= regulator_list_voltage_table
,
531 static const struct regulator_ops ab8500_regulator_mode_ops
= {
532 .enable
= ab8500_regulator_enable
,
533 .disable
= ab8500_regulator_disable
,
534 .is_enabled
= ab8500_regulator_is_enabled
,
535 .get_optimum_mode
= ab8500_regulator_get_optimum_mode
,
536 .set_mode
= ab8500_regulator_set_mode
,
537 .get_mode
= ab8500_regulator_get_mode
,
538 .list_voltage
= regulator_list_voltage_table
,
541 static const struct regulator_ops ab8500_regulator_ops
= {
542 .enable
= ab8500_regulator_enable
,
543 .disable
= ab8500_regulator_disable
,
544 .is_enabled
= ab8500_regulator_is_enabled
,
545 .list_voltage
= regulator_list_voltage_table
,
548 static const struct regulator_ops ab8500_regulator_anamic_mode_ops
= {
549 .enable
= ab8500_regulator_enable
,
550 .disable
= ab8500_regulator_disable
,
551 .is_enabled
= ab8500_regulator_is_enabled
,
552 .set_mode
= ab8500_regulator_set_mode
,
553 .get_mode
= ab8500_regulator_get_mode
,
554 .list_voltage
= regulator_list_voltage_table
,
557 /* AB8500 regulator information */
558 static struct ab8500_regulator_info
559 ab8500_regulator_info
[AB8500_NUM_REGULATORS
] = {
561 * Variable Voltage Regulators
562 * name, min mV, max mV,
563 * update bank, reg, mask, enable val
564 * volt bank, reg, mask
566 [AB8500_LDO_AUX1
] = {
569 .ops
= &ab8500_regulator_volt_mode_ops
,
570 .type
= REGULATOR_VOLTAGE
,
571 .id
= AB8500_LDO_AUX1
,
572 .owner
= THIS_MODULE
,
573 .n_voltages
= ARRAY_SIZE(ldo_vauxn_voltages
),
574 .volt_table
= ldo_vauxn_voltages
,
576 .supply_name
= "vin",
583 .update_val_idle
= 0x03,
584 .update_val_normal
= 0x01,
585 .voltage_bank
= 0x04,
587 .voltage_mask
= 0x0f,
589 [AB8500_LDO_AUX2
] = {
592 .ops
= &ab8500_regulator_volt_mode_ops
,
593 .type
= REGULATOR_VOLTAGE
,
594 .id
= AB8500_LDO_AUX2
,
595 .owner
= THIS_MODULE
,
596 .n_voltages
= ARRAY_SIZE(ldo_vauxn_voltages
),
597 .volt_table
= ldo_vauxn_voltages
,
599 .supply_name
= "vin",
606 .update_val_idle
= 0x0c,
607 .update_val_normal
= 0x04,
608 .voltage_bank
= 0x04,
610 .voltage_mask
= 0x0f,
612 [AB8500_LDO_AUX3
] = {
615 .ops
= &ab8500_regulator_volt_mode_ops
,
616 .type
= REGULATOR_VOLTAGE
,
617 .id
= AB8500_LDO_AUX3
,
618 .owner
= THIS_MODULE
,
619 .n_voltages
= ARRAY_SIZE(ldo_vaux3_voltages
),
620 .volt_table
= ldo_vaux3_voltages
,
622 .supply_name
= "vin",
629 .update_val_idle
= 0x03,
630 .update_val_normal
= 0x01,
631 .voltage_bank
= 0x04,
633 .voltage_mask
= 0x07,
635 [AB8500_LDO_INTCORE
] = {
637 .name
= "LDO-INTCORE",
638 .ops
= &ab8500_regulator_volt_mode_ops
,
639 .type
= REGULATOR_VOLTAGE
,
640 .id
= AB8500_LDO_INTCORE
,
641 .owner
= THIS_MODULE
,
642 .n_voltages
= ARRAY_SIZE(ldo_vintcore_voltages
),
643 .volt_table
= ldo_vintcore_voltages
,
651 .update_val_idle
= 0x44,
652 .update_val_normal
= 0x04,
653 .voltage_bank
= 0x03,
655 .voltage_mask
= 0x38,
659 * Fixed Voltage Regulators
661 * update bank, reg, mask, enable val
663 [AB8500_LDO_TVOUT
] = {
666 .ops
= &ab8500_regulator_mode_ops
,
667 .type
= REGULATOR_VOLTAGE
,
668 .id
= AB8500_LDO_TVOUT
,
669 .owner
= THIS_MODULE
,
671 .volt_table
= fixed_2000000_voltage
,
679 .update_val_idle
= 0x82,
680 .update_val_normal
= 0x02,
682 [AB8500_LDO_AUDIO
] = {
685 .ops
= &ab8500_regulator_ops
,
686 .type
= REGULATOR_VOLTAGE
,
687 .id
= AB8500_LDO_AUDIO
,
688 .owner
= THIS_MODULE
,
691 .volt_table
= fixed_2000000_voltage
,
698 [AB8500_LDO_ANAMIC1
] = {
700 .name
= "LDO-ANAMIC1",
701 .ops
= &ab8500_regulator_ops
,
702 .type
= REGULATOR_VOLTAGE
,
703 .id
= AB8500_LDO_ANAMIC1
,
704 .owner
= THIS_MODULE
,
707 .volt_table
= fixed_2050000_voltage
,
714 [AB8500_LDO_ANAMIC2
] = {
716 .name
= "LDO-ANAMIC2",
717 .ops
= &ab8500_regulator_ops
,
718 .type
= REGULATOR_VOLTAGE
,
719 .id
= AB8500_LDO_ANAMIC2
,
720 .owner
= THIS_MODULE
,
723 .volt_table
= fixed_2050000_voltage
,
730 [AB8500_LDO_DMIC
] = {
733 .ops
= &ab8500_regulator_ops
,
734 .type
= REGULATOR_VOLTAGE
,
735 .id
= AB8500_LDO_DMIC
,
736 .owner
= THIS_MODULE
,
739 .volt_table
= fixed_1800000_voltage
,
748 * Regulators with fixed voltage and normal/idle modes
753 .ops
= &ab8500_regulator_mode_ops
,
754 .type
= REGULATOR_VOLTAGE
,
755 .id
= AB8500_LDO_ANA
,
756 .owner
= THIS_MODULE
,
759 .volt_table
= fixed_1200000_voltage
,
766 .update_val_idle
= 0x0c,
767 .update_val_normal
= 0x04,
771 /* AB8505 regulator information */
772 static struct ab8500_regulator_info
773 ab8505_regulator_info
[AB8505_NUM_REGULATORS
] = {
775 * Variable Voltage Regulators
776 * name, min mV, max mV,
777 * update bank, reg, mask, enable val
778 * volt bank, reg, mask
780 [AB8505_LDO_AUX1
] = {
783 .ops
= &ab8500_regulator_volt_mode_ops
,
784 .type
= REGULATOR_VOLTAGE
,
785 .id
= AB8505_LDO_AUX1
,
786 .owner
= THIS_MODULE
,
787 .n_voltages
= ARRAY_SIZE(ldo_vauxn_voltages
),
788 .volt_table
= ldo_vauxn_voltages
,
795 .update_val_idle
= 0x03,
796 .update_val_normal
= 0x01,
797 .voltage_bank
= 0x04,
799 .voltage_mask
= 0x0f,
801 [AB8505_LDO_AUX2
] = {
804 .ops
= &ab8500_regulator_volt_mode_ops
,
805 .type
= REGULATOR_VOLTAGE
,
806 .id
= AB8505_LDO_AUX2
,
807 .owner
= THIS_MODULE
,
808 .n_voltages
= ARRAY_SIZE(ldo_vauxn_voltages
),
809 .volt_table
= ldo_vauxn_voltages
,
816 .update_val_idle
= 0x0c,
817 .update_val_normal
= 0x04,
818 .voltage_bank
= 0x04,
820 .voltage_mask
= 0x0f,
822 [AB8505_LDO_AUX3
] = {
825 .ops
= &ab8500_regulator_volt_mode_ops
,
826 .type
= REGULATOR_VOLTAGE
,
827 .id
= AB8505_LDO_AUX3
,
828 .owner
= THIS_MODULE
,
829 .n_voltages
= ARRAY_SIZE(ldo_vaux3_voltages
),
830 .volt_table
= ldo_vaux3_voltages
,
837 .update_val_idle
= 0x03,
838 .update_val_normal
= 0x01,
839 .voltage_bank
= 0x04,
841 .voltage_mask
= 0x07,
843 [AB8505_LDO_AUX4
] = {
846 .ops
= &ab8500_regulator_volt_mode_ops
,
847 .type
= REGULATOR_VOLTAGE
,
848 .id
= AB8505_LDO_AUX4
,
849 .owner
= THIS_MODULE
,
850 .n_voltages
= ARRAY_SIZE(ldo_vauxn_voltages
),
851 .volt_table
= ldo_vauxn_voltages
,
854 /* values for Vaux4Regu register */
859 .update_val_idle
= 0x03,
860 .update_val_normal
= 0x01,
861 /* values for Vaux4SEL register */
862 .voltage_bank
= 0x04,
864 .voltage_mask
= 0x0f,
866 [AB8505_LDO_AUX5
] = {
869 .ops
= &ab8500_regulator_volt_mode_ops
,
870 .type
= REGULATOR_VOLTAGE
,
871 .id
= AB8505_LDO_AUX5
,
872 .owner
= THIS_MODULE
,
873 .n_voltages
= ARRAY_SIZE(ldo_vaux56_voltages
),
874 .volt_table
= ldo_vaux56_voltages
,
877 /* values for CtrlVaux5 register */
882 .update_val_idle
= 0x18,
883 .update_val_normal
= 0x10,
884 .voltage_bank
= 0x01,
886 .voltage_mask
= 0x07,
888 [AB8505_LDO_AUX6
] = {
891 .ops
= &ab8500_regulator_volt_mode_ops
,
892 .type
= REGULATOR_VOLTAGE
,
893 .id
= AB8505_LDO_AUX6
,
894 .owner
= THIS_MODULE
,
895 .n_voltages
= ARRAY_SIZE(ldo_vaux56_voltages
),
896 .volt_table
= ldo_vaux56_voltages
,
899 /* values for CtrlVaux6 register */
904 .update_val_idle
= 0x18,
905 .update_val_normal
= 0x10,
906 .voltage_bank
= 0x01,
908 .voltage_mask
= 0x07,
910 [AB8505_LDO_INTCORE
] = {
912 .name
= "LDO-INTCORE",
913 .ops
= &ab8500_regulator_volt_mode_ops
,
914 .type
= REGULATOR_VOLTAGE
,
915 .id
= AB8505_LDO_INTCORE
,
916 .owner
= THIS_MODULE
,
917 .n_voltages
= ARRAY_SIZE(ldo_vintcore_voltages
),
918 .volt_table
= ldo_vintcore_voltages
,
925 .update_val_idle
= 0x44,
926 .update_val_normal
= 0x04,
927 .voltage_bank
= 0x03,
929 .voltage_mask
= 0x38,
933 * Fixed Voltage Regulators
935 * update bank, reg, mask, enable val
940 .ops
= &ab8500_regulator_mode_ops
,
941 .type
= REGULATOR_VOLTAGE
,
942 .id
= AB8505_LDO_ADC
,
943 .owner
= THIS_MODULE
,
945 .volt_table
= fixed_2000000_voltage
,
946 .enable_time
= 10000,
953 .update_val_idle
= 0x82,
954 .update_val_normal
= 0x02,
959 .ops
= &ab8500_regulator_mode_ops
,
960 .type
= REGULATOR_VOLTAGE
,
961 .id
= AB8505_LDO_USB
,
962 .owner
= THIS_MODULE
,
964 .volt_table
= fixed_3300000_voltage
,
970 .update_val_idle
= 0x03,
971 .update_val_normal
= 0x01,
973 [AB8505_LDO_AUDIO
] = {
976 .ops
= &ab8500_regulator_volt_ops
,
977 .type
= REGULATOR_VOLTAGE
,
978 .id
= AB8505_LDO_AUDIO
,
979 .owner
= THIS_MODULE
,
980 .n_voltages
= ARRAY_SIZE(ldo_vaudio_voltages
),
981 .volt_table
= ldo_vaudio_voltages
,
987 .voltage_bank
= 0x01,
989 .voltage_mask
= 0x70,
991 [AB8505_LDO_ANAMIC1
] = {
993 .name
= "LDO-ANAMIC1",
994 .ops
= &ab8500_regulator_anamic_mode_ops
,
995 .type
= REGULATOR_VOLTAGE
,
996 .id
= AB8505_LDO_ANAMIC1
,
997 .owner
= THIS_MODULE
,
999 .volt_table
= fixed_2050000_voltage
,
1001 .shared_mode
= &ldo_anamic1_shared
,
1002 .update_bank
= 0x03,
1004 .update_mask
= 0x08,
1009 .mode_val_idle
= 0x04,
1010 .mode_val_normal
= 0x00,
1012 [AB8505_LDO_ANAMIC2
] = {
1014 .name
= "LDO-ANAMIC2",
1015 .ops
= &ab8500_regulator_anamic_mode_ops
,
1016 .type
= REGULATOR_VOLTAGE
,
1017 .id
= AB8505_LDO_ANAMIC2
,
1018 .owner
= THIS_MODULE
,
1020 .volt_table
= fixed_2050000_voltage
,
1022 .shared_mode
= &ldo_anamic2_shared
,
1023 .update_bank
= 0x03,
1025 .update_mask
= 0x10,
1030 .mode_val_idle
= 0x04,
1031 .mode_val_normal
= 0x00,
1033 [AB8505_LDO_AUX8
] = {
1036 .ops
= &ab8500_regulator_ops
,
1037 .type
= REGULATOR_VOLTAGE
,
1038 .id
= AB8505_LDO_AUX8
,
1039 .owner
= THIS_MODULE
,
1041 .volt_table
= fixed_1800000_voltage
,
1043 .update_bank
= 0x03,
1045 .update_mask
= 0x04,
1049 * Regulators with fixed voltage and normal/idle modes
1051 [AB8505_LDO_ANA
] = {
1054 .ops
= &ab8500_regulator_volt_mode_ops
,
1055 .type
= REGULATOR_VOLTAGE
,
1056 .id
= AB8505_LDO_ANA
,
1057 .owner
= THIS_MODULE
,
1058 .n_voltages
= ARRAY_SIZE(ldo_vana_voltages
),
1059 .volt_table
= ldo_vana_voltages
,
1062 .update_bank
= 0x04,
1064 .update_mask
= 0x0c,
1066 .update_val_idle
= 0x0c,
1067 .update_val_normal
= 0x04,
1068 .voltage_bank
= 0x04,
1069 .voltage_reg
= 0x29,
1070 .voltage_mask
= 0x7,
1074 static struct ab8500_shared_mode ldo_anamic1_shared
= {
1075 .shared_regulator
= &ab8505_regulator_info
[AB8505_LDO_ANAMIC2
],
1078 static struct ab8500_shared_mode ldo_anamic2_shared
= {
1079 .shared_regulator
= &ab8505_regulator_info
[AB8505_LDO_ANAMIC1
],
1082 struct ab8500_reg_init
{
1088 #define REG_INIT(_id, _bank, _addr, _mask) \
1095 /* AB8500 register init */
1096 static struct ab8500_reg_init ab8500_reg_init
[] = {
1098 * 0x30, VanaRequestCtrl
1099 * 0xc0, VextSupply1RequestCtrl
1101 REG_INIT(AB8500_REGUREQUESTCTRL2
, 0x03, 0x04, 0xf0),
1103 * 0x03, VextSupply2RequestCtrl
1104 * 0x0c, VextSupply3RequestCtrl
1105 * 0x30, Vaux1RequestCtrl
1106 * 0xc0, Vaux2RequestCtrl
1108 REG_INIT(AB8500_REGUREQUESTCTRL3
, 0x03, 0x05, 0xff),
1110 * 0x03, Vaux3RequestCtrl
1113 REG_INIT(AB8500_REGUREQUESTCTRL4
, 0x03, 0x06, 0x07),
1115 * 0x08, VanaSysClkReq1HPValid
1116 * 0x20, Vaux1SysClkReq1HPValid
1117 * 0x40, Vaux2SysClkReq1HPValid
1118 * 0x80, Vaux3SysClkReq1HPValid
1120 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID1
, 0x03, 0x07, 0xe8),
1122 * 0x10, VextSupply1SysClkReq1HPValid
1123 * 0x20, VextSupply2SysClkReq1HPValid
1124 * 0x40, VextSupply3SysClkReq1HPValid
1126 REG_INIT(AB8500_REGUSYSCLKREQ1HPVALID2
, 0x03, 0x08, 0x70),
1128 * 0x08, VanaHwHPReq1Valid
1129 * 0x20, Vaux1HwHPReq1Valid
1130 * 0x40, Vaux2HwHPReq1Valid
1131 * 0x80, Vaux3HwHPReq1Valid
1133 REG_INIT(AB8500_REGUHWHPREQ1VALID1
, 0x03, 0x09, 0xe8),
1135 * 0x01, VextSupply1HwHPReq1Valid
1136 * 0x02, VextSupply2HwHPReq1Valid
1137 * 0x04, VextSupply3HwHPReq1Valid
1139 REG_INIT(AB8500_REGUHWHPREQ1VALID2
, 0x03, 0x0a, 0x07),
1141 * 0x08, VanaHwHPReq2Valid
1142 * 0x20, Vaux1HwHPReq2Valid
1143 * 0x40, Vaux2HwHPReq2Valid
1144 * 0x80, Vaux3HwHPReq2Valid
1146 REG_INIT(AB8500_REGUHWHPREQ2VALID1
, 0x03, 0x0b, 0xe8),
1148 * 0x01, VextSupply1HwHPReq2Valid
1149 * 0x02, VextSupply2HwHPReq2Valid
1150 * 0x04, VextSupply3HwHPReq2Valid
1152 REG_INIT(AB8500_REGUHWHPREQ2VALID2
, 0x03, 0x0c, 0x07),
1154 * 0x20, VanaSwHPReqValid
1155 * 0x80, Vaux1SwHPReqValid
1157 REG_INIT(AB8500_REGUSWHPREQVALID1
, 0x03, 0x0d, 0xa0),
1159 * 0x01, Vaux2SwHPReqValid
1160 * 0x02, Vaux3SwHPReqValid
1161 * 0x04, VextSupply1SwHPReqValid
1162 * 0x08, VextSupply2SwHPReqValid
1163 * 0x10, VextSupply3SwHPReqValid
1165 REG_INIT(AB8500_REGUSWHPREQVALID2
, 0x03, 0x0e, 0x1f),
1167 * 0x02, SysClkReq2Valid1
1168 * 0x04, SysClkReq3Valid1
1169 * 0x08, SysClkReq4Valid1
1170 * 0x10, SysClkReq5Valid1
1171 * 0x20, SysClkReq6Valid1
1172 * 0x40, SysClkReq7Valid1
1173 * 0x80, SysClkReq8Valid1
1175 REG_INIT(AB8500_REGUSYSCLKREQVALID1
, 0x03, 0x0f, 0xfe),
1177 * 0x02, SysClkReq2Valid2
1178 * 0x04, SysClkReq3Valid2
1179 * 0x08, SysClkReq4Valid2
1180 * 0x10, SysClkReq5Valid2
1181 * 0x20, SysClkReq6Valid2
1182 * 0x40, SysClkReq7Valid2
1183 * 0x80, SysClkReq8Valid2
1185 REG_INIT(AB8500_REGUSYSCLKREQVALID2
, 0x03, 0x10, 0xfe),
1188 * 0x04, Vintcore12Ena
1189 * 0x38, Vintcore12Sel
1190 * 0x40, Vintcore12LP
1193 REG_INIT(AB8500_REGUMISC1
, 0x03, 0x80, 0xfe),
1200 REG_INIT(AB8500_VAUDIOSUPPLY
, 0x03, 0x83, 0x1e),
1202 * 0x01, Vamic1_dzout
1203 * 0x02, Vamic2_dzout
1205 REG_INIT(AB8500_REGUCTRL1VAMIC
, 0x03, 0x84, 0x03),
1207 * 0x03, VpllRegu (NOTE! PRCMU register bits)
1210 REG_INIT(AB8500_VPLLVANAREGU
, 0x04, 0x06, 0x0f),
1213 * 0x02, VrefDDRSleepMode
1215 REG_INIT(AB8500_VREFDDR
, 0x04, 0x07, 0x03),
1217 * 0x03, VextSupply1Regu
1218 * 0x0c, VextSupply2Regu
1219 * 0x30, VextSupply3Regu
1220 * 0x40, ExtSupply2Bypass
1221 * 0x80, ExtSupply3Bypass
1223 REG_INIT(AB8500_EXTSUPPLYREGU
, 0x04, 0x08, 0xff),
1228 REG_INIT(AB8500_VAUX12REGU
, 0x04, 0x09, 0x0f),
1232 REG_INIT(AB8500_VRF1VAUX3REGU
, 0x04, 0x0a, 0x03),
1236 REG_INIT(AB8500_VAUX1SEL
, 0x04, 0x1f, 0x0f),
1240 REG_INIT(AB8500_VAUX2SEL
, 0x04, 0x20, 0x0f),
1244 REG_INIT(AB8500_VRF1VAUX3SEL
, 0x04, 0x21, 0x07),
1246 * 0x01, VextSupply12LP
1248 REG_INIT(AB8500_REGUCTRL2SPARE
, 0x04, 0x22, 0x01),
1253 * 0x20, Vintcore12Disch
1257 REG_INIT(AB8500_REGUCTRLDISCH
, 0x04, 0x43, 0xfc),
1260 * 0x04, VdmicPullDownEna
1263 REG_INIT(AB8500_REGUCTRLDISCH2
, 0x04, 0x44, 0x16),
1266 /* AB8505 register init */
1267 static struct ab8500_reg_init ab8505_reg_init
[] = {
1269 * 0x03, VarmRequestCtrl
1270 * 0x0c, VsmpsCRequestCtrl
1271 * 0x30, VsmpsARequestCtrl
1272 * 0xc0, VsmpsBRequestCtrl
1274 REG_INIT(AB8505_REGUREQUESTCTRL1
, 0x03, 0x03, 0xff),
1276 * 0x03, VsafeRequestCtrl
1277 * 0x0c, VpllRequestCtrl
1278 * 0x30, VanaRequestCtrl
1280 REG_INIT(AB8505_REGUREQUESTCTRL2
, 0x03, 0x04, 0x3f),
1282 * 0x30, Vaux1RequestCtrl
1283 * 0xc0, Vaux2RequestCtrl
1285 REG_INIT(AB8505_REGUREQUESTCTRL3
, 0x03, 0x05, 0xf0),
1287 * 0x03, Vaux3RequestCtrl
1290 REG_INIT(AB8505_REGUREQUESTCTRL4
, 0x03, 0x06, 0x07),
1292 * 0x01, VsmpsASysClkReq1HPValid
1293 * 0x02, VsmpsBSysClkReq1HPValid
1294 * 0x04, VsafeSysClkReq1HPValid
1295 * 0x08, VanaSysClkReq1HPValid
1296 * 0x10, VpllSysClkReq1HPValid
1297 * 0x20, Vaux1SysClkReq1HPValid
1298 * 0x40, Vaux2SysClkReq1HPValid
1299 * 0x80, Vaux3SysClkReq1HPValid
1301 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1
, 0x03, 0x07, 0xff),
1303 * 0x01, VsmpsCSysClkReq1HPValid
1304 * 0x02, VarmSysClkReq1HPValid
1305 * 0x04, VbbSysClkReq1HPValid
1306 * 0x08, VsmpsMSysClkReq1HPValid
1308 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2
, 0x03, 0x08, 0x0f),
1310 * 0x01, VsmpsAHwHPReq1Valid
1311 * 0x02, VsmpsBHwHPReq1Valid
1312 * 0x04, VsafeHwHPReq1Valid
1313 * 0x08, VanaHwHPReq1Valid
1314 * 0x10, VpllHwHPReq1Valid
1315 * 0x20, Vaux1HwHPReq1Valid
1316 * 0x40, Vaux2HwHPReq1Valid
1317 * 0x80, Vaux3HwHPReq1Valid
1319 REG_INIT(AB8505_REGUHWHPREQ1VALID1
, 0x03, 0x09, 0xff),
1321 * 0x08, VsmpsMHwHPReq1Valid
1323 REG_INIT(AB8505_REGUHWHPREQ1VALID2
, 0x03, 0x0a, 0x08),
1325 * 0x01, VsmpsAHwHPReq2Valid
1326 * 0x02, VsmpsBHwHPReq2Valid
1327 * 0x04, VsafeHwHPReq2Valid
1328 * 0x08, VanaHwHPReq2Valid
1329 * 0x10, VpllHwHPReq2Valid
1330 * 0x20, Vaux1HwHPReq2Valid
1331 * 0x40, Vaux2HwHPReq2Valid
1332 * 0x80, Vaux3HwHPReq2Valid
1334 REG_INIT(AB8505_REGUHWHPREQ2VALID1
, 0x03, 0x0b, 0xff),
1336 * 0x08, VsmpsMHwHPReq2Valid
1338 REG_INIT(AB8505_REGUHWHPREQ2VALID2
, 0x03, 0x0c, 0x08),
1340 * 0x01, VsmpsCSwHPReqValid
1341 * 0x02, VarmSwHPReqValid
1342 * 0x04, VsmpsASwHPReqValid
1343 * 0x08, VsmpsBSwHPReqValid
1344 * 0x10, VsafeSwHPReqValid
1345 * 0x20, VanaSwHPReqValid
1346 * 0x40, VpllSwHPReqValid
1347 * 0x80, Vaux1SwHPReqValid
1349 REG_INIT(AB8505_REGUSWHPREQVALID1
, 0x03, 0x0d, 0xff),
1351 * 0x01, Vaux2SwHPReqValid
1352 * 0x02, Vaux3SwHPReqValid
1353 * 0x20, VsmpsMSwHPReqValid
1355 REG_INIT(AB8505_REGUSWHPREQVALID2
, 0x03, 0x0e, 0x23),
1357 * 0x02, SysClkReq2Valid1
1358 * 0x04, SysClkReq3Valid1
1359 * 0x08, SysClkReq4Valid1
1361 REG_INIT(AB8505_REGUSYSCLKREQVALID1
, 0x03, 0x0f, 0x0e),
1363 * 0x02, SysClkReq2Valid2
1364 * 0x04, SysClkReq3Valid2
1365 * 0x08, SysClkReq4Valid2
1367 REG_INIT(AB8505_REGUSYSCLKREQVALID2
, 0x03, 0x10, 0x0e),
1369 * 0x01, Vaux4SwHPReqValid
1370 * 0x02, Vaux4HwHPReq2Valid
1371 * 0x04, Vaux4HwHPReq1Valid
1372 * 0x08, Vaux4SysClkReq1HPValid
1374 REG_INIT(AB8505_REGUVAUX4REQVALID
, 0x03, 0x11, 0x0f),
1377 * 0x04, VintCore12Ena
1378 * 0x38, VintCore12Sel
1379 * 0x40, VintCore12LP
1382 REG_INIT(AB8505_REGUMISC1
, 0x03, 0x80, 0xfe),
1389 REG_INIT(AB8505_VAUDIOSUPPLY
, 0x03, 0x83, 0x1e),
1391 * 0x01, Vamic1_dzout
1392 * 0x02, Vamic2_dzout
1394 REG_INIT(AB8505_REGUCTRL1VAMIC
, 0x03, 0x84, 0x03),
1397 * 0x0c, VsmpsASelCtrl
1398 * 0x10, VsmpsAAutoMode
1399 * 0x20, VsmpsAPWMMode
1401 REG_INIT(AB8505_VSMPSAREGU
, 0x04, 0x03, 0x3f),
1404 * 0x0c, VsmpsBSelCtrl
1405 * 0x10, VsmpsBAutoMode
1406 * 0x20, VsmpsBPWMMode
1408 REG_INIT(AB8505_VSMPSBREGU
, 0x04, 0x04, 0x3f),
1411 * 0x0c, VsafeSelCtrl
1412 * 0x10, VsafeAutoMode
1413 * 0x20, VsafePWMMode
1415 REG_INIT(AB8505_VSAFEREGU
, 0x04, 0x05, 0x3f),
1417 * 0x03, VpllRegu (NOTE! PRCMU register bits)
1420 REG_INIT(AB8505_VPLLVANAREGU
, 0x04, 0x06, 0x0f),
1422 * 0x03, VextSupply1Regu
1423 * 0x0c, VextSupply2Regu
1424 * 0x30, VextSupply3Regu
1425 * 0x40, ExtSupply2Bypass
1426 * 0x80, ExtSupply3Bypass
1428 REG_INIT(AB8505_EXTSUPPLYREGU
, 0x04, 0x08, 0xff),
1433 REG_INIT(AB8505_VAUX12REGU
, 0x04, 0x09, 0x0f),
1437 REG_INIT(AB8505_VRF1VAUX3REGU
, 0x04, 0x0a, 0x0f),
1441 REG_INIT(AB8505_VSMPSASEL1
, 0x04, 0x13, 0x3f),
1445 REG_INIT(AB8505_VSMPSASEL2
, 0x04, 0x14, 0x3f),
1449 REG_INIT(AB8505_VSMPSASEL3
, 0x04, 0x15, 0x3f),
1453 REG_INIT(AB8505_VSMPSBSEL1
, 0x04, 0x17, 0x3f),
1457 REG_INIT(AB8505_VSMPSBSEL2
, 0x04, 0x18, 0x3f),
1461 REG_INIT(AB8505_VSMPSBSEL3
, 0x04, 0x19, 0x3f),
1465 REG_INIT(AB8505_VSAFESEL1
, 0x04, 0x1b, 0x7f),
1469 REG_INIT(AB8505_VSAFESEL2
, 0x04, 0x1c, 0x7f),
1473 REG_INIT(AB8505_VSAFESEL3
, 0x04, 0x1d, 0x7f),
1477 REG_INIT(AB8505_VAUX1SEL
, 0x04, 0x1f, 0x0f),
1481 REG_INIT(AB8505_VAUX2SEL
, 0x04, 0x20, 0x0f),
1486 REG_INIT(AB8505_VRF1VAUX3SEL
, 0x04, 0x21, 0x37),
1488 * 0x03, Vaux4RequestCtrl
1490 REG_INIT(AB8505_VAUX4REQCTRL
, 0x04, 0x2d, 0x03),
1494 REG_INIT(AB8505_VAUX4REGU
, 0x04, 0x2e, 0x03),
1498 REG_INIT(AB8505_VAUX4SEL
, 0x04, 0x2f, 0x0f),
1503 * 0x20, Vintcore12Disch
1507 REG_INIT(AB8505_REGUCTRLDISCH
, 0x04, 0x43, 0xfc),
1510 * 0x04, VdmicPullDownEna
1513 REG_INIT(AB8505_REGUCTRLDISCH2
, 0x04, 0x44, 0x16),
1517 REG_INIT(AB8505_REGUCTRLDISCH3
, 0x04, 0x48, 0x01),
1523 * 0x40, Vaux5DisSfst
1524 * 0x80, Vaux5DisPulld
1526 REG_INIT(AB8505_CTRLVAUX5
, 0x01, 0x55, 0xff),
1531 * 0x80, Vaux6DisPulld
1533 REG_INIT(AB8505_CTRLVAUX6
, 0x01, 0x56, 0x9f),
1536 static struct of_regulator_match ab8500_regulator_match
[] = {
1537 { .name
= "ab8500_ldo_aux1", .driver_data
= (void *) AB8500_LDO_AUX1
, },
1538 { .name
= "ab8500_ldo_aux2", .driver_data
= (void *) AB8500_LDO_AUX2
, },
1539 { .name
= "ab8500_ldo_aux3", .driver_data
= (void *) AB8500_LDO_AUX3
, },
1540 { .name
= "ab8500_ldo_intcore", .driver_data
= (void *) AB8500_LDO_INTCORE
, },
1541 { .name
= "ab8500_ldo_tvout", .driver_data
= (void *) AB8500_LDO_TVOUT
, },
1542 { .name
= "ab8500_ldo_audio", .driver_data
= (void *) AB8500_LDO_AUDIO
, },
1543 { .name
= "ab8500_ldo_anamic1", .driver_data
= (void *) AB8500_LDO_ANAMIC1
, },
1544 { .name
= "ab8500_ldo_anamic2", .driver_data
= (void *) AB8500_LDO_ANAMIC2
, },
1545 { .name
= "ab8500_ldo_dmic", .driver_data
= (void *) AB8500_LDO_DMIC
, },
1546 { .name
= "ab8500_ldo_ana", .driver_data
= (void *) AB8500_LDO_ANA
, },
1549 static struct of_regulator_match ab8505_regulator_match
[] = {
1550 { .name
= "ab8500_ldo_aux1", .driver_data
= (void *) AB8505_LDO_AUX1
, },
1551 { .name
= "ab8500_ldo_aux2", .driver_data
= (void *) AB8505_LDO_AUX2
, },
1552 { .name
= "ab8500_ldo_aux3", .driver_data
= (void *) AB8505_LDO_AUX3
, },
1553 { .name
= "ab8500_ldo_aux4", .driver_data
= (void *) AB8505_LDO_AUX4
, },
1554 { .name
= "ab8500_ldo_aux5", .driver_data
= (void *) AB8505_LDO_AUX5
, },
1555 { .name
= "ab8500_ldo_aux6", .driver_data
= (void *) AB8505_LDO_AUX6
, },
1556 { .name
= "ab8500_ldo_intcore", .driver_data
= (void *) AB8505_LDO_INTCORE
, },
1557 { .name
= "ab8500_ldo_adc", .driver_data
= (void *) AB8505_LDO_ADC
, },
1558 { .name
= "ab8500_ldo_audio", .driver_data
= (void *) AB8505_LDO_AUDIO
, },
1559 { .name
= "ab8500_ldo_anamic1", .driver_data
= (void *) AB8505_LDO_ANAMIC1
, },
1560 { .name
= "ab8500_ldo_anamic2", .driver_data
= (void *) AB8505_LDO_ANAMIC2
, },
1561 { .name
= "ab8500_ldo_aux8", .driver_data
= (void *) AB8505_LDO_AUX8
, },
1562 { .name
= "ab8500_ldo_ana", .driver_data
= (void *) AB8505_LDO_ANA
, },
1566 struct ab8500_regulator_info
*info
;
1568 struct ab8500_reg_init
*init
;
1570 struct of_regulator_match
*match
;
1574 static void abx500_get_regulator_info(struct ab8500
*ab8500
)
1576 if (is_ab8505(ab8500
)) {
1577 abx500_regulator
.info
= ab8505_regulator_info
;
1578 abx500_regulator
.info_size
= ARRAY_SIZE(ab8505_regulator_info
);
1579 abx500_regulator
.init
= ab8505_reg_init
;
1580 abx500_regulator
.init_size
= AB8505_NUM_REGULATOR_REGISTERS
;
1581 abx500_regulator
.match
= ab8505_regulator_match
;
1582 abx500_regulator
.match_size
= ARRAY_SIZE(ab8505_regulator_match
);
1584 abx500_regulator
.info
= ab8500_regulator_info
;
1585 abx500_regulator
.info_size
= ARRAY_SIZE(ab8500_regulator_info
);
1586 abx500_regulator
.init
= ab8500_reg_init
;
1587 abx500_regulator
.init_size
= AB8500_NUM_REGULATOR_REGISTERS
;
1588 abx500_regulator
.match
= ab8500_regulator_match
;
1589 abx500_regulator
.match_size
= ARRAY_SIZE(ab8500_regulator_match
);
1593 static int ab8500_regulator_register(struct platform_device
*pdev
,
1594 struct regulator_init_data
*init_data
,
1595 int id
, struct device_node
*np
)
1597 struct ab8500
*ab8500
= dev_get_drvdata(pdev
->dev
.parent
);
1598 struct ab8500_regulator_info
*info
= NULL
;
1599 struct regulator_config config
= { };
1600 struct regulator_dev
*rdev
;
1602 /* assign per-regulator data */
1603 info
= &abx500_regulator
.info
[id
];
1604 info
->dev
= &pdev
->dev
;
1606 config
.dev
= &pdev
->dev
;
1607 config
.init_data
= init_data
;
1608 config
.driver_data
= info
;
1609 config
.of_node
= np
;
1611 /* fix for hardware before ab8500v2.0 */
1612 if (is_ab8500_1p1_or_earlier(ab8500
)) {
1613 if (info
->desc
.id
== AB8500_LDO_AUX3
) {
1614 info
->desc
.n_voltages
=
1615 ARRAY_SIZE(ldo_vauxn_voltages
);
1616 info
->desc
.volt_table
= ldo_vauxn_voltages
;
1617 info
->voltage_mask
= 0xf;
1621 /* register regulator with framework */
1622 rdev
= devm_regulator_register(&pdev
->dev
, &info
->desc
, &config
);
1624 dev_err(&pdev
->dev
, "failed to register regulator %s\n",
1626 return PTR_ERR(rdev
);
1632 static int ab8500_regulator_probe(struct platform_device
*pdev
)
1634 struct ab8500
*ab8500
= dev_get_drvdata(pdev
->dev
.parent
);
1635 struct device_node
*np
= pdev
->dev
.of_node
;
1636 struct of_regulator_match
*match
;
1640 dev_err(&pdev
->dev
, "null mfd parent\n");
1644 abx500_get_regulator_info(ab8500
);
1646 err
= of_regulator_match(&pdev
->dev
, np
,
1647 abx500_regulator
.match
,
1648 abx500_regulator
.match_size
);
1651 "Error parsing regulator init data: %d\n", err
);
1655 match
= abx500_regulator
.match
;
1656 for (i
= 0; i
< abx500_regulator
.info_size
; i
++) {
1657 err
= ab8500_regulator_register(pdev
, match
[i
].init_data
, i
,
1666 static struct platform_driver ab8500_regulator_driver
= {
1667 .probe
= ab8500_regulator_probe
,
1669 .name
= "ab8500-regulator",
1673 static int __init
ab8500_regulator_init(void)
1677 ret
= platform_driver_register(&ab8500_regulator_driver
);
1679 pr_err("Failed to register ab8500 regulator: %d\n", ret
);
1683 subsys_initcall(ab8500_regulator_init
);
1685 static void __exit
ab8500_regulator_exit(void)
1687 platform_driver_unregister(&ab8500_regulator_driver
);
1689 module_exit(ab8500_regulator_exit
);
1691 MODULE_LICENSE("GPL v2");
1692 MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
1693 MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
1694 MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
1695 MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
1696 MODULE_ALIAS("platform:ab8500-regulator");