proc-v7.S 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 "proc-macros.S"
  20. #define TTB_C (1 << 0)
  21. #define TTB_S (1 << 1)
  22. #define TTB_RGN_NC (0 << 3)
  23. #define TTB_RGN_OC_WBWA (1 << 3)
  24. #define TTB_RGN_OC_WT (2 << 3)
  25. #define TTB_RGN_OC_WB (3 << 3)
  26. #ifndef CONFIG_SMP
  27. #define TTB_FLAGS TTB_C|TTB_RGN_OC_WB @ mark PTWs cacheable, outer WB
  28. #else
  29. #define TTB_FLAGS TTB_C|TTB_S|TTB_RGN_OC_WBWA @ mark PTWs cacheable and shared, outer WBWA
  30. #endif
  31. ENTRY(cpu_v7_proc_init)
  32. mov pc, lr
  33. ENDPROC(cpu_v7_proc_init)
  34. ENTRY(cpu_v7_proc_fin)
  35. mov pc, lr
  36. ENDPROC(cpu_v7_proc_fin)
  37. /*
  38. * cpu_v7_reset(loc)
  39. *
  40. * Perform a soft reset of the system. Put the CPU into the
  41. * same state as it would be if it had been reset, and branch
  42. * to what would be the reset vector.
  43. *
  44. * - loc - location to jump to for soft reset
  45. *
  46. * It is assumed that:
  47. */
  48. .align 5
  49. ENTRY(cpu_v7_reset)
  50. mov pc, r0
  51. ENDPROC(cpu_v7_reset)
  52. /*
  53. * cpu_v7_do_idle()
  54. *
  55. * Idle the processor (eg, wait for interrupt).
  56. *
  57. * IRQs are already disabled.
  58. */
  59. ENTRY(cpu_v7_do_idle)
  60. dsb @ WFI may enter a low-power mode
  61. wfi
  62. mov pc, lr
  63. ENDPROC(cpu_v7_do_idle)
  64. ENTRY(cpu_v7_dcache_clean_area)
  65. #ifndef TLB_CAN_READ_FROM_L1_CACHE
  66. dcache_line_size r2, r3
  67. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  68. add r0, r0, r2
  69. subs r1, r1, r2
  70. bhi 1b
  71. dsb
  72. #endif
  73. mov pc, lr
  74. ENDPROC(cpu_v7_dcache_clean_area)
  75. /*
  76. * cpu_v7_switch_mm(pgd_phys, tsk)
  77. *
  78. * Set the translation table base pointer to be pgd_phys
  79. *
  80. * - pgd_phys - physical address of new TTB
  81. *
  82. * It is assumed that:
  83. * - we are not using split page tables
  84. */
  85. ENTRY(cpu_v7_switch_mm)
  86. #ifdef CONFIG_MMU
  87. mov r2, #0
  88. ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
  89. orr r0, r0, #TTB_FLAGS
  90. mcr p15, 0, r2, c13, c0, 1 @ set reserved context ID
  91. isb
  92. 1: mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
  93. isb
  94. mcr p15, 0, r1, c13, c0, 1 @ set context ID
  95. isb
  96. #endif
  97. mov pc, lr
  98. ENDPROC(cpu_v7_switch_mm)
  99. /*
  100. * cpu_v7_set_pte_ext(ptep, pte)
  101. *
  102. * Set a level 2 translation table entry.
  103. *
  104. * - ptep - pointer to level 2 translation table entry
  105. * (hardware version is stored at -1024 bytes)
  106. * - pte - PTE value to store
  107. * - ext - value for extended PTE bits
  108. */
  109. ENTRY(cpu_v7_set_pte_ext)
  110. #ifdef CONFIG_MMU
  111. str r1, [r0], #-2048 @ linux version
  112. bic r3, r1, #0x000003f0
  113. bic r3, r3, #PTE_TYPE_MASK
  114. orr r3, r3, r2
  115. orr r3, r3, #PTE_EXT_AP0 | 2
  116. tst r1, #1 << 4
  117. orrne r3, r3, #PTE_EXT_TEX(1)
  118. tst r1, #L_PTE_WRITE
  119. tstne r1, #L_PTE_DIRTY
  120. orreq r3, r3, #PTE_EXT_APX
  121. tst r1, #L_PTE_USER
  122. orrne r3, r3, #PTE_EXT_AP1
  123. tstne r3, #PTE_EXT_APX
  124. bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
  125. tst r1, #L_PTE_EXEC
  126. orreq r3, r3, #PTE_EXT_XN
  127. tst r1, #L_PTE_YOUNG
  128. tstne r1, #L_PTE_PRESENT
  129. moveq r3, #0
  130. str r3, [r0]
  131. mcr p15, 0, r0, c7, c10, 1 @ flush_pte
  132. #endif
  133. mov pc, lr
  134. ENDPROC(cpu_v7_set_pte_ext)
  135. cpu_v7_name:
  136. .ascii "ARMv7 Processor"
  137. .align
  138. __INIT
  139. /*
  140. * __v7_setup
  141. *
  142. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  143. * on. Return in r0 the new CP15 C1 control register setting.
  144. *
  145. * We automatically detect if we have a Harvard cache, and use the
  146. * Harvard cache control instructions insead of the unified cache
  147. * control instructions.
  148. *
  149. * This should be able to cover all ARMv7 cores.
  150. *
  151. * It is assumed that:
  152. * - cache type register is implemented
  153. */
  154. __v7_setup:
  155. #ifdef CONFIG_SMP
  156. mrc p15, 0, r0, c1, c0, 1 @ Enable SMP/nAMP mode
  157. orr r0, r0, #(0x1 << 6)
  158. mcr p15, 0, r0, c1, c0, 1
  159. #endif
  160. adr r12, __v7_setup_stack @ the local stack
  161. stmia r12, {r0-r5, r7, r9, r11, lr}
  162. bl v7_flush_dcache_all
  163. ldmia r12, {r0-r5, r7, r9, r11, lr}
  164. mov r10, #0
  165. #ifdef HARVARD_CACHE
  166. mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
  167. #endif
  168. dsb
  169. #ifdef CONFIG_MMU
  170. mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
  171. mcr p15, 0, r10, c2, c0, 2 @ TTB control register
  172. orr r4, r4, #TTB_FLAGS
  173. mcr p15, 0, r4, c2, c0, 1 @ load TTB1
  174. mov r10, #0x1f @ domains 0, 1 = manager
  175. mcr p15, 0, r10, c3, c0, 0 @ load domain access register
  176. #endif
  177. ldr r5, =0xff0aa1a8
  178. ldr r6, =0x40e040e0
  179. mcr p15, 0, r5, c10, c2, 0 @ write PRRR
  180. mcr p15, 0, r6, c10, c2, 1 @ write NMRR
  181. adr r5, v7_crval
  182. ldmia r5, {r5, r6}
  183. mrc p15, 0, r0, c1, c0, 0 @ read control register
  184. bic r0, r0, r5 @ clear bits them
  185. orr r0, r0, r6 @ set them
  186. mov pc, lr @ return to head.S:__ret
  187. ENDPROC(__v7_setup)
  188. /* AT
  189. * TFR EV X F I D LR
  190. * .EEE ..EE PUI. .T.T 4RVI ZFRS BLDP WCAM
  191. * rxxx rrxx xxx0 0101 xxxx xxxx x111 xxxx < forced
  192. * 1 0 110 0011 1.00 .111 1101 < we want
  193. */
  194. .type v7_crval, #object
  195. v7_crval:
  196. crval clear=0x0120c302, mmuset=0x10c0387d, ucset=0x00c0187c
  197. __v7_setup_stack:
  198. .space 4 * 11 @ 11 registers
  199. .type v7_processor_functions, #object
  200. ENTRY(v7_processor_functions)
  201. .word v7_early_abort
  202. .word pabort_ifar
  203. .word cpu_v7_proc_init
  204. .word cpu_v7_proc_fin
  205. .word cpu_v7_reset
  206. .word cpu_v7_do_idle
  207. .word cpu_v7_dcache_clean_area
  208. .word cpu_v7_switch_mm
  209. .word cpu_v7_set_pte_ext
  210. .size v7_processor_functions, . - v7_processor_functions
  211. .type cpu_arch_name, #object
  212. cpu_arch_name:
  213. .asciz "armv7"
  214. .size cpu_arch_name, . - cpu_arch_name
  215. .type cpu_elf_name, #object
  216. cpu_elf_name:
  217. .asciz "v7"
  218. .size cpu_elf_name, . - cpu_elf_name
  219. .align
  220. .section ".proc.info.init", #alloc, #execinstr
  221. /*
  222. * Match any ARMv7 processor core.
  223. */
  224. .type __v7_proc_info, #object
  225. __v7_proc_info:
  226. .long 0x000f0000 @ Required ID value
  227. .long 0x000f0000 @ Mask for ID
  228. .long PMD_TYPE_SECT | \
  229. PMD_SECT_BUFFERABLE | \
  230. PMD_SECT_CACHEABLE | \
  231. PMD_SECT_AP_WRITE | \
  232. PMD_SECT_AP_READ
  233. .long PMD_TYPE_SECT | \
  234. PMD_SECT_XN | \
  235. PMD_SECT_AP_WRITE | \
  236. PMD_SECT_AP_READ
  237. b __v7_setup
  238. .long cpu_arch_name
  239. .long cpu_elf_name
  240. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  241. .long cpu_v7_name
  242. .long v7_processor_functions
  243. .long v7wbi_tlb_fns
  244. .long v6_user_fns
  245. .long v7_cache_fns
  246. .size __v7_proc_info, . - __v7_proc_info