]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
sunxi: power: axp818: Enable support for ALDOs
authorChen-Yu Tsai <wens@csie.org>
Tue, 12 Jan 2016 06:42:40 +0000 (14:42 +0800)
committerHans de Goede <hdegoede@redhat.com>
Tue, 26 Jan 2016 15:20:05 +0000 (16:20 +0100)
Previously, AXP818 ALDO support was partially added to Kconfig, but
never enabled in the board file, nor properly set or configured in
Kconfig. The boards continue to work because the AXP818 is designed
to pair with the A83T/H8, and the default voltages match the reference
design's requirements.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
board/sunxi/board.c
drivers/power/Kconfig
drivers/power/axp818.c

index 958f5c5bae4640a093b0f17ff8c0c367ef295be7..420481a9fb849797bf97c1681d96480a45991801 100644 (file)
@@ -452,20 +452,18 @@ void sunxi_board_init(void)
        power_failed |= axp_set_dcdc5(CONFIG_AXP_DCDC5_VOLT);
 #endif
 
-#ifdef CONFIG_AXP221_POWER
+#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP818_POWER
        power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
 #endif
-#ifndef CONFIG_AXP818_POWER
        power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
-#endif
-#if !defined(CONFIG_AXP152_POWER) && !defined(CONFIG_AXP818_POWER)
+#if !defined(CONFIG_AXP152_POWER)
        power_failed |= axp_set_aldo3(CONFIG_AXP_ALDO3_VOLT);
 #endif
 #ifdef CONFIG_AXP209_POWER
        power_failed |= axp_set_aldo4(CONFIG_AXP_ALDO4_VOLT);
 #endif
 
-#ifdef CONFIG_AXP221_POWER
+#if defined(CONFIG_AXP221_POWER) || defined(CONFIG_AXP818_POWER)
        power_failed |= axp_set_dldo(1, CONFIG_AXP_DLDO1_VOLT);
        power_failed |= axp_set_dldo(2, CONFIG_AXP_DLDO2_VOLT);
        power_failed |= axp_set_dldo(3, CONFIG_AXP_DLDO3_VOLT);
index 3d49b872e863652ee60cfe0ad711cf5ad7838af0..10683a21d971eb9a06e817aa6437f6f9689315f4 100644 (file)
@@ -121,20 +121,24 @@ config AXP_DCDC5_VOLT
 
 config AXP_ALDO1_VOLT
        int "axp pmic (a)ldo1 voltage"
-       depends on AXP221_POWER
+       depends on AXP221_POWER || AXP818_POWER
        default 0 if MACH_SUN6I
+       default 1800 if MACH_SUN8I_A83T
        default 3000 if MACH_SUN8I
        ---help---
        Set the voltage (mV) to program the axp pmic aldo1 at, set to 0 to
        disable aldo1.
        On A31 boards aldo1 is often used to power the wifi module.
        On A23 / A33 boards aldo1 is used for VCC-IO and should be 3.0V.
+       On A83T / H8 boards aldo1 is used for MIPI CSI, DSI, HDMI, EFUSE, and
+       should be 1.8V.
 
 config AXP_ALDO2_VOLT
        int "axp pmic (a)ldo2 voltage"
        depends on AXP152_POWER || AXP209_POWER || AXP221_POWER || AXP818_POWER
        default 3000 if AXP152_POWER || AXP209_POWER
        default 0 if MACH_SUN6I
+       default 1800 if MACH_SUN8I_A83T
        default 2500 if MACH_SUN8I
        ---help---
        Set the voltage (mV) to program the axp pmic aldo2 at, set to 0 to
@@ -143,18 +147,21 @@ config AXP_ALDO2_VOLT
        On A31 boards aldo2 is typically unused and should be disabled.
        On A31 boards aldo2 may be used for LPDDR2 then it should be 1.8V.
        On A23 / A33 boards aldo2 is used for VDD-DLL and should be 2.5V.
+       On A83T / H8 boards aldo2 powers VDD-DLL, VCC18-PLL, CPVDD, VDD18-ADC,
+       LPDDR2, and the codec. It should be 1.8V.
 
 config AXP_ALDO3_VOLT
        int "axp pmic (a)ldo3 voltage"
        depends on AXP209_POWER || AXP221_POWER || AXP818_POWER
-       default 0 if AXP209_POWER || AXP818_POWER
+       default 0 if AXP209_POWER
        default 3000 if MACH_SUN6I || MACH_SUN8I
        ---help---
        Set the voltage (mV) to program the axp pmic aldo3 at, set to 0 to
        disable aldo3.
        On A10(s) / A13 / A20 boards aldo3 should be 2.8V.
        On A23 / A31 / A33 boards aldo3 is VCC-PLL and AVCC and should be 3.0V.
-       On A83T aldo3 is used for LVDS, DSI, MIPI, HDMI, etc.
+       On A83T / H8 boards aldo3 is AVCC, VCC-PL, and VCC-LED, and should be
+       3.0V.
 
 config AXP_ALDO4_VOLT
        int "axp pmic (a)ldo4 voltage"
index 3119b64ea16b3efa3b635b7561ea2c630db3d29f..e885d029840335d42a60184c72d3af7fd2b2cf47 100644 (file)
@@ -110,6 +110,43 @@ int axp_set_dcdc5(unsigned int mvolt)
                                AXP818_OUTPUT_CTRL1_DCDC5_EN);
 }
 
+int axp_set_aldo(int aldo_num, unsigned int mvolt)
+{
+       int ret;
+       u8 cfg;
+
+       if (aldo_num < 1 || aldo_num > 3)
+               return -EINVAL;
+
+       if (mvolt == 0)
+               return pmic_bus_clrbits(AXP818_OUTPUT_CTRL3,
+                               AXP818_OUTPUT_CTRL3_ALDO1_EN << (aldo_num - 1));
+
+       cfg = axp818_mvolt_to_cfg(mvolt, 700, 3300, 100);
+       ret = pmic_bus_write(AXP818_ALDO1_CTRL + (aldo_num - 1), cfg);
+       if (ret)
+               return ret;
+
+       return pmic_bus_setbits(AXP818_OUTPUT_CTRL3,
+                               AXP818_OUTPUT_CTRL3_ALDO1_EN << (aldo_num - 1));
+}
+
+/* TODO: re-work other AXP drivers to consolidate ALDO functions. */
+int axp_set_aldo1(unsigned int mvolt)
+{
+       return axp_set_aldo(1, mvolt);
+}
+
+int axp_set_aldo2(unsigned int mvolt)
+{
+       return axp_set_aldo(2, mvolt);
+}
+
+int axp_set_aldo3(unsigned int mvolt)
+{
+       return axp_set_aldo(3, mvolt);
+}
+
 int axp_set_dldo(int dldo_num, unsigned int mvolt)
 {
        int ret;