]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
common: Clean up setup_dest_addr()
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Wed, 17 Jun 2026 07:48:21 +0000 (10:48 +0300)
committerTom Rini <trini@konsulko.com>
Thu, 25 Jun 2026 00:13:24 +0000 (18:13 -0600)
Right now the function does
- Re-adjust the ram_size based on Kconfig options
- Set ram_top
- Set the relocation address

It also does not set the ram_size in case ram_top grew
from it's initial value. But ram_top and ram_size should
always be changed together.

So let's make things a bit cleaner and move the ram calculations
in their 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 e169ed9309112176eeec01d613e54fb8d61985c3..b3e633418e1bde319cd85dffac08402c20e0ff81 100644 (file)
@@ -336,15 +336,9 @@ static int setup_ram_base(void)
        return 0;
 }
 
-static int setup_dest_addr(void)
+static int setup_ram_config(void)
 {
-       int ret;
-
        debug("Monitor len: %08x\n", gd->mon_len);
-       /*
-        * Ram is setup, size stored in gd !!
-        */
-       debug("Ram size: %08llX\n", (unsigned long long)gd->ram_size);
 #if CONFIG_VAL(SYS_MEM_TOP_HIDE)
        /*
         * Subtract specified amount of memory to hide so that it won't
@@ -360,8 +354,19 @@ static int setup_dest_addr(void)
 #endif
        gd->ram_top = gd->ram_base + get_effective_memsize();
        gd->ram_top = board_get_usable_ram_top(gd->mon_len);
+
+       debug("Ram top: %08llx\n", (unsigned long long)gd->ram_top);
+       debug("Ram size: %08llx\n", (unsigned long long)gd->ram_size);
+
+       return 0;
+}
+
+static int setup_dest_addr(void)
+{
+       int ret;
+
        gd->relocaddr = gd->ram_top;
-       debug("Ram top: %08llX\n", (unsigned long long)gd->ram_top);
+       debug("Reloc addr: %08llX\n", (unsigned long long)gd->relocaddr);
 
        ret = arch_setup_dest_addr();
        if (ret)
@@ -983,6 +988,7 @@ static void initcall_run_f(void)
         *  - board info struct
         */
        INITCALL(setup_ram_base);
+       INITCALL(setup_ram_config);
        INITCALL(setup_dest_addr);
 #if CONFIG_IS_ENABLED(OF_BOARD_FIXUP) && \
     !CONFIG_IS_ENABLED(OF_INITIAL_DTB_READONLY)