misc.c 3.1 KB

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