From: Oliver Schinagl <[email protected]> The A31 uses the AXP221 pmic for various voltages.
Signed-off-by: Oliver Schinagl <[email protected]> Signed-off-by: Hans de Goede <[email protected]> --- boards.cfg | 2 +- drivers/power/Makefile | 1 + drivers/power/axp221.c | 56 ++++++++++++++++++++++++++++++++++++++++++ include/axp221.h | 25 +++++++++++++++++++ include/configs/sunxi-common.h | 4 +-- 5 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 drivers/power/axp221.c create mode 100644 include/axp221.h diff --git a/boards.cfg b/boards.cfg index 2beb4bb..b0335de 100644 --- a/boards.cfg +++ b/boards.cfg @@ -386,7 +386,7 @@ Active arm armv7 sunxi - sunxi Active arm armv7 sunxi - sunxi Coby_MID9742 sun4i:COBY_MID9742,SPL - Active arm armv7 sunxi - sunxi Iteaduino_Plus_A10 sun4i:ITEADA10,SPL,SUNXI_EMAC,STATUSLED=244,STATUSLED1=245 - Active arm armv7 sunxi - sunxi Iteaduino_Plus_A20 sun7i:ITEADA20,SPL,SUNXI_EMAC,STATUSLED=244,STATUSLED1=245 - -Active arm armv7 sunxi - sunxi Colombus sun6i:COLOMBUS - +Active arm armv7 sunxi - sunxi Colombus sun6i:COLOMBUS,AXP221_POWER - Active arm armv7 sunxi - sunxi Cubieboard sun4i:CUBIEBOARD,SPL,SUNXI_EMAC,STATUSLED=244,STATUSLED1=245 - Active arm armv7 sunxi - sunxi Cubieboard2 sun7i:CUBIEBOARD2,SPL,SUNXI_GMAC,STATUSLED=244,STATUSLED1=245,FAST_MBUS - Active arm armv7 sunxi - sunxi Cubieboard2_FEL sun7i:CUBIEBOARD2,SPL_FEL,SUNXI_GMAC,STATUSLED=244,STATUSLED1=245,FAST_MBUS - diff --git a/drivers/power/Makefile b/drivers/power/Makefile index dc64e4d..04bd996 100644 --- a/drivers/power/Makefile +++ b/drivers/power/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_AXP152_POWER) += axp152.o obj-$(CONFIG_AXP209_POWER) += axp209.o +obj-$(CONFIG_AXP221_POWER) += axp221.o obj-$(CONFIG_EXYNOS_TMU) += exynos-tmu.o obj-$(CONFIG_FTPMU010_POWER) += ftpmu010.o obj-$(CONFIG_TPS6586X_POWER) += tps6586x.o diff --git a/drivers/power/axp221.c b/drivers/power/axp221.c new file mode 100644 index 0000000..a17b8a8 --- /dev/null +++ b/drivers/power/axp221.c @@ -0,0 +1,56 @@ +/* + * (C) Copyright 2013 Oliver Schinagl <[email protected]> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <errno.h> +#include <asm/arch/p2wi.h> +#include <axp221.h> + +int axp221_set_dcdc1(unsigned int mvolt) +{ + return p2wi_write(AXP221_DCDC1_CTRL, (mvolt - 1600) / 100); +} + +int axp221_set_dcdc2(unsigned int mvolt) +{ + return p2wi_write(AXP221_DCDC2_CTRL, (mvolt - 600) / 20); +} + +int axp221_set_dcdc3(unsigned int mvolt) +{ + return p2wi_write(AXP221_DCDC3_CTRL, (mvolt - 600) / 20); +} + +int axp221_set_dcdc4(unsigned int mvolt) +{ + return p2wi_write(AXP221_DCDC4_CTRL, (mvolt - 600) / 20); +} + +int axp221_set_dcdc5(unsigned int mvolt) +{ + return p2wi_write(AXP221_DCDC5_CTRL, (mvolt - 600) / 20); +} + +int axp221_init(void) +{ + u8 axp_chip_id; + int ret; + + p2wi_init(); + ret = p2wi_set_pmu_address(AXP221_CHIP_ADDR, AXP221_CTRL_ADDR, + AXP221_INIT_DATA); + if (ret) + return ret; + + ret = p2wi_read(AXP221_CHIP_ID, &axp_chip_id); + if (ret) + return ret; + + if (!(axp_chip_id == 0x6 || axp_chip_id == 0x7 || axp_chip_id == 0x17)) + return -ENODEV; + + return 0; +} diff --git a/include/axp221.h b/include/axp221.h new file mode 100644 index 0000000..497134c --- /dev/null +++ b/include/axp221.h @@ -0,0 +1,25 @@ +/* + * (C) Copyright 2013 Oliver Schinagl <[email protected]> + * + * X-Powers AXP221 Power Management IC driver + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#define AXP221_CHIP_ADDR 0x68 +#define AXP221_CTRL_ADDR 0x3e +#define AXP221_INIT_DATA 0x3e + +#define AXP221_CHIP_ID 0x03 +#define AXP221_DCDC1_CTRL 0x21 +#define AXP221_DCDC2_CTRL 0x22 +#define AXP221_DCDC3_CTRL 0x23 +#define AXP221_DCDC4_CTRL 0x24 +#define AXP221_DCDC5_CTRL 0x25 + +int axp221_set_dcdc1(unsigned int mvolt); +int axp221_set_dcdc2(unsigned int mvolt); +int axp221_set_dcdc3(unsigned int mvolt); +int axp221_set_dcdc4(unsigned int mvolt); +int axp221_set_dcdc5(unsigned int mvolt); +int axp221_init(void); diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 1206520..6a37314 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -346,10 +346,10 @@ #define CONFIG_CMD_GPIO /* PMU */ -#if !defined CONFIG_AXP152_POWER && !defined CONFIG_NO_AXP +#if !defined CONFIG_AXP152_POWER && !defined CONFIG_AXP221_POWER && !defined CONFIG_NO_AXP #define CONFIG_AXP209_POWER #endif -#if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER +#if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || defined CONFIG_AXP221_POWER #define CONFIG_SPL_POWER_SUPPORT #endif -- 1.9.0 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
