]>
Commit | Line | Data |
---|---|---|
510e379c BM |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | |
3 | * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com> | |
4 | */ | |
5 | ||
6 | #include <common.h> | |
3c5196dc | 7 | #include <dm.h> |
c7694dd4 | 8 | #include <env.h> |
510e379c | 9 | #include <fdtdec.h> |
4d72caa5 | 10 | #include <image.h> |
f7ae49fc | 11 | #include <log.h> |
e456a819 | 12 | #include <spl.h> |
5255932f | 13 | #include <init.h> |
3c5196dc BM |
14 | #include <virtio_types.h> |
15 | #include <virtio.h> | |
510e379c | 16 | |
2e8d2f88 IA |
17 | DECLARE_GLOBAL_DATA_PTR; |
18 | ||
510e379c BM |
19 | int board_init(void) |
20 | { | |
3c5196dc BM |
21 | /* |
22 | * Make sure virtio bus is enumerated so that peripherals | |
23 | * on the virtio bus can be discovered by their drivers | |
24 | */ | |
25 | virtio_init(); | |
26 | ||
510e379c BM |
27 | return 0; |
28 | } | |
66ffe578 LA |
29 | |
30 | int board_late_init(void) | |
31 | { | |
32 | ulong kernel_start; | |
33 | ofnode chosen_node; | |
34 | int ret; | |
35 | ||
36 | chosen_node = ofnode_path("/chosen"); | |
37 | if (!ofnode_valid(chosen_node)) { | |
38 | debug("No chosen node found, can't get kernel start address\n"); | |
39 | return 0; | |
40 | } | |
41 | ||
42 | #ifdef CONFIG_ARCH_RV64I | |
43 | ret = ofnode_read_u64(chosen_node, "riscv,kernel-start", | |
44 | (u64 *)&kernel_start); | |
45 | #else | |
46 | ret = ofnode_read_u32(chosen_node, "riscv,kernel-start", | |
47 | (u32 *)&kernel_start); | |
48 | #endif | |
49 | if (ret) { | |
50 | debug("Can't find kernel start address in device tree\n"); | |
51 | return 0; | |
52 | } | |
53 | ||
54 | env_set_hex("kernel_start", kernel_start); | |
55 | ||
56 | return 0; | |
57 | } | |
897206c5 | 58 | |
e456a819 LA |
59 | #ifdef CONFIG_SPL |
60 | u32 spl_boot_device(void) | |
61 | { | |
62 | /* RISC-V QEMU only supports RAM as SPL boot device */ | |
63 | return BOOT_DEVICE_RAM; | |
64 | } | |
65 | #endif | |
66 | ||
67 | #ifdef CONFIG_SPL_LOAD_FIT | |
68 | int board_fit_config_name_match(const char *name) | |
69 | { | |
70 | /* boot using first FIT config */ | |
71 | return 0; | |
72 | } | |
73 | #endif | |
2e8d2f88 | 74 | |
e7fb7896 | 75 | void *board_fdt_blob_setup(int *err) |
2e8d2f88 | 76 | { |
e7fb7896 | 77 | *err = 0; |
2e8d2f88 IA |
78 | /* Stored the DTB address there during our init */ |
79 | return (void *)(ulong)gd->arch.firmware_fdt_addr; | |
80 | } |