From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 8/9] ARM: Rockchip: make rk3568's atf_load_bl31 reusable
Date: Mon, 8 Nov 2021 08:52:08 +0100 [thread overview]
Message-ID: <20211108075209.2366770-8-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20211108075209.2366770-1-a.fatoum@pengutronix.de>
Future support for rk3399 can use the same function, so move the bulk
into a macro. We can't use a function here, because the function itself
uses macros like IS_ENABLED() and get_builtin_firmware(), which we
would have to call outside of the common code, reducing amount of code
we share.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/mach-rockchip/atf.c | 53 ++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 24 deletions(-)
diff --git a/arch/arm/mach-rockchip/atf.c b/arch/arm/mach-rockchip/atf.c
index 3c4c9d1c8ae6..de22784489b5 100644
--- a/arch/arm/mach-rockchip/atf.c
+++ b/arch/arm/mach-rockchip/atf.c
@@ -33,30 +33,35 @@ static unsigned long load_elf64_image_phdr(const void *elf)
return ehdr->e_entry;
}
-void rk3568_atf_load_bl31(void *fdt)
-{
- const void *bl31_elf, *optee;
- unsigned long bl31;
- size_t bl31_elf_size, optee_size;
- uintptr_t optee_load_address = 0;
-
- get_builtin_firmware(rk3568_bl31_bin, &bl31_elf, &bl31_elf_size);
-
- bl31 = load_elf64_image_phdr(bl31_elf);
-
- if (IS_ENABLED(CONFIG_ARCH_RK3568_OPTEE)) {
- optee_load_address = RK3568_OPTEE_LOAD_ADDRESS;
+#define rockchip_atf_load_bl31(SOC, atf_bin, tee_bin, fdt) do { \
+ const void *bl31_elf, *optee; \
+ unsigned long bl31; \
+ size_t bl31_elf_size, optee_size; \
+ uintptr_t optee_load_address = 0; \
+ \
+ get_builtin_firmware(atf_bin, &bl31_elf, &bl31_elf_size); \
+ \
+ bl31 = load_elf64_image_phdr(bl31_elf); \
+ \
+ if (IS_ENABLED(CONFIG_ARCH_##SOC##_OPTEE)) { \
+ optee_load_address = SOC##_OPTEE_LOAD_ADDRESS; \
+ \
+ get_builtin_firmware(tee_bin, &optee, &optee_size); \
+ \
+ memcpy((void *)optee_load_address, optee, optee_size); \
+ } \
+ \
+ /* Setup an initial stack for EL2 */ \
+ asm volatile("msr sp_el2, %0" : : \
+ "r" (SOC##_BAREBOX_LOAD_ADDRESS - 16) : \
+ "cc"); \
+ \
+ bl31_entry(bl31, optee_load_address, \
+ SOC##_BAREBOX_LOAD_ADDRESS, (uintptr_t)fdt); \
+} while (0) \
- get_builtin_firmware(rk3568_op_tee_bin, &optee, &optee_size);
- memcpy((void *)optee_load_address, optee, optee_size);
- }
-
- /* Setup an initial stack for EL2 */
- asm volatile("msr sp_el2, %0" : :
- "r" (RK3568_BAREBOX_LOAD_ADDRESS - 16) :
- "cc");
-
- bl31_entry(bl31, optee_load_address,
- RK3568_BAREBOX_LOAD_ADDRESS, (uintptr_t)fdt);
+void rk3568_atf_load_bl31(void *fdt)
+{
+ rockchip_atf_load_bl31(RK3568, rk3568_bl31_bin, rk3568_op_tee_bin, fdt);
}
--
2.30.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-11-08 7:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-08 7:52 [PATCH 1/9] fixup! scripts/common: Add write_full() and read_full() Ahmad Fatoum
2021-11-08 7:52 ` [PATCH 2/9] fixup! scripts: Add rk-usb-loader tool Ahmad Fatoum
2021-11-08 7:52 ` [PATCH 3/9] ARM: Rockchip: init: propagate error in init function Ahmad Fatoum
2021-11-08 7:52 ` [PATCH 4/9] ARM: Rockchip: rk3568: make rk3568_lowlevel_init void Ahmad Fatoum
2021-11-08 7:52 ` [PATCH 5/9] ARM64: <asm/barebox-arm-head.h>: mark prologue location Ahmad Fatoum
2021-11-08 8:14 ` Ahmad Fatoum
2021-11-08 7:52 ` [PATCH 6/9] pinctrl: Rockchip: abort probe on lack of aliases Ahmad Fatoum
2021-11-08 7:52 ` [PATCH 7/9] clk: handle CLK_OF_DECLARE in deep probe Ahmad Fatoum
2021-11-08 7:52 ` Ahmad Fatoum [this message]
2021-11-08 7:52 ` [PATCH 9/9] ARM: Rockchip: add delimiter between boards and board features Ahmad Fatoum
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=20211108075209.2366770-8-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