blob: 8baee07beac1eceb33c45b9021a796fc7113ce2f [file] [log] [blame]
Lukas Auer396f0bd2019-08-21 21:14:45 +02001// 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 Glass63334482019-11-14 12:57:39 -07007#include <cpu_func.h>
Simon Glassf11478f2019-12-28 10:45:07 -07008#include <hang.h>
Simon Glass97589732020-05-10 11:40:02 -06009#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060010#include <log.h>
Lukas Auer396f0bd2019-08-21 21:14:45 +020011#include <spl.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060012#include <asm/global_data.h>
Lukas Auer396f0bd2019-08-21 21:14:45 +020013#include <asm/smp.h>
14
15DECLARE_GLOBAL_DATA_PTR;
16
Bin Meng63dcfcb2020-08-02 23:09:01 -070017__weak int spl_board_init_f(void)
18{
19 return 0;
20}
21
Lukas Auer396f0bd2019-08-21 21:14:45 +020022__weak void board_init_f(ulong dummy)
23{
24 int ret;
25
26 ret = spl_early_init();
27 if (ret)
28 panic("spl_early_init() failed: %d\n", ret);
29
30 arch_cpu_init_dm();
31
32 preloader_console_init();
Bin Meng63dcfcb2020-08-02 23:09:01 -070033
34 ret = spl_board_init_f();
35 if (ret)
36 panic("spl_board_init_f() failed: %d\n", ret);
Lukas Auer396f0bd2019-08-21 21:14:45 +020037}
38
39void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
40{
41 typedef void __noreturn (*image_entry_riscv_t)(ulong hart, void *dtb);
42 void *fdt_blob;
Heinrich Schuchardtc78eef72020-08-15 09:49:26 +020043 __maybe_unused int ret;
Lukas Auer396f0bd2019-08-21 21:14:45 +020044
45#if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
46 fdt_blob = spl_image->fdt_addr;
47#else
48 fdt_blob = (void *)gd->fdt_blob;
49#endif
50
51 image_entry_riscv_t image_entry =
52 (image_entry_riscv_t)spl_image->entry_point;
53 invalidate_icache_all();
54
55 debug("image entry point: 0x%lX\n", spl_image->entry_point);
Bin Mengb161f902020-04-16 08:09:30 -070056#ifdef CONFIG_SPL_SMP
Lukas Auerc308e012019-12-08 23:28:51 +010057 ret = smp_call_function(spl_image->entry_point, (ulong)fdt_blob, 0, 0);
Lukas Auer396f0bd2019-08-21 21:14:45 +020058 if (ret)
59 hang();
60#endif
61 image_entry(gd->arch.boot_hart, fdt_blob);
62}