spl.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. board_early_init_f();
  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. static void ps_mode_reset(ulong mode)
  32. {
  33. writel(mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_EN_SHIFT,
  34. &crlapb_base->boot_pin_ctrl);
  35. udelay(5);
  36. writel(mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_VAL_SHIFT |
  37. mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_EN_SHIFT,
  38. &crlapb_base->boot_pin_ctrl);
  39. }
  40. /*
  41. * Set default PS_MODE1 which is used for USB ULPI phy reset
  42. * Also other resets can be connected to this certain pin
  43. */
  44. #ifndef MODE_RESET
  45. # define MODE_RESET PS_MODE1
  46. #endif
  47. #ifdef CONFIG_SPL_BOARD_INIT
  48. void spl_board_init(void)
  49. {
  50. preloader_console_init();
  51. ps_mode_reset(MODE_RESET);
  52. board_init();
  53. }
  54. #endif
  55. u32 spl_boot_device(void)
  56. {
  57. u32 reg = 0;
  58. u8 bootmode;
  59. #if defined(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED)
  60. /* Change default boot mode at run-time */
  61. writel(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT,
  62. &crlapb_base->boot_mode);
  63. #endif
  64. reg = readl(&crlapb_base->boot_mode);
  65. if (reg >> BOOT_MODE_ALT_SHIFT)
  66. reg >>= BOOT_MODE_ALT_SHIFT;
  67. bootmode = reg & BOOT_MODES_MASK;
  68. switch (bootmode) {
  69. case JTAG_MODE:
  70. return BOOT_DEVICE_RAM;
  71. #ifdef CONFIG_SPL_MMC_SUPPORT
  72. case SD_MODE1:
  73. case SD1_LSHFT_MODE: /* not working on silicon v1 */
  74. /* if both controllers enabled, then these two are the second controller */
  75. #if defined(CONFIG_ZYNQ_SDHCI0) && defined(CONFIG_ZYNQ_SDHCI1)
  76. return BOOT_DEVICE_MMC2;
  77. /* else, fall through, the one SDHCI controller that is enabled is number 1 */
  78. #endif
  79. case SD_MODE:
  80. case EMMC_MODE:
  81. return BOOT_DEVICE_MMC1;
  82. #endif
  83. #ifdef CONFIG_SPL_DFU_SUPPORT
  84. case USB_MODE:
  85. return BOOT_DEVICE_DFU;
  86. #endif
  87. #ifdef CONFIG_SPL_SATA_SUPPORT
  88. case SW_SATA_MODE:
  89. return BOOT_DEVICE_SATA;
  90. #endif
  91. #ifdef CONFIG_SPL_SPI_SUPPORT
  92. case QSPI_MODE_24BIT:
  93. case QSPI_MODE_32BIT:
  94. return BOOT_DEVICE_SPI;
  95. #endif
  96. default:
  97. printf("Invalid Boot Mode:0x%x\n", bootmode);
  98. break;
  99. }
  100. return 0;
  101. }
  102. u32 spl_boot_mode(const u32 boot_device)
  103. {
  104. switch (boot_device) {
  105. case BOOT_DEVICE_RAM:
  106. return 0;
  107. case BOOT_DEVICE_MMC1:
  108. case BOOT_DEVICE_MMC2:
  109. return MMCSD_MODE_FS;
  110. default:
  111. puts("spl: error: unsupported device\n");
  112. hang();
  113. }
  114. }
  115. #ifdef CONFIG_SPL_OS_BOOT
  116. int spl_start_uboot(void)
  117. {
  118. handoff_setup();
  119. return 0;
  120. }
  121. #endif
  122. #ifdef CONFIG_SPL_LOAD_FIT
  123. int board_fit_config_name_match(const char *name)
  124. {
  125. /* Just empty function now - can't decide what to choose */
  126. debug("%s: %s\n", __func__, name);
  127. return 0;
  128. }
  129. #endif