proc-sa110.S 6.0 KB

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