proc-sa1100.S 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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/procinfo.h>
  26. #include <asm/hardware.h>
  27. #include <asm/pgtable-hwdef.h>
  28. #include <asm/pgtable.h>
  29. /*
  30. * the cache line size of the I and D cache
  31. */
  32. #define DCACHELINESIZE 32
  33. __INIT
  34. /*
  35. * cpu_sa1100_proc_init()
  36. */
  37. ENTRY(cpu_sa1100_proc_init)
  38. mov r0, #0
  39. mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
  40. mcr p15, 0, r0, c9, c0, 5 @ Allow read-buffer operations from userland
  41. mov pc, lr
  42. .previous
  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. stmfd sp!, {lr}
  52. mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
  53. msr cpsr_c, ip
  54. bl v4wb_flush_kern_cache_all
  55. mcr p15, 0, ip, c15, c2, 2 @ Disable clock switching
  56. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  57. bic r0, r0, #0x1000 @ ...i............
  58. bic r0, r0, #0x000e @ ............wca.
  59. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  60. ldmfd sp!, {pc}
  61. /*
  62. * cpu_sa1100_reset(loc)
  63. *
  64. * Perform a soft reset of the system. Put the CPU into the
  65. * same state as it would be if it had been reset, and branch
  66. * to what would be the reset vector.
  67. *
  68. * loc: location to jump to for soft reset
  69. */
  70. .align 5
  71. ENTRY(cpu_sa1100_reset)
  72. mov ip, #0
  73. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  74. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  75. #ifdef CONFIG_MMU
  76. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  77. #endif
  78. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  79. bic ip, ip, #0x000f @ ............wcam
  80. bic ip, ip, #0x1100 @ ...i...s........
  81. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  82. mov pc, r0
  83. /*
  84. * cpu_sa1100_do_idle(type)
  85. *
  86. * Cause the processor to idle
  87. *
  88. * type: call type:
  89. * 0 = slow idle
  90. * 1 = fast idle
  91. * 2 = switch to slow processor clock
  92. * 3 = switch to fast processor clock
  93. */
  94. .align 5
  95. ENTRY(cpu_sa1100_do_idle)
  96. mov r0, r0 @ 4 nop padding
  97. mov r0, r0
  98. mov r0, r0
  99. mov r0, r0 @ 4 nop padding
  100. mov r0, r0
  101. mov r0, r0
  102. mov r0, #0
  103. ldr r1, =UNCACHEABLE_ADDR @ ptr to uncacheable address
  104. @ --- aligned to a cache line
  105. mcr p15, 0, r0, c15, c2, 2 @ disable clock switching
  106. ldr r1, [r1, #0] @ force switch to MCLK
  107. mcr p15, 0, r0, c15, c8, 2 @ wait for interrupt
  108. mov r0, r0 @ safety
  109. mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
  110. mov pc, lr
  111. /* ================================= CACHE ================================ */
  112. /*
  113. * cpu_sa1100_dcache_clean_area(addr,sz)
  114. *
  115. * Clean the specified entry of any caches such that the MMU
  116. * translation fetches will obtain correct data.
  117. *
  118. * addr: cache-unaligned virtual address
  119. */
  120. .align 5
  121. ENTRY(cpu_sa1100_dcache_clean_area)
  122. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  123. add r0, r0, #DCACHELINESIZE
  124. subs r1, r1, #DCACHELINESIZE
  125. bhi 1b
  126. mov pc, lr
  127. /* =============================== PageTable ============================== */
  128. /*
  129. * cpu_sa1100_switch_mm(pgd)
  130. *
  131. * Set the translation base pointer to be as described by pgd.
  132. *
  133. * pgd: new page tables
  134. */
  135. .align 5
  136. ENTRY(cpu_sa1100_switch_mm)
  137. #ifdef CONFIG_MMU
  138. str lr, [sp, #-4]!
  139. bl v4wb_flush_kern_cache_all @ clears IP
  140. mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
  141. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  142. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  143. ldr pc, [sp], #4
  144. #else
  145. mov pc, lr
  146. #endif
  147. /*
  148. * cpu_sa1100_set_pte(ptep, pte)
  149. *
  150. * Set a PTE and flush it out
  151. */
  152. .align 5
  153. ENTRY(cpu_sa1100_set_pte)
  154. #ifdef CONFIG_MMU
  155. str r1, [r0], #-2048 @ linux version
  156. eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
  157. bic r2, r1, #PTE_SMALL_AP_MASK
  158. bic r2, r2, #PTE_TYPE_MASK
  159. orr r2, r2, #PTE_TYPE_SMALL
  160. tst r1, #L_PTE_USER @ User?
  161. orrne r2, r2, #PTE_SMALL_AP_URO_SRW
  162. tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
  163. orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
  164. tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
  165. movne r2, #0
  166. str r2, [r0] @ hardware version
  167. mov r0, r0
  168. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  169. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  170. #endif
  171. mov pc, lr
  172. __INIT
  173. .type __sa1100_setup, #function
  174. __sa1100_setup:
  175. mov r0, #0
  176. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  177. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  178. #ifdef CONFIG_MMU
  179. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  180. #endif
  181. adr r5, sa1100_crval
  182. ldmia r5, {r5, r6}
  183. mrc p15, 0, r0, c1, c0 @ get control register v4
  184. bic r0, r0, r5
  185. orr r0, r0, r6
  186. mov pc, lr
  187. .size __sa1100_setup, . - __sa1100_setup
  188. /*
  189. * R
  190. * .RVI ZFRS BLDP WCAM
  191. * ..11 0001 ..11 1101
  192. *
  193. */
  194. .type sa1100_crval, #object
  195. sa1100_crval:
  196. crval clear=0x00003f3f, mmuset=0x0000313d, ucset=0x00001130
  197. __INITDATA
  198. /*
  199. * Purpose : Function pointers used to access above functions - all calls
  200. * come through these
  201. */
  202. /*
  203. * SA1100 and SA1110 share the same function calls
  204. */
  205. .type sa1100_processor_functions, #object
  206. ENTRY(sa1100_processor_functions)
  207. .word v4_early_abort
  208. .word cpu_sa1100_proc_init
  209. .word cpu_sa1100_proc_fin
  210. .word cpu_sa1100_reset
  211. .word cpu_sa1100_do_idle
  212. .word cpu_sa1100_dcache_clean_area
  213. .word cpu_sa1100_switch_mm
  214. .word cpu_sa1100_set_pte
  215. .size sa1100_processor_functions, . - sa1100_processor_functions
  216. .section ".rodata"
  217. .type cpu_arch_name, #object
  218. cpu_arch_name:
  219. .asciz "armv4"
  220. .size cpu_arch_name, . - cpu_arch_name
  221. .type cpu_elf_name, #object
  222. cpu_elf_name:
  223. .asciz "v4"
  224. .size cpu_elf_name, . - cpu_elf_name
  225. .type cpu_sa1100_name, #object
  226. cpu_sa1100_name:
  227. .asciz "StrongARM-1100"
  228. .size cpu_sa1100_name, . - cpu_sa1100_name
  229. .type cpu_sa1110_name, #object
  230. cpu_sa1110_name:
  231. .asciz "StrongARM-1110"
  232. .size cpu_sa1110_name, . - cpu_sa1110_name
  233. .align
  234. .section ".proc.info.init", #alloc, #execinstr
  235. .type __sa1100_proc_info,#object
  236. __sa1100_proc_info:
  237. .long 0x4401a110
  238. .long 0xfffffff0
  239. .long PMD_TYPE_SECT | \
  240. PMD_SECT_BUFFERABLE | \
  241. PMD_SECT_CACHEABLE | \
  242. PMD_SECT_AP_WRITE | \
  243. PMD_SECT_AP_READ
  244. .long PMD_TYPE_SECT | \
  245. PMD_SECT_AP_WRITE | \
  246. PMD_SECT_AP_READ
  247. b __sa1100_setup
  248. .long cpu_arch_name
  249. .long cpu_elf_name
  250. .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
  251. .long cpu_sa1100_name
  252. .long sa1100_processor_functions
  253. .long v4wb_tlb_fns
  254. .long v4_mc_user_fns
  255. .long v4wb_cache_fns
  256. .size __sa1100_proc_info, . - __sa1100_proc_info
  257. .type __sa1110_proc_info,#object
  258. __sa1110_proc_info:
  259. .long 0x6901b110
  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_sa1110_name
  274. .long sa1100_processor_functions
  275. .long v4wb_tlb_fns
  276. .long v4_mc_user_fns
  277. .long v4wb_cache_fns
  278. .size __sa1110_proc_info, . - __sa1110_proc_info