proc-v6.S 6.7 KB

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