proc-v7.S 25 KB

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