cortex_a510.S 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * Copyright (c) 2023-2024, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <asm_macros.S>
  8. #include <common/bl_common.h>
  9. #include <cortex_a510.h>
  10. #include <cpu_macros.S>
  11. #include <plat_macros.S>
  12. /* Hardware handled coherency */
  13. #if HW_ASSISTED_COHERENCY == 0
  14. #error "Cortex-A510 must be compiled with HW_ASSISTED_COHERENCY enabled"
  15. #endif
  16. /* 64-bit only core */
  17. #if CTX_INCLUDE_AARCH32_REGS == 1
  18. #error "Cortex-A510 supports only AArch64. Compile with CTX_INCLUDE_AARCH32_REGS=0"
  19. #endif
  20. workaround_reset_start cortex_a510, ERRATUM(1922240), ERRATA_A510_1922240
  21. /* Apply the workaround by setting IMP_CMPXACTLR_EL1[11:10] = 0b11. */
  22. sysreg_bitfield_insert CORTEX_A510_CMPXACTLR_EL1, CORTEX_A510_CMPXACTLR_EL1_SNPPREFERUNIQUE_DISABLE, \
  23. CORTEX_A510_CMPXACTLR_EL1_SNPPREFERUNIQUE_SHIFT, CORTEX_A510_CMPXACTLR_EL1_SNPPREFERUNIQUE_WIDTH
  24. workaround_reset_end cortex_a510, ERRATUM(1922240)
  25. check_erratum_ls cortex_a510, ERRATUM(1922240), CPU_REV(0, 0)
  26. workaround_reset_start cortex_a510, ERRATUM(2041909), ERRATA_A510_2041909
  27. /* Apply workaround */
  28. mov x0, xzr
  29. msr S3_6_C15_C4_0, x0
  30. isb
  31. mov x0, #0x8500000
  32. msr S3_6_C15_C4_2, x0
  33. mov x0, #0x1F700000
  34. movk x0, #0x8, lsl #32
  35. msr S3_6_C15_C4_3, x0
  36. mov x0, #0x3F1
  37. movk x0, #0x110, lsl #16
  38. msr S3_6_C15_C4_1, x0
  39. workaround_reset_end cortex_a510, ERRATUM(2041909)
  40. check_erratum_range cortex_a510, ERRATUM(2041909), CPU_REV(0, 2), CPU_REV(0, 2)
  41. workaround_reset_start cortex_a510, ERRATUM(2042739), ERRATA_A510_2042739
  42. /* Apply the workaround by disabling ReadPreferUnique. */
  43. sysreg_bitfield_insert CORTEX_A510_CPUECTLR_EL1, CORTEX_A510_CPUECTLR_EL1_READPREFERUNIQUE_DISABLE, \
  44. CORTEX_A510_CPUECTLR_EL1_READPREFERUNIQUE_SHIFT, CORTEX_A510_CPUECTLR_EL1_READPREFERUNIQUE_WIDTH
  45. workaround_reset_end cortex_a510, ERRATUM(2042739)
  46. check_erratum_ls cortex_a510, ERRATUM(2042739), CPU_REV(0, 2)
  47. workaround_reset_start cortex_a510, ERRATUM(2080326), ERRATA_A510_2080326
  48. /* Apply workaround */
  49. mov x0, #1
  50. msr S3_6_C15_C4_0, x0
  51. isb
  52. mov x0, #0x0100
  53. movk x0, #0x0E08, lsl #16
  54. msr S3_6_C15_C4_2, x0
  55. mov x0, #0x0300
  56. movk x0, #0x0F1F, lsl #16
  57. movk x0, #0x0008, lsl #32
  58. msr S3_6_C15_C4_3, x0
  59. mov x0, #0x03F1
  60. movk x0, #0x00C0, lsl #16
  61. msr S3_6_C15_C4_1, x0
  62. isb
  63. workaround_reset_end cortex_a510, ERRATUM(2080326)
  64. check_erratum_range cortex_a510, ERRATUM(2080326), CPU_REV(0, 2), CPU_REV(0, 2)
  65. workaround_reset_start cortex_a510, ERRATUM(2172148), ERRATA_A510_2172148
  66. /*
  67. * Force L2 allocation of transient lines by setting
  68. * CPUECTLR_EL1.RSCTL=0b01 and CPUECTLR_EL1.NTCTL=0b01.
  69. */
  70. mrs x0, CORTEX_A510_CPUECTLR_EL1
  71. mov x1, #1
  72. bfi x0, x1, #CORTEX_A510_CPUECTLR_EL1_RSCTL_SHIFT, #2
  73. bfi x0, x1, #CORTEX_A510_CPUECTLR_EL1_NTCTL_SHIFT, #2
  74. msr CORTEX_A510_CPUECTLR_EL1, x0
  75. workaround_reset_end cortex_a510, ERRATUM(2172148)
  76. check_erratum_ls cortex_a510, ERRATUM(2172148), CPU_REV(1, 0)
  77. workaround_reset_start cortex_a510, ERRATUM(2218950), ERRATA_A510_2218950
  78. /* Set bit 18 in CPUACTLR_EL1 */
  79. sysreg_bitfield_insert CORTEX_A510_CPUACTLR_EL1, CORTEX_A510_CPUACTLR_EL1_ALIAS_LOADSTORE_DISABLE, \
  80. CORTEX_A510_CPUACTLR_EL1_ALIAS_LOADSTORE_SHIFT, CORTEX_A510_CPUACTLR_EL1_ALIAS_LOADSTORE_WIDTH
  81. /* Set bit 25 in CMPXACTLR_EL1 */
  82. sysreg_bitfield_insert CORTEX_A510_CMPXACTLR_EL1, CORTEX_A510_CMPXACTLR_EL1_ALIAS_LOADSTORE_DISABLE, \
  83. CORTEX_A510_CMPXACTLR_EL1_ALIAS_LOADSTORE_SHIFT, CORTEX_A510_CMPXACTLR_EL1_ALIAS_LOADSTORE_WIDTH
  84. workaround_reset_end cortex_a510, ERRATUM(2218950)
  85. check_erratum_ls cortex_a510, ERRATUM(2218950), CPU_REV(1, 0)
  86. /* --------------------------------------------------
  87. * This workaround is not a typical errata fix. MPMM
  88. * is disabled here, but this conflicts with the BL31
  89. * MPMM support. So in addition to simply disabling
  90. * the feature, a flag is set in the MPMM library
  91. * indicating that it should not be enabled even if
  92. * ENABLE_MPMM=1.
  93. * --------------------------------------------------
  94. */
  95. workaround_reset_start cortex_a510, ERRATUM(2250311), ERRATA_A510_2250311
  96. /* Disable MPMM */
  97. mrs x0, CPUMPMMCR_EL3
  98. bfm x0, xzr, #0, #0 /* bfc instruction does not work in GCC */
  99. msr CPUMPMMCR_EL3, x0
  100. #if ENABLE_MPMM && IMAGE_BL31
  101. /* If ENABLE_MPMM is set, tell the runtime lib to skip enabling it. */
  102. bl mpmm_errata_disable
  103. #endif
  104. workaround_reset_end cortex_a510, ERRATUM(2250311)
  105. check_erratum_ls cortex_a510, ERRATUM(2250311), CPU_REV(1, 0)
  106. workaround_reset_start cortex_a510, ERRATUM(2288014), ERRATA_A510_2288014
  107. /* Apply the workaround by setting IMP_CPUACTLR_EL1[18] = 0b1. */
  108. sysreg_bitfield_insert CORTEX_A510_CPUACTLR_EL1, CORTEX_A510_CPUACTLR_EL1_DATA_CORRUPT_DISABLE, \
  109. CORTEX_A510_CPUACTLR_EL1_DATA_CORRUPT_SHIFT, CORTEX_A510_CPUACTLR_EL1_DATA_CORRUPT_WIDTH
  110. workaround_reset_end cortex_a510, ERRATUM(2288014)
  111. check_erratum_ls cortex_a510, ERRATUM(2288014), CPU_REV(1, 0)
  112. workaround_reset_start cortex_a510, ERRATUM(2347730), ERRATA_A510_2347730
  113. /*
  114. * Set CPUACTLR_EL1[17] to 1'b1, which disables
  115. * specific microarchitectural clock gating
  116. * behaviour.
  117. */
  118. sysreg_bit_set CORTEX_A510_CPUACTLR_EL1, CORTEX_A510_CPUACTLR_EL1_BIT_17
  119. workaround_reset_end cortex_a510, ERRATUM(2347730)
  120. check_erratum_ls cortex_a510, ERRATUM(2347730), CPU_REV(1, 1)
  121. workaround_reset_start cortex_a510, ERRATUM(2371937), ERRATA_A510_2371937
  122. /*
  123. * Cacheable atomic operations can be forced
  124. * to be executed near by setting
  125. * IMP_CPUECTLR_EL1.ATOM=0b010. ATOM is found
  126. * in [40:38] of CPUECTLR_EL1.
  127. */
  128. sysreg_bitfield_insert CORTEX_A510_CPUECTLR_EL1, CORTEX_A510_CPUECTLR_EL1_ATOM_EXECALLINSTRNEAR, \
  129. CORTEX_A510_CPUECTLR_EL1_ATOM_SHIFT, CORTEX_A510_CPUECTLR_EL1_ATOM_WIDTH
  130. workaround_reset_end cortex_a510, ERRATUM(2371937)
  131. check_erratum_ls cortex_a510, ERRATUM(2371937), CPU_REV(1, 1)
  132. workaround_reset_start cortex_a510, ERRATUM(2666669), ERRATA_A510_2666669
  133. sysreg_bit_set CORTEX_A510_CPUACTLR_EL1, CORTEX_A510_CPUACTLR_EL1_BIT_38
  134. workaround_reset_end cortex_a510, ERRATUM(2666669)
  135. check_erratum_ls cortex_a510, ERRATUM(2666669), CPU_REV(1, 1)
  136. .global erratum_cortex_a510_2684597_wa
  137. workaround_runtime_start cortex_a510, ERRATUM(2684597), ERRATA_A510_2684597, CORTEX_A510_MIDR
  138. /*
  139. * Many assemblers do not yet understand the "tsb csync" mnemonic,
  140. * so use the equivalent hint instruction.
  141. */
  142. hint #18 /* tsb csync */
  143. workaround_runtime_end cortex_a510, ERRATUM(2684597)
  144. check_erratum_ls cortex_a510, ERRATUM(2684597), CPU_REV(1, 2)
  145. /*
  146. * ERRATA_DSU_2313941 :
  147. * The errata is defined in dsu_helpers.S but applies to cortex_a510
  148. * as well. Henceforth creating symbolic names to the already existing errata
  149. * workaround functions to get them registered under the Errata Framework.
  150. */
  151. .equ check_erratum_cortex_a510_2313941, check_errata_dsu_2313941
  152. .equ erratum_cortex_a510_2313941_wa, errata_dsu_2313941_wa
  153. add_erratum_entry cortex_a510, ERRATUM(2313941), ERRATA_DSU_2313941, APPLY_AT_RESET
  154. /* ----------------------------------------------------
  155. * HW will do the cache maintenance while powering down
  156. * ----------------------------------------------------
  157. */
  158. func cortex_a510_core_pwr_dwn
  159. /* ---------------------------------------------------
  160. * Enable CPU power down bit in power control register
  161. * ---------------------------------------------------
  162. */
  163. sysreg_bit_set CORTEX_A510_CPUPWRCTLR_EL1, CORTEX_A510_CPUPWRCTLR_EL1_CORE_PWRDN_BIT
  164. isb
  165. ret
  166. endfunc cortex_a510_core_pwr_dwn
  167. cpu_reset_func_start cortex_a510
  168. /* Disable speculative loads */
  169. msr SSBS, xzr
  170. cpu_reset_func_end cortex_a510
  171. /* ---------------------------------------------
  172. * This function provides Cortex-A510 specific
  173. * register information for crash reporting.
  174. * It needs to return with x6 pointing to
  175. * a list of register names in ascii and
  176. * x8 - x15 having values of registers to be
  177. * reported.
  178. * ---------------------------------------------
  179. */
  180. .section .rodata.cortex_a510_regs, "aS"
  181. cortex_a510_regs: /* The ascii list of register names to be reported */
  182. .asciz "cpuectlr_el1", ""
  183. func cortex_a510_cpu_reg_dump
  184. adr x6, cortex_a510_regs
  185. mrs x8, CORTEX_A510_CPUECTLR_EL1
  186. ret
  187. endfunc cortex_a510_cpu_reg_dump
  188. declare_cpu_ops cortex_a510, CORTEX_A510_MIDR, \
  189. cortex_a510_reset_func, \
  190. cortex_a510_core_pwr_dwn