stm32mp: allow calling optee_get_reserved_memory() from U-Boot

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>
diff --git a/arch/arm/mach-stm32mp/dram_init.c b/arch/arm/mach-stm32mp/dram_init.c
index e8b0a38..286791b 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;