proc-sa110.S 6.2 KB

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