Skip to content

Commit 13186da

Browse files
babnskidatabroonie
authored andcommitted
regulator: da9063: add voltage monitoring registers
Add the definitions for the registers responsible for voltage monitoring. Add a voltage monitor enable bitfield per regulator. Reviewed-by: Matti Vaittinen <[email protected]> Reviewed-by: Adam Ward <[email protected]> Signed-off-by: Benjamin Bara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 53e59b5 commit 13186da

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

drivers/regulator/da9063-regulator.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ struct da9063_regulator_info {
8383

8484
/* DA9063 event detection bit */
8585
struct reg_field oc_event;
86+
87+
/* DA9063 voltage monitor bit */
88+
struct reg_field vmon;
8689
};
8790

8891
/* Macros for LDO */
@@ -148,6 +151,7 @@ struct da9063_regulator {
148151
struct regmap_field *suspend;
149152
struct regmap_field *sleep;
150153
struct regmap_field *suspend_sleep;
154+
struct regmap_field *vmon;
151155
};
152156

153157
/* Encapsulates all information for the regulators driver */
@@ -581,91 +585,110 @@ static const struct da9063_regulator_info da9063_regulator_info[] = {
581585
da9063_buck_a_limits,
582586
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
583587
DA9063_BUCK_COMMON_FIELDS(BCORE1),
588+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BCORE1_MON_EN),
584589
},
585590
{
586591
DA9063_BUCK(DA9063, BCORE2, 300, 10, 1570,
587592
da9063_buck_a_limits,
588593
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE2_ILIM_MASK),
589594
DA9063_BUCK_COMMON_FIELDS(BCORE2),
595+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BCORE2_MON_EN),
590596
},
591597
{
592598
DA9063_BUCK(DA9063, BPRO, 530, 10, 1800,
593599
da9063_buck_a_limits,
594600
DA9063_REG_BUCK_ILIM_B, DA9063_BPRO_ILIM_MASK),
595601
DA9063_BUCK_COMMON_FIELDS(BPRO),
602+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BPRO_MON_EN),
596603
},
597604
{
598605
DA9063_BUCK(DA9063, BMEM, 800, 20, 3340,
599606
da9063_buck_b_limits,
600607
DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK),
601608
DA9063_BUCK_COMMON_FIELDS(BMEM),
609+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BMEM_MON_EN),
602610
},
603611
{
604612
DA9063_BUCK(DA9063, BIO, 800, 20, 3340,
605613
da9063_buck_b_limits,
606614
DA9063_REG_BUCK_ILIM_A, DA9063_BIO_ILIM_MASK),
607615
DA9063_BUCK_COMMON_FIELDS(BIO),
616+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BIO_MON_EN),
608617
},
609618
{
610619
DA9063_BUCK(DA9063, BPERI, 800, 20, 3340,
611620
da9063_buck_b_limits,
612621
DA9063_REG_BUCK_ILIM_B, DA9063_BPERI_ILIM_MASK),
613622
DA9063_BUCK_COMMON_FIELDS(BPERI),
623+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BPERI_MON_EN),
614624
},
615625
{
616626
DA9063_BUCK(DA9063, BCORES_MERGED, 300, 10, 1570,
617627
da9063_bcores_merged_limits,
618628
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
619629
/* BCORES_MERGED uses the same register fields as BCORE1 */
620630
DA9063_BUCK_COMMON_FIELDS(BCORE1),
631+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BCORE1_MON_EN),
621632
},
622633
{
623634
DA9063_BUCK(DA9063, BMEM_BIO_MERGED, 800, 20, 3340,
624635
da9063_bmem_bio_merged_limits,
625636
DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK),
626637
/* BMEM_BIO_MERGED uses the same register fields as BMEM */
627638
DA9063_BUCK_COMMON_FIELDS(BMEM),
639+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_4, DA9063_BMEM_MON_EN),
628640
},
629641
{
630642
DA9063_LDO(DA9063, LDO3, 900, 20, 3440),
631643
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO3_LIM),
644+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO3_MON_EN),
632645
},
633646
{
634647
DA9063_LDO(DA9063, LDO7, 900, 50, 3600),
635648
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO7_LIM),
649+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO7_MON_EN),
636650
},
637651
{
638652
DA9063_LDO(DA9063, LDO8, 900, 50, 3600),
639653
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO8_LIM),
654+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO8_MON_EN),
640655
},
641656
{
642657
DA9063_LDO(DA9063, LDO9, 950, 50, 3600),
658+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_3, DA9063_LDO9_MON_EN),
643659
},
644660
{
645661
DA9063_LDO(DA9063, LDO11, 900, 50, 3600),
646662
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO11_LIM),
663+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_3, DA9063_LDO11_MON_EN),
647664
},
648665

