summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-rockchip/atf.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-rockchip/atf.c')
-rw-r--r--arch/arm/mach-rockchip/atf.c114
1 files changed, 96 insertions, 18 deletions
diff --git a/arch/arm/mach-rockchip/atf.c b/arch/arm/mach-rockchip/atf.c
index 3c4c9d1c8a..eaba209ff3 100644
--- a/arch/arm/mach-rockchip/atf.c
+++ b/arch/arm/mach-rockchip/atf.c
@@ -2,9 +2,15 @@
#include <common.h>
#include <firmware.h>
#include <asm/system.h>
-#include <mach/atf.h>
+#include <mach/rockchip/atf.h>
#include <elf.h>
#include <asm/atf_common.h>
+#include <asm/barebox-arm.h>
+#include <mach/rockchip/dmc.h>
+#include <mach/rockchip/rockchip.h>
+#include <mach/rockchip/bootrom.h>
+#include <mach/rockchip/rk3568-regs.h>
+#include <mach/rockchip/rk3588-regs.h>
static unsigned long load_elf64_image_phdr(const void *elf)
{
@@ -33,30 +39,102 @@ static unsigned long load_elf64_image_phdr(const void *elf)
return ehdr->e_entry;
}
-void rk3568_atf_load_bl31(void *fdt)
+#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) \
+
+void rk3399_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;
+ rockchip_atf_load_bl31(RK3399, rk3399_bl31_bin, rk3399_op_tee_bin, fdt);
+}
- get_builtin_firmware(rk3568_bl31_bin, &bl31_elf, &bl31_elf_size);
+void rk3568_atf_load_bl31(void *fdt)
+{
+ rockchip_atf_load_bl31(RK3568, rk3568_bl31_bin, rk3568_op_tee_bin, fdt);
+}
- bl31 = load_elf64_image_phdr(bl31_elf);
+void __noreturn rk3568_barebox_entry(void *fdt)
+{
+ unsigned long membase, memsize;
- if (IS_ENABLED(CONFIG_ARCH_RK3568_OPTEE)) {
- optee_load_address = RK3568_OPTEE_LOAD_ADDRESS;
+ membase = RK3568_DRAM_BOTTOM;
+ memsize = rk3568_ram0_size() - RK3568_DRAM_BOTTOM;
- get_builtin_firmware(rk3568_op_tee_bin, &optee, &optee_size);
+ if (current_el() == 3) {
+ rk3568_lowlevel_init();
+ rockchip_store_bootrom_iram(membase, memsize, IOMEM(RK3568_IRAM_BASE));
- memcpy((void *)optee_load_address, optee, optee_size);
+ /*
+ * The downstream TF-A doesn't cope with our device tree when
+ * CONFIG_OF_OVERLAY_LIVE is enabled, supposedly because it is
+ * too big for some reason. Otherwise it doesn't have any visible
+ * effect if we pass a device tree or not, except that the TF-A
+ * fills in the ethernet MAC address into the device tree.
+ * The upstream TF-A doesn't use the device tree at all.
+ *
+ * Pass NULL for now until we have a good reason to pass a real
+ * device tree.
+ */
+ rk3568_atf_load_bl31(NULL);
+ /* not reached when CONFIG_ARCH_ROCKCHIP_ATF */
}
- /* Setup an initial stack for EL2 */
- asm volatile("msr sp_el2, %0" : :
- "r" (RK3568_BAREBOX_LOAD_ADDRESS - 16) :
- "cc");
+ barebox_arm_entry(membase, memsize, fdt);
+}
+
+void rk3588_atf_load_bl31(void *fdt)
+{
+ rockchip_atf_load_bl31(RK3588, rk3588_bl31_bin, rk3588_op_tee_bin, fdt);
+}
+
+void __noreturn rk3588_barebox_entry(void *fdt)
+{
+ unsigned long membase, memsize;
+
+ membase = RK3588_DRAM_BOTTOM;
+ memsize = rk3588_ram0_size() - RK3588_DRAM_BOTTOM;
+
+ if (current_el() == 3) {
+ rk3588_lowlevel_init();
+ rockchip_store_bootrom_iram(membase, memsize, IOMEM(RK3588_IRAM_BASE));
+
+ /*
+ * The downstream TF-A doesn't cope with our device tree when
+ * CONFIG_OF_OVERLAY_LIVE is enabled, supposedly because it is
+ * too big for some reason. Otherwise it doesn't have any visible
+ * effect if we pass a device tree or not, except that the TF-A
+ * fills in the ethernet MAC address into the device tree.
+ * The upstream TF-A doesn't use the device tree at all.
+ *
+ * Pass NULL for now until we have a good reason to pass a real
+ * device tree.
+ */
+ rk3588_atf_load_bl31(NULL);
+ /* not reached when CONFIG_ARCH_ROCKCHIP_ATF */
+ }
- bl31_entry(bl31, optee_load_address,
- RK3568_BAREBOX_LOAD_ADDRESS, (uintptr_t)fdt);
+ barebox_arm_entry(membase, memsize, fdt);
}