]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
xilinx: use get_mem_top() to compute ram_top
authorSughosh Ganu <sughosh.ganu@linaro.org>
Fri, 25 Oct 2024 17:27:24 +0000 (22:57 +0530)
committerMichal Simek <michal.simek@amd.com>
Fri, 15 Nov 2024 13:32:47 +0000 (14:32 +0100)
Use the get_mem_top function to compute the value of ram_top. This was
earlier done through LMB API's, which are no longer available till
after relocation. Use get_mem_top() instead to compute the ram_top
value.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Michal Simek <michal.simek@amd.com>
Tested-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/20241025172724.195093-3-sughosh.ganu@linaro.org
Signed-off-by: Michal Simek <michal.simek@amd.com>
board/xilinx/common/board.c

index 38dd80533fa8741ecf6ceb1cef84f53edcb8fb67..e14ed2cff00a94be56167252d909ae99a5a09119 100644 (file)
@@ -19,6 +19,7 @@
 #include <i2c.h>
 #include <linux/sizes.h>
 #include <malloc.h>
+#include <memtop.h>
 #include <mtd_node.h>
 #include "board.h"
 #include <dm.h>
@@ -676,3 +677,27 @@ int ft_board_setup(void *blob, struct bd_info *bd)
        return 0;
 }
 #endif
+
+#ifndef MMU_SECTION_SIZE
+#define MMU_SECTION_SIZE        (1 * 1024 * 1024)
+#endif
+
+phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
+{
+       phys_size_t size;
+       phys_addr_t reg;
+
+       if (!total_size)
+               return gd->ram_top;
+
+       if (!IS_ALIGNED((ulong)gd->fdt_blob, 0x8))
+               panic("Not 64bit aligned DT location: %p\n", gd->fdt_blob);
+
+       size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE);
+       reg = get_mem_top(gd->ram_base, gd->ram_size, size,
+                         (void *)gd->fdt_blob);
+       if (!reg)
+               reg = gd->ram_top - size;
+
+       return reg + size;
+}