proc-sa1100.S 7.1 KB

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