On newer Allwinner SoCs with the BROM start at 0x0 and the DRAM space at
<0x40000000 0xc0000000>, some parts of DRAM will be inaccessible when
4GiB module is used.

Restrict the ram_size written to global_data in SPL.

Signed-off-by: Icenowy Zheng <icen...@aosc.io>
---
 board/sunxi/board.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 5828d47294..a6620f260a 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -541,6 +541,7 @@ int board_mmc_init(bd_t *bis)
 void sunxi_board_init(void)
 {
        int power_failed = 0;
+       unsigned long long dram_real_size;
 
 #ifdef CONFIG_SY8106A_POWER
        power_failed = sy8106a_set_vout1(CONFIG_SY8106A_VOUT1_VOLT);
@@ -601,8 +602,16 @@ void sunxi_board_init(void)
 #endif
 #endif
        printf("DRAM:");
-       gd->ram_size = (phys_size_t)sunxi_dram_init();
-       printf(" %d MiB\n", (int)(gd->ram_size >> 20));
+       dram_real_size = sunxi_dram_init();
+       printf(" %d MiB", (int)(dram_real_size >> 20));
+       if (dram_real_size > CONFIG_SUNXI_DRAM_MAX_SIZE) {
+               gd->ram_size = CONFIG_SUNXI_DRAM_MAX_SIZE;
+               printf(", %d MiB usable\n", (int)(gd->ram_size >> 20));
+       } else {
+               gd->ram_size = (phys_size_t) dram_real_size;
+               printf("\n");
+       }
+
        if (!gd->ram_size)
                hang();
 
-- 
2.15.1

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to