qemu-riscv.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <env.h>
  8. #include <fdtdec.h>
  9. #include <image.h>
  10. #include <spl.h>
  11. #include <init.h>
  12. #include <virtio_types.h>
  13. #include <virtio.h>
  14. int board_init(void)
  15. {
  16. /*
  17. * Make sure virtio bus is enumerated so that peripherals
  18. * on the virtio bus can be discovered by their drivers
  19. */
  20. virtio_init();
  21. return 0;
  22. }
  23. int board_late_init(void)
  24. {
  25. ulong kernel_start;
  26. ofnode chosen_node;
  27. int ret;
  28. chosen_node = ofnode_path("/chosen");
  29. if (!ofnode_valid(chosen_node)) {
  30. debug("No chosen node found, can't get kernel start address\n");
  31. return 0;
  32. }
  33. #ifdef CONFIG_ARCH_RV64I
  34. ret = ofnode_read_u64(chosen_node, "riscv,kernel-start",
  35. (u64 *)&kernel_start);
  36. #else
  37. ret = ofnode_read_u32(chosen_node, "riscv,kernel-start",
  38. (u32 *)&kernel_start);
  39. #endif
  40. if (ret) {
  41. debug("Can't find kernel start address in device tree\n");
  42. return 0;
  43. }
  44. env_set_hex("kernel_start", kernel_start);
  45. return 0;
  46. }
  47. #ifdef CONFIG_SPL
  48. u32 spl_boot_device(void)
  49. {
  50. /* RISC-V QEMU only supports RAM as SPL boot device */
  51. return BOOT_DEVICE_RAM;
  52. }
  53. #endif
  54. #ifdef CONFIG_SPL_LOAD_FIT
  55. int board_fit_config_name_match(const char *name)
  56. {
  57. /* boot using first FIT config */
  58. return 0;
  59. }
  60. #endif