diff mbox series

[v4,25/27] stm32mp: allow calling optee_get_reserved_memory() from U-Boot

Message ID 20240826115940.3233167-26-sughosh.ganu@linaro.org
State Accepted
Commit 5fe9e0deabb1067eb6b1949b6eb4d895ab86c426
Headers show
Series Make LMB memory map global and persistent | expand

Commit Message

Sughosh Ganu Aug. 26, 2024, 11:59 a.m. UTC
The optee_get_reserved_memory() function returns the OP-TEE base
address and size. The function gets these values from the
FDT. Currently, this function is defined only to be called in the SPL
phase. Move this function to a place where it can be invoked from the
main U-Boot phase, where it will be used to compute the ram_top
address.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
Changes since V3:
* s/uint32_t/u32 in optee_get_reserved_memory() as suggested by
  checkpatch.


 arch/arm/mach-stm32mp/dram_init.c            | 17 +++++++++++++++++
 arch/arm/mach-stm32mp/include/mach/stm32mp.h | 11 +++++++++++
 arch/arm/mach-stm32mp/stm32mp1/spl.c         | 17 +----------------
 3 files changed, 29 insertions(+), 16 deletions(-)
 create mode 100644 arch/arm/mach-stm32mp/include/mach/stm32mp.h
diff mbox series

Patch

diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c
index e8b0a38be1..286791be2e 100644
--- a/arch/arm/mach-stm32mp/dram_init.c
+++ b/arch/arm/mach-stm32mp/dram_init.c
@@ -14,9 +14,26 @@ 
 #include <ram.h>
 #include <asm/global_data.h>
 #include <asm/system.h>
+#include <mach/stm32mp.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+int optee_get_reserved_memory(u32 *start, u32 *size)
+{
+	fdt_addr_t fdt_mem_size;
+	fdt_addr_t fdt_start;
+	ofnode node;
+
+	node = ofnode_path("/reserved-memory/optee");
+	if (!ofnode_valid(node))
+		return -ENOENT;
+
+	fdt_start = ofnode_get_addr_size(node, "reg", &fdt_mem_size);
+	*start = fdt_start;
+	*size = fdt_mem_size;
+	return (fdt_start < 0) ? fdt_start : 0;
+}
+
 int dram_init(void)
 {
 	struct ram_info ram;
diff --git a/arch/arm/mach-stm32mp/include/mach/stm32mp.h b/arch/arm/mach-stm32mp/include/mach/stm32mp.h
new file mode 100644
index 0000000000..506a42559b
--- /dev/null
+++ b/arch/arm/mach-stm32mp/include/mach/stm32mp.h
@@ -0,0 +1,11 @@ 
+/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
+/*
+ * Copyright (C) 2024, STMicroelectronics - All Rights Reserved
+ */
+
+#ifndef __MACH_STM32MP_H_
+#define __MACH_STM32MP_H_
+
+int optee_get_reserved_memory(u32 *start, u32 *size);
+
+#endif
diff --git a/arch/arm/mach-stm32mp/stm32mp1/spl.c b/arch/arm/mach-stm32mp/stm32mp1/spl.c
index 6eae5c2f55..9c4fafbf47 100644
--- a/arch/arm/mach-stm32mp/stm32mp1/spl.c
+++ b/arch/arm/mach-stm32mp/stm32mp1/spl.c
@@ -18,6 +18,7 @@ 
 #include <asm/io.h>
 #include <asm/arch/sys_proto.h>
 #include <mach/tzc.h>
+#include <mach/stm32mp.h>
 #include <linux/libfdt.h>
 
 u32 spl_boot_device(void)
@@ -110,22 +111,6 @@  uint32_t stm32mp_get_dram_size(void)
 	return ram.size;
 }
 
-static int optee_get_reserved_memory(uint32_t *start, uint32_t *size)
-{
-	fdt_addr_t fdt_mem_size;
-	fdt_addr_t fdt_start;
-	ofnode node;
-
-	node = ofnode_path("/reserved-memory/optee");
-	if (!ofnode_valid(node))
-		return -ENOENT;
-
-	fdt_start = ofnode_get_addr_size(node, "reg", &fdt_mem_size);
-	*start = fdt_start;
-	*size = fdt_mem_size;
-	return (fdt_start < 0) ? fdt_start : 0;
-}
-
 #define CFG_SHMEM_SIZE			0x200000
 #define STM32_TZC_NSID_ALL		0xffff
 #define STM32_TZC_FILTER_ALL		3