[PATCH] arm: mach-k3: am62p: Fixup TF-A/OP-TEE reserved-memory node in FDT

The address we load TFA and OPTEE is configurable by the CONFIG_K3_{ATF,OPTEE)_LOAD_ADDR, but the DT node reservations remain static which can cause some confusion about where exactly these firmware are exactly. Fix this by updating the reserved-memory{} nodes when the loaded address does not match the address in DT.
Reported-by: Andrew Davis afd@ti.com Signed-off-by: Bryan Brattlof bb@ti.com --- Hello everyone,
This is a little fixup to avoid any confusion once we're in the kernel. Because TF-A can be configured in U-Boot to be anywhere we want, we need up update the reserved-memory{} node with this change.
Thanks for reviewing ~Bryan --- arch/arm/mach-k3/Makefile | 1 + arch/arm/mach-k3/am62p5_fdt.c | 16 ++++++++++++++++ arch/arm/mach-k3/am62px/Kconfig | 1 + 3 files changed, 18 insertions(+)
diff --git a/arch/arm/mach-k3/Makefile b/arch/arm/mach-k3/Makefile index 1bd523329a4f8..4e9d0925f13f5 100644 --- a/arch/arm/mach-k3/Makefile +++ b/arch/arm/mach-k3/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_SOC_K3_J721S2) += j721s2_fdt.o obj-$(CONFIG_SOC_K3_AM625) += am625_fdt.o obj-$(CONFIG_SOC_K3_AM62A7) += am62a7_fdt.o obj-$(CONFIG_SOC_K3_J784S4) += j784s4_fdt.o +obj-$(CONFIG_SOC_K3_AM62P5) += am62p5_fdt.o endif ifeq ($(CONFIG_SPL_BUILD),y) obj-$(CONFIG_SOC_K3_AM654) += am654_init.o diff --git a/arch/arm/mach-k3/am62p5_fdt.c b/arch/arm/mach-k3/am62p5_fdt.c new file mode 100644 index 0000000000000..d67f012a5dcc4 --- /dev/null +++ b/arch/arm/mach-k3/am62p5_fdt.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/ + */ + +#include <asm/hardware.h> +#include "common_fdt.h" +#include <fdt_support.h> + +int ft_system_setup(void *blob, struct bd_info *bd) +{ + fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000); + fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000); + + return 0; +} diff --git a/arch/arm/mach-k3/am62px/Kconfig b/arch/arm/mach-k3/am62px/Kconfig index 38a9e6811b119..76ae86b66222f 100644 --- a/arch/arm/mach-k3/am62px/Kconfig +++ b/arch/arm/mach-k3/am62px/Kconfig @@ -13,6 +13,7 @@ config TARGET_AM62P5_A53_EVM bool "TI K3 based AM62P5 EVM running on A53" select ARM64 select BINMAN + select OF_SYSTEM_SETUP
config TARGET_AM62P5_R5_EVM bool "TI K3 based AM62P5 EVM running on R5"
--- base-commit: a7f0154c412859323396111dd0c09dbafbc153cb change-id: 20240520-am62p-fdt-fix-7c51e1a1cd54
Best regards,

On 5/23/24 11:43 AM, Bryan Brattlof wrote:
The address we load TFA and OPTEE is configurable by the CONFIG_K3_{ATF,OPTEE)_LOAD_ADDR, but the DT node reservations remain static which can cause some confusion about where exactly these firmware are exactly. Fix this by updating the reserved-memory{} nodes when the loaded address does not match the address in DT.
Reported-by: Andrew Davis afd@ti.com Signed-off-by: Bryan Brattlof bb@ti.com
Hello everyone,
This is a little fixup to avoid any confusion once we're in the kernel. Because TF-A can be configured in U-Boot to be anywhere we want, we need up update the reserved-memory{} node with this change.
Thanks for reviewing ~Bryan
arch/arm/mach-k3/Makefile | 1 + arch/arm/mach-k3/am62p5_fdt.c | 16 ++++++++++++++++
You'll want to rebase this on -next, these _fdt.c files all got moved into directories for each SoC.
Andrew
arch/arm/mach-k3/am62px/Kconfig | 1 + 3 files changed, 18 insertions(+)
diff --git a/arch/arm/mach-k3/Makefile b/arch/arm/mach-k3/Makefile index 1bd523329a4f8..4e9d0925f13f5 100644 --- a/arch/arm/mach-k3/Makefile +++ b/arch/arm/mach-k3/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_SOC_K3_J721S2) += j721s2_fdt.o obj-$(CONFIG_SOC_K3_AM625) += am625_fdt.o obj-$(CONFIG_SOC_K3_AM62A7) += am62a7_fdt.o obj-$(CONFIG_SOC_K3_J784S4) += j784s4_fdt.o +obj-$(CONFIG_SOC_K3_AM62P5) += am62p5_fdt.o endif ifeq ($(CONFIG_SPL_BUILD),y) obj-$(CONFIG_SOC_K3_AM654) += am654_init.o diff --git a/arch/arm/mach-k3/am62p5_fdt.c b/arch/arm/mach-k3/am62p5_fdt.c new file mode 100644 index 0000000000000..d67f012a5dcc4 --- /dev/null +++ b/arch/arm/mach-k3/am62p5_fdt.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/*
- Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
- */
+#include <asm/hardware.h> +#include "common_fdt.h" +#include <fdt_support.h>
+int ft_system_setup(void *blob, struct bd_info *bd) +{
- fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
- fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
- return 0;
+} diff --git a/arch/arm/mach-k3/am62px/Kconfig b/arch/arm/mach-k3/am62px/Kconfig index 38a9e6811b119..76ae86b66222f 100644 --- a/arch/arm/mach-k3/am62px/Kconfig +++ b/arch/arm/mach-k3/am62px/Kconfig @@ -13,6 +13,7 @@ config TARGET_AM62P5_A53_EVM bool "TI K3 based AM62P5 EVM running on A53" select ARM64 select BINMAN
select OF_SYSTEM_SETUP
config TARGET_AM62P5_R5_EVM bool "TI K3 based AM62P5 EVM running on R5"
base-commit: a7f0154c412859323396111dd0c09dbafbc153cb change-id: 20240520-am62p-fdt-fix-7c51e1a1cd54
Best regards,

