blob: dcfd3f20bee66176f43716361ab5f4f372cf7371 [file] [log] [blame]
Bin Meng8a8694d2018-09-26 06:55:21 -07001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
4 */
5
6#include <common.h>
Bin Meng184eadb2018-10-15 02:21:13 -07007#include <dm.h>
Simon Glass313112a2019-08-01 09:46:46 -06008#include <env.h>
Bin Meng8a8694d2018-09-26 06:55:21 -07009#include <fdtdec.h>
Simon Glass2dc9c342020-05-10 11:40:01 -060010#include <image.h>
Simon Glass0f2af882020-05-10 11:40:05 -060011#include <log.h>
Lukas Auerdf3f1002019-08-21 21:14:49 +020012#include <spl.h>
Simon Glassa7b51302019-11-14 12:57:46 -070013#include <init.h>
Bin Meng184eadb2018-10-15 02:21:13 -070014#include <virtio_types.h>
15#include <virtio.h>
Bin Meng8a8694d2018-09-26 06:55:21 -070016
Bin Meng8a8694d2018-09-26 06:55:21 -070017int board_init(void)
18{
Bin Meng184eadb2018-10-15 02:21:13 -070019 /*
20 * Make sure virtio bus is enumerated so that peripherals
21 * on the virtio bus can be discovered by their drivers
22 */
23 virtio_init();
24
Bin Meng8a8694d2018-09-26 06:55:21 -070025 return 0;
26}
Lukas Auer7fcf2122018-11-22 11:26:36 +010027
28int board_late_init(void)
29{
30 ulong kernel_start;
31 ofnode chosen_node;
32 int ret;
33
34 chosen_node = ofnode_path("/chosen");
35 if (!ofnode_valid(chosen_node)) {
36 debug("No chosen node found, can't get kernel start address\n");
37 return 0;
38 }
39
40#ifdef CONFIG_ARCH_RV64I
41 ret = ofnode_read_u64(chosen_node, "riscv,kernel-start",
42 (u64 *)&kernel_start);
43#else
44 ret = ofnode_read_u32(chosen_node, "riscv,kernel-start",
45 (u32 *)&kernel_start);
46#endif
47 if (ret) {
48 debug("Can't find kernel start address in device tree\n");
49 return 0;
50 }
51
52 env_set_hex("kernel_start", kernel_start);
53
54 return 0;
55}
Lukas Auer74c2f122018-11-22 11:26:37 +010056
Lukas Auerdf3f1002019-08-21 21:14:49 +020057#ifdef CONFIG_SPL
58u32 spl_boot_device(void)
59{
60 /* RISC-V QEMU only supports RAM as SPL boot device */
61 return BOOT_DEVICE_RAM;
62}
63#endif
64
65#ifdef CONFIG_SPL_LOAD_FIT
66int board_fit_config_name_match(const char *name)
67{
68 /* boot using first FIT config */
69 return 0;
70}
71#endif