uboot/board/emulation/qemu-riscv/qemu-riscv.c
<<
>>
Prefs
   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
  17int board_init(void)
  18{
  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
  25        return 0;
  26}
  27
  28int 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}
  56
  57#ifdef CONFIG_SPL
  58u32 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
  66int board_fit_config_name_match(const char *name)
  67{
  68        /* boot using first FIT config */
  69        return 0;
  70}
  71#endif
  72