qemu-riscv.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <dm/ofnode.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 <usb.h>
  15. #include <virtio_types.h>
  16. #include <virtio.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. #if IS_ENABLED(CONFIG_MTD_NOR_FLASH)
  19. int is_flash_available(void)
  20. {
  21. if (!ofnode_equal(ofnode_by_compatible(ofnode_null(), "cfi-flash"),
  22. ofnode_null()))
  23. return 1;
  24. return 0;
  25. }
  26. #endif
  27. int board_init(void)
  28. {
  29. /*
  30. * Make sure virtio bus is enumerated so that peripherals
  31. * on the virtio bus can be discovered by their drivers
  32. */
  33. virtio_init();
  34. return 0;
  35. }
  36. int board_late_init(void)
  37. {
  38. /* start usb so that usb keyboard can be used as input device */
  39. if (CONFIG_IS_ENABLED(USB_KEYBOARD))
  40. usb_init();
  41. return 0;
  42. }
  43. #ifdef CONFIG_SPL
  44. u32 spl_boot_device(void)
  45. {
  46. /* RISC-V QEMU only supports RAM as SPL boot device */
  47. return BOOT_DEVICE_RAM;
  48. }
  49. #endif
  50. #ifdef CONFIG_SPL_LOAD_FIT
  51. int board_fit_config_name_match(const char *name)
  52. {
  53. /* boot using first FIT config */
  54. return 0;
  55. }
  56. #endif
  57. void *board_fdt_blob_setup(int *err)
  58. {
  59. *err = 0;
  60. /* Stored the DTB address there during our init */
  61. return (void *)(ulong)gd->arch.firmware_fdt_addr;
  62. }