proc-v6.S 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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/init.h>
  14. #include <linux/linkage.h>
  15. #include <asm/assembler.h>
  16. #include <asm/asm-offsets.h>
  17. #include <asm/hwcap.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. #define TTB_FLAGS_UP TTB_RGN_WBWA
  30. #define PMD_FLAGS_UP PMD_SECT_WB
  31. #define TTB_FLAGS_SMP TTB_RGN_WBWA|TTB_S
  32. #define PMD_FLAGS_SMP PMD_SECT_WBWA|PMD_SECT_S
  33. ENTRY(cpu_v6_proc_init)
  34. mov pc, lr
  35. ENTRY(cpu_v6_proc_fin)
  36. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  37. bic r0, r0, #0x1000 @ ...i............
  38. bic r0, r0, #0x0006 @ .............ca.
  39. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  40. mov pc, lr
  41. /*
  42. * cpu_v6_reset(loc)
  43. *
  44. * Perform a soft reset of the system. Put the CPU into the
  45. * same state as it would be if it had been reset, and branch
  46. * to what would be the reset vector.
  47. *
  48. * - loc - location to jump to for soft reset
  49. */
  50. .align 5
  51. .pushsection .idmap.text, "ax"
  52. ENTRY(cpu_v6_reset)
  53. mrc p15, 0, r1, c1, c0, 0 @ ctrl register
  54. bic r1, r1, #0x1 @ ...............m
  55. mcr p15, 0, r1, c1, c0, 0 @ disable MMU
  56. mov r1, #0
  57. mcr p15, 0, r1, c7, c5, 4 @ ISB
  58. mov pc, r0
  59. ENDPROC(cpu_v6_reset)
  60. .popsection
  61. /*
  62. * cpu_v6_do_idle()
  63. *
  64. * Idle the processor (eg, wait for interrupt).
  65. *
  66. * IRQs are already disabled.
  67. */
  68. ENTRY(cpu_v6_do_idle)
  69. mov r1, #0
  70. mcr p15, 0, r1, c7, c10, 4 @ DWB - WFI may enter a low-power mode
  71. mcr p15, 0, r1, c7, c0, 4 @ wait for interrupt
  72. mov pc, lr
  73. ENTRY(cpu_v6_dcache_clean_area)
  74. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  75. add r0, r0, #D_CACHE_LINE_SIZE
  76. subs r1, r1, #D_CACHE_LINE_SIZE
  77. bhi 1b
  78. mov pc, lr
  79. /*
  80. * cpu_arm926_switch_mm(pgd_phys, tsk)
  81. *
  82. * Set the translation table base pointer to be pgd_phys
  83. *
  84. * - pgd_phys - physical address of new TTB
  85. *
  86. * It is assumed that:
  87. * - we are not using split page tables
  88. */
  89. ENTRY(cpu_v6_switch_mm)
  90. #ifdef CONFIG_MMU
  91. mov r2, #0
  92. ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
  93. ALT_SMP(orr r0, r0, #TTB_FLAGS_SMP)
  94. ALT_UP(orr r0, r0, #TTB_FLAGS_UP)
  95. mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
  96. mcr p15, 0, r2, c7, c10, 4 @ drain write buffer
  97. mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
  98. #ifdef CONFIG_PID_IN_CONTEXTIDR
  99. mrc p15, 0, r2, c13, c0, 1 @ read current context ID
  100. bic r2, r2, #0xff @ extract the PID
  101. and r1, r1, #0xff
  102. orr r1, r1, r2 @ insert the PID into r1
  103. #endif
  104. mcr p15, 0, r1, c13, c0, 1 @ set context ID
  105. #endif
  106. mov pc, lr
  107. /*
  108. * cpu_v6_set_pte_ext(ptep, pte, ext)
  109. *
  110. * Set a level 2 translation table entry.
  111. *
  112. * - ptep - pointer to level 2 translation table entry
  113. * (hardware version is stored at -1024 bytes)
  114. * - pte - PTE value to store
  115. * - ext - value for extended PTE bits
  116. */
  117. armv6_mt_table cpu_v6
  118. ENTRY(cpu_v6_set_pte_ext)
  119. #ifdef CONFIG_MMU
  120. armv6_set_pte_ext cpu_v6
  121. #endif
  122. mov pc, lr
  123. /* Suspend/resume support: taken from arch/arm/mach-s3c64xx/sleep.S */
  124. .globl cpu_v6_suspend_size
  125. .equ cpu_v6_suspend_size, 4 * 6
  126. #ifdef CONFIG_ARM_CPU_SUSPEND
  127. ENTRY(cpu_v6_do_suspend)
  128. stmfd sp!, {r4 - r9, lr}
  129. mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID
  130. mrc p15, 0, r5, c3, c0, 0 @ Domain ID
  131. mrc p15, 0, r6, c2, c0, 1 @ Translation table base 1
  132. mrc p15, 0, r7, c1, c0, 1 @ auxiliary control register
  133. mrc p15, 0, r8, c1, c0, 2 @ co-processor access control
  134. mrc p15, 0, r9, c1, c0, 0 @ control register
  135. stmia r0, {r4 - r9}
  136. ldmfd sp!, {r4- r9, pc}
  137. ENDPROC(cpu_v6_do_suspend)
  138. ENTRY(cpu_v6_do_resume)
  139. mov ip, #0
  140. mcr p15, 0, ip, c7, c14, 0 @ clean+invalidate D cache
  141. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  142. mcr p15, 0, ip, c7, c15, 0 @ clean+invalidate cache
  143. mcr p15, 0, ip, c7, c10, 4 @ drain write buffer
  144. mcr p15, 0, ip, c13, c0, 1 @ set reserved context ID
  145. ldmia r0, {r4 - r9}
  146. mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID
  147. mcr p15, 0, r5, c3, c0, 0 @ Domain ID
  148. ALT_SMP(orr r1, r1, #TTB_FLAGS_SMP)
  149. ALT_UP(orr r1, r1, #TTB_FLAGS_UP)
  150. mcr p15, 0, r1, c2, c0, 0 @ Translation table base 0
  151. mcr p15, 0, r6, c2, c0, 1 @ Translation table base 1
  152. mcr p15, 0, r7, c1, c0, 1 @ auxiliary control register
  153. mcr p15, 0, r8, c1, c0, 2 @ co-processor access control
  154. mcr p15, 0, ip, c2, c0, 2 @ TTB control register
  155. mcr p15, 0, ip, c7, c5, 4 @ ISB
  156. mov r0, r9 @ control register
  157. b cpu_resume_mmu
  158. ENDPROC(cpu_v6_do_resume)
  159. #endif
  160. string cpu_v6_name, "ARMv6-compatible processor"
  161. .align
  162. __CPUINIT
  163. /*
  164. * __v6_setup
  165. *
  166. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  167. * on. Return in r0 the new CP15 C1 control register setting.
  168. *
  169. * We automatically detect if we have a Harvard cache, and use the
  170. * Harvard cache control instructions insead of the unified cache
  171. * control instructions.
  172. *
  173. * This should be able to cover all ARMv6 cores.
  174. *
  175. * It is assumed that:
  176. * - cache type register is implemented
  177. */
  178. __v6_setup:
  179. #ifdef CONFIG_SMP
  180. ALT_SMP(mrc p15, 0, r0, c1, c0, 1) @ Enable SMP/nAMP mode
  181. ALT_UP(nop)
  182. orr r0, r0, #0x20
  183. ALT_SMP(mcr p15, 0, r0, c1, c0, 1)
  184. ALT_UP(nop)
  185. #endif
  186. mov r0, #0
  187. mcr p15, 0, r0, c7, c14, 0 @ clean+invalidate D cache
  188. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  189. mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache
  190. #ifdef CONFIG_MMU
  191. mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs
  192. mcr p15, 0, r0, c2, c0, 2 @ TTB control register
  193. ALT_SMP(orr r4, r4, #TTB_FLAGS_SMP)
  194. ALT_UP(orr r4, r4, #TTB_FLAGS_UP)
  195. ALT_SMP(orr r8, r8, #TTB_FLAGS_SMP)
  196. ALT_UP(orr r8, r8, #TTB_FLAGS_UP)
  197. mcr p15, 0, r8, c2, c0, 1 @ load TTB1
  198. #endif /* CONFIG_MMU */
  199. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer and
  200. @ complete invalidations
  201. adr r5, v6_crval
  202. ldmia r5, {r5, r6}
  203. #ifdef CONFIG_CPU_ENDIAN_BE8
  204. orr r6, r6, #1 << 25 @ big-endian page tables
  205. #endif
  206. mrc p15, 0, r0, c1, c0, 0 @ read control register
  207. bic r0, r0, r5 @ clear bits them
  208. orr r0, r0, r6 @ set them
  209. #ifdef CONFIG_ARM_ERRATA_364296
  210. /*
  211. * Workaround for the 364296 ARM1136 r0p2 erratum (possible cache data
  212. * corruption with hit-under-miss enabled). The conditional code below
  213. * (setting the undocumented bit 31 in the auxiliary control register
  214. * and the FI bit in the control register) disables hit-under-miss
  215. * without putting the processor into full low interrupt latency mode.
  216. */
  217. ldr r6, =0x4107b362 @ id for ARM1136 r0p2
  218. mrc p15, 0, r5, c0, c0, 0 @ get processor id
  219. teq r5, r6 @ check for the faulty core
  220. mrceq p15, 0, r5, c1, c0, 1 @ load aux control reg
  221. orreq r5, r5, #(1 << 31) @ set the undocumented bit 31
  222. mcreq p15, 0, r5, c1, c0, 1 @ write aux control reg
  223. orreq r0, r0, #(1 << 21) @ low interrupt latency configuration
  224. #endif
  225. mov pc, lr @ return to head.S:__ret
  226. /*
  227. * V X F I D LR
  228. * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM
  229. * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
  230. * 0 110 0011 1.00 .111 1101 < we want
  231. */
  232. .type v6_crval, #object
  233. v6_crval:
  234. crval clear=0x01e0fb7f, mmuset=0x00c0387d, ucset=0x00c0187c
  235. __INITDATA
  236. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  237. define_processor_functions v6, dabort=v6_early_abort, pabort=v6_pabort, suspend=1
  238. .section ".rodata"
  239. string cpu_arch_name, "armv6"
  240. string cpu_elf_name, "v6"
  241. .align
  242. .section ".proc.info.init", #alloc, #execinstr
  243. /*
  244. * Match any ARMv6 processor core.
  245. */
  246. .type __v6_proc_info, #object
  247. __v6_proc_info:
  248. .long 0x0007b000
  249. .long 0x0007f000
  250. ALT_SMP(.long \
  251. PMD_TYPE_SECT | \
  252. PMD_SECT_AP_WRITE | \
  253. PMD_SECT_AP_READ | \
  254. PMD_FLAGS_SMP)
  255. ALT_UP(.long \
  256. PMD_TYPE_SECT | \
  257. PMD_SECT_AP_WRITE | \
  258. PMD_SECT_AP_READ | \
  259. PMD_FLAGS_UP)
  260. .long PMD_TYPE_SECT | \
  261. PMD_SECT_XN | \
  262. PMD_SECT_AP_WRITE | \
  263. PMD_SECT_AP_READ
  264. b __v6_setup
  265. .long cpu_arch_name
  266. .long cpu_elf_name
  267. /* See also feat_v6_fixup() for HWCAP_TLS */
  268. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA|HWCAP_TLS
  269. .long cpu_v6_name
  270. .long v6_processor_functions
  271. .long v6wbi_tlb_fns
  272. .long v6_user_fns
  273. .long v6_cache_fns
  274. .size __v6_proc_info, . - __v6_proc_info