1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
11 #include <virtio_types.h>
17 * Make sure virtio bus is enumerated so that peripherals
18 * on the virtio bus can be discovered by their drivers
25 int board_late_init(void)
31 chosen_node = ofnode_path("/chosen");
32 if (!ofnode_valid(chosen_node)) {
33 debug("No chosen node found, can't get kernel start address\n");
37 #ifdef CONFIG_ARCH_RV64I
38 ret = ofnode_read_u64(chosen_node, "riscv,kernel-start",
39 (u64 *)&kernel_start);
41 ret = ofnode_read_u32(chosen_node, "riscv,kernel-start",
42 (u32 *)&kernel_start);
45 debug("Can't find kernel start address in device tree\n");
49 env_set_hex("kernel_start", kernel_start);
55 * QEMU specifies the location of Linux (supplied with the -kernel argument)
56 * in the device tree using the riscv,kernel-start and riscv,kernel-end
57 * properties. We currently rely on the SBI implementation of BBL to run
58 * Linux and therefore embed Linux as payload in BBL. This causes an issue,
59 * because BBL detects the kernel properties in the device tree and ignores
60 * the Linux payload as a result. To work around this issue, we clear the
61 * kernel properties before booting Linux.
63 * This workaround can be removed, once we do not require BBL for its SBI
64 * implementation anymore.
66 int ft_board_setup(void *blob, bd_t *bd)
68 int chosen_offset, ret;
70 chosen_offset = fdt_path_offset(blob, "/chosen");
71 if (chosen_offset < 0)
74 #ifdef CONFIG_ARCH_RV64I
75 ret = fdt_setprop_u64(blob, chosen_offset, "riscv,kernel-start", 0);
77 ret = fdt_setprop_u32(blob, chosen_offset, "riscv,kernel-start", 0);
82 #ifdef CONFIG_ARCH_RV64I
83 ret = fdt_setprop_u64(blob, chosen_offset, "riscv,kernel-end", 0);
85 ret = fdt_setprop_u32(blob, chosen_offset, "riscv,kernel-end", 0);
94 u32 spl_boot_device(void)
96 /* RISC-V QEMU only supports RAM as SPL boot device */
97 return BOOT_DEVICE_RAM;
101 #ifdef CONFIG_SPL_LOAD_FIT
102 int board_fit_config_name_match(const char *name)
104 /* boot using first FIT config */