proc-sa110.S 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /*
  2. * linux/arch/arm/mm/proc-sa110.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-110.
  14. */
  15. #include <linux/linkage.h>
  16. #include <linux/init.h>
  17. #include <asm/assembler.h>
  18. #include <asm/asm-offsets.h>
  19. #include <asm/procinfo.h>
  20. #include <asm/hardware.h>
  21. #include <asm/pgtable-hwdef.h>
  22. #include <asm/pgtable.h>
  23. #include <asm/ptrace.h>
  24. /*
  25. * the cache line size of the I and D cache
  26. */
  27. #define DCACHELINESIZE 32
  28. #define FLUSH_OFFSET 32768
  29. .macro flush_110_dcache rd, ra, re
  30. ldr \rd, =flush_base
  31. ldr \ra, [\rd]
  32. eor \ra, \ra, #FLUSH_OFFSET
  33. str \ra, [\rd]
  34. add \re, \ra, #16384 @ only necessary for 16k
  35. 1001: ldr \rd, [\ra], #DCACHELINESIZE
  36. teq \re, \ra
  37. bne 1001b
  38. .endm
  39. .data
  40. flush_base:
  41. .long FLUSH_BASE
  42. .text
  43. /*
  44. * cpu_sa110_proc_init()
  45. */
  46. ENTRY(cpu_sa110_proc_init)
  47. mov r0, #0
  48. mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
  49. mov pc, lr
  50. /*
  51. * cpu_sa110_proc_fin()
  52. */
  53. ENTRY(cpu_sa110_proc_fin)
  54. stmfd sp!, {lr}
  55. mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
  56. msr cpsr_c, ip
  57. bl v4wb_flush_kern_cache_all @ clean caches
  58. 1: mov r0, #0
  59. mcr p15, 0, r0, c15, c2, 2 @ Disable clock switching
  60. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  61. bic r0, r0, #0x1000 @ ...i............
  62. bic r0, r0, #0x000e @ ............wca.
  63. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  64. ldmfd sp!, {pc}
  65. /*
  66. * cpu_sa110_reset(loc)
  67. *
  68. * Perform a soft reset of the system. Put the CPU into the
  69. * same state as it would be if it had been reset, and branch
  70. * to what would be the reset vector.
  71. *
  72. * loc: location to jump to for soft reset
  73. */
  74. .align 5
  75. ENTRY(cpu_sa110_reset)
  76. mov ip, #0
  77. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  78. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  79. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  80. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  81. bic ip, ip, #0x000f @ ............wcam
  82. bic ip, ip, #0x1100 @ ...i...s........
  83. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  84. mov pc, r0
  85. /*
  86. * cpu_sa110_do_idle(type)
  87. *
  88. * Cause the processor to idle
  89. *
  90. * type: call type:
  91. * 0 = slow idle
  92. * 1 = fast idle
  93. * 2 = switch to slow processor clock
  94. * 3 = switch to fast processor clock
  95. */
  96. .align 5
  97. ENTRY(cpu_sa110_do_idle)
  98. mcr p15, 0, ip, c15, c2, 2 @ disable clock switching
  99. ldr r1, =UNCACHEABLE_ADDR @ load from uncacheable loc
  100. ldr r1, [r1, #0] @ force switch to MCLK
  101. mov r0, r0 @ safety
  102. mov r0, r0 @ safety
  103. mov r0, r0 @ safety
  104. mcr p15, 0, r0, c15, c8, 2 @ Wait for interrupt, cache aligned
  105. mov r0, r0 @ safety
  106. mov r0, r0 @ safety
  107. mov r0, r0 @ safety
  108. mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
  109. mov pc, lr
  110. /* ================================= CACHE ================================ */
  111. /*
  112. * cpu_sa110_dcache_clean_area(addr,sz)
  113. *
  114. * Clean the specified entry of any caches such that the MMU
  115. * translation fetches will obtain correct data.
  116. *
  117. * addr: cache-unaligned virtual address
  118. */
  119. .align 5
  120. ENTRY(cpu_sa110_dcache_clean_area)
  121. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  122. add r0, r0, #DCACHELINESIZE
  123. subs r1, r1, #DCACHELINESIZE
  124. bhi 1b
  125. mov pc, lr
  126. /* =============================== PageTable ============================== */
  127. /*
  128. * cpu_sa110_switch_mm(pgd)
  129. *
  130. * Set the translation base pointer to be as described by pgd.
  131. *
  132. * pgd: new page tables
  133. */
  134. .align 5
  135. ENTRY(cpu_sa110_switch_mm)
  136. flush_110_dcache r3, ip, r1
  137. mov r1, #0
  138. mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
  139. mcr p15, 0, r1, c7, c10, 4 @ drain WB
  140. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  141. mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
  142. mov pc, lr
  143. /*
  144. * cpu_sa110_set_pte(ptep, pte)
  145. *
  146. * Set a PTE and flush it out
  147. */
  148. .align 5
  149. ENTRY(cpu_sa110_set_pte)
  150. str r1, [r0], #-2048 @ linux version
  151. eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
  152. bic r2, r1, #PTE_SMALL_AP_MASK
  153. bic r2, r2, #PTE_TYPE_MASK
  154. orr r2, r2, #PTE_TYPE_SMALL
  155. tst r1, #L_PTE_USER @ User?
  156. orrne r2, r2, #PTE_SMALL_AP_URO_SRW
  157. tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
  158. orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
  159. tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
  160. movne r2, #0
  161. str r2, [r0] @ hardware version
  162. mov r0, r0
  163. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  164. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  165. mov pc, lr
  166. __INIT
  167. .type __sa110_setup, #function
  168. __sa110_setup:
  169. mov r10, #0
  170. mcr p15, 0, r10, c7, c7 @ invalidate I,D caches on v4
  171. mcr p15, 0, r10, c7, c10, 4 @ drain write buffer on v4
  172. mcr p15, 0, r10, c8, c7 @ invalidate I,D TLBs on v4
  173. mrc p15, 0, r0, c1, c0 @ get control register v4
  174. ldr r5, sa110_cr1_clear
  175. bic r0, r0, r5
  176. ldr r5, sa110_cr1_set
  177. orr r0, r0, r5
  178. mov pc, lr
  179. .size __sa110_setup, . - __sa110_setup
  180. /*
  181. * R
  182. * .RVI ZFRS BLDP WCAM
  183. * ..01 0001 ..11 1101
  184. *
  185. */
  186. .type sa110_cr1_clear, #object
  187. .type sa110_cr1_set, #object
  188. sa110_cr1_clear:
  189. .word 0x3f3f
  190. sa110_cr1_set:
  191. .word 0x113d
  192. __INITDATA
  193. /*
  194. * Purpose : Function pointers used to access above functions - all calls
  195. * come through these
  196. */
  197. .type sa110_processor_functions, #object
  198. ENTRY(sa110_processor_functions)
  199. .word v4_early_abort
  200. .word cpu_sa110_proc_init
  201. .word cpu_sa110_proc_fin
  202. .word cpu_sa110_reset
  203. .word cpu_sa110_do_idle
  204. .word cpu_sa110_dcache_clean_area
  205. .word cpu_sa110_switch_mm
  206. .word cpu_sa110_set_pte
  207. .size sa110_processor_functions, . - sa110_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_sa110_name, #object
  218. cpu_sa110_name:
  219. .asciz "StrongARM-110"
  220. .size cpu_sa110_name, . - cpu_sa110_name
  221. .align
  222. .section ".proc.info.init", #alloc, #execinstr
  223. .type __sa110_proc_info,#object
  224. __sa110_proc_info:
  225. .long 0x4401a100
  226. .long 0xfffffff0
  227. .long PMD_TYPE_SECT | \
  228. PMD_SECT_BUFFERABLE | \
  229. PMD_SECT_CACHEABLE | \
  230. PMD_SECT_AP_WRITE | \
  231. PMD_SECT_AP_READ
  232. b __sa110_setup
  233. .long cpu_arch_name
  234. .long cpu_elf_name
  235. .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
  236. .long cpu_sa110_name
  237. .long sa110_processor_functions
  238. .long v4wb_tlb_fns
  239. .long v4wb_user_fns
  240. .long v4wb_cache_fns
  241. .size __sa110_proc_info, . - __sa110_proc_info