On Wednesday, October 18, 2023 5:50:13 PM CEST Andre Przywara wrote:
> On boards using the AXP313 PMIC, the DRAM rail is often not setup
> correctly at reset time, so we have to program the PMIC very early in
> the SPL, before running the DRAM initialisation.
>
> Add a simple AXP313 PMIC driver that knows about DCDC2(CPU) and
> DCDC3(DRAM), so that we can bump up the voltage before the DRAM init.
>
> Signed-off-by: Andre Przywara
> ---
> arch/arm/mach-sunxi/pmic_bus.c | 3 +
> board/sunxi/board.c| 3 +-
> drivers/power/Kconfig | 17 -
> drivers/power/Makefile | 1 +
> drivers/power/axp313.c | 134 +
> 5 files changed, 155 insertions(+), 3 deletions(-)
> create mode 100644 drivers/power/axp313.c
>
> diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c
> index c0908406370..8e7625fe057 100644
> --- a/arch/arm/mach-sunxi/pmic_bus.c
> +++ b/arch/arm/mach-sunxi/pmic_bus.c
> @@ -22,6 +22,7 @@
> #define AXP209_I2C_ADDR 0x34
>
> #define AXP305_I2C_ADDR 0x36
> +#define AXP313_I2C_ADDR 0x36
>
> #define AXP221_CHIP_ADDR 0x68
>
> @@ -34,6 +35,8 @@ static int pmic_i2c_address(void)
> return AXP152_I2C_ADDR;
> if (IS_ENABLED(CONFIG_AXP305_POWER))
> return AXP305_I2C_ADDR;
> + if (IS_ENABLED(CONFIG_AXP313_POWER))
> + return AXP313_I2C_ADDR;
>
> /* Other AXP2xx and AXP8xx variants */
> return AXP209_I2C_ADDR;
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index 65d79a02c25..39b0ad73a9c 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -584,7 +584,8 @@ void sunxi_board_init(void)
>
> #if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || \
> defined CONFIG_AXP221_POWER || defined CONFIG_AXP305_POWER || \
> - defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
> + defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER || \
> + defined CONFIG_AXP313_POWER
> power_failed = axp_init();
>
> if (IS_ENABLED(CONFIG_AXP_DISABLE_BOOT_ON_POWERON) && !
power_failed) {
> diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
> index 83cb31c937a..a9117d215eb 100644
> --- a/drivers/power/Kconfig
> +++ b/drivers/power/Kconfig
> @@ -101,6 +101,15 @@ config AXP305_POWER
> Select this to enable support for the axp305 pmic found on most
> H616 boards.
>
> +config AXP313_POWER
> + bool "axp311 pmic support"
Typo: axp311 -> axp313
Other than that, it looks good. I can't test it since I don't have any
hardware with such PMIC.
So FWIW:
Acked-by: Jernej Skrabec
Best regards,
Jernej
> + depends on MACH_SUN50I_H616
> + select AXP_PMIC_BUS
> + select CMD_POWEROFF
> + ---help---
> + Select this to enable support for the AXP313 PMIC found on some
> + H616 boards.
> +
> config AXP809_POWER
> bool "axp809 pmic support"
> depends on MACH_SUN9I
> @@ -143,9 +152,10 @@ config AXP_DCDC1_VOLT
>
> config AXP_DCDC2_VOLT
> int "axp pmic dcdc2 voltage"
> - depends on AXP152_POWER || AXP209_POWER || AXP221_POWER ||
AXP809_POWER ||
> AXP818_POWER +depends on AXP152_POWER || AXP209_POWER || AXP221_POWER
||
> AXP809_POWER || AXP818_POWER || AXP313_POWER default 900 if AXP818_POWER
> default 1400 if AXP152_POWER || AXP209_POWER
> + default 1000 if AXP313_POWER
> default 1200 if MACH_SUN6I
> default 1100 if MACH_SUN8I
> default 0 if MACH_SUN9I
> @@ -158,13 +168,15 @@ config AXP_DCDC2_VOLT
> On A80 boards dcdc2 powers the GPU and can be left off.
> On A83T boards dcdc2 is used for VDD-CPUA(cluster 0) and should be
0.9V.
> On R40 boards dcdc2 is VDD-CPU and should be 1.1V
> + On boards using the AXP313 it's often VDD-CPU.
>
> config AXP_DCDC3_VOLT
> int "axp pmic dcdc3 voltage"
> - depends on AXP152_POWER || AXP209_POWER || AXP221_POWER ||
AXP809_POWER ||
> AXP818_POWER +depends on AXP152_POWER || AXP209_POWER || AXP221_POWER
||
> AXP809_POWER || AXP818_POWER || AXP313_POWER default 900 if AXP809_POWER ||
> AXP818_POWER
> default 1500 if AXP152_POWER
> default 1250 if AXP209_POWER
> + default 1100 if AXP313_POWER
> default 1100 if MACH_SUN8I_R40
> default 1200 if MACH_SUN6I || MACH_SUN8I
> ---help---
> @@ -177,6 +189,7 @@ config AXP_DCDC3_VOLT
> On A80 boards dcdc3 is used for VDD-CPUA(cluster 0) and should be
0.9V.
> On A83T boards dcdc3 is used for VDD-CPUB(cluster 1) and should be
0.9V.
> On R40 boards dcdc3 is VDD-SYS and VDD-GPU and should be 1.1V.
> + On boards using the AXP313 it's often VDD-DRAM and should be 1.1V
for
> LPDDR4.
>
> config AXP_DCDC4_VOLT
> int "axp pmic dcdc4 voltage"
> diff --git a/drivers/power/Makefile b/drivers/power/Makefile
> index ba64b2c5938..c7ee4595fc8 100644
> ---