649666
/* The following LDOs are present only on DA9063, not on DA9063L */
650667
{
651668
DA9063_LDO(DA9063, LDO1, 600, 20, 1860),
669+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO1_MON_EN),
652670
},
653671
{
654672
DA9063_LDO(DA9063, LDO2, 600, 20, 1860),
673+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO2_MON_EN),
655674
},
656675
{
657676
DA9063_LDO(DA9063, LDO4, 900, 20, 3440),
658677
.oc_event = BFIELD(DA9063_REG_STATUS_D, DA9063_LDO4_LIM),
678+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO4_MON_EN),
659679
},
660680
{
661681
DA9063_LDO(DA9063, LDO5, 900, 50, 3600),
682+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO5_MON_EN),
662683
},
663684
{
664685
DA9063_LDO(DA9063, LDO6, 900, 50, 3600),
686+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_2, DA9063_LDO6_MON_EN),
665687
},
666688

667689
{
668690
DA9063_LDO(DA9063, LDO10, 900, 50, 3600),
691+
.vmon = BFIELD(DA9063_BB_REG_MON_REG_3, DA9063_LDO10_MON_EN),
669692
},
670693
};
671694

@@ -932,6 +955,12 @@ static int da9063_regulator_probe(struct platform_device *pdev)
932955
if (IS_ERR(regl->suspend_sleep))
933956
return PTR_ERR(regl->suspend_sleep);
934957
}
958+
if (regl->info->vmon.reg) {
959+
regl->vmon = devm_regmap_field_alloc(&pdev->dev,
960+
da9063->regmap, regl->info->vmon);
961+
if (IS_ERR(regl->vmon))
962+
return PTR_ERR(regl->vmon);
963+
}
935964

936965
/* Register regulator */
937966
memset(&config, 0, sizeof(config));

include/linux/mfd/da9063/registers.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,29 @@
10401040
/* DA9063_REG_CONFIG_J (addr=0x10F) */
10411041
#define DA9063_TWOWIRE_TO 0x40
10421042

1043+
/* DA9063_REG_MON_REG_2 (addr=0x115) */
1044+
#define DA9063_LDO1_MON_EN 0x01
1045+
#define DA9063_LDO2_MON_EN 0x02
1046+
#define DA9063_LDO3_MON_EN 0x04
1047+
#define DA9063_LDO4_MON_EN 0x08
1048+
#define DA9063_LDO5_MON_EN 0x10
1049+
#define DA9063_LDO6_MON_EN 0x20
1050+
#define DA9063_LDO7_MON_EN 0x40
1051+
#define DA9063_LDO8_MON_EN 0x80
1052+
1053+
/* DA9063_REG_MON_REG_3 (addr=0x116) */
1054+
#define DA9063_LDO9_MON_EN 0x01
1055+
#define DA9063_LDO10_MON_EN 0x02
1056+
#define DA9063_LDO11_MON_EN 0x04
1057+
1058+
/* DA9063_REG_MON_REG_4 (addr=0x117) */
1059+
#define DA9063_BCORE1_MON_EN 0x04
1060+
#define DA9063_BCORE2_MON_EN 0x08
1061+
#define DA9063_BPRO_MON_EN 0x10
1062+
#define DA9063_BIO_MON_EN 0x20
1063+
#define DA9063_BMEM_MON_EN 0x40
1064+
#define DA9063_BPERI_MON_EN 0x80
1065+
10431066
/* DA9063_REG_MON_REG_5 (addr=0x116) */
10441067
#define DA9063_MON_A8_IDX_MASK 0x07
10451068
#define DA9063_MON_A8_IDX_NONE 0x00

0 commit comments

Comments
 (0)