dc7577f751660dfdc744d316464b236ce01707c3
[oweals/u-boot.git] / arch / riscv / lib / spl.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2019 Fraunhofer AISEC,
4  * Lukas Auer <lukas.auer@aisec.fraunhofer.de>
5  */
6 #include <common.h>
7 #include <cpu_func.h>
8 #include <spl.h>
9 #include <asm/smp.h>
10
11 DECLARE_GLOBAL_DATA_PTR;
12
13 __weak void board_init_f(ulong dummy)
14 {
15         int ret;
16
17         ret = spl_early_init();
18         if (ret)
19                 panic("spl_early_init() failed: %d\n", ret);
20
21         arch_cpu_init_dm();
22
23         preloader_console_init();
24 }
25
26 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
27 {
28         typedef void __noreturn (*image_entry_riscv_t)(ulong hart, void *dtb);
29         void *fdt_blob;
30         int ret;
31
32 #if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
33         fdt_blob = spl_image->fdt_addr;
34 #else
35         fdt_blob = (void *)gd->fdt_blob;
36 #endif
37
38         image_entry_riscv_t image_entry =
39                 (image_entry_riscv_t)spl_image->entry_point;
40         invalidate_icache_all();
41
42         debug("image entry point: 0x%lX\n", spl_image->entry_point);
43 #ifdef CONFIG_SMP
44         ret = smp_call_function(spl_image->entry_point, (ulong)fdt_blob, 0, 0);
45         if (ret)
46                 hang();
47 #endif
48         image_entry(gd->arch.boot_hart, fdt_blob);
49 }