Bin Meng | 510e379 | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com> |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Bin Meng | 3c5196d | 2018-10-15 02:21:13 -0700 | [diff] [blame] | 7 | #include <dm.h> |
Simon Glass | c7694dd | 2019-08-01 09:46:46 -0600 | [diff] [blame] | 8 | #include <env.h> |
Bin Meng | 510e379 | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 9 | #include <fdtdec.h> |
Simon Glass | 4d72caa | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 10 | #include <image.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame^] | 11 | #include <log.h> |
Lukas Auer | e456a81 | 2019-08-21 21:14:49 +0200 | [diff] [blame] | 12 | #include <spl.h> |
Simon Glass | 5255932 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 13 | #include <init.h> |
Bin Meng | 3c5196d | 2018-10-15 02:21:13 -0700 | [diff] [blame] | 14 | #include <virtio_types.h> |
| 15 | #include <virtio.h> |
Bin Meng | 510e379 | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 16 | |
Bin Meng | 510e379 | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 17 | int board_init(void) |
| 18 | { |
Bin Meng | 3c5196d | 2018-10-15 02:21:13 -0700 | [diff] [blame] | 19 | /* |
| 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 Meng | 510e379 | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 25 | return 0; |
| 26 | } |
Lukas Auer | 66ffe57 | 2018-11-22 11:26:36 +0100 | [diff] [blame] | 27 | |
| 28 | int 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 Auer | 897206c | 2018-11-22 11:26:37 +0100 | [diff] [blame] | 56 | |
Lukas Auer | e456a81 | 2019-08-21 21:14:49 +0200 | [diff] [blame] | 57 | #ifdef CONFIG_SPL |
| 58 | u32 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 |
| 66 | int board_fit_config_name_match(const char *name) |
| 67 | { |
| 68 | /* boot using first FIT config */ |
| 69 | return 0; |
| 70 | } |
| 71 | #endif |