proc-sa110.S 6.3 KB

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