qemu-riscv.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 <log.h>
  11. #include <spl.h>
  12. #include <init.h>
  13. #include <virtio_types.h>
  14. #include <virtio.h>
  15. int board_init(void)
  16. {
  17. /*
  18. * Make sure virtio bus is enumerated so that peripherals
  19. * on the virtio bus can be discovered by their drivers
  20. */
  21. virtio_init();
  22. return 0;
  23. }
  24. int board_late_init(void)
  25. {
  26. ulong kernel_start;
  27. ofnode chosen_node;
  28. int ret;
  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. #ifdef CONFIG_ARCH_RV64I
  35. ret = ofnode_read_u64(chosen_node, "riscv,kernel-start",
  36. (u64 *)&kernel_start);
  37. #else
  38. ret = ofnode_read_u32(chosen_node, "riscv,kernel-start",
  39. (u32 *)&kernel_start);
  40. #endif
  41. if (ret) {
  42. debug("Can't find kernel start address in device tree\n");
  43. return 0;
  44. }
  45. env_set_hex("kernel_start", kernel_start);
  46. return 0;
  47. }
  48. #ifdef CONFIG_SPL
  49. u32 spl_boot_device(void)
  50. {
  51. /* RISC-V QEMU only supports RAM as SPL boot device */
  52. return BOOT_DEVICE_RAM;
  53. }
  54. #endif
  55. #ifdef CONFIG_SPL_LOAD_FIT
  56. int board_fit_config_name_match(const char *name)
  57. {
  58. /* boot using first FIT config */
  59. return 0;
  60. }
  61. #endif