spl.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright 2015 - 2016 Xilinx, Inc.
  3. *
  4. * Michal Simek <michal.simek@xilinx.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <debug_uart.h>
  10. #include <spl.h>
  11. #include <asm/io.h>
  12. #include <asm/spl.h>
  13. #include <asm/arch/hardware.h>
  14. #include <asm/arch/sys_proto.h>
  15. void board_init_f(ulong dummy)
  16. {
  17. psu_init();
  18. board_early_init_r();
  19. #ifdef CONFIG_DEBUG_UART
  20. /* Uart debug for sure */
  21. debug_uart_init();
  22. puts("Debug uart enabled\n"); /* or printch() */
  23. #endif
  24. /* Delay is required for clocks to be propagated */
  25. udelay(1000000);
  26. /* Clear the BSS */
  27. memset(__bss_start, 0, __bss_end - __bss_start);
  28. /* No need to call timer init - it is empty for ZynqMP */
  29. board_init_r(NULL, 0);
  30. }
  31. #ifdef CONFIG_SPL_BOARD_INIT
  32. void spl_board_init(void)
  33. {
  34. preloader_console_init();
  35. board_init();
  36. }
  37. #endif
  38. u32 spl_boot_device(void)
  39. {
  40. u32 reg = 0;
  41. u8 bootmode;
  42. #if defined(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED)
  43. /* Change default boot mode at run-time */
  44. writel(BOOT_MODE_USE_ALT |
  45. CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT,
  46. &crlapb_base->boot_mode);
  47. #endif
  48. reg = readl(&crlapb_base->boot_mode);
  49. bootmode = reg & BOOT_MODES_MASK;
  50. switch (bootmode) {
  51. case JTAG_MODE:
  52. return BOOT_DEVICE_RAM;
  53. #ifdef CONFIG_SPL_MMC_SUPPORT
  54. case EMMC_MODE:
  55. case SD_MODE:
  56. case SD_MODE1:
  57. return BOOT_DEVICE_MMC1;
  58. #endif
  59. #ifdef CONFIG_SPL_DFU_SUPPORT
  60. case USB_MODE:
  61. return BOOT_DEVICE_DFU;
  62. #endif
  63. default:
  64. printf("Invalid Boot Mode:0x%x\n", bootmode);
  65. break;
  66. }
  67. return 0;
  68. }
  69. u32 spl_boot_mode(const u32 boot_device)
  70. {
  71. switch (spl_boot_device()) {
  72. case BOOT_DEVICE_RAM:
  73. return 0;
  74. case BOOT_DEVICE_MMC1:
  75. return MMCSD_MODE_FS;
  76. default:
  77. puts("spl: error: unsupported device\n");
  78. hang();
  79. }
  80. }
  81. __weak void psu_init(void)
  82. {
  83. /*
  84. * This function is overridden by the one in
  85. * board/xilinx/zynqmp/(platform)/psu_init_gpl.c, if it exists.
  86. */
  87. }
  88. #ifdef CONFIG_SPL_OS_BOOT
  89. int spl_start_uboot(void)
  90. {
  91. return 0;
  92. }
  93. #endif
  94. #ifdef CONFIG_SPL_LOAD_FIT
  95. int board_fit_config_name_match(const char *name)
  96. {
  97. /* Just empty function now - can't decide what to choose */
  98. debug("%s: %s\n", __func__, name);
  99. return 0;
  100. }
  101. #endif