[U-Boot] [PATCH 01/16] power: sunxi: add AXP803 PMIC support
Maxime Ripard
maxime.ripard at free-electrons.com
Tue Dec 12 07:58:06 UTC 2017
Hi,
On Tue, Dec 12, 2017 at 12:28:16PM +0530, Jagan Teki wrote:
> AXP803 another PMIC produced by x-powers and paired with
> A64 via RSB bus.
>
> unlike other axp chip's support in SPL this is only added
> for U-Boot proper since SPL on A64 has no space to add anything.
How do you setup the CPU and DRAM regulators then?
> Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
> ---
> arch/arm/mach-sunxi/Makefile | 9 ++
> arch/arm/mach-sunxi/pmic_bus.c | 9 +-
> arch/arm/mach-sunxi/rsb.c | 2 +-
> board/sunxi/board.c | 40 +++++++
> drivers/power/Kconfig | 95 ++++++++++-----
> drivers/power/Makefile | 3 +
> drivers/power/axp803.c | 260 +++++++++++++++++++++++++++++++++++++++++
> include/axp803.h | 68 +++++++++++
> include/axp_pmic.h | 4 +
> 9 files changed, 458 insertions(+), 32 deletions(-)
> create mode 100644 drivers/power/axp803.c
> create mode 100644 include/axp803.h
>
> diff --git a/arch/arm/mach-sunxi/Makefile b/arch/arm/mach-sunxi/Makefile
> index 2a3c379..aedf22f 100644
> --- a/arch/arm/mach-sunxi/Makefile
> +++ b/arch/arm/mach-sunxi/Makefile
> @@ -19,9 +19,15 @@ endif
> obj-$(CONFIG_MACH_SUN6I) += prcm.o
> obj-$(CONFIG_MACH_SUN8I) += prcm.o
> obj-$(CONFIG_MACH_SUN9I) += prcm.o
> +ifndef CONFIG_SPL_BUILD
> +obj-$(CONFIG_MACH_SUN50I) += prcm.o
> +endif
The number of lines here is starting to be a bit ridiculous, please
make a Kconfig option selected by the SoC families.
> obj-$(CONFIG_MACH_SUN6I) += p2wi.o
> obj-$(CONFIG_MACH_SUN8I) += rsb.o
> obj-$(CONFIG_MACH_SUN9I) += rsb.o
> +ifndef CONFIG_SPL_BUILD
> +obj-$(CONFIG_MACH_SUN50I) += rsb.o
> +endif
Ditto.
> obj-$(CONFIG_MACH_SUN4I) += clock_sun4i.o
> obj-$(CONFIG_MACH_SUN5I) += clock_sun4i.o
> obj-$(CONFIG_MACH_SUN6I) += clock_sun6i.o
> @@ -38,6 +44,9 @@ obj-$(CONFIG_AXP152_POWER) += pmic_bus.o
> obj-$(CONFIG_AXP209_POWER) += pmic_bus.o
> obj-$(CONFIG_AXP221_POWER) += pmic_bus.o
> obj-$(CONFIG_AXP809_POWER) += pmic_bus.o
> +ifndef CONFIG_SPL_BUILD
> +obj-$(CONFIG_AXP803_POWER) += pmic_bus.o
> +endif
Ditto.
> obj-$(CONFIG_AXP818_POWER) += pmic_bus.o
>
> ifdef CONFIG_SPL_BUILD
> diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c
> index f917c3e..34acd01 100644
> --- a/arch/arm/mach-sunxi/pmic_bus.c
> +++ b/arch/arm/mach-sunxi/pmic_bus.c
> @@ -36,7 +36,8 @@ int pmic_bus_init(void)
> if (!needs_init)
> return 0;
>
> -#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
> +#if defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || \
> + defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
Ditto.
> # ifdef CONFIG_MACH_SUN6I
> p2wi_init();
> ret = p2wi_change_to_p2wi_mode(AXP221_CHIP_ADDR, AXP221_CTRL_ADDR,
> @@ -65,7 +66,8 @@ int pmic_bus_read(u8 reg, u8 *data)
> return i2c_read(AXP152_I2C_ADDR, reg, 1, data, 1);
> #elif defined CONFIG_AXP209_POWER
> return i2c_read(AXP209_I2C_ADDR, reg, 1, data, 1);
> -#elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
> +#elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || \
> + defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
> # ifdef CONFIG_MACH_SUN6I
> return p2wi_read(reg, data);
> # elif defined CONFIG_MACH_SUN8I_R40
> @@ -82,7 +84,8 @@ int pmic_bus_write(u8 reg, u8 data)
> return i2c_write(AXP152_I2C_ADDR, reg, 1, &data, 1);
> #elif defined CONFIG_AXP209_POWER
> return i2c_write(AXP209_I2C_ADDR, reg, 1, &data, 1);
> -#elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
> +#elif defined CONFIG_AXP221_POWER || defined CONFIG_AXP803_POWER || \
> + defined CONFIG_AXP809_POWER || defined CONFIG_AXP818_POWER
> # ifdef CONFIG_MACH_SUN6I
> return p2wi_write(reg, data);
> # elif defined CONFIG_MACH_SUN8I_R40
> diff --git a/arch/arm/mach-sunxi/rsb.c b/arch/arm/mach-sunxi/rsb.c
> index 6fd11f1..ea52a6f 100644
> --- a/arch/arm/mach-sunxi/rsb.c
> +++ b/arch/arm/mach-sunxi/rsb.c
> @@ -27,7 +27,7 @@ static void rsb_cfg_io(void)
> sunxi_gpio_set_pull(SUNXI_GPL(1), 1);
> sunxi_gpio_set_drv(SUNXI_GPL(0), 2);
> sunxi_gpio_set_drv(SUNXI_GPL(1), 2);
> -#elif defined CONFIG_MACH_SUN9I
> +#elif defined CONFIG_MACH_SUN9I || defined CONFIG_MACH_SUN50I
> sunxi_gpio_set_cfgpin(SUNXI_GPN(0), SUN9I_GPN_R_RSB);
> sunxi_gpio_set_cfgpin(SUNXI_GPN(1), SUN9I_GPN_R_RSB);
> sunxi_gpio_set_pull(SUNXI_GPN(0), 1);
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index dcacdf3..158282e 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -173,6 +173,40 @@ void i2c_init_board(void)
> #endif
> }
>
> +#ifdef CONFIG_AXP803_POWER
> +static int axp803_init(void)
> +{
> + int power_failed = 0;
> +
> + power_failed = axp_init();
> +
> + power_failed |= axp_set_dcdc1(CONFIG_AXP_DCDC1_VOLT);
> + power_failed |= axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
> + power_failed |= axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
> + power_failed |= axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
> + power_failed |= axp_set_dcdc5(CONFIG_AXP_DCDC5_VOLT);
> + power_failed |= axp_set_dcdc6(CONFIG_AXP_DCDC6_VOLT);
> +
> + power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
> + power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
> + power_failed |= axp_set_aldo3(CONFIG_AXP_ALDO3_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);
> +
> + power_failed |= axp_set_fldo(1, CONFIG_AXP_FLDO1_VOLT);
> + power_failed |= axp_set_fldo(2, CONFIG_AXP_FLDO2_VOLT);
> +
> + return power_failed;
> +}
> +#endif
> +
> /* add board specific code here */
> int board_init(void)
> {
> @@ -209,6 +243,12 @@ int board_init(void)
> }
> #endif /* !CONFIG_ARM64 */
>
> +#ifdef CONFIG_AXP803_POWER
> + ret = axp803_init();
> + if (ret)
> + return ret;
> +#endif
> +
> ret = axp_gpio_init();
> if (ret)
> return ret;
> diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
> index d8c107e..6c1e4ff 100644
> --- a/drivers/power/Kconfig
> +++ b/drivers/power/Kconfig
> @@ -11,8 +11,9 @@ choice
> depends on ARCH_SUNXI
> default AXP209_POWER if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
> default AXP221_POWER if MACH_SUN6I || MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUN8I_R40
> + default AXP803_POWER if MACH_SUN50I
> default AXP818_POWER if MACH_SUN8I_A83T
> - default SUNXI_NO_PMIC if MACH_SUNXI_H3_H5 || MACH_SUN50I
> + default SUNXI_NO_PMIC if MACH_SUNXI_H3_H5
>
> config SUNXI_NO_PMIC
> bool "board without a pmic"
> @@ -43,6 +44,13 @@ config AXP221_POWER
> Select this to enable support for the axp221/axp223 pmic found on most
> A23 and A31 boards.
>
> +config AXP803_POWER
> + bool "axp803 pmic support"
> + depends on MACH_SUN50I
> + select CMD_POWEROFF
> + ---help---
> + Say y here to enable support for the axp803 pmic found on A64 boards.
> +
> config AXP809_POWER
> bool "axp809 pmic support"
> depends on MACH_SUN9I
> @@ -69,8 +77,8 @@ endchoice
>
> config AXP_DCDC1_VOLT
> int "axp pmic dcdc1 voltage"
> - depends on AXP221_POWER || AXP809_POWER || AXP818_POWER
> - default 3300 if AXP818_POWER || MACH_SUN8I_R40
> + depends on AXP221_POWER || AXP803_POWER || AXP809_POWER || AXP818_POWER
> + default 3300 if AXP818_POWER || MACH_SUN8I_R40 || MACH_SUN50I
> default 3000 if MACH_SUN6I || MACH_SUN8I || MACH_SUN9I
> ---help---
> Set the voltage (mV) to program the axp pmic dcdc1 at, set to 0 to
> @@ -80,14 +88,15 @@ config AXP_DCDC1_VOLT
> save battery. On A31 devices dcdc1 is also used for VCC-IO. On A83T
> dcdc1 is used for VCC-IO, nand, usb0, sd , etc. On A80 dcdc1 normally
> powers some of the pingroups, NAND/eMMC, SD/MMC, and USB OTG.
> + On A64 boards dcdc1 is used for Nand/eMMC/SDMMC/WIFI-IO and should be 3.3V.
These help messages are getting a bit ridiculous as well, since it's
essentially something that is board specific, and not SoC specific.
Please drop them.
Thanks!
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171212/d47a2749/attachment.sig>
More information about the U-Boot
mailing list