sunxi: Add axp209 pmic support
[platform/kernel/u-boot.git] / board / sunxi / board.c
index 543b809..8375711 100644 (file)
@@ -12,6 +12,9 @@
  */
 
 #include <common.h>
+#ifdef CONFIG_AXP209_POWER
+#include <axp209.h>
+#endif
 #include <asm/arch/clock.h>
 #include <asm/arch/dram.h>
 #include <asm/arch/gpio.h>
@@ -116,12 +119,31 @@ void i2c_init_board(void)
 #ifdef CONFIG_SPL_BUILD
 void sunxi_board_init(void)
 {
+       int power_failed = 0;
        unsigned long ramsize;
 
+#ifdef CONFIG_AXP209_POWER
+       power_failed |= axp209_init();
+       power_failed |= axp209_set_dcdc2(1400);
+       power_failed |= axp209_set_dcdc3(1250);
+       power_failed |= axp209_set_ldo2(3000);
+       power_failed |= axp209_set_ldo3(2800);
+       power_failed |= axp209_set_ldo4(2800);
+#endif
+
        printf("DRAM:");
        ramsize = sunxi_dram_init();
        printf(" %lu MiB\n", ramsize >> 20);
        if (!ramsize)
                hang();
+
+       /*
+        * Only clock up the CPU to full speed if we are reasonably
+        * assured it's being powered with suitable core voltage
+        */
+       if (!power_failed)
+               clock_set_pll1(CONFIG_CLK_FULL_SPEED);
+       else
+               printf("Failed to set core voltage! Can't set CPU frequency\n");
 }
 #endif