summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSughosh Ganu <[email protected]>2024-10-25 22:57:24 +0530
committerMichal Simek <[email protected]>2024-11-15 14:32:47 +0100
commit62fbddf7c8e7e0226273392fe1f81b8358ebe3c9 (patch)
treeb1523b2aab3a4b232e0a280d1930ba0a90250ceb
parentfeb423a3a3d34ed7903d6eb833ddd0593a410474 (diff)
xilinx: use get_mem_top() to compute ram_top
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 <[email protected]> Reviewed-by: Michal Simek <[email protected]> Tested-by: Michal Simek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michal Simek <[email protected]>
-rw-r--r--board/xilinx/common/board.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 38dd80533fa..e14ed2cff00 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -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;
+}