sunxi: power: axp818: Support ALDO/DLDO/ELDOs
cover sunxi: power: axp818: Support ALDO/DLDO/ELDOs
Hi everyone,
This series adds proper support for ALDO/DLDO/ELDOs on AXP818. FLDOs aren't covered yet, though the hardware defaults should work nicely with sane hardware. ALDO functions aren't consolidated or cleaned up either.
Patch 1 cleans up the axp818 header.
Patch 2 merges the separate axp221 dldo functions into 1.
Patch 3 adds support for axp818's dldos and eldos.
Patch 4 drops the LDO voltages from h8_homlet_v2_defconfig. These match the defaults.
Patch 5 adds support for axp818's aldos.
Regards
ChenYu
Chen-Yu Tsai (5):
power: axp818: Remove duplicate register definition macros
power: axp: merge separate DLDO functions into 1
power: axp818: Add support for DLDO and ELDO regulators
sunxi: h8_homlet_v2: Drop LDO settings from defconfig
sunxi: power: axp818: Enable support for ALDOs
board/sunxi/board.c | 16 ++++---- configs/h8_homlet_v2_defconfig | 3 -- drivers/power/Kconfig | 25 +++++++----- drivers/power/axp221.c | 88 ++++++++++-------------------------------- drivers/power/axp818.c | 81 ++++++++++++++++++++++++++++++++++++++ include/axp818.h | 8 ---- include/axp_pmic.h | 5 +-- 7 files changed, 125 insertions(+), 101 deletions(-)
Signature · 1 line
2.6.4
PATCH 1/5 power: axp818: Remove duplicate register definition macros
Some of the register definitions are duplicated. Drop them.
--- include/axp818.h | 8 -------- 1 file changed, 8 deletions(-)
include/axp818.h +0 -8
@@ -32,13 +32,6 @@#define AXP818_OUTPUT_CTRL3_ALDO2_EN (1 << 6)#define AXP818_OUTPUT_CTRL3_ALDO3_EN (1 << 7) -#define AXP818_DCDC1_CTRL 0x20 -#define AXP818_DCDC2_CTRL 0x21 -#define AXP818_DCDC3_CTRL 0x22 -#define AXP818_DCDC4_CTRL 0x23 -#define AXP818_DCDC5_CTRL 0x24 -#define AXP818_DCDC6_CTRL 0x25 -#define AXP818_DLDO1_CTRL 0x15#define AXP818_DLDO2_CTRL 0x16#define AXP818_DLDO3_CTRL 0x17
@@ -46,7 +39,6 @@#define AXP818_ELDO1_CTRL 0x19#define AXP818_ELDO2_CTRL 0x1a#define AXP818_ELDO3_CTRL 0x1b -#define AXP818_ELDO3_CTRL 0x1b#define AXP818_FLDO1_CTRL 0x1c#define AXP818_FLDO2_3_CTRL 0x1d#define AXP818_DCDC1_CTRL 0x20
Signature · 1 line
2.6.4
PATCH 1/5 power: axp818: Remove duplicate register definition macros
Hello Wens,
Thanks for correcting it.
Regards,
Vishnu
Quoted 36 lines · Chen-Yu Tsai
Some of the register definitions are duplicated. Drop them.
Signed-off-by Chen-Yu Tsai <[email protected]>--- include/axp818.h | 8 -------- 1 file changed, 8 deletions(-)include/axp818.h +0
-9@@ -32,13 +32,6 @@#define AXP818_OUTPUT_CTRL3_ALDO2_EN (1 << 6)#define AXP818_OUTPUT_CTRL3_ALDO3_EN (1 << 7) -#define AXP818_DCDC1_CTRL 0x20 -#define AXP818_DCDC2_CTRL 0x21 -#define AXP818_DCDC3_CTRL 0x22 -#define AXP818_DCDC4_CTRL 0x23 -#define AXP818_DCDC5_CTRL 0x24 -#define AXP818_DCDC6_CTRL 0x25 -#define AXP818_DLDO1_CTRL 0x15#define AXP818_DLDO2_CTRL 0x16#define AXP818_DLDO3_CTRL 0x17@@ -46,7 +39,6 @@#define AXP818_ELDO1_CTRL 0x19#define AXP818_ELDO2_CTRL 0x1a#define AXP818_ELDO3_CTRL 0x1b -#define AXP818_ELDO3_CTRL 0x1b#define AXP818_FLDO1_CTRL 0x1c#define AXP818_FLDO2_3_CTRL 0x1d#define AXP818_DCDC1_CTRL 0x20 --2.6.4
PATCH 2/5 power: axp: merge separate DLDO functions into 1
In reply to Chen-Yu TsaiInstead of one function for each DLDO regulator, make 1 function that takes an extra "index". Since the control bits for the DLDO regulators are contiguous, this makes the function very simple. This removes a lot of duplicate code.
--- board/sunxi/board.c | 8 ++--- drivers/power/axp221.c | 88 ++++++++++++-------------------------------------- include/axp_pmic.h | 5 +-- 3 files changed, 25 insertions(+), 76 deletions(-)
board/sunxi/board.c +4 -4
@@ -460,10 +460,10 @@ void sunxi_board_init(void)#endif #ifdef CONFIG_AXP221_POWER - power_failed |=axp_set_dldo1 (CONFIG_AXP_DLDO1_VOLT ); - power_failed |=axp_set_dldo2 (CONFIG_AXP_DLDO2_VOLT ); - power_failed |=axp_set_dldo3 (CONFIG_AXP_DLDO3_VOLT ); - power_failed |=axp_set_dldo4 (CONFIG_AXP_DLDO4_VOLT ); + 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 ); + power_failed |=axp_set_dldo (4 ,CONFIG_AXP_DLDO4_VOLT ); power_failed |=axp_set_eldo (1 ,CONFIG_AXP_ELDO1_VOLT ); power_failed |=axp_set_eldo (2 ,CONFIG_AXP_ELDO2_VOLT ); power_failed |=axp_set_eldo (3 ,CONFIG_AXP_ELDO3_VOLT );
drivers/power/axp221.c +20 -68
100 lines not on this page · raw message
include/axp_pmic.h +1 -4
@@ -29,10 +29,7 @@ int axp_set_aldo1(unsigned int mvolt);int axp_set_aldo2 (unsigned int mvolt);int axp_set_aldo3 (unsigned int mvolt);int axp_set_aldo4 (unsigned int mvolt); -int axp_set_dldo1 (unsigned int mvolt); -int axp_set_dldo2 (unsigned int mvolt); -int axp_set_dldo3 (unsigned int mvolt); -int axp_set_dldo4 (unsigned int mvolt); +int axp_set_dldo (int dldo_num,unsigned int mvolt);int axp_set_eldo (int eldo_num,unsigned int mvolt);int axp_init (void );int axp_get_sid (unsigned int *sid);
Signature · 1 line
2.6.4
PATCH 3/5 power: axp818: Add support for DLDO and ELDO regulators
In reply to Chen-Yu TsaiAXP818 provides an array of LDOs to provide power to various peripherals. None of these regulators are critical.
--- drivers/power/Kconfig | 12 ++++++------ drivers/power/axp818.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 6 deletions(-)
drivers/power/Kconfig +6 -6
@@ -164,7 +164,7 @@ config AXP_ALDO4_VOLT config AXP_DLDO1_VOLT int "axp pmic dldo1 voltage" - depends on AXP221_POWER + depends on AXP221_POWER || AXP818_POWER default 0 ---help--- Set the voltage (mV) to program the axp pmic dldo1 at, set to 0 to
@@ -174,7 +174,7 @@ config AXP_DLDO1_VOLT config AXP_DLDO2_VOLT int "axp pmic dldo2 voltage" - depends on AXP221_POWER + depends on AXP221_POWER || AXP818_POWER default 0 ---help--- Set the voltage (mV) to program the axp pmic dldo2 at, set to 0 to
@@ -182,7 +182,7 @@ config AXP_DLDO2_VOLT config AXP_DLDO3_VOLT int "axp pmic dldo3 voltage" - depends on AXP221_POWER + depends on AXP221_POWER || AXP818_POWER default 0 ---help--- Set the voltage (mV) to program the axp pmic dldo3 at, set to 0 to
@@ -198,7 +198,7 @@ config AXP_DLDO4_VOLT config AXP_ELDO1_VOLT int "axp pmic eldo1 voltage" - depends on AXP221_POWER + depends on AXP221_POWER || AXP818_POWER default 0 ---help--- Set the voltage (mV) to program the axp pmic eldo1 at, set to 0 to
@@ -206,7 +206,7 @@ config AXP_ELDO1_VOLT config AXP_ELDO2_VOLT int "axp pmic eldo2 voltage" - depends on AXP221_POWER + depends on AXP221_POWER || AXP818_POWER default 0 ---help--- Set the voltage (mV) to program the axp pmic eldo2 at, set to 0 to
@@ -214,7 +214,7 @@ config AXP_ELDO2_VOLT config AXP_ELDO3_VOLT int "axp pmic eldo3 voltage" - depends on AXP221_POWER + depends on AXP221_POWER || AXP818_POWER default 0 ---help--- Set the voltage (mV) to program the axp pmic eldo3 at, set to 0 to
drivers/power/axp818.c +44 -0
50 lines not on this page · raw message
Signature · 1 line
2.6.4
PATCH 4/5 sunxi: h8_homlet_v2: Drop LDO settings from defconfig
In reply to Chen-Yu TsaiThe LDO settings in this defconfig are either wrong (ALDOs must not be 0) or the same as Kconfig defaults.
--- configs/h8_homlet_v2_defconfig | 3 --- 1 file changed, 3 deletions(-)
configs/h8_homlet_v2_defconfig +0 -3
@@ -19,6 +19,3 @@ CONFIG_AXP_DCDC2_VOLT=900 CONFIG_AXP_DCDC3_VOLT=900 CONFIG_AXP_DCDC4_VOLT=0 CONFIG_AXP_DCDC5_VOLT=1500 -CONFIG_AXP_ALDO2_VOLT=0 -CONFIG_AXP_ALDO3_VOLT=0 -CONFIG_AXP_DLDO4_VOLT=0
Signature · 1 line
2.6.4
PATCH 5/5 sunxi: power: axp818: Enable support for ALDOs
In reply to Chen-Yu TsaiPreviously, 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.
--- board/sunxi/board.c | 8 +++----- drivers/power/Kconfig | 13 ++++++++++--- drivers/power/axp818.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 8 deletions(-)
board/sunxi/board.c +3 -5
@@ -446,20 +446,18 @@ void sunxi_board_init(void) power_failed |=axp_set_dcdc5 (CONFIG_AXP_DCDC5_VOLT );#endif -#ifdef CONFIG_AXP221_POWER +#if definedCONFIG_AXP221_POWER || definedCONFIG_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 );
drivers/power/Kconfig +10 -3
@@ -118,20 +118,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
@@ -140,18 +144,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"
drivers/power/axp818.c +37 -0
@@ -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;
Signature · 1 line
2.6.4
Hans de Goede
Appliedcover sunxi: power: axp818: Support ALDO/DLDO/ELDOs
In reply to Chen-Yu TsaiHi,
Quoted 9 lines · Chen-Yu Tsai
Hi everyone,
This series adds proper support for ALDO/DLDO/ELDOs on AXP818. FLDOs aren't covered yet, though the hardware defaults should work nicely with sane hardware. ALDO functions aren't consolidated or cleaned up either.
Patch 1 cleans up the axp818 header.
Quoted 8 lines
Patch 2 merges the separate axp221 dldo functions into 1.
Patch 3 adds support for axp818's dldos and eldos.
Patch 4 drops the LDO voltages from
h8_homlet_v2_defconfig. These match the defaults.Patch 5 adds support for axp818's aldos.
Thanks, applied.
Regards,
Hans