proc-v6.S 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /*
  2. * linux/arch/arm/mm/proc-v6.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 ARMv6 processor support.
  11. */
  12. #include <linux/linkage.h>
  13. #include <asm/assembler.h>
  14. #include <asm/asm-offsets.h>
  15. #include <asm/hardware/arm_scu.h>
  16. #include <asm/procinfo.h>
  17. #include <asm/pgtable-hwdef.h>
  18. #include <asm/pgtable.h>
  19. #include "proc-macros.S"
  20. #define D_CACHE_LINE_SIZE 32
  21. .macro cpsie, flags
  22. .ifc \flags, f
  23. .long 0xf1080040
  24. .exitm
  25. .endif
  26. .ifc \flags, i
  27. .long 0xf1080080
  28. .exitm
  29. .endif
  30. .ifc \flags, if
  31. .long 0xf10800c0
  32. .exitm
  33. .endif
  34. .err
  35. .endm
  36. .macro cpsid, flags
  37. .ifc \flags, f
  38. .long 0xf10c0040
  39. .exitm
  40. .endif
  41. .ifc \flags, i
  42. .long 0xf10c0080
  43. .exitm
  44. .endif
  45. .ifc \flags, if
  46. .long 0xf10c00c0
  47. .exitm
  48. .endif
  49. .err
  50. .endm
  51. ENTRY(cpu_v6_proc_init)
  52. mov pc, lr
  53. ENTRY(cpu_v6_proc_fin)
  54. stmfd sp!, {lr}
  55. cpsid if @ disable interrupts
  56. bl v6_flush_kern_cache_all
  57. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  58. bic r0, r0, #0x1000 @ ...i............
  59. bic r0, r0, #0x0006 @ .............ca.
  60. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  61. ldmfd sp!, {pc}
  62. /*
  63. * cpu_v6_reset(loc)
  64. *
  65. * Perform a soft reset of the system. Put the CPU into the
  66. * same state as it would be if it had been reset, and branch
  67. * to what would be the reset vector.
  68. *
  69. * - loc - location to jump to for soft reset
  70. *
  71. * It is assumed that:
  72. */
  73. .align 5
  74. ENTRY(cpu_v6_reset)
  75. mov pc, r0
  76. /*
  77. * cpu_v6_do_idle()
  78. *
  79. * Idle the processor (eg, wait for interrupt).
  80. *
  81. * IRQs are already disabled.
  82. */
  83. ENTRY(cpu_v6_do_idle)
  84. mcr p15, 0, r1, c7, c0, 4 @ wait for interrupt
  85. mov pc, lr
  86. ENTRY(cpu_v6_dcache_clean_area)
  87. #ifndef TLB_CAN_READ_FROM_L1_CACHE
  88. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  89. add r0, r0, #D_CACHE_LINE_SIZE
  90. subs r1, r1, #D_CACHE_LINE_SIZE
  91. bhi 1b
  92. #endif
  93. mov pc, lr
  94. /*
  95. * cpu_arm926_switch_mm(pgd_phys, tsk)
  96. *
  97. * Set the translation table base pointer to be pgd_phys
  98. *
  99. * - pgd_phys - physical address of new TTB
  100. *
  101. * It is assumed that:
  102. * - we are not using split page tables
  103. */
  104. ENTRY(cpu_v6_switch_mm)
  105. mov r2, #0
  106. ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
  107. #ifdef CONFIG_SMP
  108. orr r0, r0, #2 @ set shared pgtable
  109. #endif
  110. mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
  111. mcr p15, 0, r2, c7, c10, 4 @ drain write buffer
  112. mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
  113. mcr p15, 0, r1, c13, c0, 1 @ set context ID
  114. mov pc, lr
  115. /*
  116. * cpu_v6_set_pte(ptep, pte)
  117. *
  118. * Set a level 2 translation table entry.
  119. *
  120. * - ptep - pointer to level 2 translation table entry
  121. * (hardware version is stored at -1024 bytes)
  122. * - pte - PTE value to store
  123. *
  124. * Permissions:
  125. * YUWD APX AP1 AP0 SVC User
  126. * 0xxx 0 0 0 no acc no acc
  127. * 100x 1 0 1 r/o no acc
  128. * 10x0 1 0 1 r/o no acc
  129. * 1011 0 0 1 r/w no acc
  130. * 110x 0 1 0 r/w r/o
  131. * 11x0 0 1 0 r/w r/o
  132. * 1111 0 1 1 r/w r/w
  133. */
  134. ENTRY(cpu_v6_set_pte)
  135. str r1, [r0], #-2048 @ linux version
  136. bic r2, r1, #0x000003f0
  137. bic r2, r2, #0x00000003
  138. orr r2, r2, #PTE_EXT_AP0 | 2
  139. tst r1, #L_PTE_WRITE
  140. tstne r1, #L_PTE_DIRTY
  141. orreq r2, r2, #PTE_EXT_APX
  142. tst r1, #L_PTE_USER
  143. orrne r2, r2, #PTE_EXT_AP1
  144. tstne r2, #PTE_EXT_APX
  145. bicne r2, r2, #PTE_EXT_APX | PTE_EXT_AP0
  146. tst r1, #L_PTE_YOUNG
  147. biceq r2, r2, #PTE_EXT_APX | PTE_EXT_AP_MASK
  148. @ tst r1, #L_PTE_EXEC
  149. @ orreq r2, r2, #PTE_EXT_XN
  150. tst r1, #L_PTE_PRESENT
  151. moveq r2, #0
  152. str r2, [r0]
  153. mcr p15, 0, r0, c7, c10, 1 @ flush_pte
  154. mov pc, lr
  155. cpu_v6_name:
  156. .asciz "Some Random V6 Processor"
  157. .align
  158. .section ".text.init", #alloc, #execinstr
  159. /*
  160. * __v6_setup
  161. *
  162. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  163. * on. Return in r0 the new CP15 C1 control register setting.
  164. *
  165. * We automatically detect if we have a Harvard cache, and use the
  166. * Harvard cache control instructions insead of the unified cache
  167. * control instructions.
  168. *
  169. * This should be able to cover all ARMv6 cores.
  170. *
  171. * It is assumed that:
  172. * - cache type register is implemented
  173. */
  174. __v6_setup:
  175. #ifdef CONFIG_SMP
  176. /* Set up the SCU on core 0 only */
  177. mrc p15, 0, r0, c0, c0, 5 @ CPU core number
  178. ands r0, r0, #15
  179. moveq r0, #0x10000000 @ SCU_BASE
  180. orreq r0, r0, #0x00100000
  181. ldreq r5, [r0, #SCU_CTRL]
  182. orreq r5, r5, #1
  183. streq r5, [r0, #SCU_CTRL]
  184. #ifndef CONFIG_CPU_DCACHE_DISABLE
  185. mrc p15, 0, r0, c1, c0, 1 @ Enable SMP/nAMP mode
  186. orr r0, r0, #0x20
  187. mcr p15, 0, r0, c1, c0, 1
  188. #endif
  189. #endif
  190. mov r0, #0
  191. mcr p15, 0, r0, c7, c14, 0 @ clean+invalidate D cache
  192. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  193. mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache
  194. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  195. mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs
  196. mcr p15, 0, r0, c2, c0, 2 @ TTB control register
  197. #ifdef CONFIG_SMP
  198. orr r4, r4, #2 @ set shared pgtable
  199. #endif
  200. mcr p15, 0, r4, c2, c0, 1 @ load TTB1
  201. #ifdef CONFIG_VFP
  202. mrc p15, 0, r0, c1, c0, 2
  203. orr r0, r0, #(0xf << 20)
  204. mcr p15, 0, r0, c1, c0, 2 @ Enable full access to VFP
  205. #endif
  206. mrc p15, 0, r0, c1, c0, 0 @ read control register
  207. ldr r5, v6_cr1_clear @ get mask for bits to clear
  208. bic r0, r0, r5 @ clear bits them
  209. ldr r5, v6_cr1_set @ get mask for bits to set
  210. orr r0, r0, r5 @ set them
  211. mov pc, lr @ return to head.S:__ret
  212. /*
  213. * V X F I D LR
  214. * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM
  215. * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
  216. * 0 110 0011 1.00 .111 1101 < we want
  217. */
  218. .type v6_cr1_clear, #object
  219. .type v6_cr1_set, #object
  220. v6_cr1_clear:
  221. .word 0x01e0fb7f
  222. v6_cr1_set:
  223. .word 0x00c0387d
  224. .type v6_processor_functions, #object
  225. ENTRY(v6_processor_functions)
  226. .word v6_early_abort
  227. .word cpu_v6_proc_init
  228. .word cpu_v6_proc_fin
  229. .word cpu_v6_reset
  230. .word cpu_v6_do_idle
  231. .word cpu_v6_dcache_clean_area
  232. .word cpu_v6_switch_mm
  233. .word cpu_v6_set_pte
  234. .size v6_processor_functions, . - v6_processor_functions
  235. .type cpu_arch_name, #object
  236. cpu_arch_name:
  237. .asciz "armv6"
  238. .size cpu_arch_name, . - cpu_arch_name
  239. .type cpu_elf_name, #object
  240. cpu_elf_name:
  241. .asciz "v6"
  242. .size cpu_elf_name, . - cpu_elf_name
  243. .align
  244. .section ".proc.info.init", #alloc, #execinstr
  245. /*
  246. * Match any ARMv6 processor core.
  247. */
  248. .type __v6_proc_info, #object
  249. __v6_proc_info:
  250. .long 0x0007b000
  251. .long 0x0007f000
  252. .long PMD_TYPE_SECT | \
  253. PMD_SECT_BUFFERABLE | \
  254. PMD_SECT_CACHEABLE | \
  255. PMD_SECT_AP_WRITE | \
  256. PMD_SECT_AP_READ
  257. b __v6_setup
  258. .long cpu_arch_name
  259. .long cpu_elf_name
  260. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_VFP|HWCAP_EDSP|HWCAP_JAVA
  261. .long cpu_v6_name
  262. .long v6_processor_functions
  263. .long v6wbi_tlb_fns
  264. .long v6_user_fns
  265. .long v6_cache_fns
  266. .size __v6_proc_info, . - __v6_proc_info