On May 23, 2024 thus sayeth Andrew Davis:
On 5/23/24 11:43 AM, Bryan Brattlof wrote:
The address we load TFA and OPTEE is configurable by the CONFIG_K3_{ATF,OPTEE)_LOAD_ADDR, but the DT node reservations remain static which can cause some confusion about where exactly these firmware are exactly. Fix this by updating the reserved-memory{} nodes when the loaded address does not match the address in DT.
Reported-by: Andrew Davis afd@ti.com Signed-off-by: Bryan Brattlof bb@ti.com
Hello everyone,
This is a little fixup to avoid any confusion once we're in the kernel. Because TF-A can be configured in U-Boot to be anywhere we want, we need up update the reserved-memory{} node with this change.
Thanks for reviewing ~Bryan
arch/arm/mach-k3/Makefile | 1 + arch/arm/mach-k3/am62p5_fdt.c | 16 ++++++++++++++++
You'll want to rebase this on -next, these _fdt.c files all got moved into directories for each SoC.
Ah! my bad, you're right this belongs in -next. v2 incoming momentarily
Thanks Andrew ~Bryan

On May 23, 2024 thus sayeth Bryan Brattlof:
On May 23, 2024 thus sayeth Andrew Davis:
On 5/23/24 11:43 AM, Bryan Brattlof wrote:
The address we load TFA and OPTEE is configurable by the CONFIG_K3_{ATF,OPTEE)_LOAD_ADDR, but the DT node reservations remain static which can cause some confusion about where exactly these firmware are exactly. Fix this by updating the reserved-memory{} nodes when the loaded address does not match the address in DT.
Reported-by: Andrew Davis afd@ti.com Signed-off-by: Bryan Brattlof bb@ti.com
Hello everyone,
This is a little fixup to avoid any confusion once we're in the kernel. Because TF-A can be configured in U-Boot to be anywhere we want, we need up update the reserved-memory{} node with this change.
Thanks for reviewing ~Bryan
arch/arm/mach-k3/Makefile | 1 + arch/arm/mach-k3/am62p5_fdt.c | 16 ++++++++++++++++
You'll want to rebase this on -next, these _fdt.c files all got moved into directories for each SoC.
Ah! my bad, you're right this belongs in -next. v2 incoming momentarily
Wait no on second thought, this needs to be in v2024.07 also. I'll leave this for Tom for -master and maybe send out another version for -next to preempt the merge conflict for v2024.10?
~Bryan

On Thu, May 23, 2024 at 12:22:56PM -0500, Bryan Brattlof wrote:
On May 23, 2024 thus sayeth Bryan Brattlof:
On May 23, 2024 thus sayeth Andrew Davis:
On 5/23/24 11:43 AM, Bryan Brattlof wrote:
The address we load TFA and OPTEE is configurable by the CONFIG_K3_{ATF,OPTEE)_LOAD_ADDR, but the DT node reservations remain static which can cause some confusion about where exactly these firmware are exactly. Fix this by updating the reserved-memory{} nodes when the loaded address does not match the address in DT.
Reported-by: Andrew Davis afd@ti.com Signed-off-by: Bryan Brattlof bb@ti.com
Hello everyone,
This is a little fixup to avoid any confusion once we're in the kernel. Because TF-A can be configured in U-Boot to be anywhere we want, we need up update the reserved-memory{} node with this change.
Thanks for reviewing ~Bryan
arch/arm/mach-k3/Makefile | 1 + arch/arm/mach-k3/am62p5_fdt.c | 16 ++++++++++++++++
You'll want to rebase this on -next, these _fdt.c files all got moved into directories for each SoC.
Ah! my bad, you're right this belongs in -next. v2 incoming momentarily
Wait no on second thought, this needs to be in v2024.07 also. I'll leave this for Tom for -master and maybe send out another version for -next to preempt the merge conflict for v2024.10?
If this needs to go in master then git should hopefully do the right thing when I merge the next rc tag in.

On Thu, May 23, 2024 at 11:43:20AM -0500, Bryan Brattlof wrote:
The address we load TFA and OPTEE is configurable by the CONFIG_K3_{ATF,OPTEE)_LOAD_ADDR, but the DT node reservations remain static which can cause some confusion about where exactly these firmware are exactly. Fix this by updating the reserved-memory{} nodes when the loaded address does not match the address in DT.
Reported-by: Andrew Davis afd@ti.com Signed-off-by: Bryan Brattlof bb@ti.com
Applied to u-boot/master, thanks!
participants (3)
-
Andrew Davis
-
Bryan Brattlof
-
Tom Rini