riscv: Move virtio scan to board_late_init()
[platform/kernel/u-boot.git] / board / emulation / qemu-riscv / qemu-riscv.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
4  */
5
6 #include <common.h>
7 #include <dm.h>
8 #include <dm/ofnode.h>
9 #include <env.h>
10 #include <fdtdec.h>
11 #include <image.h>
12 #include <log.h>
13 #include <spl.h>
14 #include <init.h>
15 #include <usb.h>
16 #include <virtio_types.h>
17 #include <virtio.h>
18
19 DECLARE_GLOBAL_DATA_PTR;
20
21 #if IS_ENABLED(CONFIG_MTD_NOR_FLASH)
22 int is_flash_available(void)
23 {
24         if (!ofnode_equal(ofnode_by_compatible(ofnode_null(), "cfi-flash"),
25                           ofnode_null()))
26                 return 1;
27
28         return 0;
29 }
30 #endif
31
32 int board_init(void)
33 {
34         return 0;
35 }
36
37 int board_late_init(void)
38 {
39         /* start usb so that usb keyboard can be used as input device */
40         if (CONFIG_IS_ENABLED(USB_KEYBOARD))
41                 usb_init();
42
43         /*
44          * Make sure virtio bus is enumerated so that peripherals
45          * on the virtio bus can be discovered by their drivers
46          */
47         virtio_init();
48
49         return 0;
50 }
51
52 #ifdef CONFIG_SPL
53 u32 spl_boot_device(void)
54 {
55         /* RISC-V QEMU only supports RAM as SPL boot device */
56         return BOOT_DEVICE_RAM;
57 }
58 #endif
59
60 #ifdef CONFIG_SPL_LOAD_FIT
61 int board_fit_config_name_match(const char *name)
62 {
63         /* boot using first FIT config */
64         return 0;
65 }
66 #endif
67
68 void *board_fdt_blob_setup(int *err)
69 {
70         *err = 0;
71         /* Stored the DTB address there during our init */
72         return (void *)(ulong)gd->arch.firmware_fdt_addr;
73 }