cortex_a53.S 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. /*
  2. * Copyright (c) 2017-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 <assert_macros.S>
  9. #include <common/debug.h>
  10. #include <cortex_a53.h>
  11. #include <cpu_macros.S>
  12. #if A53_DISABLE_NON_TEMPORAL_HINT
  13. #undef ERRATA_A53_836870
  14. #define ERRATA_A53_836870 1
  15. #endif
  16. /* ---------------------------------------------
  17. * Disable intra-cluster coherency
  18. * ---------------------------------------------
  19. */
  20. func cortex_a53_disable_smp
  21. ldcopr16 r0, r1, CORTEX_A53_ECTLR
  22. bic64_imm r0, r1, CORTEX_A53_ECTLR_SMP_BIT
  23. stcopr16 r0, r1, CORTEX_A53_ECTLR
  24. isb
  25. dsb sy
  26. bx lr
  27. endfunc cortex_a53_disable_smp
  28. /* ---------------------------------------------------
  29. * Errata Workaround for Cortex A53 Errata #819472.
  30. * This applies only to revision <= r0p1 of Cortex A53.
  31. * ---------------------------------------------------
  32. */
  33. func check_errata_819472
  34. /*
  35. * Even though this is only needed for revision <= r0p1, it
  36. * is always applied due to limitations of the current
  37. * errata framework.
  38. */
  39. mov r0, #ERRATA_APPLIES
  40. bx lr
  41. endfunc check_errata_819472
  42. add_erratum_entry cortex_a53, ERRATUM(819472), ERRATA_A53_819472
  43. /* ---------------------------------------------------
  44. * Errata Workaround for Cortex A53 Errata #824069.
  45. * This applies only to revision <= r0p2 of Cortex A53.
  46. * ---------------------------------------------------
  47. */
  48. func check_errata_824069
  49. /*
  50. * Even though this is only needed for revision <= r0p2, it
  51. * is always applied due to limitations of the current
  52. * errata framework.
  53. */
  54. mov r0, #ERRATA_APPLIES
  55. bx lr
  56. endfunc check_errata_824069
  57. add_erratum_entry cortex_a53, ERRATUM(824069), ERRATA_A53_824069
  58. /* --------------------------------------------------
  59. * Errata Workaround for Cortex A53 Errata #826319.
  60. * This applies only to revision <= r0p2 of Cortex A53.
  61. * Inputs:
  62. * r0: variant[4:7] and revision[0:3] of current cpu.
  63. * Shall clobber: r0-r3
  64. * --------------------------------------------------
  65. */
  66. func errata_a53_826319_wa
  67. /*
  68. * Compare r0 against revision r0p2
  69. */
  70. mov r2, lr
  71. bl check_errata_826319
  72. mov lr, r2
  73. cmp r0, #ERRATA_NOT_APPLIES
  74. beq 1f
  75. ldcopr r0, CORTEX_A53_L2ACTLR
  76. bic r0, #CORTEX_A53_L2ACTLR_ENABLE_UNIQUECLEAN
  77. orr r0, #CORTEX_A53_L2ACTLR_DISABLE_CLEAN_PUSH
  78. stcopr r0, CORTEX_A53_L2ACTLR
  79. 1:
  80. bx lr
  81. endfunc errata_a53_826319_wa
  82. func check_errata_826319
  83. mov r1, #0x02
  84. b cpu_rev_var_ls
  85. endfunc check_errata_826319
  86. add_erratum_entry cortex_a53, ERRATUM(826319), ERRATA_A53_826319
  87. /* ---------------------------------------------------
  88. * Errata Workaround for Cortex A53 Errata #827319.
  89. * This applies only to revision <= r0p2 of Cortex A53.
  90. * ---------------------------------------------------
  91. */
  92. func check_errata_827319
  93. /*
  94. * Even though this is only needed for revision <= r0p2, it
  95. * is always applied due to limitations of the current
  96. * errata framework.
  97. */
  98. mov r0, #ERRATA_APPLIES
  99. bx lr
  100. endfunc check_errata_827319
  101. add_erratum_entry cortex_a53, ERRATUM(827319), ERRATA_A53_827319
  102. /* ---------------------------------------------------------------------
  103. * Disable the cache non-temporal hint.
  104. *
  105. * This ignores the Transient allocation hint in the MAIR and treats
  106. * allocations the same as non-transient allocation types. As a result,
  107. * the LDNP and STNP instructions in AArch64 behave the same as the
  108. * equivalent LDP and STP instructions.
  109. *
  110. * This is relevant only for revisions <= r0p3 of Cortex-A53.
  111. * From r0p4 and onwards, the bit to disable the hint is enabled by
  112. * default at reset.
  113. *
  114. * Inputs:
  115. * r0: variant[4:7] and revision[0:3] of current cpu.
  116. * Shall clobber: r0-r3
  117. * ---------------------------------------------------------------------
  118. */
  119. func a53_disable_non_temporal_hint
  120. /*
  121. * Compare r0 against revision r0p3
  122. */
  123. mov r2, lr
  124. bl check_errata_disable_non_temporal_hint
  125. mov lr, r2
  126. cmp r0, #ERRATA_NOT_APPLIES
  127. beq 1f
  128. ldcopr16 r0, r1, CORTEX_A53_CPUACTLR
  129. orr64_imm r0, r1, CORTEX_A53_CPUACTLR_DTAH
  130. stcopr16 r0, r1, CORTEX_A53_CPUACTLR
  131. 1:
  132. bx lr
  133. endfunc a53_disable_non_temporal_hint
  134. func check_errata_disable_non_temporal_hint
  135. mov r1, #0x03
  136. b cpu_rev_var_ls
  137. endfunc check_errata_disable_non_temporal_hint
  138. add_erratum_entry cortex_a53, ERRATUM(836870), ERRATA_A53_836870 | A53_DISABLE_NON_TEMPORAL_HINT, \
  139. disable_non_temporal_hint
  140. /* --------------------------------------------------
  141. * Errata Workaround for Cortex A53 Errata #855873.
  142. *
  143. * This applies only to revisions >= r0p3 of Cortex A53.
  144. * Earlier revisions of the core are affected as well, but don't
  145. * have the chicken bit in the CPUACTLR register. It is expected that
  146. * the rich OS takes care of that, especially as the workaround is
  147. * shared with other erratas in those revisions of the CPU.
  148. * Inputs:
  149. * r0: variant[4:7] and revision[0:3] of current cpu.
  150. * Shall clobber: r0-r3
  151. * --------------------------------------------------
  152. */
  153. func errata_a53_855873_wa
  154. /*
  155. * Compare r0 against revision r0p3 and higher
  156. */
  157. mov r2, lr
  158. bl check_errata_855873
  159. mov lr, r2
  160. cmp r0, #ERRATA_NOT_APPLIES
  161. beq 1f
  162. ldcopr16 r0, r1, CORTEX_A53_CPUACTLR
  163. orr64_imm r0, r1, CORTEX_A53_CPUACTLR_ENDCCASCI
  164. stcopr16 r0, r1, CORTEX_A53_CPUACTLR
  165. 1:
  166. bx lr
  167. endfunc errata_a53_855873_wa
  168. func check_errata_855873
  169. mov r1, #0x03
  170. b cpu_rev_var_hs
  171. endfunc check_errata_855873
  172. add_erratum_entry cortex_a53, ERRATUM(855873), ERRATA_A53_855873
  173. /* -------------------------------------------------
  174. * The CPU Ops reset function for Cortex-A53.
  175. * Shall clobber: r0-r6
  176. * -------------------------------------------------
  177. */
  178. func cortex_a53_reset_func
  179. mov r5, lr
  180. bl cpu_get_rev_var
  181. mov r4, r0
  182. #if ERRATA_A53_826319
  183. mov r0, r4
  184. bl errata_a53_826319_wa
  185. #endif
  186. #if ERRATA_A53_836870
  187. mov r0, r4
  188. bl a53_disable_non_temporal_hint
  189. #endif
  190. #if ERRATA_A53_855873
  191. mov r0, r4
  192. bl errata_a53_855873_wa
  193. #endif
  194. /* ---------------------------------------------
  195. * Enable the SMP bit.
  196. * ---------------------------------------------
  197. */
  198. ldcopr16 r0, r1, CORTEX_A53_ECTLR
  199. orr64_imm r0, r1, CORTEX_A53_ECTLR_SMP_BIT
  200. stcopr16 r0, r1, CORTEX_A53_ECTLR
  201. isb
  202. bx r5
  203. endfunc cortex_a53_reset_func
  204. /* ----------------------------------------------------
  205. * The CPU Ops core power down function for Cortex-A53.
  206. * ----------------------------------------------------
  207. */
  208. func cortex_a53_core_pwr_dwn
  209. push {r12, lr}
  210. /* Assert if cache is enabled */
  211. #if ENABLE_ASSERTIONS
  212. ldcopr r0, SCTLR
  213. tst r0, #SCTLR_C_BIT
  214. ASM_ASSERT(eq)
  215. #endif
  216. /* ---------------------------------------------
  217. * Flush L1 caches.
  218. * ---------------------------------------------
  219. */
  220. mov r0, #DC_OP_CISW
  221. bl dcsw_op_level1
  222. /* ---------------------------------------------
  223. * Come out of intra cluster coherency
  224. * ---------------------------------------------
  225. */
  226. pop {r12, lr}
  227. b cortex_a53_disable_smp
  228. endfunc cortex_a53_core_pwr_dwn
  229. /* -------------------------------------------------------
  230. * The CPU Ops cluster power down function for Cortex-A53.
  231. * Clobbers: r0-r3
  232. * -------------------------------------------------------
  233. */
  234. func cortex_a53_cluster_pwr_dwn
  235. push {r12, lr}
  236. /* Assert if cache is enabled */
  237. #if ENABLE_ASSERTIONS
  238. ldcopr r0, SCTLR
  239. tst r0, #SCTLR_C_BIT
  240. ASM_ASSERT(eq)
  241. #endif
  242. /* ---------------------------------------------
  243. * Flush L1 caches.
  244. * ---------------------------------------------
  245. */
  246. mov r0, #DC_OP_CISW
  247. bl dcsw_op_level1
  248. /* ---------------------------------------------
  249. * Disable the optional ACP.
  250. * ---------------------------------------------
  251. */
  252. bl plat_disable_acp
  253. /* ---------------------------------------------
  254. * Flush L2 caches.
  255. * ---------------------------------------------
  256. */
  257. mov r0, #DC_OP_CISW
  258. bl dcsw_op_level2
  259. /* ---------------------------------------------
  260. * Come out of intra cluster coherency
  261. * ---------------------------------------------
  262. */
  263. pop {r12, lr}
  264. b cortex_a53_disable_smp
  265. endfunc cortex_a53_cluster_pwr_dwn
  266. declare_cpu_ops cortex_a53, CORTEX_A53_MIDR, \
  267. cortex_a53_reset_func, \
  268. cortex_a53_core_pwr_dwn, \
  269. cortex_a53_cluster_pwr_dwn