cortex_a53.S 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. * Copyright (c) 2014-2024, 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 <common/bl_common.h>
  9. #include <common/debug.h>
  10. #include <cortex_a53.h>
  11. #include <cpu_macros.S>
  12. #include <plat_macros.S>
  13. #include <lib/cpus/errata.h>
  14. /* ---------------------------------------------
  15. * Disable L1 data cache and unified L2 cache
  16. * ---------------------------------------------
  17. */
  18. func cortex_a53_disable_dcache
  19. sysreg_bit_clear sctlr_el3, SCTLR_C_BIT
  20. isb
  21. ret
  22. endfunc cortex_a53_disable_dcache
  23. /* ---------------------------------------------
  24. * Disable intra-cluster coherency
  25. * ---------------------------------------------
  26. */
  27. func cortex_a53_disable_smp
  28. sysreg_bit_clear CORTEX_A53_ECTLR_EL1, CORTEX_A53_ECTLR_SMP_BIT
  29. isb
  30. dsb sy
  31. ret
  32. endfunc cortex_a53_disable_smp
  33. /* Due to the nature of the errata it is applied unconditionally when chosen */
  34. check_erratum_ls cortex_a53, ERRATUM(819472), CPU_REV(0, 1)
  35. /* erratum workaround is interleaved with generic code */
  36. add_erratum_entry cortex_a53, ERRATUM(819472), ERRATUM_ALWAYS_CHOSEN, NO_APPLY_AT_RESET
  37. /* Due to the nature of the errata it is applied unconditionally when chosen */
  38. check_erratum_ls cortex_a53, ERRATUM(824069), CPU_REV(0, 2)
  39. /* erratum workaround is interleaved with generic code */
  40. add_erratum_entry cortex_a53, ERRATUM(824069), ERRATUM_ALWAYS_CHOSEN, NO_APPLY_AT_RESET
  41. workaround_reset_start cortex_a53, ERRATUM(826319), ERRATA_A53_826319
  42. mrs x1, CORTEX_A53_L2ACTLR_EL1
  43. bic x1, x1, #CORTEX_A53_L2ACTLR_ENABLE_UNIQUECLEAN
  44. orr x1, x1, #CORTEX_A53_L2ACTLR_DISABLE_CLEAN_PUSH
  45. msr CORTEX_A53_L2ACTLR_EL1, x1
  46. workaround_reset_end cortex_a53, ERRATUM(826319)
  47. check_erratum_ls cortex_a53, ERRATUM(826319), CPU_REV(0, 2)
  48. /* Due to the nature of the errata it is applied unconditionally when chosen */
  49. check_erratum_ls cortex_a53, ERRATUM(827319), CPU_REV(0, 2)
  50. /* erratum workaround is interleaved with generic code */
  51. add_erratum_entry cortex_a53, ERRATUM(827319), ERRATUM_ALWAYS_CHOSEN, NO_APPLY_AT_RESET
  52. check_erratum_custom_start cortex_a53, ERRATUM(835769)
  53. cmp x0, CPU_REV(0, 4)
  54. b.hi errata_not_applies
  55. /*
  56. * Fix potentially available for revisions r0p2, r0p3 and r0p4.
  57. * If r0p2, r0p3 or r0p4; check for fix in REVIDR, else exit.
  58. */
  59. cmp x0, #0x01
  60. mov x0, #ERRATA_APPLIES
  61. b.ls exit_check_errata_835769
  62. /* Load REVIDR. */
  63. mrs x1, revidr_el1
  64. /* If REVIDR[7] is set (fix exists) set ERRATA_NOT_APPLIES, else exit. */
  65. tbz x1, #7, exit_check_errata_835769
  66. errata_not_applies:
  67. mov x0, #ERRATA_NOT_APPLIES
  68. exit_check_errata_835769:
  69. ret
  70. check_erratum_custom_end cortex_a53, ERRATUM(835769)
  71. /* workaround at build time */
  72. add_erratum_entry cortex_a53, ERRATUM(835769), ERRATA_A53_835769, NO_APPLY_AT_RESET
  73. /*
  74. * Disable the cache non-temporal hint.
  75. *
  76. * This ignores the Transient allocation hint in the MAIR and treats
  77. * allocations the same as non-transient allocation types. As a result,
  78. * the LDNP and STNP instructions in AArch64 behave the same as the
  79. * equivalent LDP and STP instructions.
  80. */
  81. workaround_reset_start cortex_a53, ERRATUM(836870), ERRATA_A53_836870 | A53_DISABLE_NON_TEMPORAL_HINT
  82. sysreg_bit_set CORTEX_A53_CPUACTLR_EL1, CORTEX_A53_CPUACTLR_EL1_DTAH
  83. workaround_reset_end cortex_a53, ERRATUM(836870)
  84. check_erratum_ls cortex_a53, ERRATUM(836870), CPU_REV(0, 3)
  85. check_erratum_custom_start cortex_a53, ERRATUM(843419)
  86. mov x1, #ERRATA_APPLIES
  87. mov x2, #ERRATA_NOT_APPLIES
  88. cmp x0, CPU_REV(0, 4)
  89. csel x0, x1, x2, ls
  90. /*
  91. * Fix potentially available for revision r0p4.
  92. * If r0p4 check for fix in REVIDR, else exit.
  93. */
  94. b.ne exit_check_errata_843419
  95. /* Load REVIDR. */
  96. mrs x3, revidr_el1
  97. /* If REVIDR[8] is set (fix exists) set ERRATA_NOT_APPLIES, else exit. */
  98. tbz x3, #8, exit_check_errata_843419
  99. mov x0, x2
  100. exit_check_errata_843419:
  101. ret
  102. check_erratum_custom_end cortex_a53, ERRATUM(843419)
  103. /* workaround at build time */
  104. add_erratum_entry cortex_a53, ERRATUM(843419), ERRATA_A53_843419, NO_APPLY_AT_RESET
  105. /*
  106. * Earlier revisions of the core are affected as well, but don't
  107. * have the chicken bit in the CPUACTLR register. It is expected that
  108. * the rich OS takes care of that, especially as the workaround is
  109. * shared with other erratas in those revisions of the CPU.
  110. */
  111. workaround_reset_start cortex_a53, ERRATUM(855873), ERRATA_A53_855873
  112. sysreg_bit_set CORTEX_A53_CPUACTLR_EL1, CORTEX_A53_CPUACTLR_EL1_ENDCCASCI
  113. workaround_reset_end cortex_a53, ERRATUM(855873)
  114. check_erratum_hs cortex_a53, ERRATUM(855873), CPU_REV(0, 3)
  115. check_erratum_chosen cortex_a53, ERRATUM(1530924), ERRATA_A53_1530924
  116. /* erratum has no workaround in the cpu. Generic code must take care */
  117. add_erratum_entry cortex_a53, ERRATUM(1530924), ERRATA_A53_1530924, NO_APPLY_AT_RESET
  118. cpu_reset_func_start cortex_a53
  119. /* Enable the SMP bit. */
  120. sysreg_bit_set CORTEX_A53_ECTLR_EL1, CORTEX_A53_ECTLR_SMP_BIT
  121. cpu_reset_func_end cortex_a53
  122. func cortex_a53_core_pwr_dwn
  123. mov x18, x30
  124. /* ---------------------------------------------
  125. * Turn off caches.
  126. * ---------------------------------------------
  127. */
  128. bl cortex_a53_disable_dcache
  129. /* ---------------------------------------------
  130. * Flush L1 caches.
  131. * ---------------------------------------------
  132. */
  133. mov x0, #DCCISW
  134. bl dcsw_op_level1
  135. /* ---------------------------------------------
  136. * Come out of intra cluster coherency
  137. * ---------------------------------------------
  138. */
  139. mov x30, x18
  140. b cortex_a53_disable_smp
  141. endfunc cortex_a53_core_pwr_dwn
  142. func cortex_a53_cluster_pwr_dwn
  143. mov x18, x30
  144. /* ---------------------------------------------
  145. * Turn off caches.
  146. * ---------------------------------------------
  147. */
  148. bl cortex_a53_disable_dcache
  149. /* ---------------------------------------------
  150. * Flush L1 caches.
  151. * ---------------------------------------------
  152. */
  153. mov x0, #DCCISW
  154. bl dcsw_op_level1
  155. /* ---------------------------------------------
  156. * Disable the optional ACP.
  157. * ---------------------------------------------
  158. */
  159. bl plat_disable_acp
  160. /* ---------------------------------------------
  161. * Flush L2 caches.
  162. * ---------------------------------------------
  163. */
  164. mov x0, #DCCISW
  165. bl dcsw_op_level2
  166. /* ---------------------------------------------
  167. * Come out of intra cluster coherency
  168. * ---------------------------------------------
  169. */
  170. mov x30, x18
  171. b cortex_a53_disable_smp
  172. endfunc cortex_a53_cluster_pwr_dwn
  173. /* ---------------------------------------------
  174. * This function provides cortex_a53 specific
  175. * register information for crash reporting.
  176. * It needs to return with x6 pointing to
  177. * a list of register names in ascii and
  178. * x8 - x15 having values of registers to be
  179. * reported.
  180. * ---------------------------------------------
  181. */
  182. .section .rodata.cortex_a53_regs, "aS"
  183. cortex_a53_regs: /* The ascii list of register names to be reported */
  184. .asciz "cpuectlr_el1", "cpumerrsr_el1", "l2merrsr_el1", \
  185. "cpuactlr_el1", ""
  186. func cortex_a53_cpu_reg_dump
  187. adr x6, cortex_a53_regs
  188. mrs x8, CORTEX_A53_ECTLR_EL1
  189. mrs x9, CORTEX_A53_MERRSR_EL1
  190. mrs x10, CORTEX_A53_L2MERRSR_EL1
  191. mrs x11, CORTEX_A53_CPUACTLR_EL1
  192. ret
  193. endfunc cortex_a53_cpu_reg_dump
  194. declare_cpu_ops cortex_a53, CORTEX_A53_MIDR, \
  195. cortex_a53_reset_func, \
  196. cortex_a53_core_pwr_dwn, \
  197. cortex_a53_cluster_pwr_dwn