obj-y  += clock.o
 obj-y  += pinmux.o
 obj-$(CONFIG_SUN4I)    += clock_sun4i.o
+obj-$(CONFIG_SUN5I)    += clock_sun4i.o
 obj-$(CONFIG_SUN7I)    += clock_sun4i.o
 
 ifndef CONFIG_SPL_BUILD
 
 ifdef CONFIG_SPL_BUILD
 obj-$(CONFIG_SUN4I)    += dram.o
+obj-$(CONFIG_SUN5I)    += dram.o
 obj-$(CONFIG_SUN7I)    += dram.o
 ifdef CONFIG_SPL_FEL
 obj-y  += start.o
 
 
 int gpio_init(void)
 {
+#if CONFIG_CONS_INDEX == 1 && (defined(CONFIG_SUN4I) || defined(CONFIG_SUN7I))
        sunxi_gpio_set_cfgpin(SUNXI_GPB(22), SUN4I_GPB22_UART0_TX);
        sunxi_gpio_set_cfgpin(SUNXI_GPB(23), SUN4I_GPB23_UART0_RX);
        sunxi_gpio_set_pull(SUNXI_GPB(23), 1);
+#elif CONFIG_CONS_INDEX == 1 && defined(CONFIG_SUN5I)
+       sunxi_gpio_set_cfgpin(SUNXI_GPB(19), SUN5I_GPB19_UART0_TX);
+       sunxi_gpio_set_cfgpin(SUNXI_GPB(20), SUN5I_GPB20_UART0_RX);
+       sunxi_gpio_set_pull(SUNXI_GPB(20), 1);
+#elif CONFIG_CONS_INDEX == 2 && defined(CONFIG_SUN5I)
+       sunxi_gpio_set_cfgpin(SUNXI_GPG(3), SUN5I_GPG3_UART1_TX);
+       sunxi_gpio_set_cfgpin(SUNXI_GPG(4), SUN5I_GPG4_UART1_RX);
+       sunxi_gpio_set_pull(SUNXI_GPG(4), 1);
+#else
+#error Unsupported console port number. Please fix pin mux settings in board.c
+#endif
 
        return 0;
 }
 
 {
 #ifdef CONFIG_SUN4I
        puts("CPU:   Allwinner A10 (SUN4I)\n");
+#elif defined CONFIG_SUN5I
+       u32 val = readl(SUNXI_SID_BASE + 0x08);
+       switch ((val >> 12) & 0xf) {
+       case 0: puts("CPU:   Allwinner A12 (SUN5I)\n"); break;
+       case 3: puts("CPU:   Allwinner A13 (SUN5I)\n"); break;
+       case 7: puts("CPU:   Allwinner A10s (SUN5I)\n"); break;
+       default: puts("CPU:   Allwinner A1X (SUN5I)\n");
+       }
 #elif defined CONFIG_SUN7I
        puts("CPU:   Allwinner A20 (SUN7I)\n");
 #else
 
 }
 
 static u32 hpcr_value[32] = {
+#ifdef CONFIG_SUN5I
+       0, 0, 0, 0,
+       0, 0, 0, 0,
+       0, 0, 0, 0,
+       0, 0, 0, 0,
+       0x1031, 0x1031, 0x0735, 0x1035,
+       0x1035, 0x0731, 0x1031, 0,
+       0x0301, 0x0301, 0x0301, 0x0301,
+       0x0301, 0x0301, 0x0301, 0
+#endif
 #ifdef CONFIG_SUN4I
        0x0301, 0x0301, 0x0301, 0x0301,
        0x0301, 0x0301, 0, 0,
 #if defined(CONFIG_SUN5I) || defined(CONFIG_SUN7I)
        /* setup MBUS clock */
        reg_val = CCM_MBUS_CTRL_GATE |
+#ifdef CONFIG_SUN7I
                  CCM_MBUS_CTRL_CLK_SRC(CCM_MBUS_CTRL_CLK_SRC_PLL6) |
                  CCM_MBUS_CTRL_N(CCM_MBUS_CTRL_N_X(2)) |
                  CCM_MBUS_CTRL_M(CCM_MBUS_CTRL_M_X(2));
+#else /* defined(CONFIG_SUN5I) */
+                 CCM_MBUS_CTRL_CLK_SRC(CCM_MBUS_CTRL_CLK_SRC_PLL5) |
+                 CCM_MBUS_CTRL_N(CCM_MBUS_CTRL_N_X(1)) |
+                 CCM_MBUS_CTRL_M(CCM_MBUS_CTRL_M_X(2));
+#endif
        writel(reg_val, &ccm->mbus_clk_cfg);
 #endif
 
        /* setup DRAM relative clock */
        mctl_setup_dram_clock(para->clock);
 
+#ifdef CONFIG_SUN5I
+       /* Disable any pad power save control */
+       writel(0, &dram->ppwrsctl);
+#endif
+
        /* reset external DRAM */
 #ifndef CONFIG_SUN7I
        mctl_ddr3_reset();
 
 #
 obj-y  += board.o
 obj-$(CONFIG_SUNXI_GMAC)       += gmac.o
+obj-$(CONFIG_A13_OLINUXINOM)   += dram_a13_oli_micro.o
 obj-$(CONFIG_CUBIEBOARD)       += dram_cubieboard.o
 obj-$(CONFIG_CUBIETRUCK)       += dram_cubietruck.o
+obj-$(CONFIG_R7DONGLE)         += dram_r7dongle.o
 
--- /dev/null
+/* this file is generated, don't edit it yourself */
+
+#include <common.h>
+#include <asm/arch/dram.h>
+
+static struct dram_para dram_para = {
+       .clock = 408,
+       .type = 3,
+       .rank_num = 1,
+       .density = 2048,
+       .io_width = 16,
+       .bus_width = 16,
+       .cas = 9,
+       .zq = 123,
+       .odt_en = 0,
+       .size = 256,
+       .tpr0 = 0x42d899b7,
+       .tpr1 = 0xa090,
+       .tpr2 = 0x22a00,
+       .tpr3 = 0,
+       .tpr4 = 0,
+       .tpr5 = 0,
+       .emr1 = 0,
+       .emr2 = 0x10,
+       .emr3 = 0,
+
+};
+
+unsigned long sunxi_dram_init(void)
+{
+       return dramc_init(&dram_para);
+}
 
--- /dev/null
+/* this file is generated, don't edit it yourself */
+
+#include <common.h>
+#include <asm/arch/dram.h>
+
+static struct dram_para dram_para = {
+       .clock = 384,
+       .type = 3,
+       .rank_num = 1,
+       .density = 2048,
+       .io_width = 8,
+       .bus_width = 32,
+       .cas = 9,
+       .zq = 123,
+       .odt_en = 0,
+       .size = 1024,
+       .tpr0 = 0x42d899b7,
+       .tpr1 = 0xa090,
+       .tpr2 = 0x22a00,
+       .tpr3 = 0,
+       .tpr4 = 0,
+       .tpr5 = 0,
+       .emr1 = 0x04,
+       .emr2 = 0x10,
+       .emr3 = 0,
+};
+
+unsigned long sunxi_dram_init(void)
+{
+       return dramc_init(&dram_para);
+}
 
 Active  arm         armv7          s5pc1xx     samsung         goni                s5p_goni                              -                                                                                                                                 Robert Baldyga <r.baldyga@samsung.com>
 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               A13-OLinuXinoM                        sun5i:A13_OLINUXINOM,SPL,CONS_INDEX=2                                                                                             Hans de Goede <hdegoede@redhat.com>
 Active  arm         armv7          sunxi       -               sunxi               Cubieboard                            sun4i:CUBIEBOARD,SPL                                                                                                              Hans de Goede <hdegoede@redhat.com>
 Active  arm         armv7          sunxi       -               sunxi               Cubietruck                            sun7i:CUBIETRUCK,SPL,SUNXI_GMAC,RGMII                                                                                             -
 Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                        sun7i:CUBIETRUCK,SPL_FEL,SUNXI_GMAC,RGMII                                                                                         -
+Active  arm         armv7          sunxi       -               sunxi               r7-tv-dongle                          sun5i:R7DONGLE,SPL                                                                                                                Hans de Goede <hdegoede@redhat.com>
 Active  arm         armv7          u8500       st-ericsson     snowball            snowball                              -                                                                                                                                 Mathieu Poirier <mathieu.poirier@linaro.org>
 Active  arm         armv7          u8500       st-ericsson     u8500               u8500_href                            -                                                                                                                                 -
 Active  arm         armv7          vf610       freescale       vf610twr            vf610twr                              vf610twr:IMX_CONFIG=board/freescale/vf610twr/imximage.cfg                                                                         Alison Wang <b18965@freescale.com>
 
--- /dev/null
+/*
+ * (C) Copyright 2012-2013 Henrik Nordstrom <henrik@henriknordstrom.net>
+ *
+ * Configuration settings for the Allwinner A13 (sun5i) CPU
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * High Level Configuration Options
+ */
+#define CONFIG_SUN5I           /* sun5i SoC generation */
+
+#define CONFIG_SYS_PROMPT              "sun5i# "
+
+/*
+ * Include common sunxi configuration where most the settings are
+ */
+#include <configs/sunxi-common.h>
+
+#endif /* __CONFIG_H */
 
 #undef CONFIG_CMD_NET
 #undef CONFIG_CMD_NFS
 
+#ifndef CONFIG_CONS_INDEX
 #define CONFIG_CONS_INDEX              1       /* UART0 */
+#endif
 
 #ifdef CONFIG_SUNXI_GMAC
 #define CONFIG_DESIGNWARE_ETH          /* GMAC can use designware driver */