mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/4] drivers: implement of_optee_fixup helper function
Date: Tue,  7 Mar 2023 10:34:24 +0100	[thread overview]
Message-ID: <20230307093426.1551193-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230307093426.1551193-1-a.fatoum@pengutronix.de>

This function can be called by board-code after checking whether OP-TEE
was installed or not.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/include/asm/optee.h | 18 ++++++++++++++++
 drivers/Makefile             |  1 +
 drivers/tee/optee/of.c       | 42 ++++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 arch/arm/include/asm/optee.h
 create mode 100644 drivers/tee/optee/of.c

diff --git a/arch/arm/include/asm/optee.h b/arch/arm/include/asm/optee.h
new file mode 100644
index 000000000000..f8eb7b4a8b0f
--- /dev/null
+++ b/arch/arm/include/asm/optee.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ARM_OPTEE_H__
+#define __ARM_OPTEE_H__
+
+#include <linux/types.h>
+
+struct device_node;
+
+struct of_optee_fixup_data {
+	const char *method;
+	size_t shm_size;
+};
+
+int of_optee_fixup(struct device_node *root, void *fixup_data);
+
+#endif /* __ARM_OPTEE_H__ */
+
diff --git a/drivers/Makefile b/drivers/Makefile
index 10ec145be5e5..be2f736eb188 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -47,3 +47,4 @@ obj-y	+= ddr/
 obj-y	+= power/
 obj-$(CONFIG_SOUND) += sound/
 obj-y	+= virtio/
+obj-$(CONFIG_HAVE_OPTEE)	+= tee/optee/of.o
diff --git a/drivers/tee/optee/of.c b/drivers/tee/optee/of.c
new file mode 100644
index 000000000000..8295a1751c52
--- /dev/null
+++ b/drivers/tee/optee/of.c
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <of.h>
+#include <linux/ioport.h>
+#include <asm/barebox-arm.h>
+#include <asm/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;
+	int ret;
+
+	node = of_create_node(root, "/firmware/optee");
+	if (!node)
+		return -ENOMEM;
+
+	ret = of_property_write_string(node, "compatible", "linaro,optee-tz");
+	if (ret)
+		return ret;
+
+	ret = of_property_write_string(node, "method", fixup_data->method);
+	if (ret)
+		return ret;
+
+	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";
+
+	ret = of_fixup_reserved_memory(root, &res);
+	if (ret)
+		return ret;
+
+	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";
+
+	return of_fixup_reserved_memory(root, &res);
+}
-- 
2.30.2




  reply	other threads:[~2023-03-07  9:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07  9:34 [PATCH 1/4] ARM: i.MX8M: add option to install OP-TEE Ahmad Fatoum
2023-03-07  9:34 ` Ahmad Fatoum [this message]
2023-03-07  9:34 ` [PATCH 3/4] ARM: i.MX8M: fixup op-tee nodes Ahmad Fatoum
2023-03-07  9:34 ` [PATCH 4/4] drivers: drop unneeded CONFIG_CRYPTO_HW guard Ahmad Fatoum
2023-03-09 11:04 ` [PATCH 1/4] ARM: i.MX8M: add option to install OP-TEE Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230307093426.1551193-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox