qemu-riscv.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. DECLARE_GLOBAL_DATA_PTR;
  16. int board_init(void)
  17. {
  18. /*
  19. * Make sure virtio bus is enumerated so that peripherals
  20. * on the virtio bus can be discovered by their drivers
  21. */
  22. virtio_init();
  23. return 0;
  24. }
  25. int board_late_init(void)
  26. {
  27. ulong kernel_start;
  28. ofnode chosen_node;
  29. int ret;
  30. chosen_node = ofnode_path("/chosen");
  31. if (!ofnode_valid(chosen_node)) {
  32. debug("No chosen node found, can't get kernel start address\n");
  33. return 0;
  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. env_set_hex("kernel_start", kernel_start);
  47. return 0;
  48. }
  49. #ifdef CONFIG_SPL
  50. u32 spl_boot_device(void)
  51. {
  52. /* RISC-V QEMU only supports RAM as SPL boot device */
  53. return BOOT_DEVICE_RAM;
  54. }
  55. #endif
  56. #ifdef CONFIG_SPL_LOAD_FIT
  57. int board_fit_config_name_match(const char *name)
  58. {
  59. /* boot using first FIT config */
  60. return 0;
  61. }
  62. #endif
  63. void *board_fdt_blob_setup(int *err)
  64. {
  65. *err = 0;
  66. /* Stored the DTB address there during our init */
  67. return (void *)(ulong)gd->arch.firmware_fdt_addr;
  68. }