[U-Boot] [PATCH v2 4/6] sunxi: restrict the ram_size to the accessible range in SPL

Maxime Ripard
2018-03-23T09:43:09Z

On Fri, Mar 23, 2018 at 04:18:55PM +0800, Icenowy Zheng wrote:
> 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 <icenowy@aosc.io>
> ---
> No changes in v2.
>
> 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 1c5e1f380a..73dd41437d 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -518,6 +518,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);
> @@ -578,8 +579,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");
> + }
> +

This really look like something that should be addressed generically
and not in one board.

Maxime

--
Maxime Ripard, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering