cortex_a72.S 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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_a72.h>
  11. #include <cpu_macros.S>
  12. /* ---------------------------------------------
  13. * Disable all types of L2 prefetches.
  14. * ---------------------------------------------
  15. */
  16. func cortex_a72_disable_l2_prefetch
  17. ldcopr16 r0, r1, CORTEX_A72_ECTLR
  18. orr64_imm r0, r1, CORTEX_A72_ECTLR_DIS_TWD_ACC_PFTCH_BIT
  19. bic64_imm r0, r1, (CORTEX_A72_ECTLR_L2_IPFTCH_DIST_MASK | \
  20. CORTEX_A72_ECTLR_L2_DPFTCH_DIST_MASK)
  21. stcopr16 r0, r1, CORTEX_A72_ECTLR
  22. isb
  23. bx lr
  24. endfunc cortex_a72_disable_l2_prefetch
  25. /* ---------------------------------------------
  26. * Disable the load-store hardware prefetcher.
  27. * ---------------------------------------------
  28. */
  29. func cortex_a72_disable_hw_prefetcher
  30. ldcopr16 r0, r1, CORTEX_A72_CPUACTLR
  31. orr64_imm r0, r1, CORTEX_A72_CPUACTLR_DISABLE_L1_DCACHE_HW_PFTCH
  32. stcopr16 r0, r1, CORTEX_A72_CPUACTLR
  33. isb
  34. dsb ish
  35. bx lr
  36. endfunc cortex_a72_disable_hw_prefetcher
  37. /* ---------------------------------------------
  38. * Disable intra-cluster coherency
  39. * Clobbers: r0-r1
  40. * ---------------------------------------------
  41. */
  42. func cortex_a72_disable_smp
  43. ldcopr16 r0, r1, CORTEX_A72_ECTLR
  44. bic64_imm r0, r1, CORTEX_A72_ECTLR_SMP_BIT
  45. stcopr16 r0, r1, CORTEX_A72_ECTLR
  46. bx lr
  47. endfunc cortex_a72_disable_smp
  48. /* ---------------------------------------------
  49. * Disable debug interfaces
  50. * ---------------------------------------------
  51. */
  52. func cortex_a72_disable_ext_debug
  53. mov r0, #1
  54. stcopr r0, DBGOSDLR
  55. isb
  56. dsb sy
  57. bx lr
  58. endfunc cortex_a72_disable_ext_debug
  59. /* ---------------------------------------------------
  60. * Errata Workaround for Cortex A72 Errata #859971.
  61. * This applies only to revision <= r0p3 of Cortex A72.
  62. * Inputs:
  63. * r0: variant[4:7] and revision[0:3] of current cpu.
  64. * Shall clobber: r0-r3
  65. * ---------------------------------------------------
  66. */
  67. func errata_a72_859971_wa
  68. mov r2,lr
  69. bl check_errata_859971
  70. mov lr, r2
  71. cmp r0, #ERRATA_NOT_APPLIES
  72. beq 1f
  73. ldcopr16 r0, r1, CORTEX_A72_CPUACTLR
  74. orr64_imm r1, r1, CORTEX_A72_CPUACTLR_DIS_INSTR_PREFETCH
  75. stcopr16 r0, r1, CORTEX_A72_CPUACTLR
  76. 1:
  77. bx lr
  78. endfunc errata_a72_859971_wa
  79. func check_errata_859971
  80. mov r1, #0x03
  81. b cpu_rev_var_ls
  82. endfunc check_errata_859971
  83. add_erratum_entry cortex_a72, ERRATUM(859971), ERRATA_A72_859971
  84. func check_errata_cve_2017_5715
  85. mov r0, #ERRATA_MISSING
  86. bx lr
  87. endfunc check_errata_cve_2017_5715
  88. add_erratum_entry cortex_a72, CVE(2017, 5715), WORKAROUND_CVE_2017_5715
  89. func check_errata_cve_2018_3639
  90. #if WORKAROUND_CVE_2018_3639
  91. mov r0, #ERRATA_APPLIES
  92. #else
  93. mov r0, #ERRATA_MISSING
  94. #endif
  95. bx lr
  96. endfunc check_errata_cve_2018_3639
  97. add_erratum_entry cortex_a72, CVE(2018, 3639), WORKAROUND_CVE_2018_3639
  98. func check_errata_cve_2022_23960
  99. mov r0, #ERRATA_MISSING
  100. bx lr
  101. endfunc check_errata_cve_2022_23960
  102. add_erratum_entry cortex_a72, CVE(2022, 23960), WORKAROUND_CVE_2022_23960
  103. /* -------------------------------------------------
  104. * The CPU Ops reset function for Cortex-A72.
  105. * -------------------------------------------------
  106. */
  107. func cortex_a72_reset_func
  108. mov r5, lr
  109. bl cpu_get_rev_var
  110. mov r4, r0
  111. #if ERRATA_A72_859971
  112. mov r0, r4
  113. bl errata_a72_859971_wa
  114. #endif
  115. #if WORKAROUND_CVE_2018_3639
  116. ldcopr16 r0, r1, CORTEX_A72_CPUACTLR
  117. orr64_imm r0, r1, CORTEX_A72_CPUACTLR_DIS_LOAD_PASS_STORE
  118. stcopr16 r0, r1, CORTEX_A72_CPUACTLR
  119. isb
  120. dsb sy
  121. #endif
  122. /* ---------------------------------------------
  123. * Enable the SMP bit.
  124. * ---------------------------------------------
  125. */
  126. ldcopr16 r0, r1, CORTEX_A72_ECTLR
  127. orr64_imm r0, r1, CORTEX_A72_ECTLR_SMP_BIT
  128. stcopr16 r0, r1, CORTEX_A72_ECTLR
  129. isb
  130. bx r5
  131. endfunc cortex_a72_reset_func
  132. /* ----------------------------------------------------
  133. * The CPU Ops core power down function for Cortex-A72.
  134. * ----------------------------------------------------
  135. */
  136. func cortex_a72_core_pwr_dwn
  137. push {r12, lr}
  138. /* Assert if cache is enabled */
  139. #if ENABLE_ASSERTIONS
  140. ldcopr r0, SCTLR
  141. tst r0, #SCTLR_C_BIT
  142. ASM_ASSERT(eq)
  143. #endif
  144. /* ---------------------------------------------
  145. * Disable the L2 prefetches.
  146. * ---------------------------------------------
  147. */
  148. bl cortex_a72_disable_l2_prefetch
  149. /* ---------------------------------------------
  150. * Disable the load-store hardware prefetcher.
  151. * ---------------------------------------------
  152. */
  153. bl cortex_a72_disable_hw_prefetcher
  154. /* ---------------------------------------------
  155. * Flush L1 caches.
  156. * ---------------------------------------------
  157. */
  158. mov r0, #DC_OP_CISW
  159. bl dcsw_op_level1
  160. /* ---------------------------------------------
  161. * Come out of intra cluster coherency
  162. * ---------------------------------------------
  163. */
  164. bl cortex_a72_disable_smp
  165. /* ---------------------------------------------
  166. * Force the debug interfaces to be quiescent
  167. * ---------------------------------------------
  168. */
  169. pop {r12, lr}
  170. b cortex_a72_disable_ext_debug
  171. endfunc cortex_a72_core_pwr_dwn
  172. /* -------------------------------------------------------
  173. * The CPU Ops cluster power down function for Cortex-A72.
  174. * -------------------------------------------------------
  175. */
  176. func cortex_a72_cluster_pwr_dwn
  177. push {r12, lr}
  178. /* Assert if cache is enabled */
  179. #if ENABLE_ASSERTIONS
  180. ldcopr r0, SCTLR
  181. tst r0, #SCTLR_C_BIT
  182. ASM_ASSERT(eq)
  183. #endif
  184. /* ---------------------------------------------
  185. * Disable the L2 prefetches.
  186. * ---------------------------------------------
  187. */
  188. bl cortex_a72_disable_l2_prefetch
  189. /* ---------------------------------------------
  190. * Disable the load-store hardware prefetcher.
  191. * ---------------------------------------------
  192. */
  193. bl cortex_a72_disable_hw_prefetcher
  194. #if !SKIP_A72_L1_FLUSH_PWR_DWN
  195. /* ---------------------------------------------
  196. * Flush L1 caches.
  197. * ---------------------------------------------
  198. */
  199. mov r0, #DC_OP_CISW
  200. bl dcsw_op_level1
  201. #endif
  202. /* ---------------------------------------------
  203. * Disable the optional ACP.
  204. * ---------------------------------------------
  205. */
  206. bl plat_disable_acp
  207. /* -------------------------------------------------
  208. * Flush the L2 caches.
  209. * -------------------------------------------------
  210. */
  211. mov r0, #DC_OP_CISW
  212. bl dcsw_op_level2
  213. /* ---------------------------------------------
  214. * Come out of intra cluster coherency
  215. * ---------------------------------------------
  216. */
  217. bl cortex_a72_disable_smp
  218. /* ---------------------------------------------
  219. * Force the debug interfaces to be quiescent
  220. * ---------------------------------------------
  221. */
  222. pop {r12, lr}
  223. b cortex_a72_disable_ext_debug
  224. endfunc cortex_a72_cluster_pwr_dwn
  225. declare_cpu_ops cortex_a72, CORTEX_A72_MIDR, \
  226. cortex_a72_reset_func, \
  227. cortex_a72_core_pwr_dwn, \
  228. cortex_a72_cluster_pwr_dwn