diff --git a/board/sunxi/board_helper.c b/board/sunxi/board_helper.c index 58645297..5b789065 100644 --- a/board/sunxi/board_helper.c +++ b/board/sunxi/board_helper.c @@ -104,6 +104,34 @@ int __attribute__((weak)) update_bmu_info_to_kernel() int disp_lcd_param_update_to_kernel(void); int sunxi_drm_kernel_para_flush(void); +int sunxi_fixup_external_fdt_dram(void *dtb_base) +{ + phys_size_t dram_size; + + if (!dtb_base) { + pr_err("%s: dtb_base is NULL\n", __func__); + return -1; + } + + dram_size = (phys_size_t)uboot_spare_head.boot_data.dram_scan_size * + 1024 * 1024; + if (!dram_size) { + pr_err("%s: invalid dram_scan_size %u MiB\n", __func__, + uboot_spare_head.boot_data.dram_scan_size); + return -1; + } + + gd->bd->bi_dram[0].size = dram_size; + if (arch_fixup_fdt(dtb_base) < 0) { + pr_err("%s: arch_fixup_fdt failed\n", __func__); + return -1; + } + + tick_printf("sunxi: fixed external FDT DRAM size to %u MiB\n", + uboot_spare_head.boot_data.dram_scan_size); + return 0; +} + #ifdef CONFIG_SUNXI_BOOT_PARAM int update_fdt_dram_para_from_bootpara(void *dtb_base) { diff --git a/board/sunxi/board_helper.h b/board/sunxi/board_helper.h index 4bd5e05d..2679d8c3 100644 --- a/board/sunxi/board_helper.h +++ b/board/sunxi/board_helper.h @@ -12,6 +12,7 @@ void sunxi_dump(void *addr, unsigned int size); int sunxi_update_fdt_para_for_kernel(void); +int sunxi_fixup_external_fdt_dram(void *dtb_base); int sunxi_update_bootcmd(void); int sunxi_update_partinfo(void); int sunxi_update_rotpk_info(void); diff --git a/common/bootm.c b/common/bootm.c index 188d16df..10be2f03 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -30,6 +30,8 @@ #include #include +int sunxi_fixup_external_fdt_dram(void *dtb_base); + #ifndef CONFIG_SYS_BOOTM_LEN /* use 8MByte as default max gunzip size * want to change the CONFIG_SYS_BOOTM_LEN @@ -363,6 +365,8 @@ int bootm_find_images(int flag, int argc, char * const argv[]) */ images.ft_addr = (char *)simple_strtoul(argv[2], NULL, 16); images.ft_len = fdt_totalsize(images.ft_addr); + sunxi_fixup_external_fdt_dram(images.ft_addr); + images.ft_len = fdt_totalsize(images.ft_addr); printf("sunxi: using explicit FDT @ %p size 0x%lx\n", images.ft_addr, images.ft_len); }