Commit 0a8143dd authored by Michal Simek's avatar Michal Simek
Browse files

feat(plat/zynqmp): extend DT description by TF-A



In case of TF-A running out of DDR there is a need to reserved
memory to let other SW know that none can't use this memory. HW
wise this region can be (and should be) also protected by
protection unit XMPU. This is the first step to add reserved
memory location to DT.

DT address corresponds with default address in U-Boot and also
default address in Xilinx BSPs.

Code is valid only when TF-A runs out of DDR. When it runs out
of OCM there is no need to reseve anything because OCM is hidden
to OS.

Change-Id: I01f230ced67207a159128cc11d11d36dd4590cab
Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
parent 7737fdf0
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include <plat_private.h> #include <plat_private.h>
#include <zynqmp_def.h> #include <zynqmp_def.h>
#include <common/fdt_fixup.h>
#include <common/fdt_wrappers.h>
#include <libfdt.h>
static entry_point_info_t bl32_image_ep_info; static entry_point_info_t bl32_image_ep_info;
static entry_point_info_t bl33_image_ep_info; static entry_point_info_t bl33_image_ep_info;
...@@ -178,8 +182,55 @@ static uint64_t rdo_el3_interrupt_handler(uint32_t id, uint32_t flags, ...@@ -178,8 +182,55 @@ static uint64_t rdo_el3_interrupt_handler(uint32_t id, uint32_t flags,
} }
#endif #endif
#if (BL31_LIMIT < PLAT_DDR_LOWMEM_MAX)
static void prepare_dtb(void)
{
void *dtb = (void *)XILINX_OF_BOARD_DTB_ADDR;
int ret;
/* Return if no device tree is detected */
if (fdt_check_header(dtb) != 0) {
NOTICE("Can't read DT at 0x%p\n", dtb);
return;
}
ret = fdt_open_into(dtb, dtb, XILINX_OF_BOARD_DTB_MAX_SIZE);
if (ret < 0) {
ERROR("Invalid Device Tree at %p: error %d\n", dtb, ret);
return;
}
if (dt_add_psci_node(dtb)) {
ERROR("Failed to add PSCI Device Tree node\n");
return;
}
if (dt_add_psci_cpu_enable_methods(dtb)) {
ERROR("Failed to add PSCI cpu enable methods in Device Tree\n");
return;
}
/* Reserve memory used by Trusted Firmware. */
if (fdt_add_reserved_memory(dtb, "tf-a", BL31_BASE, BL31_LIMIT - BL31_BASE)) {
WARN("Failed to add reserved memory nodes to DT.\n");
}
ret = fdt_pack(dtb);
if (ret < 0) {
ERROR("Failed to pack Device Tree at %p: error %d\n", dtb, ret);
}
clean_dcache_range((uintptr_t)dtb, fdt_blob_size(dtb));
INFO("Changed device tree to advertise PSCI and reserved memories.\n");
}
#endif
void bl31_platform_setup(void) void bl31_platform_setup(void)
{ {
#if (BL31_LIMIT < PLAT_DDR_LOWMEM_MAX)
prepare_dtb();
#endif
/* Initialize the gic cpu and distributor interfaces */ /* Initialize the gic cpu and distributor interfaces */
plat_arm_gic_driver_init(); plat_arm_gic_driver_init();
plat_arm_gic_init(); plat_arm_gic_init();
...@@ -211,6 +262,10 @@ void bl31_plat_arch_setup(void) ...@@ -211,6 +262,10 @@ void bl31_plat_arch_setup(void)
const mmap_region_t bl_regions[] = { const mmap_region_t bl_regions[] = {
#if (BL31_LIMIT < PLAT_DDR_LOWMEM_MAX)
MAP_REGION_FLAT(XILINX_OF_BOARD_DTB_ADDR, XILINX_OF_BOARD_DTB_MAX_SIZE,
MT_MEMORY | MT_RW | MT_NS),
#endif
MAP_REGION_FLAT(BL31_BASE, BL31_END - BL31_BASE, MAP_REGION_FLAT(BL31_BASE, BL31_END - BL31_BASE,
MT_MEMORY | MT_RW | MT_SECURE), MT_MEMORY | MT_RW | MT_SECURE),
MAP_REGION_FLAT(BL_CODE_BASE, BL_CODE_END - BL_CODE_BASE, MAP_REGION_FLAT(BL_CODE_BASE, BL_CODE_END - BL_CODE_BASE,
......
...@@ -83,9 +83,17 @@ ...@@ -83,9 +83,17 @@
/******************************************************************************* /*******************************************************************************
* Platform specific page table and MMU setup constants * Platform specific page table and MMU setup constants
******************************************************************************/ ******************************************************************************/
#define XILINX_OF_BOARD_DTB_ADDR 0x100000
#define XILINX_OF_BOARD_DTB_MAX_SIZE 0x200000
#define PLAT_DDR_LOWMEM_MAX 0x80000000
#define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 32) #define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 32)
#define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 32) #define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 32)
#if (BL31_LIMIT < PLAT_DDR_LOWMEM_MAX)
#define MAX_MMAP_REGIONS 8
#else
#define MAX_MMAP_REGIONS 7 #define MAX_MMAP_REGIONS 7
#endif
#define MAX_XLAT_TABLES 5 #define MAX_XLAT_TABLES 5
#define CACHE_WRITEBACK_SHIFT 6 #define CACHE_WRITEBACK_SHIFT 6
......
...@@ -63,6 +63,7 @@ PLAT_INCLUDES := -Iinclude/plat/arm/common/ \ ...@@ -63,6 +63,7 @@ PLAT_INCLUDES := -Iinclude/plat/arm/common/ \
-Iplat/xilinx/zynqmp/include/ \ -Iplat/xilinx/zynqmp/include/ \
-Iplat/xilinx/zynqmp/pm_service/ \ -Iplat/xilinx/zynqmp/pm_service/ \
include lib/libfdt/libfdt.mk
# Include GICv2 driver files # Include GICv2 driver files
include drivers/arm/gic/v2/gicv2.mk include drivers/arm/gic/v2/gicv2.mk
...@@ -94,6 +95,8 @@ BL31_SOURCES += drivers/arm/cci/cci.c \ ...@@ -94,6 +95,8 @@ BL31_SOURCES += drivers/arm/cci/cci.c \
lib/cpus/aarch64/aem_generic.S \ lib/cpus/aarch64/aem_generic.S \
lib/cpus/aarch64/cortex_a53.S \ lib/cpus/aarch64/cortex_a53.S \
plat/common/plat_psci_common.c \ plat/common/plat_psci_common.c \
common/fdt_fixup.c \
${LIBFDT_SRCS} \
plat/xilinx/common/ipi_mailbox_service/ipi_mailbox_svc.c \ plat/xilinx/common/ipi_mailbox_service/ipi_mailbox_svc.c \
plat/xilinx/common/pm_service/pm_ipi.c \ plat/xilinx/common/pm_service/pm_ipi.c \
plat/xilinx/common/plat_startup.c \ plat/xilinx/common/plat_startup.c \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment