proc-sa1100.S 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /*
  2. * linux/arch/arm/mm/proc-sa1100.S
  3. *
  4. * Copyright (C) 1997-2002 Russell King
  5. * hacked for non-paged-MM by Hyok S. Choi, 2003.
  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. * MMU functions for SA110
  12. *
  13. * These are the low level assembler for performing cache and TLB
  14. * functions on the StrongARM-1100 and StrongARM-1110.
  15. *
  16. * Note that SA1100 and SA1110 share everything but their name and CPU ID.
  17. *
  18. * 12-jun-2000, Erik Mouw (J.A.K.Mouw@its.tudelft.nl):
  19. * Flush the read buffer at context switches
  20. */
  21. #include <linux/linkage.h>
  22. #include <linux/init.h>
  23. #include <asm/assembler.h>
  24. #include <asm/asm-offsets.h>
  25. #include <asm/hwcap.h>
  26. #include <mach/hardware.h>
  27. #include <asm/pgtable-hwdef.h>
  28. #include <asm/pgtable.h>
  29. #include "proc-macros.S"
  30. /*
  31. * the cache line size of the I and D cache
  32. */
  33. #define DCACHELINESIZE 32
  34. .section .text
  35. /*
  36. * cpu_sa1100_proc_init()
  37. */
  38. ENTRY(cpu_sa1100_proc_init)
  39. mov r0, #0
  40. mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
  41. mcr p15, 0, r0, c9, c0, 5 @ Allow read-buffer operations from userland
  42. mov pc, lr
  43. /*
  44. * cpu_sa1100_proc_fin()
  45. *
  46. * Prepare the CPU for reset:
  47. * - Disable interrupts
  48. * - Clean and turn off caches.
  49. */
  50. ENTRY(cpu_sa1100_proc_fin)
  51. mcr p15, 0, ip, c15, c2, 2 @ Disable clock switching
  52. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  53. bic r0, r0, #0x1000 @ ...i............
  54. bic r0, r0, #0x000e @ ............wca.
  55. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  56. mov pc, lr
  57. /*
  58. * cpu_sa1100_reset(loc)
  59. *
  60. * Perform a soft reset of the system. Put the CPU into the
  61. * same state as it would be if it had been reset, and branch
  62. * to what would be the reset vector.
  63. *
  64. * loc: location to jump to for soft reset
  65. */
  66. .align 5
  67. ENTRY(cpu_sa1100_reset)
  68. mov ip, #0
  69. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  70. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  71. #ifdef CONFIG_MMU
  72. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  73. #endif
  74. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  75. bic ip, ip, #0x000f @ ............wcam
  76. bic ip, ip, #0x1100 @ ...i...s........
  77. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  78. mov pc, r0
  79. /*
  80. * cpu_sa1100_do_idle(type)
  81. *
  82. * Cause the processor to idle
  83. *
  84. * type: call type:
  85. * 0 = slow idle
  86. * 1 = fast idle
  87. * 2 = switch to slow processor clock
  88. * 3 = switch to fast processor clock
  89. */
  90. .align 5
  91. ENTRY(cpu_sa1100_do_idle)
  92. mov r0, r0 @ 4 nop padding
  93. mov r0, r0
  94. mov r0, r0
  95. mov r0, r0 @ 4 nop padding
  96. mov r0, r0
  97. mov r0, r0
  98. mov r0, #0
  99. ldr r1, =UNCACHEABLE_ADDR @ ptr to uncacheable address
  100. @ --- aligned to a cache line
  101. mcr p15, 0, r0, c15, c2, 2 @ disable clock switching
  102. ldr r1, [r1, #0] @ force switch to MCLK
  103. mcr p15, 0, r0, c15, c8, 2 @ wait for interrupt
  104. mov r0, r0 @ safety
  105. mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
  106. mov pc, lr
  107. /* ================================= CACHE ================================ */
  108. /*
  109. * cpu_sa1100_dcache_clean_area(addr,sz)
  110. *
  111. * Clean the specified entry of any caches such that the MMU
  112. * translation fetches will obtain correct data.
  113. *
  114. * addr: cache-unaligned virtual address
  115. */
  116. .align 5
  117. ENTRY(cpu_sa1100_dcache_clean_area)
  118. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  119. add r0, r0, #DCACHELINESIZE
  120. subs r1, r1, #DCACHELINESIZE
  121. bhi 1b
  122. mov pc, lr
  123. /* =============================== PageTable ============================== */
  124. /*
  125. * cpu_sa1100_switch_mm(pgd)
  126. *
  127. * Set the translation base pointer to be as described by pgd.
  128. *
  129. * pgd: new page tables
  130. */
  131. .align 5
  132. ENTRY(cpu_sa1100_switch_mm)
  133. #ifdef CONFIG_MMU
  134. str lr, [sp, #-4]!
  135. bl v4wb_flush_kern_cache_all @ clears IP
  136. mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
  137. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  138. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  139. ldr pc, [sp], #4
  140. #else
  141. mov pc, lr
  142. #endif
  143. /*
  144. * cpu_sa1100_set_pte_ext(ptep, pte, ext)
  145. *
  146. * Set a PTE and flush it out
  147. */
  148. .align 5
  149. ENTRY(cpu_sa1100_set_pte_ext)
  150. #ifdef CONFIG_MMU
  151. armv3_set_pte_ext wc_disable=0
  152. mov r0, r0
  153. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  154. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  155. #endif
  156. mov pc, lr
  157. .globl cpu_sa1100_suspend_size
  158. .equ cpu_sa1100_suspend_size, 4*4
  159. #ifdef CONFIG_PM_SLEEP
  160. ENTRY(cpu_sa1100_do_suspend)
  161. stmfd sp!, {r4 - r7, lr}
  162. mrc p15, 0, r4, c3, c0, 0 @ domain ID
  163. mrc p15, 0, r5, c2, c0, 0 @ translation table base addr
  164. mrc p15, 0, r6, c13, c0, 0 @ PID
  165. mrc p15, 0, r7, c1, c0, 0 @ control reg
  166. stmia r0, {r4 - r7} @ store cp regs
  167. ldmfd sp!, {r4 - r7, pc}
  168. ENDPROC(cpu_sa1100_do_suspend)
  169. ENTRY(cpu_sa1100_do_resume)
  170. ldmia r0, {r4 - r7} @ load cp regs
  171. mov r1, #0
  172. mcr p15, 0, r1, c8, c7, 0 @ flush I+D TLBs
  173. mcr p15, 0, r1, c7, c7, 0 @ flush I&D cache
  174. mcr p15, 0, r1, c9, c0, 0 @ invalidate RB
  175. mcr p15, 0, r1, c9, c0, 5 @ allow user space to use RB
  176. mcr p15, 0, r4, c3, c0, 0 @ domain ID
  177. mcr p15, 0, r5, c2, c0, 0 @ translation table base addr
  178. mcr p15, 0, r6, c13, c0, 0 @ PID
  179. mov r0, r7 @ control register
  180. mov r2, r5, lsr #14 @ get TTB0 base
  181. mov r2, r2, lsl #14
  182. ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \
  183. PMD_SECT_CACHEABLE | PMD_SECT_AP_WRITE
  184. b cpu_resume_mmu
  185. ENDPROC(cpu_sa1100_do_resume)
  186. #else
  187. #define cpu_sa1100_do_suspend 0
  188. #define cpu_sa1100_do_resume 0
  189. #endif
  190. __CPUINIT
  191. .type __sa1100_setup, #function
  192. __sa1100_setup:
  193. mov r0, #0
  194. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  195. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  196. #ifdef CONFIG_MMU
  197. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  198. #endif
  199. adr r5, sa1100_crval
  200. ldmia r5, {r5, r6}
  201. mrc p15, 0, r0, c1, c0 @ get control register v4
  202. bic r0, r0, r5
  203. orr r0, r0, r6
  204. mov pc, lr
  205. .size __sa1100_setup, . - __sa1100_setup
  206. /*
  207. * R
  208. * .RVI ZFRS BLDP WCAM
  209. * ..11 0001 ..11 1101
  210. *
  211. */
  212. .type sa1100_crval, #object
  213. sa1100_crval:
  214. crval clear=0x00003f3f, mmuset=0x0000313d, ucset=0x00001130
  215. __INITDATA
  216. /*
  217. * Purpose : Function pointers used to access above functions - all calls
  218. * come through these
  219. */
  220. /*
  221. * SA1100 and SA1110 share the same function calls
  222. */
  223. .type sa1100_processor_functions, #object
  224. ENTRY(sa1100_processor_functions)
  225. .word v4_early_abort
  226. .word legacy_pabort
  227. .word cpu_sa1100_proc_init
  228. .word cpu_sa1100_proc_fin
  229. .word cpu_sa1100_reset
  230. .word cpu_sa1100_do_idle
  231. .word cpu_sa1100_dcache_clean_area
  232. .word cpu_sa1100_switch_mm
  233. .word cpu_sa1100_set_pte_ext
  234. .word cpu_sa1100_suspend_size
  235. .word cpu_sa1100_do_suspend
  236. .word cpu_sa1100_do_resume
  237. .size sa1100_processor_functions, . - sa1100_processor_functions
  238. .section ".rodata"
  239. .type cpu_arch_name, #object
  240. cpu_arch_name:
  241. .asciz "armv4"
  242. .size cpu_arch_name, . - cpu_arch_name
  243. .type cpu_elf_name, #object
  244. cpu_elf_name:
  245. .asciz "v4"
  246. .size cpu_elf_name, . - cpu_elf_name
  247. .type cpu_sa1100_name, #object
  248. cpu_sa1100_name:
  249. .asciz "StrongARM-1100"
  250. .size cpu_sa1100_name, . - cpu_sa1100_name
  251. .type cpu_sa1110_name, #object
  252. cpu_sa1110_name:
  253. .asciz "StrongARM-1110"
  254. .size cpu_sa1110_name, . - cpu_sa1110_name
  255. .align
  256. .section ".proc.info.init", #alloc, #execinstr
  257. .type __sa1100_proc_info,#object
  258. __sa1100_proc_info:
  259. .long 0x4401a110
  260. .long 0xfffffff0
  261. .long PMD_TYPE_SECT | \
  262. PMD_SECT_BUFFERABLE | \
  263. PMD_SECT_CACHEABLE | \
  264. PMD_SECT_AP_WRITE | \
  265. PMD_SECT_AP_READ
  266. .long PMD_TYPE_SECT | \
  267. PMD_SECT_AP_WRITE | \
  268. PMD_SECT_AP_READ
  269. b __sa1100_setup
  270. .long cpu_arch_name
  271. .long cpu_elf_name
  272. .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
  273. .long cpu_sa1100_name
  274. .long sa1100_processor_functions
  275. .long v4wb_tlb_fns
  276. .long v4_mc_user_fns
  277. .long v4wb_cache_fns
  278. .size __sa1100_proc_info, . - __sa1100_proc_info
  279. .type __sa1110_proc_info,#object
  280. __sa1110_proc_info:
  281. .long 0x6901b110
  282. .long 0xfffffff0
  283. .long PMD_TYPE_SECT | \
  284. PMD_SECT_BUFFERABLE | \
  285. PMD_SECT_CACHEABLE | \
  286. PMD_SECT_AP_WRITE | \
  287. PMD_SECT_AP_READ
  288. .long PMD_TYPE_SECT | \
  289. PMD_SECT_AP_WRITE | \
  290. PMD_SECT_AP_READ
  291. b __sa1100_setup
  292. .long cpu_arch_name
  293. .long cpu_elf_name
  294. .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
  295. .long cpu_sa1110_name
  296. .long sa1100_processor_functions
  297. .long v4wb_tlb_fns
  298. .long v4_mc_user_fns
  299. .long v4wb_cache_fns
  300. .size __sa1110_proc_info, . - __sa1110_proc_info