[U-Boot] [PATCH 1/2 RFT] sunxi: power: Add AXP806 and AXP808 support
Rask Ingemann Lambertsen
rask at formelder.dk
Wed Mar 1 21:29:14 UTC 2017
On Mon, Feb 27, 2017 at 11:26:33AM +0800, Chen-Yu Tsai wrote:
> On Mon, Feb 27, 2017 at 3:01 AM, Rask Ingemann Lambertsen
> <rask at formelder.dk> wrote:
> > An X-Powers AXP806 or AXP808 PMIC is usually found on boards using the
> > Allwinner A80 ARM SoC. This patch adds support for the PMIC's regulators
> > and sets up the runtime address and master/slave mode in pmic_bus_init().
> >
> > AXP806/AXP808 support is enabled by default on all MACH_SUN9I boards.
> >
> > Because there are boards with both an AXP806 and an AXP809,
> > drivers/power/Kconfig and arch/arm/mach-sunxi/pmic_bus.c are changed to
> > make it possible to have more than one PMIC enabled at a time.
> >
> > Signed-off-by: Rask Ingemann Lambertsen <rask at formelder.dk>
> > ---
> > This patch needs to be tested on the following boards which I don't have:
> > Cubietech Cubieboard4
> > Merrii A80 Optimus
[...]
> > diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c
> > index 7c57f02..a2da40c 100644
> > --- a/arch/arm/mach-sunxi/pmic_bus.c
> > +++ b/arch/arm/mach-sunxi/pmic_bus.c
[...]
> > +#ifdef CONFIG_AXP806_POWER
> > +int pmic2_bus_read(u8 reg, u8 *data)
> > {
> > - int ret;
> > - u8 val;
> > -
> > - ret = pmic_bus_read(reg, &val);
> > - if (ret)
> > - return ret;
> > -
> > - val &= ~bits;
> > - return pmic_bus_write(reg, val);
> > + return rsb_read(AXP806_RUNTIME_ADDR, reg, data);
> > }
> > +
> > +int pmic2_bus_write(u8 reg, u8 data)
> > +{
> > + return rsb_write(AXP806_RUNTIME_ADDR, reg, data);
> > +}
> > +
> > +int pmic2_bus_setbits(u8 reg, u8 bits)
> > +PMIC_BUS_SETBITS(pmic2_bus_read, pmic2_bus_write, reg, bits)
> > +
> > +int pmic2_bus_clrbits(u8 reg, u8 bits)
> > +PMIC_BUS_CLRBITS(pmic2_bus_read, pmic2_bus_write, reg, bits)
> > +#endif
>
> Please split the pmic_bus changes into separate patches, such as the following:
>
> - Pull out PMIC_BUS_*. However please don't use macros. Just make some
> static functions. The compiler can choose to inline them.
>
> - Add AXP806 support in master mode
>
> - Add support for second PMIC to pmic_bus
>
> - Add AXP806 slave mode support.
OK. I'll take care to not leave a broken state between individual patches.
> > diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> > index 5365638..7847837 100644
> > --- a/board/sunxi/board.c
> > +++ b/board/sunxi/board.c
> > @@ -540,6 +540,26 @@ void sunxi_board_init(void)
> > power_failed |= axp_set_sw(IS_ENABLED(CONFIG_AXP_SW_ON));
> > #endif
> > #endif
> > +#ifdef CONFIG_AXP806_POWER
> > + power_failed |= axp2_init();
> > +
> > + power_failed |= axp_set_dcdca(CONFIG_AXP_DCDCA_VOLT);
> > + power_failed |= axp_set_dcdcb(CONFIG_AXP_DCDCB_VOLT);
> > + power_failed |= axp_set_dcdcc(CONFIG_AXP_DCDCC_VOLT);
> > + power_failed |= axp_set_dcdcd(CONFIG_AXP_DCDCD_VOLT);
> > + power_failed |= axp_set_dcdce(CONFIG_AXP_DCDCE_VOLT);
> > + power_failed |= axp2_set_aldo(1, CONFIG_AXP2_ALDO1_VOLT);
> > + power_failed |= axp2_set_aldo(2, CONFIG_AXP2_ALDO2_VOLT);
> > + power_failed |= axp2_set_aldo(3, CONFIG_AXP2_ALDO3_VOLT);
>
> Allwinner code calls them s_aldo.
OK.
> > + power_failed |= axp2_set_sw(IS_ENABLED(CONFIG_AXP2_SW_ON));
>
> And this s_sw.
OK.
> > diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
> > index f2c5629..aa32e5a 100644
> > --- a/drivers/power/Kconfig
> > +++ b/drivers/power/Kconfig
> > @@ -6,19 +6,18 @@ source "drivers/power/pmic/Kconfig"
> >
> > source "drivers/power/regulator/Kconfig"
> >
> > -choice
> > - prompt "Select Sunxi PMIC Variant"
> > - 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
> > - default AXP818_POWER if MACH_SUN8I_A83T
> > - default SUNXI_NO_PMIC if MACH_SUN8I_H3 || MACH_SUN50I
> > +if ARCH_SUNXI
> > +
> > +comment "Select Sunxi PMIC Variant"
>
> Would this change break existing defconfigs?
It was fine with the six or so that I checked, but that's just 0.5 % of the
defconfigs. It might actually be feasible to check them all, so I'll try
that.
> > @@ -141,6 +164,63 @@ config AXP_DCDC5_VOLT
> > On A23 / A31 / A33 / A80 / A83T boards dcdc5 is VCC-DRAM and
> > should be 1.5V, 1.35V if DDR3L is used.
> >
> > +config AXP_DCDCA_VOLT
> > + int "axp pmic dcdca voltage"
> > + depends on AXP806_POWER
> > + default 900 if MACH_SUN9I
> > + ---help---
> > + Set the voltage (mV) to program the axp pmic dcdca at, set to 0 to
> > + disable dcdca.
> > + On the Cubietech Cubieboard4 and Merrii A80 Optimus boards, dcdca
> > + powers the Cortex-A15 cores (VDD-CPUB) and should be 0.9 V.
> > + On the Sunchip CX-A99 board, dcdca powers the Cortex-A7 cores
> > + (VDD-CPUA) and should be 0.9 V at the default 1008 MHz clock frequency.
>
> Don't mention board names. Instead you could say boards with 2 PMICs with AXP806
> in slave mode do A, and boards with only one PMIC do B.
OK.
> > +
> > +config AXP_DCDCB_VOLT
> > + int "axp pmic dcdcb voltage"
> > + depends on AXP806_POWER
> > + default 0 if MACH_SUN9I && AXP806_POWER && AXP809_POWER
> > + default 1500 if MACH_SUN9I && AXP806_POWER && !AXP809_POWER
>
> !AXP806_POWER_SLAVE_MODE would be better
OK.
> > +config AXP2_ALDO2_VOLT
> > + int "axp pmic (2) aldo2 voltage"
> > + depends on AXP806_POWER
> > + default 0 if MACH_SUN9I && AXP806_POWER && AXP809_POWER
> > + default 1800 if MACH_SUN9I && AXP806_POWER && !AXP809_POWER
> > + ---help---
> > + Set the voltage (mV) to program the axp pmic aldo2 at, set to 0 to
> > + disable aldo2.
> > + On the Cubietech Cubieboard4 and Merrii A80 Optimus boards, aldo2 is
> > + unused and can be left off.
> > + On the Sunchip CX-A99, aldo2 powers pin groups G and M, Wifi I/O and
> > + codec I/O and should be 1.8 V.
>
> These pins are not used by U-boot are they? Leave them off.
Pin group M controls the LEDs and to my surprice, CONFIG_CMD_LED can't
simply be enabled in the config menu (and thus not in defconfig either)
because it hasn't been converted to Kconfig yet. I'll leave also2 off.
It would be nice to get some sort of feedback without the serial console,
for high on my TODO list is to get USB ports working, so you can attach a
keyboard. An LED could then light up to tell you when extlinux.conf has
been loaded and is ready to accept a selection from the menu, for example.
> > diff --git a/drivers/power/axp806.c b/drivers/power/axp806.c
> > new file mode 100644
> > index 0000000..be6a9a8
> > --- /dev/null
> > +++ b/drivers/power/axp806.c
[...]
> > +/* The AXP809 driver also implements do_poweroff() and we can't have both. */
> > +#ifndef CONFIG_AXP809_POWER
>
> Use CONFIG_AXP806_POWER_SLAVE_MODE. System power would be controlled by the
> master PMIC.
OK.
--
Rask Ingemann Lambertsen
More information about the U-Boot
mailing list