proc-v6.S 8.2 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. ret 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. ret 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. ret 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. ret 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. ret lr
  79. /*
  80. * cpu_v6_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. mmid r1, r1 @ 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 into new context ID
  103. #endif
  104. mcr p15, 0, r1, c13, c0, 1 @ set context ID
  105. #endif
  106. ret 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. ret 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. #ifdef CONFIG_MMU
  131. mrc p15, 0, r5, c3, c0, 0 @ Domain ID
  132. mrc p15, 0, r6, c2, c0, 1 @ Translation table base 1
  133. #endif
  134. mrc p15, 0, r7, c1, c0, 1 @ auxiliary control register
  135. mrc p15, 0, r8, c1, c0, 2 @ co-processor access control
  136. mrc p15, 0, r9, c1, c0, 0 @ control register
  137. stmia r0, {r4 - r9}
  138. ldmfd sp!, {r4- r9, pc}
  139. ENDPROC(cpu_v6_do_suspend)
  140. ENTRY(cpu_v6_do_resume)
  141. mov ip, #0
  142. mcr p15, 0, ip, c7, c14, 0 @ clean+invalidate D cache
  143. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  144. mcr p15, 0, ip, c7, c15, 0 @ clean+invalidate cache
  145. mcr p15, 0, ip, c7, c10, 4 @ drain write buffer
  146. mcr p15, 0, ip, c13, c0, 1 @ set reserved context ID
  147. ldmia r0, {r4 - r9}
  148. mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID
  149. #ifdef CONFIG_MMU
  150. mcr p15, 0, r5, c3, c0, 0 @ Domain ID
  151. ALT_SMP(orr r1, r1, #TTB_FLAGS_SMP)
  152. ALT_UP(orr r1, r1, #TTB_FLAGS_UP)
  153. mcr p15, 0, r1, c2, c0, 0 @ Translation table base 0
  154. mcr p15, 0, r6, c2, c0, 1 @ Translation table base 1
  155. mcr p15, 0, ip, c2, c0, 2 @ TTB control register
  156. #endif
  157. mcr p15, 0, r7, c1, c0, 1 @ auxiliary control register
  158. mcr p15, 0, r8, c1, c0, 2 @ co-processor access control
  159. mcr p15, 0, ip, c7, c5, 4 @ ISB
  160. mov r0, r9 @ control register
  161. b cpu_resume_mmu
  162. ENDPROC(cpu_v6_do_resume)
  163. #endif
  164. string cpu_v6_name, "ARMv6-compatible processor"
  165. .align
  166. /*
  167. * __v6_setup
  168. *
  169. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  170. * on. Return in r0 the new CP15 C1 control register setting.
  171. *
  172. * We automatically detect if we have a Harvard cache, and use the
  173. * Harvard cache control instructions insead of the unified cache
  174. * control instructions.
  175. *
  176. * This should be able to cover all ARMv6 cores.
  177. *
  178. * It is assumed that:
  179. * - cache type register is implemented
  180. */
  181. __v6_setup:
  182. #ifdef CONFIG_SMP
  183. ALT_SMP(mrc p15, 0, r0, c1, c0, 1) @ Enable SMP/nAMP mode
  184. ALT_UP(nop)
  185. orr r0, r0, #0x20
  186. ALT_SMP(mcr p15, 0, r0, c1, c0, 1)
  187. ALT_UP(nop)
  188. #endif
  189. mov r0, #0
  190. mcr p15, 0, r0, c7, c14, 0 @ clean+invalidate D cache
  191. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  192. mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache
  193. #ifdef CONFIG_MMU
  194. mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs
  195. mcr p15, 0, r0, c2, c0, 2 @ TTB control register
  196. ALT_SMP(orr r4, r4, #TTB_FLAGS_SMP)
  197. ALT_UP(orr r4, r4, #TTB_FLAGS_UP)
  198. ALT_SMP(orr r8, r8, #TTB_FLAGS_SMP)
  199. ALT_UP(orr r8, r8, #TTB_FLAGS_UP)
  200. mcr p15, 0, r8, c2, c0, 1 @ load TTB1
  201. #endif /* CONFIG_MMU */
  202. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer and
  203. @ complete invalidations
  204. adr r5, v6_crval
  205. ldmia r5, {r5, r6}
  206. ARM_BE8(orr r6, r6, #1 << 25) @ big-endian page tables
  207. mrc p15, 0, r0, c1, c0, 0 @ read control register
  208. bic r0, r0, r5 @ clear bits them
  209. orr r0, r0, r6 @ set them
  210. #ifdef CONFIG_ARM_ERRATA_364296
  211. /*
  212. * Workaround for the 364296 ARM1136 r0p2 erratum (possible cache data
  213. * corruption with hit-under-miss enabled). The conditional code below
  214. * (setting the undocumented bit 31 in the auxiliary control register
  215. * and the FI bit in the control register) disables hit-under-miss
  216. * without putting the processor into full low interrupt latency mode.
  217. */
  218. ldr r6, =0x4107b362 @ id for ARM1136 r0p2
  219. mrc p15, 0, r5, c0, c0, 0 @ get processor id
  220. teq r5, r6 @ check for the faulty core
  221. mrceq p15, 0, r5, c1, c0, 1 @ load aux control reg
  222. orreq r5, r5, #(1 << 31) @ set the undocumented bit 31
  223. mcreq p15, 0, r5, c1, c0, 1 @ write aux control reg
  224. orreq r0, r0, #(1 << 21) @ low interrupt latency configuration
  225. #endif
  226. ret lr @ return to head.S:__ret
  227. /*
  228. * V X F I D LR
  229. * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM
  230. * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
  231. * 0 110 0011 1.00 .111 1101 < we want
  232. */
  233. .type v6_crval, #object
  234. v6_crval:
  235. crval clear=0x01e0fb7f, mmuset=0x00c0387d, ucset=0x00c0187c
  236. __INITDATA
  237. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  238. define_processor_functions v6, dabort=v6_early_abort, pabort=v6_pabort, suspend=1
  239. .section ".rodata"
  240. string cpu_arch_name, "armv6"
  241. string cpu_elf_name, "v6"
  242. .align
  243. .section ".proc.info.init", #alloc
  244. /*
  245. * Match any ARMv6 processor core.
  246. */
  247. .type __v6_proc_info, #object
  248. __v6_proc_info:
  249. .long 0x0007b000
  250. .long 0x0007f000
  251. ALT_SMP(.long \
  252. PMD_TYPE_SECT | \
  253. PMD_SECT_AP_WRITE | \
  254. PMD_SECT_AP_READ | \
  255. PMD_FLAGS_SMP)
  256. ALT_UP(.long \
  257. PMD_TYPE_SECT | \
  258. PMD_SECT_AP_WRITE | \
  259. PMD_SECT_AP_READ | \
  260. PMD_FLAGS_UP)
  261. .long PMD_TYPE_SECT | \
  262. PMD_SECT_XN | \
  263. PMD_SECT_AP_WRITE | \
  264. PMD_SECT_AP_READ
  265. initfn __v6_setup, __v6_proc_info
  266. .long cpu_arch_name
  267. .long cpu_elf_name
  268. /* See also feat_v6_fixup() for HWCAP_TLS */
  269. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA|HWCAP_TLS
  270. .long cpu_v6_name
  271. .long v6_processor_functions
  272. .long v6wbi_tlb_fns
  273. .long v6_user_fns
  274. .long v6_cache_fns
  275. .size __v6_proc_info, . - __v6_proc_info