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> |
Bin Meng | 510e379 | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 8 | #include <fdtdec.h> |
Bin Meng | 3c5196d | 2018-10-15 02:21:13 -0700 | [diff] [blame] | 9 | #include <virtio_types.h> |
| 10 | #include <virtio.h> |
Bin Meng | 510e379 | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 11 | |
Bin Meng | 510e379 | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 12 | int board_init(void) |
| 13 | { |
Bin Meng | 3c5196d | 2018-10-15 02:21:13 -0700 | [diff] [blame] | 14 | /* |
| 15 | * Make sure virtio bus is enumerated so that peripherals |
| 16 | * on the virtio bus can be discovered by their drivers |
| 17 | */ |
| 18 | virtio_init(); |
| 19 | |
Bin Meng | 510e379 | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 20 | return 0; |
| 21 | } |
Lukas Auer | 66ffe57 | 2018-11-22 11:26:36 +0100 | [diff] [blame^] | 22 | |
| 23 | int board_late_init(void) |
| 24 | { |
| 25 | ulong kernel_start; |
| 26 | ofnode chosen_node; |
| 27 | int ret; |
| 28 | |
| 29 | chosen_node = ofnode_path("/chosen"); |
| 30 | if (!ofnode_valid(chosen_node)) { |
| 31 | debug("No chosen node found, can't get kernel start address\n"); |
| 32 | return 0; |
| 33 | } |
| 34 | |
| 35 | #ifdef CONFIG_ARCH_RV64I |
| 36 | ret = ofnode_read_u64(chosen_node, "riscv,kernel-start", |
| 37 | (u64 *)&kernel_start); |
| 38 | #else |
| 39 | ret = ofnode_read_u32(chosen_node, "riscv,kernel-start", |
| 40 | (u32 *)&kernel_start); |
| 41 | #endif |
| 42 | if (ret) { |
| 43 | debug("Can't find kernel start address in device tree\n"); |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | env_set_hex("kernel_start", kernel_start); |
| 48 | |
| 49 | return 0; |
| 50 | } |