misc.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2012-2017 Altera Corporation <www.altera.com>
  4. */
  5. #include <common.h>
  6. #include <asm/io.h>
  7. #include <errno.h>
  8. #include <fdtdec.h>
  9. #include <linux/libfdt.h>
  10. #include <altera.h>
  11. #include <miiphy.h>
  12. #include <netdev.h>
  13. #include <watchdog.h>
  14. #include <asm/arch/misc.h>
  15. #include <asm/arch/reset_manager.h>
  16. #include <asm/arch/scan_manager.h>
  17. #include <asm/arch/system_manager.h>
  18. #include <asm/arch/nic301.h>
  19. #include <asm/arch/scu.h>
  20. #include <asm/pl310.h>
  21. DECLARE_GLOBAL_DATA_PTR;
  22. static const struct pl310_regs *const pl310 =
  23. (struct pl310_regs *)CONFIG_SYS_PL310_BASE;
  24. struct bsel bsel_str[] = {
  25. { "rsvd", "Reserved", },
  26. { "fpga", "FPGA (HPS2FPGA Bridge)", },
  27. { "nand", "NAND Flash (1.8V)", },
  28. { "nand", "NAND Flash (3.0V)", },
  29. { "sd", "SD/MMC External Transceiver (1.8V)", },
  30. { "sd", "SD/MMC Internal Transceiver (3.0V)", },
  31. { "qspi", "QSPI Flash (1.8V)", },
  32. { "qspi", "QSPI Flash (3.0V)", },
  33. };
  34. int dram_init(void)
  35. {
  36. gd->ram_size = get_ram_size((long *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE);
  37. return 0;
  38. }
  39. void enable_caches(void)
  40. {
  41. #ifndef CONFIG_SYS_ICACHE_OFF
  42. icache_enable();
  43. #endif
  44. #ifndef CONFIG_SYS_DCACHE_OFF
  45. dcache_enable();
  46. #endif
  47. }
  48. void v7_outer_cache_enable(void)
  49. {
  50. /* Disable the L2 cache */
  51. clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
  52. /* enable BRESP, instruction and data prefetch, full line of zeroes */
  53. setbits_le32(&pl310->pl310_aux_ctrl,
  54. L310_AUX_CTRL_DATA_PREFETCH_MASK |
  55. L310_AUX_CTRL_INST_PREFETCH_MASK |
  56. L310_SHARED_ATT_OVERRIDE_ENABLE);
  57. /* Enable the L2 cache */
  58. setbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
  59. }
  60. void v7_outer_cache_disable(void)
  61. {
  62. /* Disable the L2 cache */
  63. clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
  64. }
  65. #if defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) && \
  66. defined(CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE)
  67. int overwrite_console(void)
  68. {
  69. return 0;
  70. }
  71. #endif
  72. #ifdef CONFIG_FPGA
  73. /*
  74. * FPGA programming support for SoC FPGA Cyclone V
  75. */
  76. static Altera_desc altera_fpga[] = {
  77. {
  78. /* Family */
  79. Altera_SoCFPGA,
  80. /* Interface type */
  81. fast_passive_parallel,
  82. /* No limitation as additional data will be ignored */
  83. -1,
  84. /* No device function table */
  85. NULL,
  86. /* Base interface address specified in driver */
  87. NULL,
  88. /* No cookie implementation */
  89. 0
  90. },
  91. };
  92. /* add device descriptor to FPGA device table */
  93. void socfpga_fpga_add(void)
  94. {
  95. int i;
  96. fpga_init();
  97. for (i = 0; i < ARRAY_SIZE(altera_fpga); i++)
  98. fpga_add(fpga_altera, &altera_fpga[i]);
  99. }
  100. #endif
  101. int arch_cpu_init(void)
  102. {
  103. #ifdef CONFIG_HW_WATCHDOG
  104. /*
  105. * In case the watchdog is enabled, make sure to (re-)configure it
  106. * so that the defined timeout is valid. Otherwise the SPL (Perloader)
  107. * timeout value is still active which might too short for Linux
  108. * booting.
  109. */
  110. hw_watchdog_init();
  111. #else
  112. /*
  113. * If the HW watchdog is NOT enabled, make sure it is not running,
  114. * for example because it was enabled in the preloader. This might
  115. * trigger a watchdog-triggered reboot of Linux kernel later.
  116. * Toggle watchdog reset, so watchdog in not running state.
  117. */
  118. socfpga_per_reset(SOCFPGA_RESET(L4WD0), 1);
  119. socfpga_per_reset(SOCFPGA_RESET(L4WD0), 0);
  120. #endif
  121. return 0;
  122. }