cortex_a72.S 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /*
  2. * Copyright (c) 2015-2018, 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 <cortex_a72.h>
  10. #include <cpu_macros.S>
  11. #include <plat_macros.S>
  12. /* ---------------------------------------------
  13. * Disable L1 data cache and unified L2 cache
  14. * ---------------------------------------------
  15. */
  16. func cortex_a72_disable_dcache
  17. mrs x1, sctlr_el3
  18. bic x1, x1, #SCTLR_C_BIT
  19. msr sctlr_el3, x1
  20. isb
  21. ret
  22. endfunc cortex_a72_disable_dcache
  23. /* ---------------------------------------------
  24. * Disable all types of L2 prefetches.
  25. * ---------------------------------------------
  26. */
  27. func cortex_a72_disable_l2_prefetch
  28. mrs x0, CORTEX_A72_ECTLR_EL1
  29. orr x0, x0, #CORTEX_A72_ECTLR_DIS_TWD_ACC_PFTCH_BIT
  30. mov x1, #CORTEX_A72_ECTLR_L2_IPFTCH_DIST_MASK
  31. orr x1, x1, #CORTEX_A72_ECTLR_L2_DPFTCH_DIST_MASK
  32. bic x0, x0, x1
  33. msr CORTEX_A72_ECTLR_EL1, x0
  34. isb
  35. ret
  36. endfunc cortex_a72_disable_l2_prefetch
  37. /* ---------------------------------------------
  38. * Disable the load-store hardware prefetcher.
  39. * ---------------------------------------------
  40. */
  41. func cortex_a72_disable_hw_prefetcher
  42. mrs x0, CORTEX_A72_CPUACTLR_EL1
  43. orr x0, x0, #CORTEX_A72_CPUACTLR_EL1_DISABLE_L1_DCACHE_HW_PFTCH
  44. msr CORTEX_A72_CPUACTLR_EL1, x0
  45. isb
  46. dsb ish
  47. ret
  48. endfunc cortex_a72_disable_hw_prefetcher
  49. /* ---------------------------------------------
  50. * Disable intra-cluster coherency
  51. * ---------------------------------------------
  52. */
  53. func cortex_a72_disable_smp
  54. mrs x0, CORTEX_A72_ECTLR_EL1
  55. bic x0, x0, #CORTEX_A72_ECTLR_SMP_BIT
  56. msr CORTEX_A72_ECTLR_EL1, x0
  57. ret
  58. endfunc cortex_a72_disable_smp
  59. /* ---------------------------------------------
  60. * Disable debug interfaces
  61. * ---------------------------------------------
  62. */
  63. func cortex_a72_disable_ext_debug
  64. mov x0, #1
  65. msr osdlr_el1, x0
  66. isb
  67. dsb sy
  68. ret
  69. endfunc cortex_a72_disable_ext_debug
  70. /* --------------------------------------------------
  71. * Errata Workaround for Cortex A72 Errata #859971.
  72. * This applies only to revision <= r0p3 of Cortex A72.
  73. * Inputs:
  74. * x0: variant[4:7] and revision[0:3] of current cpu.
  75. * Shall clobber:
  76. * --------------------------------------------------
  77. */
  78. func errata_a72_859971_wa
  79. mov x17,x30
  80. bl check_errata_859971
  81. cbz x0, 1f
  82. mrs x1, CORTEX_A72_CPUACTLR_EL1
  83. orr x1, x1, #CORTEX_A72_CPUACTLR_EL1_DIS_INSTR_PREFETCH
  84. msr CORTEX_A72_CPUACTLR_EL1, x1
  85. 1:
  86. ret x17
  87. endfunc errata_a72_859971_wa
  88. func check_errata_859971
  89. mov x1, #0x03
  90. b cpu_rev_var_ls
  91. endfunc check_errata_859971
  92. func check_errata_cve_2017_5715
  93. cpu_check_csv2 x0, 1f
  94. #if WORKAROUND_CVE_2017_5715
  95. mov x0, #ERRATA_APPLIES
  96. #else
  97. mov x0, #ERRATA_MISSING
  98. #endif
  99. ret
  100. 1:
  101. mov x0, #ERRATA_NOT_APPLIES
  102. ret
  103. endfunc check_errata_cve_2017_5715
  104. /* -------------------------------------------------
  105. * The CPU Ops reset function for Cortex-A72.
  106. * -------------------------------------------------
  107. */
  108. func cortex_a72_reset_func
  109. mov x19, x30
  110. bl cpu_get_rev_var
  111. mov x18, x0
  112. #if ERRATA_A72_859971
  113. mov x0, x18
  114. bl errata_a72_859971_wa
  115. #endif
  116. #if IMAGE_BL31 && WORKAROUND_CVE_2017_5715
  117. cpu_check_csv2 x0, 1f
  118. adr x0, workaround_mmu_runtime_exceptions
  119. msr vbar_el3, x0
  120. 1:
  121. #endif
  122. /* ---------------------------------------------
  123. * Enable the SMP bit.
  124. * ---------------------------------------------
  125. */
  126. mrs x0, CORTEX_A72_ECTLR_EL1
  127. orr x0, x0, #CORTEX_A72_ECTLR_SMP_BIT
  128. msr CORTEX_A72_ECTLR_EL1, x0
  129. isb
  130. ret x19
  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. mov x18, x30
  138. /* ---------------------------------------------
  139. * Turn off caches.
  140. * ---------------------------------------------
  141. */
  142. bl cortex_a72_disable_dcache
  143. /* ---------------------------------------------
  144. * Disable the L2 prefetches.
  145. * ---------------------------------------------
  146. */
  147. bl cortex_a72_disable_l2_prefetch
  148. /* ---------------------------------------------
  149. * Disable the load-store hardware prefetcher.
  150. * ---------------------------------------------
  151. */
  152. bl cortex_a72_disable_hw_prefetcher
  153. /* ---------------------------------------------
  154. * Flush L1 caches.
  155. * ---------------------------------------------
  156. */
  157. mov x0, #DCCISW
  158. bl dcsw_op_level1
  159. /* ---------------------------------------------
  160. * Come out of intra cluster coherency
  161. * ---------------------------------------------
  162. */
  163. bl cortex_a72_disable_smp
  164. /* ---------------------------------------------
  165. * Force the debug interfaces to be quiescent
  166. * ---------------------------------------------
  167. */
  168. mov x30, x18
  169. b cortex_a72_disable_ext_debug
  170. endfunc cortex_a72_core_pwr_dwn
  171. /* -------------------------------------------------------
  172. * The CPU Ops cluster power down function for Cortex-A72.
  173. * -------------------------------------------------------
  174. */
  175. func cortex_a72_cluster_pwr_dwn
  176. mov x18, x30
  177. /* ---------------------------------------------
  178. * Turn off caches.
  179. * ---------------------------------------------
  180. */
  181. bl cortex_a72_disable_dcache
  182. /* ---------------------------------------------
  183. * Disable the L2 prefetches.
  184. * ---------------------------------------------
  185. */
  186. bl cortex_a72_disable_l2_prefetch
  187. /* ---------------------------------------------
  188. * Disable the load-store hardware prefetcher.
  189. * ---------------------------------------------
  190. */
  191. bl cortex_a72_disable_hw_prefetcher
  192. #if !SKIP_A72_L1_FLUSH_PWR_DWN
  193. /* ---------------------------------------------
  194. * Flush L1 caches.
  195. * ---------------------------------------------
  196. */
  197. mov x0, #DCCISW
  198. bl dcsw_op_level1
  199. #endif
  200. /* ---------------------------------------------
  201. * Disable the optional ACP.
  202. * ---------------------------------------------
  203. */
  204. bl plat_disable_acp
  205. /* -------------------------------------------------
  206. * Flush the L2 caches.
  207. * -------------------------------------------------
  208. */
  209. mov x0, #DCCISW
  210. bl dcsw_op_level2
  211. /* ---------------------------------------------
  212. * Come out of intra cluster coherency
  213. * ---------------------------------------------
  214. */
  215. bl cortex_a72_disable_smp
  216. /* ---------------------------------------------
  217. * Force the debug interfaces to be quiescent
  218. * ---------------------------------------------
  219. */
  220. mov x30, x18
  221. b cortex_a72_disable_ext_debug
  222. endfunc cortex_a72_cluster_pwr_dwn
  223. #if REPORT_ERRATA
  224. /*
  225. * Errata printing function for Cortex A72. Must follow AAPCS.
  226. */
  227. func cortex_a72_errata_report
  228. stp x8, x30, [sp, #-16]!
  229. bl cpu_get_rev_var
  230. mov x8, x0
  231. /*
  232. * Report all errata. The revision-variant information is passed to
  233. * checking functions of each errata.
  234. */
  235. report_errata ERRATA_A72_859971, cortex_a72, 859971
  236. report_errata WORKAROUND_CVE_2017_5715, cortex_a72, cve_2017_5715
  237. ldp x8, x30, [sp], #16
  238. ret
  239. endfunc cortex_a72_errata_report
  240. #endif
  241. /* ---------------------------------------------
  242. * This function provides cortex_a72 specific
  243. * register information for crash reporting.
  244. * It needs to return with x6 pointing to
  245. * a list of register names in ascii and
  246. * x8 - x15 having values of registers to be
  247. * reported.
  248. * ---------------------------------------------
  249. */
  250. .section .rodata.cortex_a72_regs, "aS"
  251. cortex_a72_regs: /* The ascii list of register names to be reported */
  252. .asciz "cpuectlr_el1", "cpumerrsr_el1", "l2merrsr_el1", ""
  253. func cortex_a72_cpu_reg_dump
  254. adr x6, cortex_a72_regs
  255. mrs x8, CORTEX_A72_ECTLR_EL1
  256. mrs x9, CORTEX_A72_MERRSR_EL1
  257. mrs x10, CORTEX_A72_L2MERRSR_EL1
  258. ret
  259. endfunc cortex_a72_cpu_reg_dump
  260. declare_cpu_ops_workaround_cve_2017_5715 cortex_a72, CORTEX_A72_MIDR, \
  261. cortex_a72_reset_func, \
  262. check_errata_cve_2017_5715, \
  263. cortex_a72_core_pwr_dwn, \
  264. cortex_a72_cluster_pwr_dwn