proc-sa1100.S 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /*
  2. * linux/arch/arm/mm/proc-sa1100.S
  3. *
  4. * Copyright (C) 1997-2002 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * MMU functions for SA110
  11. *
  12. * These are the low level assembler for performing cache and TLB
  13. * functions on the StrongARM-1100 and StrongARM-1110.
  14. *
  15. * Note that SA1100 and SA1110 share everything but their name and CPU ID.
  16. *
  17. * 12-jun-2000, Erik Mouw (J.A.K.Mouw@its.tudelft.nl):
  18. * Flush the read buffer at context switches
  19. */
  20. #include <linux/linkage.h>
  21. #include <linux/init.h>
  22. #include <asm/assembler.h>
  23. #include <asm/constants.h>
  24. #include <asm/procinfo.h>
  25. #include <asm/hardware.h>
  26. #include <asm/pgtable.h>
  27. /*
  28. * the cache line size of the I and D cache
  29. */
  30. #define DCACHELINESIZE 32
  31. #define FLUSH_OFFSET 32768
  32. .macro flush_1100_dcache rd, ra, re
  33. ldr \rd, =flush_base
  34. ldr \ra, [\rd]
  35. eor \ra, \ra, #FLUSH_OFFSET
  36. str \ra, [\rd]
  37. add \re, \ra, #8192 @ only necessary for 8k
  38. 1001: ldr \rd, [\ra], #DCACHELINESIZE
  39. teq \re, \ra
  40. bne 1001b
  41. #ifdef FLUSH_BASE_MINICACHE
  42. add \ra, \ra, #FLUSH_BASE_MINICACHE - FLUSH_BASE
  43. add \re, \ra, #512 @ only 512 bytes
  44. 1002: ldr \rd, [\ra], #DCACHELINESIZE
  45. teq \re, \ra
  46. bne 1002b
  47. #endif
  48. .endm
  49. .data
  50. flush_base:
  51. .long FLUSH_BASE
  52. .text
  53. __INIT
  54. /*
  55. * cpu_sa1100_proc_init()
  56. */
  57. ENTRY(cpu_sa1100_proc_init)
  58. mov r0, #0
  59. mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
  60. mcr p15, 0, r0, c9, c0, 5 @ Allow read-buffer operations from userland
  61. mov pc, lr
  62. .previous
  63. /*
  64. * cpu_sa1100_proc_fin()
  65. *
  66. * Prepare the CPU for reset:
  67. * - Disable interrupts
  68. * - Clean and turn off caches.
  69. */
  70. ENTRY(cpu_sa1100_proc_fin)
  71. stmfd sp!, {lr}
  72. mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
  73. msr cpsr_c, ip
  74. flush_1100_dcache r0, r1, r2 @ clean caches
  75. mov r0, #0
  76. mcr p15, 0, r0, c15, c2, 2 @ Disable clock switching
  77. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  78. bic r0, r0, #0x1000 @ ...i............
  79. bic r0, r0, #0x000e @ ............wca.
  80. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  81. ldmfd sp!, {pc}
  82. /*
  83. * cpu_sa1100_reset(loc)
  84. *
  85. * Perform a soft reset of the system. Put the CPU into the
  86. * same state as it would be if it had been reset, and branch
  87. * to what would be the reset vector.
  88. *
  89. * loc: location to jump to for soft reset
  90. */
  91. .align 5
  92. ENTRY(cpu_sa1100_reset)
  93. mov ip, #0
  94. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  95. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  96. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  97. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  98. bic ip, ip, #0x000f @ ............wcam
  99. bic ip, ip, #0x1100 @ ...i...s........
  100. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  101. mov pc, r0
  102. /*
  103. * cpu_sa1100_do_idle(type)
  104. *
  105. * Cause the processor to idle
  106. *
  107. * type: call type:
  108. * 0 = slow idle
  109. * 1 = fast idle
  110. * 2 = switch to slow processor clock
  111. * 3 = switch to fast processor clock
  112. */
  113. .align 5
  114. ENTRY(cpu_sa1100_do_idle)
  115. mov r0, r0 @ 4 nop padding
  116. mov r0, r0
  117. mov r0, r0
  118. mov r0, r0 @ 4 nop padding
  119. mov r0, r0
  120. mov r0, r0
  121. mov r0, #0
  122. ldr r1, =UNCACHEABLE_ADDR @ ptr to uncacheable address
  123. @ --- aligned to a cache line
  124. mcr p15, 0, r0, c15, c2, 2 @ disable clock switching
  125. ldr r1, [r1, #0] @ force switch to MCLK
  126. mcr p15, 0, r0, c15, c8, 2 @ wait for interrupt
  127. mov r0, r0 @ safety
  128. mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
  129. mov pc, lr
  130. /* ================================= CACHE ================================ */
  131. /*
  132. * cpu_sa1100_dcache_clean_area(addr,sz)
  133. *
  134. * Clean the specified entry of any caches such that the MMU
  135. * translation fetches will obtain correct data.
  136. *
  137. * addr: cache-unaligned virtual address
  138. */
  139. .align 5
  140. ENTRY(cpu_sa1100_dcache_clean_area)
  141. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  142. add r0, r0, #DCACHELINESIZE
  143. subs r1, r1, #DCACHELINESIZE
  144. bhi 1b
  145. mov pc, lr
  146. /* =============================== PageTable ============================== */
  147. /*
  148. * cpu_sa1100_switch_mm(pgd)
  149. *
  150. * Set the translation base pointer to be as described by pgd.
  151. *
  152. * pgd: new page tables
  153. */
  154. .align 5
  155. ENTRY(cpu_sa1100_switch_mm)
  156. flush_1100_dcache r3, ip, r1
  157. mov ip, #0
  158. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  159. mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
  160. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  161. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  162. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  163. mov pc, lr
  164. /*
  165. * cpu_sa1100_set_pte(ptep, pte)
  166. *
  167. * Set a PTE and flush it out
  168. */
  169. .align 5
  170. ENTRY(cpu_sa1100_set_pte)
  171. str r1, [r0], #-2048 @ linux version
  172. eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
  173. bic r2, r1, #PTE_SMALL_AP_MASK
  174. bic r2, r2, #PTE_TYPE_MASK
  175. orr r2, r2, #PTE_TYPE_SMALL
  176. tst r1, #L_PTE_USER @ User?
  177. orrne r2, r2, #PTE_SMALL_AP_URO_SRW
  178. tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
  179. orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
  180. tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
  181. movne r2, #0
  182. str r2, [r0] @ hardware version
  183. mov r0, r0
  184. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  185. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  186. mov pc, lr
  187. __INIT
  188. .type __sa1100_setup, #function
  189. __sa1100_setup:
  190. mov r0, #0
  191. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  192. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  193. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  194. mrc p15, 0, r0, c1, c0 @ get control register v4
  195. ldr r5, sa1100_cr1_clear
  196. bic r0, r0, r5
  197. ldr r5, sa1100_cr1_set
  198. orr r0, r0, r5
  199. mov pc, lr
  200. .size __sa1100_setup, . - __sa1100_setup
  201. /*
  202. * R
  203. * .RVI ZFRS BLDP WCAM
  204. * ..11 0001 ..11 1101
  205. *
  206. */
  207. .type sa1100_cr1_clear, #object
  208. .type sa1100_cr1_set, #object
  209. sa1100_cr1_clear:
  210. .word 0x3f3f
  211. sa1100_cr1_set:
  212. .word 0x313d
  213. __INITDATA
  214. /*
  215. * Purpose : Function pointers used to access above functions - all calls
  216. * come through these
  217. */
  218. /*
  219. * SA1100 and SA1110 share the same function calls
  220. */
  221. .type sa1100_processor_functions, #object
  222. ENTRY(sa1100_processor_functions)
  223. .word v4_early_abort
  224. .word cpu_sa1100_proc_init
  225. .word cpu_sa1100_proc_fin
  226. .word cpu_sa1100_reset
  227. .word cpu_sa1100_do_idle
  228. .word cpu_sa1100_dcache_clean_area
  229. .word cpu_sa1100_switch_mm
  230. .word cpu_sa1100_set_pte
  231. .size sa1100_processor_functions, . - sa1100_processor_functions
  232. .section ".rodata"
  233. .type cpu_arch_name, #object
  234. cpu_arch_name:
  235. .asciz "armv4"
  236. .size cpu_arch_name, . - cpu_arch_name
  237. .type cpu_elf_name, #object
  238. cpu_elf_name:
  239. .asciz "v4"
  240. .size cpu_elf_name, . - cpu_elf_name
  241. .type cpu_sa1100_name, #object
  242. cpu_sa1100_name:
  243. .asciz "StrongARM-1100"
  244. .size cpu_sa1100_name, . - cpu_sa1100_name
  245. .type cpu_sa1110_name, #object
  246. cpu_sa1110_name:
  247. .asciz "StrongARM-1110"
  248. .size cpu_sa1110_name, . - cpu_sa1110_name
  249. .align
  250. .section ".proc.info", #alloc, #execinstr
  251. .type __sa1100_proc_info,#object
  252. __sa1100_proc_info:
  253. .long 0x4401a110
  254. .long 0xfffffff0
  255. .long PMD_TYPE_SECT | \
  256. PMD_SECT_BUFFERABLE | \
  257. PMD_SECT_CACHEABLE | \
  258. PMD_SECT_AP_WRITE | \
  259. PMD_SECT_AP_READ
  260. b __sa1100_setup
  261. .long cpu_arch_name
  262. .long cpu_elf_name
  263. .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
  264. .long cpu_sa1100_name
  265. .long sa1100_processor_functions
  266. .long v4wb_tlb_fns
  267. .long v4_mc_user_fns
  268. .long v4wb_cache_fns
  269. .size __sa1100_proc_info, . - __sa1100_proc_info
  270. .type __sa1110_proc_info,#object
  271. __sa1110_proc_info:
  272. .long 0x6901b110
  273. .long 0xfffffff0
  274. .long PMD_TYPE_SECT | \
  275. PMD_SECT_BUFFERABLE | \
  276. PMD_SECT_CACHEABLE | \
  277. PMD_SECT_AP_WRITE | \
  278. PMD_SECT_AP_READ
  279. b __sa1100_setup
  280. .long cpu_arch_name
  281. .long cpu_elf_name
  282. .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
  283. .long cpu_sa1110_name
  284. .long sa1100_processor_functions
  285. .long v4wb_tlb_fns
  286. .long v4_mc_user_fns
  287. .long v4wb_cache_fns
  288. .size __sa1110_proc_info, . - __sa1110_proc_info