From c28bc439b4bb75fdc90027d8f1e1649636f2c4e0 Mon Sep 17 00:00:00 2001
From: Przemyslaw Marczak
Date: Mon, 28 Jul 2014 20:18:54 +0200
Subject: [PATCH] samsung:board: init dram info based on memory node in fdt
Change-Id: I3677f0ab0b4aed264de8af37e87b081f66a36b97
Signed-off-by: Przemyslaw Marczak
---
board/samsung/common/board.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
index 94bcc8c..5346608 100644
--- a/board/samsung/common/board.c
+++ b/board/samsung/common/board.c
@@ -96,18 +96,45 @@ int board_init(void)
int dram_init(void)
{
int i;
+#ifdef CONFIG_FDTDEC_MEMORY
+ int dram_banks;
+
+ uint64_t mem_size[CONFIG_NR_DRAM_BANKS];
+
+ dram_banks = fdtdec_decode_memory(gd->fdt_blob, NULL, mem_size,
+ CONFIG_NR_DRAM_BANKS);
+
+ for (i = 0; i < dram_banks; i++)
+ gd->ram_size += (uint32_t)mem_size[i];
+
+#else
u32 addr;
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
addr = CONFIG_SYS_SDRAM_BASE + (i * SDRAM_BANK_SIZE);
gd->ram_size += get_ram_size((long *)addr, SDRAM_BANK_SIZE);
}
+#endif
return 0;
}
void dram_init_banksize(void)
{
int i;
+#ifdef CONFIG_FDTDEC_MEMORY
+ int dram_banks;
+
+ uint64_t mem_addr[CONFIG_NR_DRAM_BANKS];
+ uint64_t mem_size[CONFIG_NR_DRAM_BANKS];
+
+ dram_banks = fdtdec_decode_memory(gd->fdt_blob, mem_addr, mem_size,
+ CONFIG_NR_DRAM_BANKS);
+
+ for (i = 0; i < dram_banks; i++) {
+ gd->bd->bi_dram[i].start = (uint32_t)mem_addr[i];
+ gd->bd->bi_dram[i].size = (uint32_t)mem_size[i];
+ }
+#else
u32 addr, size;
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
@@ -117,6 +144,7 @@ void dram_init_banksize(void)
gd->bd->bi_dram[i].start = addr;
gd->bd->bi_dram[i].size = size;
}
+#endif
}
static int board_uart_init(void)
--
2.7.4