proc-v7.S 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /*
  2. * linux/arch/arm/mm/proc-v7.S
  3. *
  4. * Copyright (C) 2001 Deep Blue Solutions Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This is the "shell" of the ARMv7 processor support.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/linkage.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/pgtable.h>
  19. #include <asm/memory.h>
  20. #include "proc-macros.S"
  21. #ifdef CONFIG_ARM_LPAE
  22. #include "proc-v7-3level.S"
  23. #else
  24. #include "proc-v7-2level.S"
  25. #endif
  26. ENTRY(cpu_v7_proc_init)
  27. ret lr
  28. ENDPROC(cpu_v7_proc_init)
  29. ENTRY(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. ENDPROC(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. ENTRY(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. ENDPROC(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. ENTRY(cpu_v7_do_idle)
  72. dsb @ WFI may enter a low-power mode
  73. wfi
  74. ret lr
  75. ENDPROC(cpu_v7_do_idle)
  76. ENTRY(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. ENDPROC(cpu_v7_dcache_clean_area)
  88. string cpu_v7_name, "ARMv7 Processor"
  89. .align
  90. /* Suspend/resume support: derived from arch/arm/mach-s5pv210/sleep.S */
  91. .globl cpu_v7_suspend_size
  92. .equ cpu_v7_suspend_size, 4 * 9
  93. #ifdef CONFIG_ARM_CPU_SUSPEND
  94. ENTRY(cpu_v7_do_suspend)
  95. stmfd sp!, {r4 - r11, lr}
  96. mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID
  97. mrc p15, 0, r5, c13, c0, 3 @ User r/o thread ID
  98. stmia r0!, {r4 - r5}
  99. #ifdef CONFIG_MMU
  100. mrc p15, 0, r6, c3, c0, 0 @ Domain ID
  101. #ifdef CONFIG_ARM_LPAE
  102. mrrc p15, 1, r5, r7, c2 @ TTB 1
  103. #else
  104. mrc p15, 0, r7, c2, c0, 1 @ TTB 1
  105. #endif
  106. mrc p15, 0, r11, c2, c0, 2 @ TTB control register
  107. #endif
  108. mrc p15, 0, r8, c1, c0, 0 @ Control register
  109. mrc p15, 0, r9, c1, c0, 1 @ Auxiliary control register
  110. mrc p15, 0, r10, c1, c0, 2 @ Co-processor access control
  111. stmia r0, {r5 - r11}
  112. ldmfd sp!, {r4 - r11, pc}
  113. ENDPROC(cpu_v7_do_suspend)
  114. ENTRY(cpu_v7_do_resume)
  115. mov ip, #0
  116. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  117. mcr p15, 0, ip, c13, c0, 1 @ set reserved context ID
  118. ldmia r0!, {r4 - r5}
  119. mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID
  120. mcr p15, 0, r5, c13, c0, 3 @ User r/o thread ID
  121. ldmia r0, {r5 - r11}
  122. #ifdef CONFIG_MMU
  123. mcr p15, 0, ip, c8, c7, 0 @ invalidate TLBs
  124. mcr p15, 0, r6, c3, c0, 0 @ Domain ID
  125. #ifdef CONFIG_ARM_LPAE
  126. mcrr p15, 0, r1, ip, c2 @ TTB 0
  127. mcrr p15, 1, r5, r7, c2 @ TTB 1
  128. #else
  129. ALT_SMP(orr r1, r1, #TTB_FLAGS_SMP)
  130. ALT_UP(orr r1, r1, #TTB_FLAGS_UP)
  131. mcr p15, 0, r1, c2, c0, 0 @ TTB 0
  132. mcr p15, 0, r7, c2, c0, 1 @ TTB 1
  133. #endif
  134. mcr p15, 0, r11, c2, c0, 2 @ TTB control register
  135. ldr r4, =PRRR @ PRRR
  136. ldr r5, =NMRR @ NMRR
  137. mcr p15, 0, r4, c10, c2, 0 @ write PRRR
  138. mcr p15, 0, r5, c10, c2, 1 @ write NMRR
  139. #endif /* CONFIG_MMU */
  140. mrc p15, 0, r4, c1, c0, 1 @ Read Auxiliary control register
  141. teq r4, r9 @ Is it already set?
  142. mcrne p15, 0, r9, c1, c0, 1 @ No, so write it
  143. mcr p15, 0, r10, c1, c0, 2 @ Co-processor access control
  144. isb
  145. dsb
  146. mov r0, r8 @ control register
  147. b cpu_resume_mmu
  148. ENDPROC(cpu_v7_do_resume)
  149. #endif
  150. /*
  151. * Cortex-A8
  152. */
  153. globl_equ cpu_ca8_proc_init, cpu_v7_proc_init
  154. globl_equ cpu_ca8_proc_fin, cpu_v7_proc_fin
  155. globl_equ cpu_ca8_reset, cpu_v7_reset
  156. globl_equ cpu_ca8_do_idle, cpu_v7_do_idle
  157. globl_equ cpu_ca8_dcache_clean_area, cpu_v7_dcache_clean_area
  158. globl_equ cpu_ca8_set_pte_ext, cpu_v7_set_pte_ext
  159. globl_equ cpu_ca8_suspend_size, cpu_v7_suspend_size
  160. #ifdef CONFIG_ARM_CPU_SUSPEND
  161. globl_equ cpu_ca8_do_suspend, cpu_v7_do_suspend
  162. globl_equ cpu_ca8_do_resume, cpu_v7_do_resume
  163. #endif
  164. /*
  165. * Cortex-A9 processor functions
  166. */
  167. globl_equ cpu_ca9mp_proc_init, cpu_v7_proc_init
  168. globl_equ cpu_ca9mp_proc_fin, cpu_v7_proc_fin
  169. globl_equ cpu_ca9mp_reset, cpu_v7_reset
  170. globl_equ cpu_ca9mp_do_idle, cpu_v7_do_idle
  171. globl_equ cpu_ca9mp_dcache_clean_area, cpu_v7_dcache_clean_area
  172. globl_equ cpu_ca9mp_switch_mm, cpu_v7_switch_mm
  173. globl_equ cpu_ca9mp_set_pte_ext, cpu_v7_set_pte_ext
  174. .globl cpu_ca9mp_suspend_size
  175. .equ cpu_ca9mp_suspend_size, cpu_v7_suspend_size + 4 * 2
  176. #ifdef CONFIG_ARM_CPU_SUSPEND
  177. ENTRY(cpu_ca9mp_do_suspend)
  178. stmfd sp!, {r4 - r5}
  179. mrc p15, 0, r4, c15, c0, 1 @ Diagnostic register
  180. mrc p15, 0, r5, c15, c0, 0 @ Power register
  181. stmia r0!, {r4 - r5}
  182. ldmfd sp!, {r4 - r5}
  183. b cpu_v7_do_suspend
  184. ENDPROC(cpu_ca9mp_do_suspend)
  185. ENTRY(cpu_ca9mp_do_resume)
  186. ldmia r0!, {r4 - r5}
  187. mrc p15, 0, r10, c15, c0, 1 @ Read Diagnostic register
  188. teq r4, r10 @ Already restored?
  189. mcrne p15, 0, r4, c15, c0, 1 @ No, so restore it
  190. mrc p15, 0, r10, c15, c0, 0 @ Read Power register
  191. teq r5, r10 @ Already restored?
  192. mcrne p15, 0, r5, c15, c0, 0 @ No, so restore it
  193. b cpu_v7_do_resume
  194. ENDPROC(cpu_ca9mp_do_resume)
  195. #endif
  196. #ifdef CONFIG_CPU_PJ4B
  197. globl_equ cpu_pj4b_switch_mm, cpu_v7_switch_mm
  198. globl_equ cpu_pj4b_set_pte_ext, cpu_v7_set_pte_ext
  199. globl_equ cpu_pj4b_proc_init, cpu_v7_proc_init
  200. globl_equ cpu_pj4b_proc_fin, cpu_v7_proc_fin
  201. globl_equ cpu_pj4b_reset, cpu_v7_reset
  202. #ifdef CONFIG_PJ4B_ERRATA_4742
  203. ENTRY(cpu_pj4b_do_idle)
  204. dsb @ WFI may enter a low-power mode
  205. wfi
  206. dsb @barrier
  207. ret lr
  208. ENDPROC(cpu_pj4b_do_idle)
  209. #else
  210. globl_equ cpu_pj4b_do_idle, cpu_v7_do_idle
  211. #endif
  212. globl_equ cpu_pj4b_dcache_clean_area, cpu_v7_dcache_clean_area
  213. #ifdef CONFIG_ARM_CPU_SUSPEND
  214. ENTRY(cpu_pj4b_do_suspend)
  215. stmfd sp!, {r6 - r10}
  216. mrc p15, 1, r6, c15, c1, 0 @ save CP15 - extra features
  217. mrc p15, 1, r7, c15, c2, 0 @ save CP15 - Aux Func Modes Ctrl 0
  218. mrc p15, 1, r8, c15, c1, 2 @ save CP15 - Aux Debug Modes Ctrl 2
  219. mrc p15, 1, r9, c15, c1, 1 @ save CP15 - Aux Debug Modes Ctrl 1
  220. mrc p15, 0, r10, c9, c14, 0 @ save CP15 - PMC
  221. stmia r0!, {r6 - r10}
  222. ldmfd sp!, {r6 - r10}
  223. b cpu_v7_do_suspend
  224. ENDPROC(cpu_pj4b_do_suspend)
  225. ENTRY(cpu_pj4b_do_resume)
  226. ldmia r0!, {r6 - r10}
  227. mcr p15, 1, r6, c15, c1, 0 @ restore CP15 - extra features
  228. mcr p15, 1, r7, c15, c2, 0 @ restore CP15 - Aux Func Modes Ctrl 0
  229. mcr p15, 1, r8, c15, c1, 2 @ restore CP15 - Aux Debug Modes Ctrl 2
  230. mcr p15, 1, r9, c15, c1, 1 @ restore CP15 - Aux Debug Modes Ctrl 1
  231. mcr p15, 0, r10, c9, c14, 0 @ restore CP15 - PMC
  232. b cpu_v7_do_resume
  233. ENDPROC(cpu_pj4b_do_resume)
  234. #endif
  235. .globl cpu_pj4b_suspend_size
  236. .equ cpu_pj4b_suspend_size, cpu_v7_suspend_size + 4 * 5
  237. #endif
  238. /*
  239. * __v7_setup
  240. *
  241. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  242. * on. Return in r0 the new CP15 C1 control register setting.
  243. *
  244. * r1, r2, r4, r5, r9, r13 must be preserved - r13 is not a stack
  245. * r4: TTBR0 (low word)
  246. * r5: TTBR0 (high word if LPAE)
  247. * r8: TTBR1
  248. * r9: Main ID register
  249. *
  250. * This should be able to cover all ARMv7 cores.
  251. *
  252. * It is assumed that:
  253. * - cache type register is implemented
  254. */
  255. __v7_ca5mp_setup:
  256. __v7_ca9mp_setup:
  257. __v7_cr7mp_setup:
  258. mov r10, #(1 << 0) @ Cache/TLB ops broadcasting
  259. b 1f
  260. __v7_ca7mp_setup:
  261. __v7_ca12mp_setup:
  262. __v7_ca15mp_setup:
  263. __v7_b15mp_setup:
  264. __v7_ca17mp_setup:
  265. mov r10, #0
  266. 1: adr r0, __v7_setup_stack_ptr
  267. ldr r12, [r0]
  268. add r12, r12, r0 @ the local stack
  269. stmia r12, {r1-r6, lr} @ v7_invalidate_l1 touches r0-r6
  270. bl v7_invalidate_l1
  271. ldmia r12, {r1-r6, lr}
  272. #ifdef CONFIG_SMP
  273. orr r10, r10, #(1 << 6) @ Enable SMP/nAMP mode
  274. ALT_SMP(mrc p15, 0, r0, c1, c0, 1)
  275. ALT_UP(mov r0, r10) @ fake it for UP
  276. orr r10, r10, r0 @ Set required bits
  277. teq r10, r0 @ Were they already set?
  278. mcrne p15, 0, r10, c1, c0, 1 @ No, update register
  279. #endif
  280. b __v7_setup_cont
  281. /*
  282. * Errata:
  283. * r0, r10 available for use
  284. * r1, r2, r4, r5, r9, r13: must be preserved
  285. * r3: contains MIDR rX number in bits 23-20
  286. * r6: contains MIDR rXpY as 8-bit XY number
  287. * r9: MIDR
  288. */
  289. __ca8_errata:
  290. #if defined(CONFIG_ARM_ERRATA_430973) && !defined(CONFIG_ARCH_MULTIPLATFORM)
  291. teq r3, #0x00100000 @ only present in r1p*
  292. mrceq p15, 0, r0, c1, c0, 1 @ read aux control register
  293. orreq r0, r0, #(1 << 6) @ set IBE to 1
  294. mcreq p15, 0, r0, c1, c0, 1 @ write aux control register
  295. #endif
  296. #ifdef CONFIG_ARM_ERRATA_458693
  297. teq r6, #0x20 @ only present in r2p0
  298. mrceq p15, 0, r0, c1, c0, 1 @ read aux control register
  299. orreq r0, r0, #(1 << 5) @ set L1NEON to 1
  300. orreq r0, r0, #(1 << 9) @ set PLDNOP to 1
  301. mcreq p15, 0, r0, c1, c0, 1 @ write aux control register
  302. #endif
  303. #ifdef CONFIG_ARM_ERRATA_460075
  304. teq r6, #0x20 @ only present in r2p0
  305. mrceq p15, 1, r0, c9, c0, 2 @ read L2 cache aux ctrl register
  306. tsteq r0, #1 << 22
  307. orreq r0, r0, #(1 << 22) @ set the Write Allocate disable bit
  308. mcreq p15, 1, r0, c9, c0, 2 @ write the L2 cache aux ctrl register
  309. #endif
  310. b __errata_finish
  311. __ca9_errata:
  312. #ifdef CONFIG_ARM_ERRATA_742230
  313. cmp r6, #0x22 @ only present up to r2p2
  314. mrcle p15, 0, r0, c15, c0, 1 @ read diagnostic register
  315. orrle r0, r0, #1 << 4 @ set bit #4
  316. mcrle p15, 0, r0, c15, c0, 1 @ write diagnostic register
  317. #endif
  318. #ifdef CONFIG_ARM_ERRATA_742231
  319. teq r6, #0x20 @ present in r2p0
  320. teqne r6, #0x21 @ present in r2p1
  321. teqne r6, #0x22 @ present in r2p2
  322. mrceq p15, 0, r0, c15, c0, 1 @ read diagnostic register
  323. orreq r0, r0, #1 << 12 @ set bit #12
  324. orreq r0, r0, #1 << 22 @ set bit #22
  325. mcreq p15, 0, r0, c15, c0, 1 @ write diagnostic register
  326. #endif
  327. #ifdef CONFIG_ARM_ERRATA_743622
  328. teq r3, #0x00200000 @ only present in r2p*
  329. mrceq p15, 0, r0, c15, c0, 1 @ read diagnostic register
  330. orreq r0, r0, #1 << 6 @ set bit #6
  331. mcreq p15, 0, r0, c15, c0, 1 @ write diagnostic register
  332. #endif
  333. #if defined(CONFIG_ARM_ERRATA_751472) && defined(CONFIG_SMP)
  334. ALT_SMP(cmp r6, #0x30) @ present prior to r3p0
  335. ALT_UP_B(1f)
  336. mrclt p15, 0, r0, c15, c0, 1 @ read diagnostic register
  337. orrlt r0, r0, #1 << 11 @ set bit #11
  338. mcrlt p15, 0, r0, c15, c0, 1 @ write diagnostic register
  339. 1:
  340. #endif
  341. b __errata_finish
  342. __ca15_errata:
  343. #ifdef CONFIG_ARM_ERRATA_773022
  344. cmp r6, #0x4 @ only present up to r0p4
  345. mrcle p15, 0, r0, c1, c0, 1 @ read aux control register
  346. orrle r0, r0, #1 << 1 @ disable loop buffer
  347. mcrle p15, 0, r0, c1, c0, 1 @ write aux control register
  348. #endif
  349. b __errata_finish
  350. __ca12_errata:
  351. #ifdef CONFIG_ARM_ERRATA_818325_852422
  352. mrc p15, 0, r10, c15, c0, 1 @ read diagnostic register
  353. orr r10, r10, #1 << 12 @ set bit #12
  354. mcr p15, 0, r10, c15, c0, 1 @ write diagnostic register
  355. #endif
  356. #ifdef CONFIG_ARM_ERRATA_821420
  357. mrc p15, 0, r10, c15, c0, 2 @ read internal feature reg
  358. orr r10, r10, #1 << 1 @ set bit #1
  359. mcr p15, 0, r10, c15, c0, 2 @ write internal feature reg
  360. #endif
  361. #ifdef CONFIG_ARM_ERRATA_825619
  362. mrc p15, 0, r10, c15, c0, 1 @ read diagnostic register
  363. orr r10, r10, #1 << 24 @ set bit #24
  364. mcr p15, 0, r10, c15, c0, 1 @ write diagnostic register
  365. #endif
  366. b __errata_finish
  367. __ca17_errata:
  368. #ifdef CONFIG_ARM_ERRATA_852421
  369. cmp r6, #0x12 @ only present up to r1p2
  370. mrcle p15, 0, r10, c15, c0, 1 @ read diagnostic register
  371. orrle r10, r10, #1 << 24 @ set bit #24
  372. mcrle p15, 0, r10, c15, c0, 1 @ write diagnostic register
  373. #endif
  374. #ifdef CONFIG_ARM_ERRATA_852423
  375. cmp r6, #0x12 @ only present up to r1p2
  376. mrcle p15, 0, r10, c15, c0, 1 @ read diagnostic register
  377. orrle r10, r10, #1 << 12 @ set bit #12
  378. mcrle p15, 0, r10, c15, c0, 1 @ write diagnostic register
  379. #endif
  380. b __errata_finish
  381. __v7_pj4b_setup:
  382. #ifdef CONFIG_CPU_PJ4B
  383. /* Auxiliary Debug Modes Control 1 Register */
  384. #define PJ4B_STATIC_BP (1 << 2) /* Enable Static BP */
  385. #define PJ4B_INTER_PARITY (1 << 8) /* Disable Internal Parity Handling */
  386. #define PJ4B_CLEAN_LINE (1 << 16) /* Disable data transfer for clean line */
  387. /* Auxiliary Debug Modes Control 2 Register */
  388. #define PJ4B_FAST_LDR (1 << 23) /* Disable fast LDR */
  389. #define PJ4B_SNOOP_DATA (1 << 25) /* Do not interleave write and snoop data */
  390. #define PJ4B_CWF (1 << 27) /* Disable Critical Word First feature */
  391. #define PJ4B_OUTSDNG_NC (1 << 29) /* Disable outstanding non cacheable rqst */
  392. #define PJ4B_L1_REP_RR (1 << 30) /* L1 replacement - Strict round robin */
  393. #define PJ4B_AUX_DBG_CTRL2 (PJ4B_SNOOP_DATA | PJ4B_CWF |\
  394. PJ4B_OUTSDNG_NC | PJ4B_L1_REP_RR)
  395. /* Auxiliary Functional Modes Control Register 0 */
  396. #define PJ4B_SMP_CFB (1 << 1) /* Set SMP mode. Join the coherency fabric */
  397. #define PJ4B_L1_PAR_CHK (1 << 2) /* Support L1 parity checking */
  398. #define PJ4B_BROADCAST_CACHE (1 << 8) /* Broadcast Cache and TLB maintenance */
  399. /* Auxiliary Debug Modes Control 0 Register */
  400. #define PJ4B_WFI_WFE (1 << 22) /* WFI/WFE - serve the DVM and back to idle */
  401. /* Auxiliary Debug Modes Control 1 Register */
  402. mrc p15, 1, r0, c15, c1, 1
  403. orr r0, r0, #PJ4B_CLEAN_LINE
  404. orr r0, r0, #PJ4B_INTER_PARITY
  405. bic r0, r0, #PJ4B_STATIC_BP
  406. mcr p15, 1, r0, c15, c1, 1
  407. /* Auxiliary Debug Modes Control 2 Register */
  408. mrc p15, 1, r0, c15, c1, 2
  409. bic r0, r0, #PJ4B_FAST_LDR
  410. orr r0, r0, #PJ4B_AUX_DBG_CTRL2
  411. mcr p15, 1, r0, c15, c1, 2
  412. /* Auxiliary Functional Modes Control Register 0 */
  413. mrc p15, 1, r0, c15, c2, 0
  414. #ifdef CONFIG_SMP
  415. orr r0, r0, #PJ4B_SMP_CFB
  416. #endif
  417. orr r0, r0, #PJ4B_L1_PAR_CHK
  418. orr r0, r0, #PJ4B_BROADCAST_CACHE
  419. mcr p15, 1, r0, c15, c2, 0
  420. /* Auxiliary Debug Modes Control 0 Register */
  421. mrc p15, 1, r0, c15, c1, 0
  422. orr r0, r0, #PJ4B_WFI_WFE
  423. mcr p15, 1, r0, c15, c1, 0
  424. #endif /* CONFIG_CPU_PJ4B */
  425. __v7_setup:
  426. adr r0, __v7_setup_stack_ptr
  427. ldr r12, [r0]
  428. add r12, r12, r0 @ the local stack
  429. stmia r12, {r1-r6, lr} @ v7_invalidate_l1 touches r0-r6
  430. bl v7_invalidate_l1
  431. ldmia r12, {r1-r6, lr}
  432. __v7_setup_cont:
  433. and r0, r9, #0xff000000 @ ARM?
  434. teq r0, #0x41000000
  435. bne __errata_finish
  436. and r3, r9, #0x00f00000 @ variant
  437. and r6, r9, #0x0000000f @ revision
  438. orr r6, r6, r3, lsr #20-4 @ combine variant and revision
  439. ubfx r0, r9, #4, #12 @ primary part number
  440. /* Cortex-A8 Errata */
  441. ldr r10, =0x00000c08 @ Cortex-A8 primary part number
  442. teq r0, r10
  443. beq __ca8_errata
  444. /* Cortex-A9 Errata */
  445. ldr r10, =0x00000c09 @ Cortex-A9 primary part number
  446. teq r0, r10
  447. beq __ca9_errata
  448. /* Cortex-A12 Errata */
  449. ldr r10, =0x00000c0d @ Cortex-A12 primary part number
  450. teq r0, r10
  451. beq __ca12_errata
  452. /* Cortex-A17 Errata */
  453. ldr r10, =0x00000c0e @ Cortex-A17 primary part number
  454. teq r0, r10
  455. beq __ca17_errata
  456. /* Cortex-A15 Errata */
  457. ldr r10, =0x00000c0f @ Cortex-A15 primary part number
  458. teq r0, r10
  459. beq __ca15_errata
  460. __errata_finish:
  461. mov r10, #0
  462. mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
  463. #ifdef CONFIG_MMU
  464. mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
  465. v7_ttb_setup r10, r4, r5, r8, r3 @ TTBCR, TTBRx setup
  466. ldr r3, =PRRR @ PRRR
  467. ldr r6, =NMRR @ NMRR
  468. mcr p15, 0, r3, c10, c2, 0 @ write PRRR
  469. mcr p15, 0, r6, c10, c2, 1 @ write NMRR
  470. #endif
  471. dsb @ Complete invalidations
  472. #ifndef CONFIG_ARM_THUMBEE
  473. mrc p15, 0, r0, c0, c1, 0 @ read ID_PFR0 for ThumbEE
  474. and r0, r0, #(0xf << 12) @ ThumbEE enabled field
  475. teq r0, #(1 << 12) @ check if ThumbEE is present
  476. bne 1f
  477. mov r3, #0
  478. mcr p14, 6, r3, c1, c0, 0 @ Initialize TEEHBR to 0
  479. mrc p14, 6, r0, c0, c0, 0 @ load TEECR
  480. orr r0, r0, #1 @ set the 1st bit in order to
  481. mcr p14, 6, r0, c0, c0, 0 @ stop userspace TEEHBR access
  482. 1:
  483. #endif
  484. adr r3, v7_crval
  485. ldmia r3, {r3, r6}
  486. ARM_BE8(orr r6, r6, #1 << 25) @ big-endian page tables
  487. #ifdef CONFIG_SWP_EMULATE
  488. orr r3, r3, #(1 << 10) @ set SW bit in "clear"
  489. bic r6, r6, #(1 << 10) @ clear it in "mmuset"
  490. #endif
  491. mrc p15, 0, r0, c1, c0, 0 @ read control register
  492. bic r0, r0, r3 @ clear bits them
  493. orr r0, r0, r6 @ set them
  494. THUMB( orr r0, r0, #1 << 30 ) @ Thumb exceptions
  495. ret lr @ return to head.S:__ret
  496. .align 2
  497. __v7_setup_stack_ptr:
  498. .word PHYS_RELATIVE(__v7_setup_stack, .)
  499. ENDPROC(__v7_setup)
  500. .bss
  501. .align 2
  502. __v7_setup_stack:
  503. .space 4 * 7 @ 7 registers
  504. __INITDATA
  505. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  506. define_processor_functions v7, dabort=v7_early_abort, pabort=v7_pabort, suspend=1
  507. #ifndef CONFIG_ARM_LPAE
  508. define_processor_functions ca8, dabort=v7_early_abort, pabort=v7_pabort, suspend=1
  509. define_processor_functions ca9mp, dabort=v7_early_abort, pabort=v7_pabort, suspend=1
  510. #endif
  511. #ifdef CONFIG_CPU_PJ4B
  512. define_processor_functions pj4b, dabort=v7_early_abort, pabort=v7_pabort, suspend=1
  513. #endif
  514. .section ".rodata"
  515. string cpu_arch_name, "armv7"
  516. string cpu_elf_name, "v7"
  517. .align
  518. .section ".proc.info.init", #alloc
  519. /*
  520. * Standard v7 proc info content
  521. */
  522. .macro __v7_proc name, initfunc, mm_mmuflags = 0, io_mmuflags = 0, hwcaps = 0, proc_fns = v7_processor_functions, cache_fns = v7_cache_fns
  523. ALT_SMP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \
  524. PMD_SECT_AF | PMD_FLAGS_SMP | \mm_mmuflags)
  525. ALT_UP(.long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | \
  526. PMD_SECT_AF | PMD_FLAGS_UP | \mm_mmuflags)
  527. .long PMD_TYPE_SECT | PMD_SECT_AP_WRITE | \
  528. PMD_SECT_AP_READ | PMD_SECT_AF | \io_mmuflags
  529. initfn \initfunc, \name
  530. .long cpu_arch_name
  531. .long cpu_elf_name
  532. .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_FAST_MULT | \
  533. HWCAP_EDSP | HWCAP_TLS | \hwcaps
  534. .long cpu_v7_name
  535. .long \proc_fns
  536. .long v7wbi_tlb_fns
  537. .long v6_user_fns
  538. .long \cache_fns
  539. .endm
  540. #ifndef CONFIG_ARM_LPAE
  541. /*
  542. * ARM Ltd. Cortex A5 processor.
  543. */
  544. .type __v7_ca5mp_proc_info, #object
  545. __v7_ca5mp_proc_info:
  546. .long 0x410fc050
  547. .long 0xff0ffff0
  548. __v7_proc __v7_ca5mp_proc_info, __v7_ca5mp_setup
  549. .size __v7_ca5mp_proc_info, . - __v7_ca5mp_proc_info
  550. /*
  551. * ARM Ltd. Cortex A9 processor.
  552. */
  553. .type __v7_ca9mp_proc_info, #object
  554. __v7_ca9mp_proc_info:
  555. .long 0x410fc090
  556. .long 0xff0ffff0
  557. __v7_proc __v7_ca9mp_proc_info, __v7_ca9mp_setup, proc_fns = ca9mp_processor_functions
  558. .size __v7_ca9mp_proc_info, . - __v7_ca9mp_proc_info
  559. /*
  560. * ARM Ltd. Cortex A8 processor.
  561. */
  562. .type __v7_ca8_proc_info, #object
  563. __v7_ca8_proc_info:
  564. .long 0x410fc080
  565. .long 0xff0ffff0
  566. __v7_proc __v7_ca8_proc_info, __v7_setup, proc_fns = ca8_processor_functions
  567. .size __v7_ca8_proc_info, . - __v7_ca8_proc_info
  568. #endif /* CONFIG_ARM_LPAE */
  569. /*
  570. * Marvell PJ4B processor.
  571. */
  572. #ifdef CONFIG_CPU_PJ4B
  573. .type __v7_pj4b_proc_info, #object
  574. __v7_pj4b_proc_info:
  575. .long 0x560f5800
  576. .long 0xff0fff00
  577. __v7_proc __v7_pj4b_proc_info, __v7_pj4b_setup, proc_fns = pj4b_processor_functions
  578. .size __v7_pj4b_proc_info, . - __v7_pj4b_proc_info
  579. #endif
  580. /*
  581. * ARM Ltd. Cortex R7 processor.
  582. */
  583. .type __v7_cr7mp_proc_info, #object
  584. __v7_cr7mp_proc_info:
  585. .long 0x410fc170
  586. .long 0xff0ffff0
  587. __v7_proc __v7_cr7mp_proc_info, __v7_cr7mp_setup
  588. .size __v7_cr7mp_proc_info, . - __v7_cr7mp_proc_info
  589. /*
  590. * ARM Ltd. Cortex A7 processor.
  591. */
  592. .type __v7_ca7mp_proc_info, #object
  593. __v7_ca7mp_proc_info:
  594. .long 0x410fc070
  595. .long 0xff0ffff0
  596. __v7_proc __v7_ca7mp_proc_info, __v7_ca7mp_setup
  597. .size __v7_ca7mp_proc_info, . - __v7_ca7mp_proc_info
  598. /*
  599. * ARM Ltd. Cortex A12 processor.
  600. */
  601. .type __v7_ca12mp_proc_info, #object
  602. __v7_ca12mp_proc_info:
  603. .long 0x410fc0d0
  604. .long 0xff0ffff0
  605. __v7_proc __v7_ca12mp_proc_info, __v7_ca12mp_setup
  606. .size __v7_ca12mp_proc_info, . - __v7_ca12mp_proc_info
  607. /*
  608. * ARM Ltd. Cortex A15 processor.
  609. */
  610. .type __v7_ca15mp_proc_info, #object
  611. __v7_ca15mp_proc_info:
  612. .long 0x410fc0f0
  613. .long 0xff0ffff0
  614. __v7_proc __v7_ca15mp_proc_info, __v7_ca15mp_setup
  615. .size __v7_ca15mp_proc_info, . - __v7_ca15mp_proc_info
  616. /*
  617. * Broadcom Corporation Brahma-B15 processor.
  618. */
  619. .type __v7_b15mp_proc_info, #object
  620. __v7_b15mp_proc_info:
  621. .long 0x420f00f0
  622. .long 0xff0ffff0
  623. __v7_proc __v7_b15mp_proc_info, __v7_b15mp_setup, cache_fns = b15_cache_fns
  624. .size __v7_b15mp_proc_info, . - __v7_b15mp_proc_info
  625. /*
  626. * ARM Ltd. Cortex A17 processor.
  627. */
  628. .type __v7_ca17mp_proc_info, #object
  629. __v7_ca17mp_proc_info:
  630. .long 0x410fc0e0
  631. .long 0xff0ffff0
  632. __v7_proc __v7_ca17mp_proc_info, __v7_ca17mp_setup
  633. .size __v7_ca17mp_proc_info, . - __v7_ca17mp_proc_info
  634. /*
  635. * Qualcomm Inc. Krait processors.
  636. */
  637. .type __krait_proc_info, #object
  638. __krait_proc_info:
  639. .long 0x510f0400 @ Required ID value
  640. .long 0xff0ffc00 @ Mask for ID
  641. /*
  642. * Some Krait processors don't indicate support for SDIV and UDIV
  643. * instructions in the ARM instruction set, even though they actually
  644. * do support them. They also don't indicate support for fused multiply
  645. * instructions even though they actually do support them.
  646. */
  647. __v7_proc __krait_proc_info, __v7_setup, hwcaps = HWCAP_IDIV | HWCAP_VFPv4
  648. .size __krait_proc_info, . - __krait_proc_info
  649. /*
  650. * Match any ARMv7 processor core.
  651. */
  652. .type __v7_proc_info, #object
  653. __v7_proc_info:
  654. .long 0x000f0000 @ Required ID value
  655. .long 0x000f0000 @ Mask for ID
  656. __v7_proc __v7_proc_info, __v7_setup
  657. .size __v7_proc_info, . - __v7_proc_info