Lukas Auer | 396f0bd | 2019-08-21 21:14:45 +0200 | [diff] [blame] | 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> |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 7 | #include <cpu_func.h> |
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 8 | #include <hang.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 10 | #include <log.h> |
Lukas Auer | 396f0bd | 2019-08-21 21:14:45 +0200 | [diff] [blame] | 11 | #include <spl.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 12 | #include <asm/global_data.h> |
Lukas Auer | 396f0bd | 2019-08-21 21:14:45 +0200 | [diff] [blame] | 13 | #include <asm/smp.h> |
Simon Glass | fc55736 | 2022-03-04 08:43:05 -0700 | [diff] [blame] | 14 | #include <asm/system.h> |
Lukas Auer | 396f0bd | 2019-08-21 21:14:45 +0200 | [diff] [blame] | 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
Bin Meng | 63dcfcb | 2020-08-02 23:09:01 -0700 | [diff] [blame] | 18 | __weak int spl_board_init_f(void) |
| 19 | { |
| 20 | return 0; |
| 21 | } |
| 22 | |
Lukas Auer | 396f0bd | 2019-08-21 21:14:45 +0200 | [diff] [blame] | 23 | __weak void board_init_f(ulong dummy) |
| 24 | { |
| 25 | int ret; |
| 26 | |
| 27 | ret = spl_early_init(); |
| 28 | if (ret) |
| 29 | panic("spl_early_init() failed: %d\n", ret); |
| 30 | |
Simon Glass | fc55736 | 2022-03-04 08:43:05 -0700 | [diff] [blame] | 31 | riscv_cpu_setup(NULL, NULL); |
Lukas Auer | 396f0bd | 2019-08-21 21:14:45 +0200 | [diff] [blame] | 32 | |
| 33 | preloader_console_init(); |
Bin Meng | 63dcfcb | 2020-08-02 23:09:01 -0700 | [diff] [blame] | 34 | |
| 35 | ret = spl_board_init_f(); |
| 36 | if (ret) |
| 37 | panic("spl_board_init_f() failed: %d\n", ret); |
Lukas Auer | 396f0bd | 2019-08-21 21:14:45 +0200 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) |
| 41 | { |
| 42 | typedef void __noreturn (*image_entry_riscv_t)(ulong hart, void *dtb); |
| 43 | void *fdt_blob; |
Heinrich Schuchardt | c78eef7 | 2020-08-15 09:49:26 +0200 | [diff] [blame] | 44 | __maybe_unused int ret; |
Lukas Auer | 396f0bd | 2019-08-21 21:14:45 +0200 | [diff] [blame] | 45 | |
| 46 | #if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL) |
| 47 | fdt_blob = spl_image->fdt_addr; |
| 48 | #else |
| 49 | fdt_blob = (void *)gd->fdt_blob; |
| 50 | #endif |
| 51 | |
| 52 | image_entry_riscv_t image_entry = |
| 53 | (image_entry_riscv_t)spl_image->entry_point; |
| 54 | invalidate_icache_all(); |
| 55 | |
| 56 | debug("image entry point: 0x%lX\n", spl_image->entry_point); |
Bin Meng | b161f90 | 2020-04-16 08:09:30 -0700 | [diff] [blame] | 57 | #ifdef CONFIG_SPL_SMP |
Lukas Auer | c308e01 | 2019-12-08 23:28:51 +0100 | [diff] [blame] | 58 | ret = smp_call_function(spl_image->entry_point, (ulong)fdt_blob, 0, 0); |
Lukas Auer | 396f0bd | 2019-08-21 21:14:45 +0200 | [diff] [blame] | 59 | if (ret) |
| 60 | hang(); |
| 61 | #endif |
| 62 | image_entry(gd->arch.boot_hart, fdt_blob); |
| 63 | } |