spl_a10.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2012 Altera Corporation <www.altera.com>
  4. */
  5. #include <common.h>
  6. #include <asm/io.h>
  7. #include <asm/pl310.h>
  8. #include <asm/u-boot.h>
  9. #include <asm/utils.h>
  10. #include <image.h>
  11. #include <asm/arch/reset_manager.h>
  12. #include <spl.h>
  13. #include <asm/arch/system_manager.h>
  14. #include <asm/arch/freeze_controller.h>
  15. #include <asm/arch/clock_manager.h>
  16. #include <asm/arch/scan_manager.h>
  17. #include <asm/arch/sdram.h>
  18. #include <asm/arch/scu.h>
  19. #include <asm/arch/misc.h>
  20. #include <asm/arch/nic301.h>
  21. #include <asm/sections.h>
  22. #include <fdtdec.h>
  23. #include <watchdog.h>
  24. #include <asm/arch/pinmux.h>
  25. DECLARE_GLOBAL_DATA_PTR;
  26. static const struct socfpga_system_manager *sysmgr_regs =
  27. (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
  28. u32 spl_boot_device(void)
  29. {
  30. const u32 bsel = readl(&sysmgr_regs->bootinfo);
  31. switch (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
  32. case 0x1: /* FPGA (HPS2FPGA Bridge) */
  33. return BOOT_DEVICE_RAM;
  34. case 0x2: /* NAND Flash (1.8V) */
  35. case 0x3: /* NAND Flash (3.0V) */
  36. socfpga_per_reset(SOCFPGA_RESET(NAND), 0);
  37. return BOOT_DEVICE_NAND;
  38. case 0x4: /* SD/MMC External Transceiver (1.8V) */
  39. case 0x5: /* SD/MMC Internal Transceiver (3.0V) */
  40. socfpga_per_reset(SOCFPGA_RESET(SDMMC), 0);
  41. socfpga_per_reset(SOCFPGA_RESET(DMA), 0);
  42. return BOOT_DEVICE_MMC1;
  43. case 0x6: /* QSPI Flash (1.8V) */
  44. case 0x7: /* QSPI Flash (3.0V) */
  45. socfpga_per_reset(SOCFPGA_RESET(QSPI), 0);
  46. return BOOT_DEVICE_SPI;
  47. default:
  48. printf("Invalid boot device (bsel=%08x)!\n", bsel);
  49. hang();
  50. }
  51. }
  52. #ifdef CONFIG_SPL_MMC_SUPPORT
  53. u32 spl_boot_mode(const u32 boot_device)
  54. {
  55. #if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
  56. return MMCSD_MODE_FS;
  57. #else
  58. return MMCSD_MODE_RAW;
  59. #endif
  60. }
  61. #endif
  62. void spl_board_init(void)
  63. {
  64. /* enable console uart printing */
  65. preloader_console_init();
  66. WATCHDOG_RESET();
  67. arch_early_init_r();
  68. }
  69. void board_init_f(ulong dummy)
  70. {
  71. socfpga_init_security_policies();
  72. socfpga_sdram_remap_zero();
  73. /* Assert reset to all except L4WD0 and L4TIMER0 */
  74. socfpga_per_reset_all();
  75. socfpga_watchdog_disable();
  76. spl_early_init();
  77. /* Configure the clock based on handoff */
  78. cm_basic_init(gd->fdt_blob);
  79. #ifdef CONFIG_HW_WATCHDOG
  80. /* release osc1 watchdog timer 0 from reset */
  81. socfpga_reset_deassert_osc1wd0();
  82. /* reconfigure and enable the watchdog */
  83. hw_watchdog_init();
  84. WATCHDOG_RESET();
  85. #endif /* CONFIG_HW_WATCHDOG */
  86. config_dedicated_pins(gd->fdt_blob);
  87. WATCHDOG_RESET();
  88. }