On September  5, 2025 thus sayeth Anshul Dalal:
> K3 platforms have reserved memory regions for TFA and OPTEE which should
> be unmapped for U-Boot.
> 
> Therefore this patch adds the necessary fdt fixups to properly set the
> load address for TFA/OPTEE and unmaps both by mmu_unmap_reserved_mem.
> 
> Signed-off-by: Anshul Dalal <[email protected]>
> ---
>  arch/arm/mach-k3/common.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
> index 9c2fe92cf25..71fc7d31abe 100644
> --- a/arch/arm/mach-k3/common.c
> +++ b/arch/arm/mach-k3/common.c
> @@ -31,6 +31,7 @@
>  #include <dm/uclass-internal.h>
>  #include <dm/device-internal.h>
>  #include <asm/armv8/mmu.h>
> +#include <mach/k3-common-fdt.h>
>  #include <mach/k3-ddr.h>
>  
>  #define PROC_BOOT_CTRL_FLAG_R5_CORE_HALT     0x00000001
> @@ -263,6 +264,7 @@ void board_prep_linux(struct bootm_headers *images)
>  
>  void enable_caches(void)
>  {
> +     void *fdt = (void *)gd->fdt_blob;
>       int ret;
>  
>       ret = mem_map_fix_dram_banks(K3_MEM_MAP_FIRST_BANK_IDX, K3_MEM_MAP_LEN,
> @@ -273,6 +275,30 @@ void enable_caches(void)
>  
>       mmu_setup();
>  
> +     if (CONFIG_K3_ATF_LOAD_ADDR >= CFG_SYS_SDRAM_BASE) {
> +             ret = fdt_fixup_reserved(fdt, "tfa", CONFIG_K3_ATF_LOAD_ADDR,
> +                                      0x80000);
> +             if (ret)
> +                     debug("%s: Failed to perform tfa fixups (%s)\n",
> +                           __func__, fdt_strerror(ret));
> +             ret = mmu_unmap_reserved_mem("tfa");
> +             if (ret)
> +                     debug("%s: Failed to unmap tfa rsvd mem (%s)\n",
> +                           __func__, fdt_strerror(ret));
> +     }
> +
> +     if (CONFIG_K3_OPTEE_LOAD_ADDR >= CFG_SYS_SDRAM_BASE) {
> +             ret = fdt_fixup_reserved(fdt, "optee",
> +                                      CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);

We will most likely need to move these sizes into Kconfig. The fact they 
have remained the same is purely an artifact from us not changing
anything nor developing much on OP-TEE for most of K3's lifetime.

For future chips BL1 and OP-TEE will likely need to grow.

~Bryan

Reply via email to