@@ -12,6 +12,9 @@
*/
#include <common.h>
+#ifdef CONFIG_AXP152_POWER
+#include <axp152.h>
+#endif
#ifdef CONFIG_AXP209_POWER
#include <axp209.h>
#endif
@@ -71,6 +74,13 @@ void sunxi_board_init(void)
if (!ramsize)
hang();
+#ifdef CONFIG_AXP152_POWER
+ power_failed = axp152_init();
+ power_failed |= axp152_set_dcdc2(1400);
+ power_failed |= axp152_set_dcdc3(1500);
+ power_failed |= axp152_set_dcdc4(1250);
+ power_failed |= axp152_set_ldo2(3000);
+#endif
#ifdef CONFIG_AXP209_POWER
power_failed |= axp209_init();
power_failed |= axp209_set_dcdc2(1400);
@@ -354,7 +354,7 @@ Active arm armv7 s5pc1xx samsung goni
Active arm armv7 s5pc1xx samsung smdkc100 smdkc100 - Minkyu Kang <mk7.kang@samsung.com>
Active arm armv7 socfpga altera socfpga socfpga_cyclone5 - -
Active arm armv7 sunxi - sunxi A10-OLinuXino-Lime sun4i:A10_OLINUXINO_L,AXP209_POWER,SPL -
-Active arm armv7 sunxi - sunxi A10s-OLinuXino-M sun5i:A10S_OLINUXINO_M,SPL -
+Active arm armv7 sunxi - sunxi A10s-OLinuXino-M sun5i:A10S_OLINUXINO_M,AXP152_POWER,SPL -
Active arm armv7 sunxi - sunxi Cubietruck sun7i:CUBIETRUCK,AXP209_POWER,SPL -
Active arm armv7 sunxi - sunxi Cubietruck_FEL sun7i:CUBIETRUCK,AXP209_POWER,SPL_FEL -
Active arm armv7 u8500 st-ericsson snowball snowball - Mathieu Poirier <mathieu.poirier@linaro.org>
@@ -5,6 +5,7 @@
# SPDX-License-Identifier: GPL-2.0+
#
+obj-$(CONFIG_AXP152_POWER) += axp152.o
obj-$(CONFIG_AXP209_POWER) += axp209.o
obj-$(CONFIG_EXYNOS_TMU) += exynos-tmu.o
obj-$(CONFIG_FTPMU010_POWER) += ftpmu010.o
new file mode 100644
@@ -0,0 +1,122 @@
+/*
+ * (C) Copyright 2012
+ * Henrik Nordstrom <henrik@henriknordstrom.net>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#include <common.h>
+#include <i2c.h>
+#include <axp152.h>
+
+enum axp152_reg {
+ AXP152_CHIP_VERSION = 0x3,
+ AXP152_DCDC2_VOLTAGE = 0x23,
+ AXP152_DCDC3_VOLTAGE = 0x27,
+ AXP152_DCDC4_VOLTAGE = 0x2B,
+ AXP152_LDO2_VOLTAGE = 0x2A,
+ AXP152_SHUTDOWN = 0x32,
+};
+
+int axp152_write(enum axp152_reg reg, u8 val)
+{
+ return i2c_write(0x30, reg, 1, &val, 1);
+}
+
+int axp152_read(enum axp152_reg reg, u8 *val)
+{
+ return i2c_read(0x30, reg, 1, val, 1);
+}
+
+int axp152_set_dcdc2(int mvolt)
+{
+ int target = (mvolt - 700) / 25;
+ int rc;
+ u8 current;
+
+ if (target < 0)
+ target = 0;
+ if (target > (1<<6)-1)
+ target = (1<<6)-1;
+ /* Do we really need to be this gentle? It has built-in voltage slope */
+ while ((rc = axp152_read(AXP152_DCDC2_VOLTAGE, ¤t)) == 0 &&
+ current != target) {
+ if (current < target)
+ current++;
+ else
+ current--;
+ rc = axp152_write(AXP152_DCDC2_VOLTAGE, current);
+ if (rc)
+ break;
+ }
+ return rc;
+}
+
+int axp152_set_dcdc3(int mvolt)
+{
+ int target = (mvolt - 700) / 50;
+ u8 reg;
+ int rc;
+
+ if (target < 0)
+ target = 0;
+ if (target > (1<<6)-1)
+ target = (1<<6)-1;
+ rc = axp152_write(AXP152_DCDC3_VOLTAGE, target);
+ rc |= axp152_read(AXP152_DCDC3_VOLTAGE, ®);
+ return rc;
+}
+
+int axp152_set_dcdc4(int mvolt)
+{
+ int target = (mvolt - 700) / 25;
+ u8 reg;
+ int rc;
+
+ if (target < 0)
+ target = 0;
+ if (target > (1<<7)-1)
+ target = (1<<7)-1;
+ rc = axp152_write(AXP152_DCDC4_VOLTAGE, target);
+ rc |= axp152_read(AXP152_DCDC4_VOLTAGE, ®);
+ return rc;
+}
+
+int axp152_set_ldo2(int mvolt)
+{
+ int target = (mvolt - 700) / 100;
+ int rc;
+ u8 reg;
+
+ if (target < 0)
+ target = 0;
+ if (target > 31)
+ target = 31;
+ rc = axp152_write(AXP152_LDO2_VOLTAGE, target);
+ rc |= axp152_read(AXP152_LDO2_VOLTAGE, ®);
+ return rc;
+}
+
+void axp152_poweroff(void)
+{
+ u8 val;
+
+ if (axp152_read(AXP152_SHUTDOWN, &val) != 0)
+ return;
+ val |= 1 << 7;
+ if (axp152_write(AXP152_SHUTDOWN, val) != 0)
+ return;
+ udelay(10000); /* wait for power to drain */
+}
+
+int axp152_init(void)
+{
+ u8 ver;
+ int rc;
+
+ rc = axp152_read(AXP152_CHIP_VERSION, &ver);
+ if (rc)
+ return rc;
+ if (ver != 0x05)
+ return -1;
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,11 @@
+/*
+ * (C) Copyright 2012 Henrik Nordstrom <henrik@henriknordstrom.net>
+ *
+ * SPDX-License-Identifier: GPL-2.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);
+void axp152_poweroff(void);
+int axp152_init(void);