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 <env.h> 9 #include <fdtdec.h> 10 #include <image.h> 11 #include <log.h> 12 #include <spl.h> 13 #include <init.h> 14 #include <virtio_types.h> 15 #include <virtio.h> 16 17 DECLARE_GLOBAL_DATA_PTR; 18 board_init(void)19int board_init(void) 20 { 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 27 return 0; 28 } 29 board_late_init(void)30int 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 } 58 59 #ifdef CONFIG_SPL spl_boot_device(void)60u32 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 board_fit_config_name_match(const char * name)68int board_fit_config_name_match(const char *name) 69 { 70 /* boot using first FIT config */ 71 return 0; 72 } 73 #endif 74 board_fdt_blob_setup(int * err)75void *board_fdt_blob_setup(int *err) 76 { 77 *err = 0; 78 /* Stored the DTB address there during our init */ 79 return (void *)(ulong)gd->arch.firmware_fdt_addr; 80 } 81