k3_helpers.S 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <asm_macros.S>
  8. #include <cortex_a72.h>
  9. #include <cpu_macros.S>
  10. #include <platform_def.h>
  11. #define K3_BOOT_REASON_COLD_RESET 0x1
  12. /* ------------------------------------------------------------------
  13. * uintptr_t plat_get_my_entrypoint(void)
  14. * ------------------------------------------------------------------
  15. *
  16. * This function is called with the called with the MMU and caches
  17. * disabled (SCTLR_EL3.M = 0 and SCTLR_EL3.C = 0). The function is
  18. * responsible for distinguishing between a warm and cold reset for the
  19. * current CPU using platform-specific means. If it's a warm reset,
  20. * then it returns the warm reset entrypoint point provided to
  21. * plat_setup_psci_ops() during BL31 initialization. If it's a cold
  22. * reset then this function must return zero.
  23. *
  24. * This function does not follow the Procedure Call Standard used by
  25. * the Application Binary Interface for the ARM 64-bit architecture.
  26. * The caller should not assume that callee saved registers are
  27. * preserved across a call to this function.
  28. */
  29. .globl plat_get_my_entrypoint
  30. func plat_get_my_entrypoint
  31. ldr x0, k3_boot_reason_data_store
  32. cmp x0, #K3_BOOT_REASON_COLD_RESET
  33. /* We ONLY support cold boot at this point */
  34. bne plat_unsupported_boot
  35. mov x0, #0
  36. ret
  37. /*
  38. * We self manage our boot reason.
  39. * At load time, we have just a default reason - which is cold reset
  40. */
  41. k3_boot_reason_data_store:
  42. .word K3_BOOT_REASON_COLD_RESET
  43. plat_unsupported_boot:
  44. b plat_unsupported_boot
  45. endfunc plat_get_my_entrypoint
  46. /* ------------------------------------------------------------------
  47. * unsigned int plat_my_core_pos(void)
  48. * ------------------------------------------------------------------
  49. *
  50. * This function returns the index of the calling CPU which is used as a
  51. * CPU-specific linear index into blocks of memory (for example while
  52. * allocating per-CPU stacks). This function will be invoked very early
  53. * in the initialization sequence which mandates that this function
  54. * should be implemented in assembly and should not rely on the
  55. * avalability of a C runtime environment. This function can clobber x0
  56. * - x8 and must preserve x9 - x29.
  57. *
  58. * This function plays a crucial role in the power domain topology
  59. * framework in PSCI and details of this can be found in Power Domain
  60. * Topology Design.
  61. */
  62. .globl plat_my_core_pos
  63. func plat_my_core_pos
  64. mrs x0, MPIDR_EL1
  65. and x1, x0, #MPIDR_CLUSTER_MASK
  66. lsr x1, x1, #MPIDR_AFF1_SHIFT
  67. and x0, x0, #MPIDR_CPU_MASK
  68. cmp x1, 0
  69. b.eq out
  70. add x0, x0, #K3_CLUSTER0_CORE_COUNT
  71. cmp x1, 1
  72. b.eq out
  73. add x0, x0, #K3_CLUSTER1_CORE_COUNT
  74. cmp x1, 2
  75. b.eq out
  76. add x0, x0, #K3_CLUSTER2_CORE_COUNT
  77. out:
  78. ret
  79. endfunc plat_my_core_pos
  80. /* --------------------------------------------------------------------
  81. * This handler does the following:
  82. * - Set the L2 Data RAM latency to 2 (i.e. 3 cycles) for Cortex-A72
  83. * --------------------------------------------------------------------
  84. */
  85. .globl plat_reset_handler
  86. func plat_reset_handler
  87. /* Only on Cortex-A72 */
  88. jump_if_cpu_midr CORTEX_A72_MIDR, a72
  89. ret
  90. /* Cortex-A72 specific settings */
  91. a72:
  92. mrs x0, CORTEX_A72_L2CTLR_EL1
  93. #if K3_DATA_RAM_4_LATENCY
  94. /* Set L2 cache data RAM latency to 4 cycles */
  95. orr x0, x0, #(CORTEX_A72_L2_DATA_RAM_LATENCY_4_CYCLES << \
  96. CORTEX_A72_L2CTLR_DATA_RAM_LATENCY_SHIFT)
  97. #else
  98. /* Set L2 cache data RAM latency to 3 cycles */
  99. orr x0, x0, #(CORTEX_A72_L2_DATA_RAM_LATENCY_3_CYCLES << \
  100. CORTEX_A72_L2CTLR_DATA_RAM_LATENCY_SHIFT)
  101. #endif
  102. /* Enable L2 ECC and parity with inline data */
  103. orr x0, x0, #CORTEX_A72_L2CTLR_EL1_ECC_AND_PARITY_ENABLE
  104. orr x0, x0, #CORTEX_A72_L2CTLR_EL1_DATA_INLINE_ECC_ENABLE
  105. msr CORTEX_A72_L2CTLR_EL1, x0
  106. mrs x0, CORTEX_A72_L2ACTLR_EL1
  107. /* Enable L2 UniqueClean evictions with data */
  108. orr x0, x0, #CORTEX_A72_L2ACTLR_ENABLE_UNIQUE_CLEAN
  109. msr CORTEX_A72_L2ACTLR_EL1, x0
  110. #if K3_EXCLUSIVE_SNOOP_DELAY
  111. mrs x0, CORTEX_A72_CPUACTLR_EL1
  112. /* Set Snoop-delayed exclusive handling */
  113. orr x0, x0, #CORTEX_A72_CPUACTLR_EL1_DELAY_EXCLUSIVE_SNOOP
  114. msr CORTEX_A72_CPUACTLR_EL1, x0
  115. #endif
  116. isb
  117. ret
  118. endfunc plat_reset_handler
  119. /* ---------------------------------------------
  120. * int plat_crash_console_init(void)
  121. * Function to initialize the crash console
  122. * without a C Runtime to print crash report.
  123. * Clobber list : x0 - x4
  124. * ---------------------------------------------
  125. */
  126. .globl plat_crash_console_init
  127. func plat_crash_console_init
  128. mov_imm x0, CRASH_CONSOLE_BASE
  129. mov_imm x1, CRASH_CONSOLE_CLK
  130. mov_imm x2, CRASH_CONSOLE_BAUD_RATE
  131. mov w3, #0x0
  132. b console_16550_core_init
  133. endfunc plat_crash_console_init
  134. /* ---------------------------------------------
  135. * int plat_crash_console_putc(void)
  136. * Function to print a character on the crash
  137. * console without a C Runtime.
  138. * Clobber list : x1, x2
  139. * ---------------------------------------------
  140. */
  141. .globl plat_crash_console_putc
  142. func plat_crash_console_putc
  143. mov_imm x1, CRASH_CONSOLE_BASE
  144. b console_16550_core_putc
  145. endfunc plat_crash_console_putc
  146. /* ---------------------------------------------
  147. * void plat_crash_console_flush()
  148. * Function to force a write of all buffered
  149. * data that hasn't been output.
  150. * Out : void.
  151. * Clobber list : x0, x1
  152. * ---------------------------------------------
  153. */
  154. .globl plat_crash_console_flush
  155. func plat_crash_console_flush
  156. mov_imm x0, CRASH_CONSOLE_BASE
  157. b console_16550_core_flush
  158. endfunc plat_crash_console_flush