diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-11-08 08:52:08 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-11-10 08:53:47 +0100 |
commit | da4ade48e94302d5779f48451ac4a706a8ceaa81 (patch) | |
tree | 7525d9c9ba41f72b984bc115ab81ca4b15c2102c /arch | |
parent | bd516e38dd1490cb83b58f8f7914912f3a702978 (diff) | |
download | barebox-da4ade48e94302d5779f48451ac4a706a8ceaa81.tar.gz barebox-da4ade48e94302d5779f48451ac4a706a8ceaa81.tar.xz |
ARM: Rockchip: make rk3568's atf_load_bl31 reusable
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>
Link: https://lore.barebox.org/20211108075209.2366770-8-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-rockchip/atf.c | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/arch/arm/mach-rockchip/atf.c b/arch/arm/mach-rockchip/atf.c index 3c4c9d1c8a..de22784489 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); } |