#include <asm/io.h>
#include <asm/arch/cpu.h>
#include <asm/arch/clock.h>
-#include <axp221.h>
+#include <axp_pmic.h>
#include <errno.h>
#ifdef CONFIG_MACH_SUN6I
int sunxi_get_sid(unsigned int *sid)
{
#ifdef CONFIG_AXP221_POWER
- return axp221_get_sid(sid);
+ return axp_get_sid(sid);
#elif defined SUNXI_SID_BASE
int i;
#include <asm/gpio.h>
#include <asm/io.h>
#include <errno.h>
-#ifdef CONFIG_AXP152_POWER
-#include <axp152.h>
-#endif
-#ifdef CONFIG_AXP209_POWER
-#include <axp209.h>
-#endif
-#ifdef CONFIG_AXP221_POWER
-#include <axp221.h>
-#endif
#define SUNXI_USB_PMU_IRQ_ENABLE 0x800
#ifdef CONFIG_MACH_SUN8I_A33
#include <common.h>
#include <mmc.h>
-#ifdef CONFIG_AXP152_POWER
-#include <axp152.h>
-#endif
-#ifdef CONFIG_AXP209_POWER
-#include <axp209.h>
-#endif
-#ifdef CONFIG_AXP221_POWER
-#include <axp221.h>
-#endif
+#include <axp_pmic.h>
#include <asm/arch/clock.h>
#include <asm/arch/cpu.h>
#include <asm/arch/display.h>
int power_failed = 0;
unsigned long ramsize;
-#ifdef CONFIG_AXP152_POWER
- power_failed = axp152_init();
- power_failed |= axp152_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
- power_failed |= axp152_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
- power_failed |= axp152_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
- power_failed |= axp152_set_ldo2(CONFIG_AXP_ALDO2_VOLT);
+#if defined CONFIG_AXP152_POWER || defined CONFIG_AXP209_POWER || defined CONFIG_AXP221_POWER
+ power_failed = axp_init();
+
+#ifdef CONFIG_AXP221_POWER
+ power_failed |= axp_set_dcdc1(CONFIG_AXP_DCDC1_VOLT);
#endif
-#ifdef CONFIG_AXP209_POWER
- power_failed |= axp209_init();
- power_failed |= axp209_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
- power_failed |= axp209_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
- power_failed |= axp209_set_ldo2(CONFIG_AXP_ALDO2_VOLT);
- power_failed |= axp209_set_ldo3(CONFIG_AXP_ALDO3_VOLT);
- power_failed |= axp209_set_ldo4(CONFIG_AXP_ALDO4_VOLT);
+ power_failed |= axp_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
+ power_failed |= axp_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
+#ifndef CONFIG_AXP209_POWER
+ power_failed |= axp_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
#endif
#ifdef CONFIG_AXP221_POWER
- power_failed = axp221_init();
- power_failed |= axp221_set_dcdc1(CONFIG_AXP_DCDC1_VOLT);
- power_failed |= axp221_set_dcdc2(CONFIG_AXP_DCDC2_VOLT);
- power_failed |= axp221_set_dcdc3(CONFIG_AXP_DCDC3_VOLT);
- power_failed |= axp221_set_dcdc4(CONFIG_AXP_DCDC4_VOLT);
- power_failed |= axp221_set_dcdc5(CONFIG_AXP_DCDC5_VOLT);
- power_failed |= axp221_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
- power_failed |= axp221_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
- power_failed |= axp221_set_aldo3(CONFIG_AXP_ALDO3_VOLT);
- power_failed |= axp221_set_dldo1(CONFIG_AXP_DLDO1_VOLT);
- power_failed |= axp221_set_dldo2(CONFIG_AXP_DLDO2_VOLT);
- power_failed |= axp221_set_dldo3(CONFIG_AXP_DLDO3_VOLT);
- power_failed |= axp221_set_dldo4(CONFIG_AXP_DLDO4_VOLT);
- power_failed |= axp221_set_eldo(1, CONFIG_AXP_ELDO1_VOLT);
- power_failed |= axp221_set_eldo(2, CONFIG_AXP_ELDO2_VOLT);
- power_failed |= axp221_set_eldo(3, CONFIG_AXP_ELDO3_VOLT);
+ power_failed |= axp_set_dcdc5(CONFIG_AXP_DCDC5_VOLT);
#endif
+#ifdef CONFIG_AXP221_POWER
+ power_failed |= axp_set_aldo1(CONFIG_AXP_ALDO1_VOLT);
+#endif
+ power_failed |= axp_set_aldo2(CONFIG_AXP_ALDO2_VOLT);
+#ifndef 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
+ 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_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);
+#endif
+#endif
printf("DRAM:");
ramsize = sunxi_dram_init();
printf(" %lu MiB\n", ramsize >> 20);
#include <asm/arch/gpio.h>
#include <asm/arch/pmic_bus.h>
#include <asm/gpio.h>
+#include <axp_pmic.h>
#include <dm.h>
#include <dm/device-internal.h>
#include <dm/lists.h>
#include <dm/root.h>
#include <errno.h>
-#ifdef CONFIG_AXP152_POWER
-#include <axp152.h>
-#elif defined CONFIG_AXP209_POWER
-#include <axp209.h>
-#elif defined CONFIG_AXP221_POWER
-#include <axp221.h>
-#else
-#error Unknown AXP model
-#endif
-
static int axp_gpio_set_value(struct udevice *dev, unsigned pin, int val);
static u8 axp_get_gpio_ctrl_reg(unsigned pin)
*/
#include <common.h>
#include <i2c.h>
-#include <axp152.h>
+#include <axp_pmic.h>
static int axp152_write(enum axp152_reg reg, u8 val)
{
return (mvolt - min) / div;
}
-int axp152_set_dcdc2(int mvolt)
+int axp_set_dcdc2(unsigned int mvolt)
{
int rc;
u8 current, target;
return rc;
}
-int axp152_set_dcdc3(int mvolt)
+int axp_set_dcdc3(unsigned int mvolt)
{
u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 50);
return axp152_write(AXP152_DCDC3_VOLTAGE, target);
}
-int axp152_set_dcdc4(int mvolt)
+int axp_set_dcdc4(unsigned int mvolt)
{
u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 25);
return axp152_write(AXP152_DCDC4_VOLTAGE, target);
}
-int axp152_set_ldo2(int mvolt)
+int axp_set_aldo2(unsigned int mvolt)
{
u8 target = axp152_mvolt_to_target(mvolt, 700, 3500, 100);
return axp152_write(AXP152_LDO2_VOLTAGE, target);
}
-int axp152_init(void)
+int axp_init(void)
{
u8 ver;
int rc;
#include <common.h>
#include <i2c.h>
-#include <asm/arch/gpio.h>
-#include <axp209.h>
+#include <axp_pmic.h>
static int axp209_write(enum axp209_reg reg, u8 val)
{
return (mvolt - min) / div;
}
-int axp209_set_dcdc2(int mvolt)
+int axp_set_dcdc2(unsigned int mvolt)
{
int rc;
u8 cfg, current;
return rc;
}
-int axp209_set_dcdc3(int mvolt)
+int axp_set_dcdc3(unsigned int mvolt)
{
u8 cfg = axp209_mvolt_to_cfg(mvolt, 700, 3500, 25);
return axp209_write(AXP209_DCDC3_VOLTAGE, cfg);
}
-int axp209_set_ldo2(int mvolt)
+int axp_set_aldo2(unsigned int mvolt)
{
int rc;
u8 cfg, reg;
return axp209_write(AXP209_LDO24_VOLTAGE, reg);
}
-int axp209_set_ldo3(int mvolt)
+int axp_set_aldo3(unsigned int mvolt)
{
u8 cfg;
return axp209_write(AXP209_LDO3_VOLTAGE, cfg);
}
-int axp209_set_ldo4(int mvolt)
+int axp_set_aldo4(unsigned int mvolt)
{
int rc;
- static const int vindex[] = {
+ static const unsigned int vindex[] = {
1250, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2500,
2700, 2800, 3000, 3100, 3200, 3300
};
return axp209_write(AXP209_LDO24_VOLTAGE, reg);
}
-int axp209_init(void)
+int axp_init(void)
{
u8 ver;
int i, rc;
return 0;
}
-
-int axp209_poweron_by_dc(void)
-{
- u8 v;
-
- if (axp209_read(AXP209_POWER_STATUS, &v))
- return 0;
-
- return (v & AXP209_POWER_STATUS_ON_BY_DC);
-}
-
-int axp209_power_button(void)
-{
- u8 v;
-
- if (axp209_read(AXP209_IRQ_STATUS5, &v))
- return 0;
-
- axp209_write(AXP209_IRQ_STATUS5, AXP209_IRQ5_PEK_DOWN);
-
- return v & AXP209_IRQ5_PEK_DOWN;
-}
#include <common.h>
#include <errno.h>
-#include <asm/arch/gpio.h>
#include <asm/arch/pmic_bus.h>
-#include <axp221.h>
+#include <axp_pmic.h>
static u8 axp221_mvolt_to_cfg(int mvolt, int min, int max, int div)
{
return (mvolt - min) / div;
}
-int axp221_set_dcdc1(unsigned int mvolt)
+int axp_set_dcdc1(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 1600, 3400, 100);
AXP221_OUTPUT_CTRL1_DCDC1_EN);
}
-int axp221_set_dcdc2(unsigned int mvolt)
+int axp_set_dcdc2(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 600, 1540, 20);
AXP221_OUTPUT_CTRL1_DCDC2_EN);
}
-int axp221_set_dcdc3(unsigned int mvolt)
+int axp_set_dcdc3(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 600, 1860, 20);
AXP221_OUTPUT_CTRL1_DCDC3_EN);
}
-int axp221_set_dcdc4(unsigned int mvolt)
+int axp_set_dcdc4(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 600, 1540, 20);
AXP221_OUTPUT_CTRL1_DCDC4_EN);
}
-int axp221_set_dcdc5(unsigned int mvolt)
+int axp_set_dcdc5(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 1000, 2550, 50);
AXP221_OUTPUT_CTRL1_DCDC5_EN);
}
-int axp221_set_dldo1(unsigned int mvolt)
+int axp_set_dldo1(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
AXP221_OUTPUT_CTRL2_DLDO1_EN);
}
-int axp221_set_dldo2(unsigned int mvolt)
+int axp_set_dldo2(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
AXP221_OUTPUT_CTRL2_DLDO2_EN);
}
-int axp221_set_dldo3(unsigned int mvolt)
+int axp_set_dldo3(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
AXP221_OUTPUT_CTRL2_DLDO3_EN);
}
-int axp221_set_dldo4(unsigned int mvolt)
+int axp_set_dldo4(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
AXP221_OUTPUT_CTRL2_DLDO4_EN);
}
-int axp221_set_aldo1(unsigned int mvolt)
+int axp_set_aldo1(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
AXP221_OUTPUT_CTRL1_ALDO1_EN);
}
-int axp221_set_aldo2(unsigned int mvolt)
+int axp_set_aldo2(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
AXP221_OUTPUT_CTRL1_ALDO2_EN);
}
-int axp221_set_aldo3(unsigned int mvolt)
+int axp_set_aldo3(unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
AXP221_OUTPUT_CTRL3_ALDO3_EN);
}
-int axp221_set_eldo(int eldo_num, unsigned int mvolt)
+int axp_set_eldo(int eldo_num, unsigned int mvolt)
{
int ret;
u8 cfg = axp221_mvolt_to_cfg(mvolt, 700, 3300, 100);
return pmic_bus_setbits(AXP221_OUTPUT_CTRL2, bits);
}
-int axp221_init(void)
+int axp_init(void)
{
/* This cannot be 0 because it is used in SPL before BSS is ready */
static int needs_init = 1;
return 0;
}
-int axp221_get_sid(unsigned int *sid)
+int axp_get_sid(unsigned int *sid)
{
u8 *dest = (u8 *)sid;
int i, ret;
- ret = axp221_init();
+ ret = pmic_bus_init();
if (ret)
return ret;
#include <asm/global_data.h>
#include <asm/gpio.h>
#include <asm/io.h>
-#include <axp221.h>
+#include <axp_pmic.h>
#include <errno.h>
#include <fdtdec.h>
#include <fdt_support.h>
if (IS_ENABLED(CONFIG_VIDEO_LCD_PANEL_EDP_4_LANE_1620M_VIA_ANX9804)) {
/*
* The anx9804 needs 1.8V from eldo3, we do this here
- * and not via CONFIG_AXP221_ELDO3 from board_init()
+ * and not via CONFIG_AXP_ELDO3_VOLT from board_init()
* to avoid turning this on when using hdmi output.
*/
- axp221_set_eldo(3, 1800);
+ axp_set_eldo(3, 1800);
anx9804_init(CONFIG_VIDEO_LCD_I2C_BUS, 4,
ANX9804_DATA_RATE_1620M,
sunxi_display.depth);
#define AXP_GPIO_CTRL_INPUT 0x02 /* Input */
#define AXP_GPIO_STATE 0x97
#define AXP_GPIO_STATE_OFFSET 0
-
-int axp152_set_dcdc2(int mvolt);
-int axp152_set_dcdc3(int mvolt);
-int axp152_set_dcdc4(int mvolt);
-int axp152_set_ldo2(int mvolt);
-int axp152_init(void);
#define AXP_GPIO_CTRL_INPUT 0x02 /* Input */
#define AXP_GPIO_STATE 0x94
#define AXP_GPIO_STATE_OFFSET 4
-
-extern int axp209_set_dcdc2(int mvolt);
-extern int axp209_set_dcdc3(int mvolt);
-extern int axp209_set_ldo2(int mvolt);
-extern int axp209_set_ldo3(int mvolt);
-extern int axp209_set_ldo4(int mvolt);
-extern int axp209_init(void);
-extern int axp209_poweron_by_dc(void);
-extern int axp209_power_button(void);
#define AXP_GPIO_CTRL_INPUT 0x02 /* Input */
#define AXP_GPIO_STATE 0x94
#define AXP_GPIO_STATE_OFFSET 0
-
-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_set_dldo1(unsigned int mvolt);
-int axp221_set_dldo2(unsigned int mvolt);
-int axp221_set_dldo3(unsigned int mvolt);
-int axp221_set_dldo4(unsigned int mvolt);
-int axp221_set_aldo1(unsigned int mvolt);
-int axp221_set_aldo2(unsigned int mvolt);
-int axp221_set_aldo3(unsigned int mvolt);
-int axp221_set_eldo(int eldo_num, unsigned int mvolt);
-int axp221_init(void);
-int axp221_get_sid(unsigned int *sid);
--- /dev/null
+/*
+ * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
+ *
+ * X-Powers AX Power Management IC support header
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#ifndef _AXP_PMIC_H_
+
+#ifdef CONFIG_AXP152_POWER
+#include <axp152.h>
+#endif
+#ifdef CONFIG_AXP209_POWER
+#include <axp209.h>
+#endif
+#ifdef CONFIG_AXP221_POWER
+#include <axp221.h>
+#endif
+
+int axp_set_dcdc1(unsigned int mvolt);
+int axp_set_dcdc2(unsigned int mvolt);
+int axp_set_dcdc3(unsigned int mvolt);
+int axp_set_dcdc4(unsigned int mvolt);
+int axp_set_dcdc5(unsigned int mvolt);
+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_eldo(int eldo_num, unsigned int mvolt);
+int axp_init(void);
+int axp_get_sid(unsigned int *sid);
+
+#endif