Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <stwiss.opensource@diasemi.com>
Tested-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Felix Riemann <felix.riemann@sma.de>
Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Felix Riemann and committed by
Mark Brown
fd5d1005 0211f68e

+27 -16
+24 -16
drivers/regulator/da9062-regulator.c
··· 493 493 .desc.ops = &da9062_ldo_ops, 494 494 .desc.min_uV = (900) * 1000, 495 495 .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, 497 498 .desc.enable_reg = DA9062AA_LDO1_CONT, 498 499 .desc.enable_mask = DA9062AA_LDO1_EN_MASK, 499 500 .desc.vsel_reg = DA9062AA_VLDO1_A, 500 501 .desc.vsel_mask = DA9062AA_VLDO1_A_MASK, 501 - .desc.linear_min_sel = 0, 502 + .desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL, 502 503 .sleep = REG_FIELD(DA9062AA_VLDO1_A, 503 504 __builtin_ffs((int)DA9062AA_LDO1_SL_A_MASK) - 1, 504 505 sizeof(unsigned int) * 8 - ··· 526 525 .desc.ops = &da9062_ldo_ops, 527 526 .desc.min_uV = (900) * 1000, 528 527 .desc.uV_step = (50) * 1000, 529 - .desc.n_voltages = ((3600) - (600))/(50) + 1, 528 + .desc.n_voltages = ((3600) - (900))/(50) + 1 529 + + DA9062AA_VLDO_A_MIN_SEL, 530 530 .desc.enable_reg = DA9062AA_LDO2_CONT, 531 531 .desc.enable_mask = DA9062AA_LDO2_EN_MASK, 532 532 .desc.vsel_reg = DA9062AA_VLDO2_A, 533 533 .desc.vsel_mask = DA9062AA_VLDO2_A_MASK, 534 - .desc.linear_min_sel = 0, 534 + .desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL, 535 535 .sleep = REG_FIELD(DA9062AA_VLDO2_A, 536 536 __builtin_ffs((int)DA9062AA_LDO2_SL_A_MASK) - 1, 537 537 sizeof(unsigned int) * 8 - ··· 559 557 .desc.ops = &da9062_ldo_ops, 560 558 .desc.min_uV = (900) * 1000, 561 559 .desc.uV_step = (50) * 1000, 562 - .desc.n_voltages = ((3600) - (900))/(50) + 1, 560 + .desc.n_voltages = ((3600) - (900))/(50) + 1 561 + + DA9062AA_VLDO_A_MIN_SEL, 563 562 .desc.enable_reg = DA9062AA_LDO3_CONT, 564 563 .desc.enable_mask = DA9062AA_LDO3_EN_MASK, 565 564 .desc.vsel_reg = DA9062AA_VLDO3_A, 566 565 .desc.vsel_mask = DA9062AA_VLDO3_A_MASK, 567 - .desc.linear_min_sel = 0, 566 + .desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL, 568 567 .sleep = REG_FIELD(DA9062AA_VLDO3_A, 569 568 __builtin_ffs((int)DA9062AA_LDO3_SL_A_MASK) - 1, 570 569 sizeof(unsigned int) * 8 - ··· 592 589 .desc.ops = &da9062_ldo_ops, 593 590 .desc.min_uV = (900) * 1000, 594 591 .desc.uV_step = (50) * 1000, 595 - .desc.n_voltages = ((3600) - (900))/(50) + 1, 592 + .desc.n_voltages = ((3600) - (900))/(50) + 1 593 + + DA9062AA_VLDO_A_MIN_SEL, 596 594 .desc.enable_reg = DA9062AA_LDO4_CONT, 597 595 .desc.enable_mask = DA9062AA_LDO4_EN_MASK, 598 596 .desc.vsel_reg = DA9062AA_VLDO4_A, 599 597 .desc.vsel_mask = DA9062AA_VLDO4_A_MASK, 600 - .desc.linear_min_sel = 0, 598 + .desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL, 601 599 .sleep = REG_FIELD(DA9062AA_VLDO4_A, 602 600 __builtin_ffs((int)DA9062AA_LDO4_SL_A_MASK) - 1, 603 601 sizeof(unsigned int) * 8 - ··· 773 769 .desc.ops = &da9062_ldo_ops, 774 770 .desc.min_uV = (900) * 1000, 775 771 .desc.uV_step = (50) * 1000, 776 - .desc.n_voltages = ((3600) - (900))/(50) + 1, 772 + .desc.n_voltages = ((3600) - (900))/(50) + 1 773 + + DA9062AA_VLDO_A_MIN_SEL, 777 774 .desc.enable_reg = DA9062AA_LDO1_CONT, 778 775 .desc.enable_mask = DA9062AA_LDO1_EN_MASK, 779 776 .desc.vsel_reg = DA9062AA_VLDO1_A, 780 777 .desc.vsel_mask = DA9062AA_VLDO1_A_MASK, 781 - .desc.linear_min_sel = 0, 778 + .desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL, 782 779 .sleep = REG_FIELD(DA9062AA_VLDO1_A, 783 780 __builtin_ffs((int)DA9062AA_LDO1_SL_A_MASK) - 1, 784 781 sizeof(unsigned int) * 8 - ··· 806 801 .desc.ops = &da9062_ldo_ops, 807 802 .desc.min_uV = (900) * 1000, 808 803 .desc.uV_step = (50) * 1000, 809 - .desc.n_voltages = ((3600) - (600))/(50) + 1, 804 + .desc.n_voltages = ((3600) - (900))/(50) + 1 805 + + DA9062AA_VLDO_A_MIN_SEL, 810 806 .desc.enable_reg = DA9062AA_LDO2_CONT, 811 807 .desc.enable_mask = DA9062AA_LDO2_EN_MASK, 812 808 .desc.vsel_reg = DA9062AA_VLDO2_A, 813 809 .desc.vsel_mask = DA9062AA_VLDO2_A_MASK, 814 - .desc.linear_min_sel = 0, 810 + .desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL, 815 811 .sleep = REG_FIELD(DA9062AA_VLDO2_A, 816 812 __builtin_ffs((int)DA9062AA_LDO2_SL_A_MASK) - 1, 817 813 sizeof(unsigned int) * 8 - ··· 839 833 .desc.ops = &da9062_ldo_ops, 840 834 .desc.min_uV = (900) * 1000, 841 835 .desc.uV_step = (50) * 1000, 842 - .desc.n_voltages = ((3600) - (900))/(50) + 1, 836 + .desc.n_voltages = ((3600) - (900))/(50) + 1 837 + + DA9062AA_VLDO_A_MIN_SEL, 843 838 .desc.enable_reg = DA9062AA_LDO3_CONT, 844 839 .desc.enable_mask = DA9062AA_LDO3_EN_MASK, 845 840 .desc.vsel_reg = DA9062AA_VLDO3_A, 846 841 .desc.vsel_mask = DA9062AA_VLDO3_A_MASK, 847 - .desc.linear_min_sel = 0, 842 + .desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL, 848 843 .sleep = REG_FIELD(DA9062AA_VLDO3_A, 849 844 __builtin_ffs((int)DA9062AA_LDO3_SL_A_MASK) - 1, 850 845 sizeof(unsigned int) * 8 - ··· 872 865 .desc.ops = &da9062_ldo_ops, 873 866 .desc.min_uV = (900) * 1000, 874 867 .desc.uV_step = (50) * 1000, 875 - .desc.n_voltages = ((3600) - (900))/(50) + 1, 868 + .desc.n_voltages = ((3600) - (900))/(50) + 1 869 + + DA9062AA_VLDO_A_MIN_SEL, 876 870 .desc.enable_reg = DA9062AA_LDO4_CONT, 877 871 .desc.enable_mask = DA9062AA_LDO4_EN_MASK, 878 872 .desc.vsel_reg = DA9062AA_VLDO4_A, 879 873 .desc.vsel_mask = DA9062AA_VLDO4_A_MASK, 880 - .desc.linear_min_sel = 0, 874 + .desc.linear_min_sel = DA9062AA_VLDO_A_MIN_SEL, 881 875 .sleep = REG_FIELD(DA9062AA_VLDO4_A, 882 876 __builtin_ffs((int)DA9062AA_LDO4_SL_A_MASK) - 1, 883 877 sizeof(unsigned int) * 8 -
+3
include/linux/mfd/da9062/registers.h
··· 797 797 #define DA9062AA_BUCK3_SL_A_SHIFT 7 798 798 #define DA9062AA_BUCK3_SL_A_MASK BIT(7) 799 799 800 + /* DA9062AA_VLDO[1-4]_A common */ 801 + #define DA9062AA_VLDO_A_MIN_SEL 2 802 + 800 803 /* DA9062AA_VLDO1_A = 0x0A9 */ 801 804 #define DA9062AA_VLDO1_A_SHIFT 0 802 805 #define DA9062AA_VLDO1_A_MASK 0x3f