[PATCH v2 14/18] drivers: tee: optee: add support for dynamic optee memory base address
Marco Felsch
m.felsch at pengutronix.de
Tue Jan 16 09:07:34 PST 2024
Make use of the platform provided optee memory base address. Fallback to
the current behaviour if the platform doesn't provide the optee memory
base.
Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
---
drivers/tee/optee/of_fixup.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/tee/optee/of_fixup.c b/drivers/tee/optee/of_fixup.c
index 8295a1751c52..cdf650592e90 100644
--- a/drivers/tee/optee/of_fixup.c
+++ b/drivers/tee/optee/of_fixup.c
@@ -4,12 +4,14 @@
#include <linux/ioport.h>
#include <asm/barebox-arm.h>
#include <asm/optee.h>
+#include <tee/optee.h>
int of_optee_fixup(struct device_node *root, void *_data)
{
struct of_optee_fixup_data *fixup_data = _data;
struct resource res = {};
struct device_node *node;
+ u64 optee_membase;
int ret;
node = of_create_node(root, "/firmware/optee");
@@ -24,8 +26,13 @@ int of_optee_fixup(struct device_node *root, void *_data)
if (ret)
return ret;
- res.start = arm_mem_endmem_get() - OPTEE_SIZE;
- res.end = arm_mem_endmem_get() - fixup_data->shm_size -1;
+ if (!optee_get_membase(&optee_membase)) {
+ res.start = optee_membase;
+ res.end = optee_membase + OPTEE_SIZE - fixup_data->shm_size - 1;
+ } else {
+ res.start = arm_mem_endmem_get() - OPTEE_SIZE;
+ res.end = arm_mem_endmem_get() - fixup_data->shm_size - 1;
+ }
res.flags = IORESOURCE_BUSY;
res.name = "optee_core";
@@ -33,8 +40,13 @@ int of_optee_fixup(struct device_node *root, void *_data)
if (ret)
return ret;
- res.start = arm_mem_endmem_get() - fixup_data->shm_size;
- res.end = arm_mem_endmem_get() - 1;
+ if (!optee_get_membase(&optee_membase)) {
+ res.start = optee_membase + OPTEE_SIZE - fixup_data->shm_size;
+ res.end = optee_membase + OPTEE_SIZE - 1;
+ } else {
+ res.start = arm_mem_endmem_get() - fixup_data->shm_size;
+ res.end = arm_mem_endmem_get() - 1;
+ }
res.flags &= ~IORESOURCE_BUSY;
res.name = "optee_shm";
--
2.39.2
More information about the barebox
mailing list