diff mbox

[U-Boot,v2,4/9] arm: meson: use device tree

Message ID 1459667897-2824-5-git-send-email-b.galvani@gmail.com
State Changes Requested
Delegated to: Tom Rini
Headers show

Commit Message

Beniamino Galvani April 3, 2016, 7:18 a.m. UTC
Convert the board and config files to the use of device tree.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
---
 arch/arm/mach-meson/board.c | 25 +++++++++++++++++++++++++
 configs/odroid-c2_defconfig |  2 ++
 2 files changed, 27 insertions(+)

Comments

Tom Rini April 3, 2016, 4:09 p.m. UTC | #1
On Sun, Apr 03, 2016 at 09:18:12AM +0200, Beniamino Galvani wrote:

> Convert the board and config files to the use of device tree.
> 
> Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>

Since we're always adding this board with device tree support, this
should be folded into the first patch.  Along with importing the initial
device tree from the kernel (and just say what release / githash it's
from).  For the contents:

Reviewed-by: Tom Rini <trini@konsulko.com>
diff mbox

Patch

diff --git a/arch/arm/mach-meson/board.c b/arch/arm/mach-meson/board.c
index 346a2c2..945a5f4 100644
--- a/arch/arm/mach-meson/board.c
+++ b/arch/arm/mach-meson/board.c
@@ -5,6 +5,8 @@ 
  */
 
 #include <common.h>
+#include <libfdt.h>
+#include <linux/err.h>
 #include <asm/arch/gxbb.h>
 #include <asm/armv8/mmu.h>
 
@@ -17,9 +19,32 @@  int board_init(void)
 
 int dram_init(void)
 {
+	const fdt32_t *val;
+	int offset;
+	int len;
+
+	offset = fdt_path_offset(gd->fdt_blob, "/memory");
+	if (offset < 0)
+		return -EINVAL;
+
+	val = fdt_getprop(gd->fdt_blob, offset, "reg", &len);
+	if (len < sizeof(*val) * 4)
+		return -EINVAL;
+
+	/* Don't use fdt64_t to avoid unaligned access */
+	gd->ram_size = (uint64_t)fdt32_to_cpu(val[2]) << 32;
+	gd->ram_size |= fdt32_to_cpu(val[3]);
+
 	return 0;
 }
 
+void dram_init_banksize(void)
+{
+	/* Reserve first 16 MiB of RAM */
+	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE + (16 * 1024 * 1024);
+	gd->bd->bi_dram[0].size = gd->ram_size - (16 * 1024 * 1024);
+}
+
 void reset_cpu(ulong addr)
 {
 }
diff --git a/configs/odroid-c2_defconfig b/configs/odroid-c2_defconfig
index 8e6df12..765076a 100644
--- a/configs/odroid-c2_defconfig
+++ b/configs/odroid-c2_defconfig
@@ -2,6 +2,7 @@  CONFIG_ARM=y
 CONFIG_ARCH_MESON=y
 CONFIG_MESON_GXBB=y
 CONFIG_TARGET_ODROID_C2=y
+CONFIG_DEFAULT_DEVICE_TREE="meson-gxbb-odroidc2"
 # CONFIG_CMD_BDI is not set
 # CONFIG_CMD_IMI is not set
 # CONFIG_CMD_IMLS is not set
@@ -9,3 +10,4 @@  CONFIG_TARGET_ODROID_C2=y
 # CONFIG_CMD_FPGA is not set
 # CONFIG_CMD_SOURCE is not set
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_OF_CONTROL=y