From: Ley Foon Tan Date: Tue, 12 Mar 2019 16:31:10 +0800 Subject: [U-Boot] [PATCH 06/10] board: altera: Stratix10: Add ft_board_setup() In-Reply-To: <1552379474-12867-1-git-send-email-ley.foon.tan@intel.com> References: <1552379474-12867-1-git-send-email-ley.foon.tan@intel.com> Message-ID: <1552379474-12867-7-git-send-email-ley.foon.tan@intel.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Add ft_board_setup() function to setup memory banks before boot to Linux. Signed-off-by: Ley Foon Tan --- board/altera/stratix10-socdk/socfpga.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/board/altera/stratix10-socdk/socfpga.c b/board/altera/stratix10-socdk/socfpga.c index 99c10d313c..ca6e0e9085 100644 --- a/board/altera/stratix10-socdk/socfpga.c +++ b/board/altera/stratix10-socdk/socfpga.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -17,3 +18,27 @@ ulong board_get_usable_ram_top(ulong total_size) return sdram_calculate_size(); } #endif + +#ifdef CONFIG_OF_BOARD_SETUP +int ft_board_setup(void *blob, bd_t *bd) +{ + int ret = 0; +#ifdef CONFIG_OF_LIBFDT + int bank; + int actual_bank = 0; + u64 start[CONFIG_NR_DRAM_BANKS]; + u64 size[CONFIG_NR_DRAM_BANKS]; + + for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { + if (bd->bi_dram[bank].size) { + start[actual_bank] = bd->bi_dram[bank].start; + size[actual_bank++] = bd->bi_dram[bank].size; + } + } + + ret = fdt_fixup_memory_banks(blob, start, size, actual_bank); +#endif /* CONFIG_OF_LIBFDT */ + + return ret; +} +#endif -- 2.19.0