From 3340eab26d89176dd0bf543e6d2590665c577423 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 29 Jul 2014 18:29:27 +0200
Subject: [PATCH] sun7i: Add bananapi board

The Banana Pi is an A20 based development board using Raspberry Pi compatible
IO headers. It comes with 1 GB RAM, 1 Gb ethernet, 2x USB host, sata, hdmi
and stereo audio out + various expansion headers:

http://www.lemaker.org/

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
---
 board/sunxi/MAINTAINERS     |  1 +
 board/sunxi/Makefile        |  1 +
 board/sunxi/dram_bananapi.c | 31 +++++++++++++++++++++++++++++++
 configs/Bananapi_defconfig  |  4 ++++
 4 files changed, 37 insertions(+)
 create mode 100644 board/sunxi/dram_bananapi.c
 create mode 100644 configs/Bananapi_defconfig

diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS
index 64fdee89a6..b0b1804c50 100644
--- a/board/sunxi/MAINTAINERS
+++ b/board/sunxi/MAINTAINERS
@@ -18,6 +18,7 @@ F:	configs/Auxtek-T004_defconfig
 F:	configs/r7-tv-dongle_defconfig
 F:	include/configs/sun7i.h
 F:	configs/A20-OLinuXino_MICRO_defconfig
+F:	configs/Bananapi_defconfig
 F:	configs/i12-tvbox_defconfig
 F:	configs/Linksprite_pcDuino3_defconfig
 F:	configs/qt840a_defconfig
diff --git a/board/sunxi/Makefile b/board/sunxi/Makefile
index 3fc7513852..cf001e71fa 100644
--- a/board/sunxi/Makefile
+++ b/board/sunxi/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_A20_OLINUXINO_M)	+= dram_sun7i_384_1024_iow16.o
 # This is not a typo, uses the same mem settings as the a10s-olinuxino-m
 obj-$(CONFIG_AUXTEK_T004)	+= dram_a10s_olinuxino_m.o
 obj-$(CONFIG_BA10_TV_BOX)	+= dram_sun4i_384_1024_iow8.o
+obj-$(CONFIG_BANANAPI)		+= dram_bananapi.o
 obj-$(CONFIG_CUBIEBOARD)	+= dram_cubieboard.o
 obj-$(CONFIG_CUBIEBOARD2)	+= dram_cubieboard2.o
 obj-$(CONFIG_CUBIETRUCK)	+= dram_cubietruck.o
diff --git a/board/sunxi/dram_bananapi.c b/board/sunxi/dram_bananapi.c
new file mode 100644
index 0000000000..0ed7943043
--- /dev/null
+++ b/board/sunxi/dram_bananapi.c
@@ -0,0 +1,31 @@
+/* this file is generated, don't edit it yourself */
+
+#include <common.h>
+#include <asm/arch/dram.h>
+
+static struct dram_para dram_para = {
+	.clock = 432,
+	.type = 3,
+	.rank_num = 1,
+	.density = 4096,
+	.io_width = 16,
+	.bus_width = 32,
+	.cas = 9,
+	.zq = 0x7f,
+	.odt_en = 0,
+	.size = 1024,
+	.tpr0 = 0x42d899b7,
+	.tpr1 = 0xa090,
+	.tpr2 = 0x22a00,
+	.tpr3 = 0x0,
+	.tpr4 = 0x1,
+	.tpr5 = 0x0,
+	.emr1 = 0x4,
+	.emr2 = 0x10,
+	.emr3 = 0x0,
+};
+
+unsigned long sunxi_dram_init(void)
+{
+	return dramc_init(&dram_para);
+}
diff --git a/configs/Bananapi_defconfig b/configs/Bananapi_defconfig
new file mode 100644
index 0000000000..be3d815568
--- /dev/null
+++ b/configs/Bananapi_defconfig
@@ -0,0 +1,4 @@
+CONFIG_SPL=y
+CONFIG_SYS_EXTRA_OPTIONS="BANANAPI,SPL,AXP209_POWER,SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23),AHCI,USB_EHCI"
++S:CONFIG_ARM=y
++S:CONFIG_TARGET_SUN7I=y
-- 
2.39.5