spl.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2015 - 2016 Xilinx, Inc.
  4. *
  5. * Michal Simek <michal.simek@xilinx.com>
  6. */
  7. #include <common.h>
  8. #include <image.h>
  9. #include <init.h>
  10. #include <log.h>
  11. #include <spl.h>
  12. #include <linux/delay.h>
  13. #include <asm/io.h>
  14. #include <asm/spl.h>
  15. #include <asm/arch/hardware.h>
  16. #include <asm/arch/psu_init_gpl.h>
  17. #include <asm/arch/sys_proto.h>
  18. void board_init_f(ulong dummy)
  19. {
  20. board_early_init_f();
  21. board_early_init_r();
  22. }
  23. static void ps_mode_reset(ulong mode)
  24. {
  25. writel(mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_EN_SHIFT,
  26. &crlapb_base->boot_pin_ctrl);
  27. udelay(5);
  28. writel(mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_VAL_SHIFT |
  29. mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_EN_SHIFT,
  30. &crlapb_base->boot_pin_ctrl);
  31. }
  32. /*
  33. * Set default PS_MODE1 which is used for USB ULPI phy reset
  34. * Also other resets can be connected to this certain pin
  35. */
  36. #ifndef MODE_RESET
  37. # define MODE_RESET PS_MODE1
  38. #endif
  39. #ifdef CONFIG_SPL_BOARD_INIT
  40. void spl_board_init(void)
  41. {
  42. preloader_console_init();
  43. ps_mode_reset(MODE_RESET);
  44. board_init();
  45. psu_post_config_data();
  46. }
  47. #endif
  48. void board_boot_order(u32 *spl_boot_list)
  49. {
  50. spl_boot_list[0] = spl_boot_device();
  51. if (spl_boot_list[0] == BOOT_DEVICE_MMC1)
  52. spl_boot_list[1] = BOOT_DEVICE_MMC2;
  53. if (spl_boot_list[0] == BOOT_DEVICE_MMC2)
  54. spl_boot_list[1] = BOOT_DEVICE_MMC1;
  55. spl_boot_list[2] = BOOT_DEVICE_RAM;
  56. }
  57. u32 spl_boot_device(void)
  58. {
  59. u32 reg = 0;
  60. u8 bootmode;
  61. #if defined(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED)
  62. /* Change default boot mode at run-time */
  63. writel(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT,
  64. &crlapb_base->boot_mode);
  65. #endif
  66. reg = readl(&crlapb_base->boot_mode);
  67. if (reg >> BOOT_MODE_ALT_SHIFT)
  68. reg >>= BOOT_MODE_ALT_SHIFT;
  69. bootmode = reg & BOOT_MODES_MASK;
  70. switch (bootmode) {
  71. case JTAG_MODE:
  72. return BOOT_DEVICE_RAM;
  73. #ifdef CONFIG_SPL_MMC_SUPPORT
  74. case SD_MODE1:
  75. case SD1_LSHFT_MODE: /* not working on silicon v1 */
  76. return BOOT_DEVICE_MMC2;
  77. case SD_MODE:
  78. case EMMC_MODE:
  79. return BOOT_DEVICE_MMC1;
  80. #endif
  81. #ifdef CONFIG_SPL_DFU
  82. case USB_MODE:
  83. return BOOT_DEVICE_DFU;
  84. #endif
  85. #ifdef CONFIG_SPL_SATA_SUPPORT
  86. case SW_SATA_MODE:
  87. return BOOT_DEVICE_SATA;
  88. #endif
  89. #ifdef CONFIG_SPL_SPI_SUPPORT
  90. case QSPI_MODE_24BIT:
  91. case QSPI_MODE_32BIT:
  92. return BOOT_DEVICE_SPI;
  93. #endif
  94. default:
  95. printf("Invalid Boot Mode:0x%x\n", bootmode);
  96. break;
  97. }
  98. return 0;
  99. }
  100. #ifdef CONFIG_SPL_OS_BOOT
  101. int spl_start_uboot(void)
  102. {
  103. return 0;
  104. }
  105. #endif
  106. #ifdef CONFIG_SPL_LOAD_FIT
  107. int board_fit_config_name_match(const char *name)
  108. {
  109. /* Just empty function now - can't decide what to choose */
  110. debug("%s: %s\n", __func__, name);
  111. return -1;
  112. }
  113. #endif