]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: gateworks: venice: get mem size from dt
authorTim Harvey <tharvey@gateworks.com>
Tue, 27 Jul 2021 22:19:37 +0000 (15:19 -0700)
committerStefano Babic <sbabic@denx.de>
Mon, 9 Aug 2021 12:46:50 +0000 (14:46 +0200)
Get mem size from dt which SPL updated per EEPROM config.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
board/gateworks/venice/imx8mm_venice.c

index 2657bd675fd1dd8f0949d147f3e5c0f23b7a1d2b..ff64d697a739bb29b3286955c0f55d9cddd455ee 100644 (file)
@@ -13,6 +13,7 @@
 #include <asm/arch/clock.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/io.h>
+#include <asm/unaligned.h>
 
 #include "gsc.h"
 
@@ -20,20 +21,19 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int board_phys_sdram_size(phys_size_t *size)
 {
-       int ddr_size = readl(M4_BOOTROM_BASE_ADDR);
-
-       if (ddr_size == 0x4) {
-               *size = 0x100000000;
-       } else if (ddr_size == 0x3) {
-               *size = 0xc0000000;
-       } else if (ddr_size == 0x2) {
-               *size = 0x80000000;
-       } else if (ddr_size == 0x1) {
-               *size = 0x40000000;
-       } else {
-               printf("Unknown DDR type!!!\n");
-               *size = 0x40000000;
-       }
+       const fdt64_t *val;
+       int offset;
+       int len;
+
+       /* get size from dt which SPL updated per EEPROM config */
+       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) * 2)
+               return -EINVAL;
+       *size = get_unaligned_be64(&val[1]);
 
        return 0;
 }