aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@amd.com>2022-08-25 14:23:10 +0200
committerMichal Simek <michal.simek@amd.com>2022-09-13 11:32:48 +0200
commita32c3e9e4fb6932f80a165f56dc52e7afcffb2b2 (patch)
tree31c30941857385ddee334bd3449dcbe51860e36b
parentbe3a73c0c42c548bb892faed5b4e8e4fe7cd3295 (diff)
downloadu-boot-a32c3e9e4fb6932f80a165f56dc52e7afcffb2b2.zip
u-boot-a32c3e9e4fb6932f80a165f56dc52e7afcffb2b2.tar.gz
u-boot-a32c3e9e4fb6932f80a165f56dc52e7afcffb2b2.tar.bz2
arm64: xilinx: Move board_get_usable_ram_top() to common location
The commit ce39ee28ec31 ("zynqmp: Do not place u-boot to reserved memory location") adds functionality for ZynqMP to read reserved memory node and do not place U-Boot to reserved location. This functionality is generic across all Xilinx SOCs that's why move it to common location to be used by all Xilinx SOCs. On zynq platform this is also fixing issue where U-Boot was placed to locating which was reserved already which ends up with error message "ERROR: reserving fdt memory region failed (addr=30000000 size=10000000 flags=4)" which is shown when bdinfo is called. Tested on vck190, zcu102, zc706 and kc705 to cover all platforms. Signed-off-by: Michal Simek <michal.simek@amd.com> Link: https://lore.kernel.org/r/b0817807912f7c7af6a8e1cf9ee04e5ab5de5f6a.1661430188.git.michal.simek@amd.com
-rw-r--r--board/xilinx/common/board.c29
-rw-r--r--board/xilinx/microblaze-generic/microblaze-generic.c21
-rw-r--r--board/xilinx/versal/board.c23
-rw-r--r--board/xilinx/zynqmp/zynqmp.c29
4 files changed, 29 insertions, 73 deletions
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 9b4aded..5e36386 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -8,6 +8,8 @@
#include <efi.h>
#include <efi_loader.h>
#include <env.h>
+#include <image.h>
+#include <lmb.h>
#include <log.h>
#include <asm/global_data.h>
#include <asm/sections.h>
@@ -602,3 +604,30 @@ int embedded_dtb_select(void)
return 0;
}
#endif
+
+#if defined(CONFIG_LMB)
+ulong board_get_usable_ram_top(ulong total_size)
+{
+ phys_size_t size;
+ phys_addr_t reg;
+ struct lmb lmb;
+
+ 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);
+
+ /* found enough not-reserved memory to relocated U-Boot */
+ lmb_init(&lmb);
+ lmb_add(&lmb, gd->ram_base, gd->ram_size);
+ boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
+ size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE);
+ reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE);
+
+ if (!reg)
+ reg = gd->ram_top - size;
+
+ return reg + size;
+}
+#endif
diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
index f58ecd1..a427ac9 100644
--- a/board/xilinx/microblaze-generic/microblaze-generic.c
+++ b/board/xilinx/microblaze-generic/microblaze-generic.c
@@ -14,8 +14,6 @@
#include <config.h>
#include <env.h>
#include <init.h>
-#include <image.h>
-#include <lmb.h>
#include <log.h>
#include <asm/global_data.h>
#include <dm/lists.h>
@@ -38,25 +36,6 @@ int dram_init(void)
return 0;
};
-ulong board_get_usable_ram_top(ulong total_size)
-{
- phys_size_t size;
- phys_addr_t reg;
- struct lmb lmb;
-
- /* found enough not-reserved memory to relocated U-Boot */
- lmb_init(&lmb);
- lmb_add(&lmb, gd->ram_base, gd->ram_size);
- boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
- size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE);
- reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE);
-
- if (!reg)
- reg = gd->ram_top - size;
-
- return reg + size;
-}
-
int board_late_init(void)
{
ulong max_size;
diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
index d8f39be..f9f5457 100644
--- a/board/xilinx/versal/board.c
+++ b/board/xilinx/versal/board.c
@@ -9,7 +9,6 @@
#include <env.h>
#include <fdtdec.h>
#include <init.h>
-#include <image.h>
#include <env_internal.h>
#include <log.h>
#include <malloc.h>
@@ -270,28 +269,6 @@ int dram_init(void)
return 0;
}
-ulong board_get_usable_ram_top(ulong total_size)
-{
- phys_size_t size;
- phys_addr_t reg;
- struct lmb lmb;
-
- if (!total_size)
- return gd->ram_top;
-
- /* found enough not-reserved memory to relocated U-Boot */
- lmb_init(&lmb);
- lmb_add(&lmb, gd->ram_base, gd->ram_size);
- boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
- size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE);
- reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE);
-
- if (!reg)
- reg = gd->ram_top - size;
-
- return reg + size;
-}
-
void reset_cpu(void)
{
}
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index 21bcc26..6253776 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -12,8 +12,6 @@
#include <env.h>
#include <env_internal.h>
#include <init.h>
-#include <image.h>
-#include <lmb.h>
#include <log.h>
#include <net.h>
#include <sata.h>
@@ -256,33 +254,6 @@ int dram_init(void)
return 0;
}
-#if defined(CONFIG_LMB)
-ulong board_get_usable_ram_top(ulong total_size)
-{
- phys_size_t size;
- phys_addr_t reg;
- struct lmb lmb;
-
- 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);
-
- /* found enough not-reserved memory to relocated U-Boot */
- lmb_init(&lmb);
- lmb_add(&lmb, gd->ram_base, gd->ram_size);
- boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob);
- size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE);
- reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE);
-
- if (!reg)
- reg = gd->ram_top - size;
-
- return reg + size;
-}
-#endif
-
#else
int dram_init_banksize(void)
{