]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
common: move ram_base calculation to independent INITCALL()
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Wed, 17 Jun 2026 07:48:20 +0000 (10:48 +0300)
committerTom Rini <trini@konsulko.com>
Thu, 25 Jun 2026 00:13:24 +0000 (18:13 -0600)
Currently, ram_base is calculated within setup_dest_addr().
However, upcoming patches that enable U-Boot relocation to the highest
DRAM bank require ram_base to be initialized earlier.

The default dram_init_banksize() definition relies on ram_base
to calculate the start of the first bank. But following patches
will move that function to execute immediately before setup_dest_addr().

So let's split the ram_base initialization in its own INITCALL.

Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Anshul Dalal <anshuld@ti.com>
Tested-by: Michal Simek <michal.simek@amd.com> # Versal Gen 2 Vek385
Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
common/board_f.c

index a3abec352716ddc0b3a3c44bbbc24a804aa4efac..e169ed9309112176eeec01d613e54fb8d61985c3 100644 (file)
@@ -328,6 +328,14 @@ __weak int arch_setup_dest_addr(void)
        return 0;
 }
 
+static int setup_ram_base(void)
+{
+#ifdef CFG_SYS_SDRAM_BASE
+       gd->ram_base = CFG_SYS_SDRAM_BASE;
+#endif
+       return 0;
+}
+
 static int setup_dest_addr(void)
 {
        int ret;
@@ -349,9 +357,6 @@ static int setup_dest_addr(void)
         * get fixed.
         */
        gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
-#endif
-#ifdef CFG_SYS_SDRAM_BASE
-       gd->ram_base = CFG_SYS_SDRAM_BASE;
 #endif
        gd->ram_top = gd->ram_base + get_effective_memsize();
        gd->ram_top = board_get_usable_ram_top(gd->mon_len);
@@ -977,6 +982,7 @@ static void initcall_run_f(void)
         *  - monitor code
         *  - board info struct
         */
+       INITCALL(setup_ram_base);
        INITCALL(setup_dest_addr);
 #if CONFIG_IS_ENABLED(OF_BOARD_FIXUP) && \
     !CONFIG_IS_ENABLED(OF_INITIAL_DTB_READONLY)