proc-v7.S 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/arch/arm/mm/proc-v7.S
  4. *
  5. * Copyright (C) 2001 Deep Blue Solutions Ltd.
  6. *
  7. * This is the "shell" of the ARMv7 processor support.
  8. */
  9. #include <linux/arm-smccc.h>
  10. #include <linux/cfi_types.h>
  11. #include <linux/init.h>
  12. #include <linux/linkage.h>
  13. #include <linux/pgtable.h>
  14. #include <asm/assembler.h>
  15. #include <asm/asm-offsets.h>
  16. #include <asm/hwcap.h>
  17. #include <asm/pgtable-hwdef.h>
  18. #include <asm/page.h>
  19. #include "proc-macros.S"
  20. #ifdef CONFIG_ARM_LPAE
  21. #include "proc-v7-3level.S"
  22. #else
  23. #include "proc-v7-2level.S"
  24. #endif
  25. .arch armv7-a
  26. SYM_TYPED_FUNC_START(cpu_v7_proc_init)
  27. ret lr
  28. SYM_FUNC_END(cpu_v7_proc_init)
  29. SYM_TYPED_FUNC_START(cpu_v7_proc_fin)
  30. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  31. bic r0, r0, #0x1000 @ ...i............
  32. bic r0, r0, #0x0006 @ .............ca.
  33. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  34. ret lr
  35. SYM_FUNC_END(cpu_v7_proc_fin)
  36. /*
  37. * cpu_v7_reset(loc, hyp)
  38. *
  39. * Perform a soft reset of the system. Put the CPU into the
  40. * same state as it would be if it had been reset, and branch
  41. * to what would be the reset vector.
  42. *
  43. * - loc - location to jump to for soft reset
  44. * - hyp - indicate if restart occurs in HYP mode
  45. *
  46. * This code must be executed using a flat identity mapping with
  47. * caches disabled.
  48. */
  49. .align 5
  50. .pushsection .idmap.text, "ax"
  51. SYM_TYPED_FUNC_START(cpu_v7_reset)
  52. mrc p15, 0, r2, c1, c0, 0 @ ctrl register
  53. bic r2, r2, #0x1 @ ...............m
  54. THUMB( bic r2, r2, #1 << 30 ) @ SCTLR.TE (Thumb exceptions)
  55. mcr p15, 0, r2, c1, c0, 0 @ disable MMU
  56. isb
  57. #ifdef CONFIG_ARM_VIRT_EXT
  58. teq r1, #0
  59. bne __hyp_soft_restart
  60. #endif
  61. bx r0
  62. SYM_FUNC_END(cpu_v7_reset)
  63. .popsection
  64. /*
  65. * cpu_v7_do_idle()
  66. *
  67. * Idle the processor (eg, wait for interrupt).
  68. *
  69. * IRQs are already disabled.
  70. */
  71. SYM_TYPED_FUNC_START(cpu_v7_do_idle)
  72. dsb @ WFI may enter a low-power mode
  73. wfi
  74. ret lr
  75. SYM_FUNC_END(cpu_v7_do_idle)
  76. SYM_TYPED_FUNC_START(cpu_v7_dcache_clean_area)
  77. ALT_SMP(W(nop)) @ MP extensions imply L1 PTW
  78. ALT_UP_B(1f)
  79. ret lr
  80. 1: dcache_line_size r2, r3
  81. 2: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  82. add r0, r0, r2
  83. subs r1, r1, r2
  84. bhi 2b
  85. dsb ishst
  86. ret lr
  87. SYM_FUNC_END(cpu_v7_dcache_clean_area)
  88. #if defined(CONFIG_ARM_PSCI) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR)
  89. .arch_extension sec
  90. SYM_TYPED_FUNC_START(cpu_v7_smc_switch_mm)
  91. stmfd sp!, {r0 - r3}
  92. movw r0, #:lower16:ARM_SMCCC_ARCH_WORKAROUND_1
  93. movt r0, #:upper16:ARM_SMCCC_ARCH_WORKAROUND_1
  94. smc #0
  95. ldmfd sp!, {r0 - r3}
  96. b cpu_v7_switch_mm
  97. SYM_FUNC_END(cpu_v7_smc_switch_mm)
  98. .arch_extension virt
  99. SYM_TYPED_FUNC_START(cpu_v7_hvc_switch_mm)
  100. stmfd sp!, {r0 - r3}
  101. movw r0, #:lower16:ARM_SMCCC_ARCH_WORKAROUND_1
  102. movt r0, #:upper16:ARM_SMCCC_ARCH_WORKAROUND_1
  103. hvc #0
  104. ldmfd sp!, {r0 - r3}
  105. b cpu_v7_switch_mm
  106. SYM_FUNC_END(cpu_v7_hvc_switch_mm)
  107. #endif
  108. SYM_TYPED_FUNC_START(cpu_v7_iciallu_switch_mm)
  109. mov r3, #0
  110. mcr p15, 0, r3, c7, c5, 0 @ ICIALLU
  111. b cpu_v7_switch_mm
  112. SYM_FUNC_END(cpu_v7_iciallu_switch_mm)
  113. SYM_TYPED_FUNC_START(cpu_v7_bpiall_switch_mm)
  114. mov r3, #0
  115. mcr p15, 0, r3, c7, c5, 6 @ flush BTAC/BTB
  116. b cpu_v7_switch_mm
  117. SYM_FUNC_END(cpu_v7_bpiall_switch_mm)
  118. string cpu_v7_name, "ARMv7 Processor"
  119. .align
  120. /* Suspend/resume support: derived from arch/arm/mach-s5pv210/sleep.S */
  121. .globl cpu_v7_suspend_size
  122. .equ cpu_v7_suspend_size, 4 * 9
  123. #ifdef CONFIG_ARM_CPU_SUSPEND
  124. SYM_TYPED_FUNC_START(cpu_v7_do_suspend)
  125. stmfd sp!, {r4 - r11, lr}
  126. mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID
  127. mrc p15, 0, r5, c13, c0, 3 @ User r/o thread ID
  128. stmia r0!, {r4 - r5}
  129. #ifdef CONFIG_MMU
  130. mrc p15, 0, r6, c3, c0, 0 @ Domain ID
  131. #ifdef CONFIG_ARM_LPAE
  132. mrrc p15, 1, r5, r7, c2 @ TTB 1
  133. #else
  134. mrc p15, 0, r7, c2, c0, 1 @ TTB 1
  135. #endif
  136. mrc p15, 0, r11, c2, c0, 2 @ TTB control register
  137. #endif
  138. mrc p15, 0, r8, c1, c0, 0 @ Control register
  139. mrc p15, 0, r9, c1, c0, 1 @ Auxiliary control register
  140. mrc p15, 0, r10, c1, c0, 2 @ Co-processor access control
  141. stmia r0, {r5 - r11}
  142. ldmfd sp!, {r4 - r11, pc}
  143. SYM_FUNC_END(cpu_v7_do_suspend)
  144. SYM_TYPED_FUNC_START(cpu_v7_do_resume)
  145. mov ip, #0
  146. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  147. mcr p15, 0, ip, c13, c0, 1 @ set reserved context ID
  148. ldmia r0!, {r4 - r5}
  149. mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID
  150. mcr p15, 0, r5, c13, c0, 3 @ User r/o thread ID
  151. ldmia r0, {r5 - r11}
  152. #ifdef CONFIG_MMU
  153. mcr p15, 0, ip, c8, c7, 0 @ invalidate TLBs
  154. mcr p15, 0, r6, c3, c0, 0 @ Domain ID
  155. #ifdef CONFIG_ARM_LPAE
  156. mcrr p15, 0, r1, ip, c2 @ TTB 0
  157. mcrr p15, 1, r5, r7, c2 @ TTB 1
  158. #else
  159. ALT_SMP(orr r1, r1, #TTB_FLAGS_SMP)
  160. ALT_UP(orr r1, r1, #TTB_FLAGS_UP)
  161. mcr p15, 0, r1, c2, c0, 0 @ TTB 0
  162. mcr p15, 0, r7, c2, c0, 1 @ TTB 1
  163. #endif
  164. mcr p15, 0, r11, c2, c0, 2 @ TTB control register
  165. ldr r4, =PRRR @ PRRR
  166. ldr r5, =NMRR @ NMRR
  167. mcr p15, 0, r4, c10, c2, 0 @ write PRRR
  168. mcr p15, 0, r5, c10, c2, 1 @ write NMRR
  169. #endif /* CONFIG_MMU */
  170. mrc p15, 0, r4, c1, c0, 1 @ Read Auxiliary control register
  171. teq r4, r9 @ Is it already set?
  172. mcrne p15, 0, r9, c1, c0, 1 @ No, so write it
  173. mcr p15, 0, r10, c1, c0, 2 @ Co-processor access control
  174. isb
  175. dsb
  176. mov r0, r8 @ control register
  177. b cpu_resume_mmu
  178. SYM_FUNC_END(cpu_v7_do_resume)
  179. #endif
  180. .globl cpu_ca9mp_suspend_size
  181. .equ cpu_ca9mp_suspend_size, cpu_v7_suspend_size + 4 * 2
  182. #ifdef CONFIG_ARM_CPU_SUSPEND
  183. SYM_TYPED_FUNC_START(cpu_ca9mp_do_suspend)
  184. stmfd sp!, {r4 - r5}
  185. mrc p15, 0, r4, c15, c0, 1 @ Diagnostic register
  186. mrc p15, 0, r5, c15, c0, 0 @ Power register
  187. stmia r0!, {r4 - r5}
  188. ldmfd sp!, {r4 - r5}
  189. b cpu_v7_do_suspend
  190. SYM_FUNC_END(cpu_ca9mp_do_suspend)
  191. SYM_TYPED_FUNC_START(cpu_ca9mp_do_resume)
  192. ldmia r0!, {r4 - r5}
  193. mrc p15, 0, r10, c15, c0, 1 @ Read Diagnostic register
  194. teq r4, r10 @ Already restored?
  195. mcrne p15, 0, r4, c15, c0, 1 @ No, so restore it
  196. mrc p15, 0, r10, c15, c0, 0 @ Read Power register
  197. teq r5, r10 @ Already restored?
  198. mcrne p15, 0, r5, c15, c0, 0 @ No, so restore it
  199. b cpu_v7_do_resume
  200. SYM_FUNC_END(cpu_ca9mp_do_resume)
  201. #endif
  202. #ifdef CONFIG_CPU_PJ4B
  203. globl_equ cpu_pj4b_switch_mm, cpu_v7_switch_mm
  204. globl_equ cpu_pj4b_set_pte_ext, cpu_v7_set_pte_ext
  205. globl_equ cpu_pj4b_proc_init, cpu_v7_proc_init
  206. globl_equ cpu_pj4b_proc_fin, cpu_v7_proc_fin
  207. globl_equ cpu_pj4b_reset, cpu_v7_reset
  208. #ifdef CONFIG_PJ4B_ERRATA_4742
  209. SYM_TYPED_FUNC_START(cpu_pj4b_do_idle)
  210. dsb @ WFI may enter a low-power mode
  211. wfi
  212. dsb @barrier
  213. ret lr
  214. SYM_FUNC_END(cpu_pj4b_do_idle)
  215. #else
  216. globl_equ cpu_pj4b_do_idle, cpu_v7_do_idle
  217. #endif
  218. globl_equ cpu_pj4b_dcache_clean_area, cpu_v7_dcache_clean_area
  219. #ifdef CONFIG_ARM_CPU_SUSPEND
  220. SYM_TYPED_FUNC_START(cpu_pj4b_do_suspend)
  221. stmfd sp!, {r6 - r10}
  222. mrc p15, 1, r6, c15, c1, 0 @ save CP15 - extra features
  223. mrc p15, 1, r7, c15, c2, 0 @ save CP15 - Aux Func Modes Ctrl 0
  224. mrc p15, 1, r8, c15, c1, 2 @ save CP15 - Aux Debug Modes Ctrl 2
  225. mrc p15, 1, r9, c15, c1, 1 @ save CP15 - Aux Debug Modes Ctrl 1
  226. mrc p15, 0, r10, c9, c14, 0 @ save CP15 - PMC
  227. stmia r0!, {r6 - r10}
  228. ldmfd sp!, {r6 - r10}
  229. b cpu_v7_do_suspend
  230. SYM_FUNC_END(cpu_pj4b_do_suspend)
  231. SYM_TYPED_FUNC_START(cpu_pj4b_do_resume)
  232. ldmia r0!, {r6 - r10}
  233. mcr p15, 1, r6, c15, c1, 0 @ restore CP15 - extra features
  234. mcr p15, 1, r7, c15, c2, 0 @ restore CP15 - Aux Func Modes Ctrl 0
  235. mcr p15, 1, r8, c15, c1, 2 @ restore CP15 - Aux Debug Modes Ctrl 2
  236. mcr p15, 1, r9, c15, c1, 1 @ restore CP15 - Aux Debug Modes Ctrl 1
  237. mcr p15, 0, r10, c9, c14, 0 @ restore CP15 - PMC
  238. b cpu_v7_do_resume
  239. SYM_FUNC_END(cpu_pj4b_do_resume)
  240. #endif
  241. .globl cpu_pj4b_suspend_size
  242. .equ cpu_pj4b_suspend_size, cpu_v7_suspend_size + 4 * 5
  243. #endif
  244. @
  245. @ Invoke the v7_invalidate_l1() function, which adheres to the AAPCS
  246. @ rules, and so it may corrupt registers that we need to preserve.
  247. @
  248. .macro do_invalidate_l1
  249. mov r6, r1
  250. mov r7, r2
  251. mov r10, lr
  252. bl v7_invalidate_l1 @ corrupts {r0-r3, ip, lr}
  253. mov r1, r6
  254. mov r2, r7
  255. mov lr, r10
  256. .endm
  257. /*
  258. * __v7_setup
  259. *
  260. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  261. * on. Return in r0 the new CP15 C1 control register setting.
  262. *
  263. * r1, r2, r4, r5, r9, r13 must be preserved - r13 is not a stack
  264. * r4: TTBR0 (low word)
  265. * r5: TTBR0 (high word if LPAE)
  266. * r8: TTBR1
  267. * r9: Main ID register
  268. *
  269. * This should be able to cover all ARMv7 cores.
  270. *
  271. * It is assumed that:
  272. * - cache type register is implemented
  273. */
  274. __v7_ca5mp_setup:
  275. __v7_ca9mp_setup:
  276. __v7_cr7mp_setup:
  277. __v7_cr8mp_setup:
  278. do_invalidate_l1
  279. mov r10, #(1 << 0) @ Cache/TLB ops broadcasting
  280. b 1f
  281. __v7_ca7mp_setup:
  282. __v7_ca12mp_setup:
  283. __v7_ca15mp_setup:
  284. __v7_b15mp_setup:
  285. __v7_ca17mp_setup:
  286. do_invalidate_l1
  287. mov r10, #0
  288. 1:
  289. #ifdef CONFIG_SMP
  290. orr r10, r10, #(1 << 6) @ Enable SMP/nAMP mode
  291. ALT_SMP(mrc p15, 0, r0, c1, c0, 1)
  292. ALT_UP(mov r0, r10) @ fake it for UP
  293. orr r10, r10, r0 @ Set required bits
  294. teq r10, r0 @ Were they already set?
  295. mcrne p15, 0, r10, c1, c0, 1 @ No, update register
  296. #endif
  297. b __v7_setup_cont
  298. /*
  299. * Errata:
  300. * r0, r10 available for use
  301. * r1, r2, r4, r5, r9, r13: must be preserved
  302. * r3: contains MIDR rX number in bits 23-20
  303. * r6: contains MIDR rXpY as 8-bit XY number
  304. * r9: MIDR
  305. */
  306. __ca8_errata:
  307. #if defined(CONFIG_ARM_ERRATA_430973) && !defined(CONFIG_ARCH_MULTIPLATFORM)
  308. teq r3, #0x00100000 @ only present in r1p*
  309. mrceq p15, 0, r0, c1, c0, 1 @ read aux control register
  310. orreq r0, r0, #(1 << 6) @ set IBE to 1
  311. mcreq p15, 0, r0, c1, c0, 1 @ write aux control register
  312. #endif
  313. #ifdef CONFIG_ARM_ERRATA_458693
  314. teq r6, #0x20 @ only present in r2p0
  315. mrceq p15, 0, r0, c1, c0, 1 @ read aux control register
  316. orreq r0, r0, #(1 << 5) @ set L1NEON to 1
  317. orreq r0, r0, #(1 << 9) @ set PLDNOP to 1
  318. mcreq p15, 0, r0, c1, c0, 1 @ write aux control register
  319. #endif
  320. #ifdef CONFIG_ARM_ERRATA_460075
  321. teq r6, #0x20 @ only present in r2p0
  322. mrceq p15, 1, r0, c9, c0, 2 @ read L2 cache aux ctrl register
  323. tsteq r0, #1 << 22
  324. orreq r0, r0, #(1 << 22) @ set the Write Allocate disable bit
  325. mcreq p15, 1, r0, c9, c0, 2 @ write the L2 cache aux ctrl register
  326. #endif
  327. b __errata_finish
  328. __ca9_errata:
  329. #ifdef CONFIG_ARM_ERRATA_742230
  330. cmp r6, #0x22 @ only present up to r2p2
  331. mrcle p15, 0, r0, c15, c0, 1 @ read diagnostic register
  332. orrle r0, r0, #1 << 4 @ set bit #4
  333. mcrle p15, 0, r0, c15, c0, 1 @ write diagnostic register
  334. #endif
  335. #ifdef CONFIG_ARM_ERRATA_742231
  336. teq r6, #0x20 @ present in r2p0
  337. teqne r6, #0x21 @ present in r2p1
  338. teqne r6, #0x22 @ present in r2p2
  339. mrceq p15, 0, r0, c15, c0, 1 @ read diagnostic register
  340. orreq r0, r0, #1 << 12 @ set bit #12
  341. orreq r0, r0, #1 << 22 @ set bit #22
  342. mcreq p15, 0, r0, c15, c0, 1 @ write diagnostic register
  343. #endif
  344. #ifdef CONFIG_ARM_ERRATA_743622
  345. teq r3, #0x00200000 @ only present in r2p*
  346. mrceq p15, 0, r0, c15, c0, 1 @ read diagnostic register
  347. orreq r0, r0, #1 << 6 @ set bit #6
  348. mcreq p15, 0, r0, c15, c0, 1 @ write diagnostic register
  349. #endif
  350. #if defined(CONFIG_ARM_ERRATA_751472) && defined(CONFIG_SMP)
  351. ALT_SMP(cmp r6, #0x30) @ present prior to r3p0
  352. ALT_UP_B(1f)
  353. mrclt p15, 0, r0, c15, c0, 1 @ read diagnostic register
  354. orrlt r0, r0, #1 << 11 @ set bit #11
  355. mcrlt p15, 0, r0, c15, c0, 1 @ write diagnostic register
  356. 1:
  357. #endif
  358. b __errata_finish
  359. __ca15_errata:
  360. #ifdef CONFIG_ARM_ERRATA_773022
  361. cmp r6, #0x4 @ only present up to r0p4
  362. mrcle p15, 0, r0, c1, c0, 1 @ read aux control register
  363. orrle r0, r0, #1 << 1 @ disable loop buffer
  364. mcrle p15, 0, r0, c1, c0, 1 @ write aux control register
  365. #endif
  366. b __errata_finish
  367. __ca12_errata:
  368. #ifdef CONFIG_ARM_ERRATA_818325_852422
  369. mrc p15, 0, r10, c15, c0, 1 @ read diagnostic register
  370. orr r10, r10, #1 << 12 @ set bit #12
  371. mcr p15, 0, r10, c15, c0, 1 @ write diagnostic register
  372. #endif
  373. #ifdef CONFIG_ARM_ERRATA_821420
  374. mrc p15, 0, r10, c15, c0, 2 @ read internal feature reg
  375. orr r10, r10, #1 << 1 @ set bit #1
  376. mcr p15, 0, r10, c15, c0, 2 @ write internal feature reg
  377. #endif
  378. #ifdef CONFIG_ARM_ERRATA_825619
  379. mrc p15, 0, r10, c15, c0, 1 @ read diagnostic register
  380. orr r10, r10, #1 << 24 @ set bit #24
  381. mcr p15, 0, r10, c15, c0, 1 @ write diagnostic register
  382. #endif
  383. #ifdef CONFIG_ARM_ERRATA_857271
  384. mrc p15, 0, r10, c15, c0, 1 @ read diagnostic register
  385. orr r10, r10, #3 << 10 @ set bits #10 and #11
  386. mcr p15, 0, r10, c15, c0, 1 @ write diagnostic register
  387. #endif
  388. b __errata_finish
  389. __ca17_errata:
  390. #ifdef CONFIG_ARM_ERRATA_852421
  391. cmp r6, #0x12 @ only present up to r1p2
  392. mrcle p15, 0, r10, c15, c0, 1 @ read diagnostic register
  393. orrle r10, r10, #1 << 24 @ set bit #24
  394. mcrle p15, 0, r10, c15, c0, 1 @ write diagnostic register
  395. #endif
  396. #ifdef CONFIG_ARM_ERRATA_852423
  397. cmp r6, #0x12 @ only present up to r1p2
  398. mrcle p15, 0, r10, c15, c0, 1 @ read diagnostic register
  399. orrle r10, r10, #1 << 12 @ set bit #12
  400. mcrle p15, 0, r10, c15, c0, 1 @ write diagnostic register
  401. #endif
  402. #ifdef CONFIG_ARM_ERRATA_857272
  403. mrc p15, 0, r10, c15, c0, 1 @ read diagnostic register
  404. orr r10, r10, #3 << 10 @ set bits #10 and #11
  405. mcr p15, 0, r10, c15, c0, 1 @ write diagnostic register
  406. #endif
  407. b __errata_finish
  408. __v7_pj4b_setup:
  409. #ifdef CONFIG_CPU_PJ4B
  410. /* Auxiliary Debug Modes Control 1 Register */
  411. #define PJ4B_STATIC_BP (1 << 2) /* Enable Static BP */
  412. #define PJ4B_INTER_PARITY (1 << 8) /* Disable Internal Parity Handling */
  413. #define PJ4B_CLEAN_LINE (1 << 16) /* Disable data transfer for clean line */
  414. /* Auxiliary Debug Modes Control 2 Register */
  415. #define PJ4B_FAST_LDR (1 << 23) /* Disable fast LDR */
  416. #define PJ4B_SNOOP_DATA (1 << 25) /* Do not interleave write and snoop data */
  417. #define PJ4B_CWF (1 << 27) /* Disable Critical Word First feature */
  418. #define PJ4B_OUTSDNG_NC (1 << 29) /* Disable outstanding non cacheable rqst */
  419. #define PJ4B_L1_REP_RR (1 << 30) /* L1 replacement - Strict round robin */
  420. #define PJ4B_AUX_DBG_CTRL2 (PJ4B_SNOOP_DATA | PJ4B_CWF |\
  421. PJ4B_OUTSDNG_NC | PJ4B_L1_REP_RR)
  422. /* Auxiliary Functional Modes Control Register 0 */
  423. #define PJ4B_SMP_CFB (1 << 1) /* Set SMP mode. Join the coherency fabric */
  424. #define PJ4B_L1_PAR_CHK (1 << 2) /* Support L1 parity checking */
  425. #define PJ4B_BROADCAST_CACHE (1 << 8) /* Broadcast Cache and TLB maintenance */
  426. /* Auxiliary Debug Modes Control 0 Register */
  427. #define PJ4B_WFI_WFE (1 << 22) /* WFI/WFE - serve the DVM and back to idle */
  428. /* Auxiliary Debug Modes Control 1 Register */
  429. mrc p15, 1, r0, c15, c1, 1
  430. orr r0, r0, #PJ4B_CLEAN_LINE
  431. orr r0, r0, #PJ4B_INTER_PARITY
  432. bic r0, r0, #PJ4B_STATIC_BP
  433. mcr p15, 1, r0, c15, c1, 1
  434. /* Auxiliary Debug Modes Control 2 Register */
  435. mrc p15, 1, r0, c15, c1, 2
  436. bic r0, r0, #PJ4B_FAST_LDR
  437. orr r0, r0, #PJ4B_AUX_DBG_CTRL2
  438. mcr p15, 1, r0, c15, c1, 2
  439. /* Auxiliary Functional Modes Control Register 0 */
  440. mrc p15, 1, r0, c15, c2, 0
  441. #ifdef CONFIG_SMP
  442. orr r0, r0, #PJ4B_SMP_CFB
  443. #endif
  444. orr r0, r0, #PJ4B_L1_PAR_CHK
  445. orr r0, r0, #PJ4B_BROADCAST_CACHE
  446. mcr p15, 1, r0, c15, c2, 0
  447. /* Auxiliary Debug Modes Control 0 Register */
  448. mrc p15, 1, r0, c15, c1, 0
  449. orr r0, r0, #PJ4B_WFI_WFE
  450. mcr p15, 1, r0, c15, c1, 0
  451. #endif /* CONFIG_CPU_PJ4B */
  452. __v7_setup:
  453. do_invalidate_l1
  454. __v7_setup_cont:
  455. and r0, r9, #0xff000000 @ ARM?
  456. teq r0, #0x41000000
  457. bne __errata_finish
  458. and r3, r9, #0x00f00000 @ variant
  459. and r6, r9, #0x0000000f @ revision
  460. orr r6, r6, r3, lsr #20-4 @ combine variant and revision
  461. ubfx r0, r9, #4, #12 @ primary part number
  462. /* Cortex-A8 Errata */
  463. ldr r10, =0x00000c08 @ Cortex-A8 primary part number
  464. teq r0, r10
  465. beq __ca8_errata
  466. /* Cortex-A9 Errata */
  467. ldr r10, =0x00000c09 @ Cortex-A9 primary part number
  468. teq r0, r10
  469. beq __ca9_errata
  470. /* Cortex-A12 Errata */
  471. ldr r10, =0x00000c0d @ Cortex-A12 primary part number
  472. teq r0, r10
  473. beq __ca12_errata
  474. /* Cortex-A17 Errata */
  475. ldr r10, =0x00000c0e @ Cortex-A17 primary part number
  476. teq r0, r10
  477. beq __ca17_errata
  478. /* Cortex-A15 Errata */
  479. ldr r10, =0x00000c0f @ Cortex-A15 primary part number
  480. teq r0, r10
  481. beq __ca15_errata
  482. __errata_finish:
  483. mov r10, #0
  484. mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
  485. #ifdef CONFIG_MMU
  486. mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
  487. v7_ttb_setup r10, r4, r5, r8, r3 @ TTBCR, TTBRx setup
  488. ldr r3, =PRRR @ PRRR
  489. ldr r6, =NMRR @ NMRR
  490. mcr p15, 0, r3, c10, c2, 0 @ write PRRR
  491. mcr p15, 0, r6, c10, c2, 1 @ write NMRR
  492. #endif
  493. dsb @ Complete invalidations
  494. #ifndef CONFIG_ARM_THUMBEE
  495. mrc p15, 0, r0, c0, c1, 0 @ read ID_PFR0 for ThumbEE
  496. and r0, r0, #(0xf << 12) @ ThumbEE enabled field
  497. teq r0, #(1 << 12) @ check if ThumbEE is present
  498. bne 1f
  499. mov r3, #0
  500. mcr p14, 6, r3, c1, c0, 0 @ Initialize TEEHBR to 0
  501. mrc p14, 6, r0, c0, c0, 0 @ load TEECR
  502. orr r0, r0, #1 @ set the 1st bit in order to
  503. mcr p14, 6, r0, c0, c0, 0 @ stop userspace TEEHBR access
  504. 1:
  505. #endif
  506. adr r3, v7_crval
  507. ldmia r3, {r3, r6}
  508. ARM_BE8(orr r6, r6, #1 << 25) @ big-endian page tables
  509. #ifdef CONFIG_SWP_EMULATE
  510. orr r3, r3, #(1 << 10) @ set SW bit in "clear"
  511. bic r6, r6, #(1 << 10) @ clear it in "mmuset"
  512. #endif
  513. mrc p15, 0, r0, c1, c0, 0 @ read control register
  514. bic r0, r0, r3 @ clear bits them
  515. orr r0, r0, r6 @ set them
  516. THUMB( orr r0, r0, #1 << 30 ) @ Thumb exceptions
  517. ret lr @ return to head.S:__ret
  518. ENDPROC(__v7_setup)
  519. __INITDATA
  520. .weak cpu_v7_bugs_init
  521. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  522. define_processor_functions v7, dabort=v7_early_abort, pabort=v7_pabort, suspend=1, bugs=cpu_v7_bugs_init
  523. #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
  524. @ generic v7 bpiall on context switch
  525. globl_equ cpu_v7_bpiall_proc_init, cpu_v7_proc_init
  526. globl_equ cpu_v7_bpiall_proc_fin, cpu_v7_proc_fin
  527. globl_equ cpu_v7_bpiall_reset, cpu_v7_reset
  528. globl_equ cpu_v7_bpiall_do_idle, cpu_v7_do_idle
  529. globl_equ cpu_v7_bpiall_dcache_clean_area, cpu_v7_dcache_clean_area
  530. globl_equ cpu_v7_bpiall_set_pte_ext, cpu_v7_set_pte_ext
  531. globl_equ cpu_v7_bpiall_suspend_size, cpu_v7_suspend_size
  532. #ifdef CONFIG_ARM_CPU_SUSPEND
  533. globl_equ cpu_v7_bpiall_do_suspend, cpu_v7_do_suspend
  534. globl_equ cpu_v7_bpiall_do_resume, cpu_v7_do_resume
  535. #endif
  536. define_processor_functions v7_bpiall, dabort=v7_early_abort, pabort=v7_pabort, suspend=1, bugs=cpu_v7_bugs_init
  537. #define HARDENED_BPIALL_PROCESSOR_FUNCTIONS v7_bpiall_processor_functions
  538. #else
  539. #define HARDENED_BPIALL_PROCESSOR_FUNCTIONS v7_processor_functions
  540. #endif
  541. #ifndef CONFIG_ARM_LPAE
  542. @ Cortex-A8 - always needs bpiall switch_mm implementation
  543. globl_equ cpu_ca8_proc_init, cpu_v7_proc_init
  544. globl_equ cpu_ca8_proc_fin, cpu_v7_proc_fin
  545. globl_equ cpu_ca8_reset, cpu_v7_reset
  546. globl_equ cpu_ca8_do_idle, cpu_v7_do_idle
  547. globl_equ cpu_ca8_dcache_clean_area, cpu_v7_dcache_clean_area
  548. globl_equ cpu_ca8_set_pte_ext, cpu_v7_set_pte_ext
  549. globl_equ cpu_ca8_switch_mm, cpu_v7_bpiall_switch_mm
  550. globl_equ cpu_ca8_suspend_size, cpu_v7_suspend_size
  551. #ifdef CONFIG_ARM_CPU_SUSPEND
  552. globl_equ cpu_ca8_do_suspend, cpu_v7_do_suspend
  553. globl_equ cpu_ca8_do_resume, cpu_v7_do_resume
  554. #endif
  555. define_processor_functions ca8, dabort=v7_early_abort, pabort=v7_pabort, suspend=1, bugs=cpu_v7_ca8_ibe
  556. @ Cortex-A9 - needs more registers preserved across suspend/resume
  557. @ and bpiall switch_mm for hardening
  558. globl_equ cpu_ca9mp_proc_init, cpu_v7_proc_init
  559. globl_equ cpu_ca9mp_proc_fin, cpu_v7_proc_fin
  560. globl_equ cpu_ca9mp_reset, cpu_v7_reset
  561. globl_equ cpu_ca9mp_do_idle, cpu_v7_do_idle
  562. globl_equ cpu_ca9mp_dcache_clean_area, cpu_v7_dcache_clean_area
  563. #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
  564. globl_equ cpu_ca9mp_switch_mm, cpu_v7_bpiall_switch_mm
  565. #else
  566. globl_equ cpu_ca9mp_switch_mm, cpu_v7_switch_mm
  567. #endif
  568. globl_equ cpu_ca9mp_set_pte_ext, cpu_v7_set_pte_ext
  569. define_processor_functions ca9mp, dabort=v7_early_abort, pabort=v7_pabort, suspend=1, bugs=cpu_v7_bugs_init
  570. #endif
  571. @ Cortex-A15 - needs iciallu switch_mm for hardening
  572. globl_equ cpu_ca15_proc_init, cpu_v7_proc_init
  573. globl_equ cpu_ca15_proc_fin, cpu_v7_proc_fin
  574. globl_equ cpu_ca15_reset, cpu_v7_reset
  575. globl_equ cpu_ca15_do_idle, cpu_v7_do_idle
  576. globl_equ cpu_ca15_dcache_clean_area, cpu_v7_dcache_clean_area
  577. #ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
  578. globl_equ cpu_ca15_switch_mm, cpu_v7_iciallu_switch_mm
  579. #else
  580. globl_equ cpu_ca15_switch_mm, cpu_v7_switch_mm
  581. #endif
  582. globl_equ cpu_ca15_set_pte_ext, cpu_v7_set_pte_ext
  583. globl_equ cpu_ca15_suspend_size, cpu_v7_suspend_size
  584. globl_equ cpu_ca15_do_suspend, cpu_v7_do_suspend
  585. globl_equ cpu_ca15_do_resume, cpu_v7_do_resume
  586. define_processor_functions ca15, dabort=v7_early_abort, pabort=v7_pabort, suspend=1, bugs=cpu_v7_ca15_ibe
  587. #ifdef CONFIG_CPU_PJ4B
  588. define_processor_functions pj4b, dabort=v7_early_abort, pabort=v7_pabort, suspend=1
  589. #endif
  590. .section ".rodata"
  591. string cpu_arch_name, "armv7"
  592. string cpu_elf_name, "v7"
  593. .align
  594. .section ".proc.info.init", "a"
  595. /*
  596. * Standard v7 proc info content
  597. */
  598. .macro __v7_proc name, initfunc, mm_mmuflags = 0, io_mmuflags = 0, hwcaps = 0, proc_fns = v7_processor_functions, cache_fns = v7_cache_fns
  599. ALT_SMP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \
  600. PMD_SECT_AF | PMD_FLAGS_SMP | \mm_mmuflags)
  601. ALT_UP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \
  602. PMD_SECT_AF | PMD_FLAGS_UP | \mm_mmuflags)
  603. .long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | \
  604. PMD_SECT_AP_READ | PMD_SECT_AF | \io_mmuflags
  605. initfn \initfunc, \name
  606. .long cpu_arch_name
  607. .long cpu_elf_name
  608. .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_FAST_MULT | \
  609. HWCAP_EDSP | HWCAP_TLS | \hwcaps
  610. .long cpu_v7_name
  611. .long \proc_fns
  612. .long v7wbi_tlb_fns
  613. .long v6_user_fns
  614. .long \cache_fns
  615. .endm
  616. #ifndef CONFIG_ARM_LPAE
  617. /*
  618. * ARM Ltd. Cortex A5 processor.
  619. */
  620. .type __v7_ca5mp_proc_info, #object
  621. __v7_ca5mp_proc_info:
  622. .long 0x410fc050
  623. .long 0xff0ffff0
  624. __v7_proc __v7_ca5mp_proc_info, __v7_ca5mp_setup
  625. .size __v7_ca5mp_proc_info, . - __v7_ca5mp_proc_info
  626. /*
  627. * ARM Ltd. Cortex A9 processor.
  628. */
  629. .type __v7_ca9mp_proc_info, #object
  630. __v7_ca9mp_proc_info:
  631. .long 0x410fc090
  632. .long 0xff0ffff0
  633. __v7_proc __v7_ca9mp_proc_info, __v7_ca9mp_setup, proc_fns = ca9mp_processor_functions
  634. .size __v7_ca9mp_proc_info, . - __v7_ca9mp_proc_info
  635. /*
  636. * ARM Ltd. Cortex A8 processor.
  637. */
  638. .type __v7_ca8_proc_info, #object
  639. __v7_ca8_proc_info:
  640. .long 0x410fc080
  641. .long 0xff0ffff0
  642. __v7_proc __v7_ca8_proc_info, __v7_setup, proc_fns = ca8_processor_functions
  643. .size __v7_ca8_proc_info, . - __v7_ca8_proc_info
  644. #endif /* CONFIG_ARM_LPAE */
  645. /*
  646. * Marvell PJ4B processor.
  647. */
  648. #ifdef CONFIG_CPU_PJ4B
  649. .type __v7_pj4b_proc_info, #object
  650. __v7_pj4b_proc_info:
  651. .long 0x560f5800
  652. .long 0xff0fff00
  653. __v7_proc __v7_pj4b_proc_info, __v7_pj4b_setup, proc_fns = pj4b_processor_functions
  654. .size __v7_pj4b_proc_info, . - __v7_pj4b_proc_info
  655. #endif
  656. /*
  657. * ARM Ltd. Cortex R7 processor.
  658. */
  659. .type __v7_cr7mp_proc_info, #object
  660. __v7_cr7mp_proc_info:
  661. .long 0x410fc170
  662. .long 0xff0ffff0
  663. __v7_proc __v7_cr7mp_proc_info, __v7_cr7mp_setup
  664. .size __v7_cr7mp_proc_info, . - __v7_cr7mp_proc_info
  665. /*
  666. * ARM Ltd. Cortex R8 processor.
  667. */
  668. .type __v7_cr8mp_proc_info, #object
  669. __v7_cr8mp_proc_info:
  670. .long 0x410fc180
  671. .long 0xff0ffff0
  672. __v7_proc __v7_cr8mp_proc_info, __v7_cr8mp_setup
  673. .size __v7_cr8mp_proc_info, . - __v7_cr8mp_proc_info
  674. /*
  675. * ARM Ltd. Cortex A7 processor.
  676. */
  677. .type __v7_ca7mp_proc_info, #object
  678. __v7_ca7mp_proc_info:
  679. .long 0x410fc070
  680. .long 0xff0ffff0
  681. __v7_proc __v7_ca7mp_proc_info, __v7_ca7mp_setup
  682. .size __v7_ca7mp_proc_info, . - __v7_ca7mp_proc_info
  683. /*
  684. * ARM Ltd. Cortex A12 processor.
  685. */
  686. .type __v7_ca12mp_proc_info, #object
  687. __v7_ca12mp_proc_info:
  688. .long 0x410fc0d0
  689. .long 0xff0ffff0
  690. __v7_proc __v7_ca12mp_proc_info, __v7_ca12mp_setup, proc_fns = HARDENED_BPIALL_PROCESSOR_FUNCTIONS
  691. .size __v7_ca12mp_proc_info, . - __v7_ca12mp_proc_info
  692. /*
  693. * ARM Ltd. Cortex A15 processor.
  694. */
  695. .type __v7_ca15mp_proc_info, #object
  696. __v7_ca15mp_proc_info:
  697. .long 0x410fc0f0
  698. .long 0xff0ffff0
  699. __v7_proc __v7_ca15mp_proc_info, __v7_ca15mp_setup, proc_fns = ca15_processor_functions
  700. .size __v7_ca15mp_proc_info, . - __v7_ca15mp_proc_info
  701. /*
  702. * Broadcom Corporation Brahma-B15 processor.
  703. */
  704. .type __v7_b15mp_proc_info, #object
  705. __v7_b15mp_proc_info:
  706. .long 0x420f00f0
  707. .long 0xff0ffff0
  708. __v7_proc __v7_b15mp_proc_info, __v7_b15mp_setup, proc_fns = ca15_processor_functions, cache_fns = b15_cache_fns
  709. .size __v7_b15mp_proc_info, . - __v7_b15mp_proc_info
  710. /*
  711. * ARM Ltd. Cortex A17 processor.
  712. */
  713. .type __v7_ca17mp_proc_info, #object
  714. __v7_ca17mp_proc_info:
  715. .long 0x410fc0e0
  716. .long 0xff0ffff0
  717. __v7_proc __v7_ca17mp_proc_info, __v7_ca17mp_setup, proc_fns = HARDENED_BPIALL_PROCESSOR_FUNCTIONS
  718. .size __v7_ca17mp_proc_info, . - __v7_ca17mp_proc_info
  719. /* ARM Ltd. Cortex A73 processor */
  720. .type __v7_ca73_proc_info, #object
  721. __v7_ca73_proc_info:
  722. .long 0x410fd090
  723. .long 0xff0ffff0
  724. __v7_proc __v7_ca73_proc_info, __v7_setup, proc_fns = HARDENED_BPIALL_PROCESSOR_FUNCTIONS
  725. .size __v7_ca73_proc_info, . - __v7_ca73_proc_info
  726. /* ARM Ltd. Cortex A75 processor */
  727. .type __v7_ca75_proc_info, #object
  728. __v7_ca75_proc_info:
  729. .long 0x410fd0a0
  730. .long 0xff0ffff0
  731. __v7_proc __v7_ca75_proc_info, __v7_setup, proc_fns = HARDENED_BPIALL_PROCESSOR_FUNCTIONS
  732. .size __v7_ca75_proc_info, . - __v7_ca75_proc_info
  733. /*
  734. * Qualcomm Inc. Krait processors.
  735. */
  736. .type __krait_proc_info, #object
  737. __krait_proc_info:
  738. .long 0x510f0400 @ Required ID value
  739. .long 0xff0ffc00 @ Mask for ID
  740. /*
  741. * Some Krait processors don't indicate support for SDIV and UDIV
  742. * instructions in the ARM instruction set, even though they actually
  743. * do support them. They also don't indicate support for fused multiply
  744. * instructions even though they actually do support them.
  745. */
  746. __v7_proc __krait_proc_info, __v7_setup, hwcaps = HWCAP_IDIV | HWCAP_VFPv4
  747. .size __krait_proc_info, . - __krait_proc_info
  748. /*
  749. * Match any ARMv7 processor core.
  750. */
  751. .type __v7_proc_info, #object
  752. __v7_proc_info:
  753. .long 0x000f0000 @ Required ID value
  754. .long 0x000f0000 @ Mask for ID
  755. __v7_proc __v7_proc_info, __v7_setup
  756. .size __v7_proc_info, . - __v7_proc_info