Skip to content

Commit fd5d100

Browse files
Felix Riemannbroonie
authored andcommitted
regulator: da9061/62: Adjust LDO voltage selection minimum value
According to the DA9061 and DA9062 datasheets the LDO voltage selection registers have a lower value of 0x02. This applies to voltage registers VLDO1_A, VLDO2_A, VLDO3_A and VLDO4_A. This linear offset of 0x02 was previously not observed by the driver, causing the LDO output voltage to be systematically lower by two steps (= 0.1V). This patch fixes the minimum linear selector offset by setting it to a value of 2 and increases the n_voltages by the same amount allowing voltages in the range 0x02 -> 0.9V to 0x38 -> 3.6V to be correctly selected. Also fixes an incorrect calculaton for the n_voltages value in the regulator LDO2. These fixes effect all LDO regulators for DA9061 and DA9062. Acked-by: Steve Twiss <[email protected]> Tested-by: Steve Twiss <[email protected]> Signed-off-by: Felix Riemann <[email protected]> Signed-off-by: Steve Twiss <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 0211f68 commit fd5d100

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

drivers/regulator/da9062-regulator.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,13 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
493493
.desc.ops = &da9062_ldo_ops,
494494
.desc.min_uV = (900) * 1000,
495495
.desc.uV_step = (50) * 1000,
496-
.desc.n_voltages = ((3600) - (900))/(50) + 1,
496+
.desc.n_voltages = ((3600) - (900))/(50) + 1
497+
+ DA9062AA_VLDO_A_MIN_SEL,
497498
.desc.enable_reg = DA9062AA_LDO1_CONT,
498499
.desc.enable_mask = DA9062AA_LDO1_EN_MASK,
499500
.desc.vsel_reg = DA9062AA_VLDO1_A,
500501
.desc.vsel_mask = DA9062AA_VLDO1_A_MASK,
501-
.desc.linear_min_sel = 0,
502+
.desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL,
502503
.sleep = REG_FIELD(DA9062AA_VLDO1_A,
503504
__builtin_ffs((int)DA9062AA_LDO1_SL_A_MASK) - 1,
504505
sizeof(unsigned int) * 8 -
@@ -525,12 +526,13 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
525526
.desc.ops = &da9062_ldo_ops,
526527
.desc.min_uV = (900) * 1000,
527528
.desc.uV_step = (50) * 1000,
528-
.desc.n_voltages = ((3600) - (600))/(50) + 1,
529+
.desc.n_voltages = ((3600) - (900))/(50) + 1
530+
+ DA9062AA_VLDO_A_MIN_SEL,
529531
.desc.enable_reg = DA9062AA_LDO2_CONT,
530532
.desc.enable_mask = DA9062AA_LDO2_EN_MASK,
531533
.desc.vsel_reg = DA9062AA_VLDO2_A,
532534
.desc.vsel_mask = DA9062AA_VLDO2_A_MASK,
533-
.desc.linear_min_sel = 0,
535+
.desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL,
534536
.sleep = REG_FIELD(DA9062AA_VLDO2_A,
535537
__builtin_ffs((int)DA9062AA_LDO2_SL_A_MASK) - 1,
536538
sizeof(unsigned int) * 8 -
@@ -557,12 +559,13 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
557559
.desc.ops = &da9062_ldo_ops,
558560
.desc.min_uV = (900) * 1000,
559561
.desc.uV_step = (50) * 1000,
560-
.desc.n_voltages = ((3600) - (900))/(50) + 1,
562+
.desc.n_voltages = ((3600) - (900))/(50) + 1
563+
+ DA9062AA_VLDO_A_MIN_SEL,
561564
.desc.enable_reg = DA9062AA_LDO3_CONT,
562565
.desc.enable_mask = DA9062AA_LDO3_EN_MASK,
563566
.desc.vsel_reg = DA9062AA_VLDO3_A,
564567
.desc.vsel_mask = DA9062AA_VLDO3_A_MASK,
565-
.desc.linear_min_sel = 0,
568+
.desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL,
566569
.sleep = REG_FIELD(DA9062AA_VLDO3_A,
567570
__builtin_ffs((int)DA9062AA_LDO3_SL_A_MASK) - 1,
568571
sizeof(unsigned int) * 8 -
@@ -589,12 +592,13 @@ static const struct da9062_regulator_info local_da9061_regulator_info[] = {
589592
.desc.ops = &da9062_ldo_ops,
590593
.desc.min_uV = (900) * 1000,
591594
.desc.uV_step = (50) * 1000,
592-
.desc.n_voltages = ((3600) - (900))/(50) + 1,
595+
.desc.n_voltages = ((3600) - (900))/(50) + 1
596+
+ DA9062AA_VLDO_A_MIN_SEL,
593597
.desc.enable_reg = DA9062AA_LDO4_CONT,
594598
.desc.enable_mask = DA9062AA_LDO4_EN_MASK,
595599
.desc.vsel_reg = DA9062AA_VLDO4_A,
596600
.desc.vsel_mask = DA9062AA_VLDO4_A_MASK,
597-
.desc.linear_min_sel = 0,
601+
.desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL,
598602
.sleep = REG_FIELD(DA9062AA_VLDO4_A,
599603
__builtin_ffs((int)DA9062AA_LDO4_SL_A_MASK) - 1,
600604
sizeof(unsigned int) * 8 -
@@ -769,12 +773,13 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
769773
.desc.ops = &da9062_ldo_ops,
770774
.desc.min_uV = (900) * 1000,
771775
.desc.uV_step = (50) * 1000,
772-
.desc.n_voltages = ((3600) - (900))/(50) + 1,
776+
.desc.n_voltages = ((3600) - (900))/(50) + 1
777+
+ DA9062AA_VLDO_A_MIN_SEL,
773778
.desc.enable_reg = DA9062AA_LDO1_CONT,
774779
.desc.enable_mask = DA9062AA_LDO1_EN_MASK,
775780
.desc.vsel_reg = DA9062AA_VLDO1_A,
776781
.desc.vsel_mask = DA9062AA_VLDO1_A_MASK,
777-
.desc.linear_min_sel = 0,
782+
.desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL,
778783
.sleep = REG_FIELD(DA9062AA_VLDO1_A,
779784
__builtin_ffs((int)DA9062AA_LDO1_SL_A_MASK) - 1,
780785
sizeof(unsigned int) * 8 -
@@ -801,12 +806,13 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
801806
.desc.ops = &da9062_ldo_ops,
802807
.desc.min_uV = (900) * 1000,
803808
.desc.uV_step = (50) * 1000,
804-
.desc.n_voltages = ((3600) - (600))/(50) + 1,
809+
.desc.n_voltages = ((3600) - (900))/(50) + 1
810+
+ DA9062AA_VLDO_A_MIN_SEL,
805811
.desc.enable_reg = DA9062AA_LDO2_CONT,
806812
.desc.enable_mask = DA9062AA_LDO2_EN_MASK,
807813
.desc.vsel_reg = DA9062AA_VLDO2_A,
808814
.desc.vsel_mask = DA9062AA_VLDO2_A_MASK,
809-
.desc.linear_min_sel = 0,
815+
.desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL,
810816
.sleep = REG_FIELD(DA9062AA_VLDO2_A,
811817
__builtin_ffs((int)DA9062AA_LDO2_SL_A_MASK) - 1,
812818
sizeof(unsigned int) * 8 -
@@ -833,12 +839,13 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
833839
.desc.ops = &da9062_ldo_ops,
834840
.desc.min_uV = (900) * 1000,
835841
.desc.uV_step = (50) * 1000,
836-
.desc.n_voltages = ((3600) - (900))/(50) + 1,
842+
.desc.n_voltages = ((3600) - (900))/(50) + 1
843+
+ DA9062AA_VLDO_A_MIN_SEL,
837844
.desc.enable_reg = DA9062AA_LDO3_CONT,
838845
.desc.enable_mask = DA9062AA_LDO3_EN_MASK,
839846
.desc.vsel_reg = DA9062AA_VLDO3_A,
840847
.desc.vsel_mask = DA9062AA_VLDO3_A_MASK,
841-
.desc.linear_min_sel = 0,
848+
.desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL,
842849
.sleep = REG_FIELD(DA9062AA_VLDO3_A,
843850
__builtin_ffs((int)DA9062AA_LDO3_SL_A_MASK) - 1,
844851
sizeof(unsigned int) * 8 -
@@ -865,12 +872,13 @@ static const struct da9062_regulator_info local_da9062_regulator_info[] = {
865872
.desc.ops = &da9062_ldo_ops,
866873
.desc.min_uV = (900) * 1000,
867874
.desc.uV_step = (50) * 1000,
868-
.desc.n_voltages = ((3600) - (900))/(50) + 1,
875+
.desc.n_voltages = ((3600) - (900))/(50) + 1
876+
+ DA9062AA_VLDO_A_MIN_SEL,
869877
.desc.enable_reg = DA9062AA_LDO4_CONT,
870878
.desc.enable_mask = DA9062AA_LDO4_EN_MASK,
871879
.desc.vsel_reg = DA9062AA_VLDO4_A,
872880
.desc.vsel_mask = DA9062AA_VLDO4_A_MASK,
873-
.desc.linear_min_sel = 0,
881+
.desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL,
874882
.sleep = REG_FIELD(DA9062AA_VLDO4_A,
875883
__builtin_ffs((int)DA9062AA_LDO4_SL_A_MASK) - 1,
876884
sizeof(unsigned int) * 8 -

include/linux/mfd/da9062/registers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,9 @@
797797
#define DA9062AA_BUCK3_SL_A_SHIFT 7
798798
#define DA9062AA_BUCK3_SL_A_MASK BIT(7)
799799

800+
/* DA9062AA_VLDO[1-4]_A common */
801+
#define DA9062AA_VLDO_A_MIN_SEL 2
802+
800803
/* DA9062AA_VLDO1_A = 0x0A9 */
801804
#define DA9062AA_VLDO1_A_SHIFT 0
802805
#define DA9062AA_VLDO1_A_MASK 0x3f

0 commit comments

Comments
 (0)