proc-sa1100.S 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /*
  2. * linux/arch/arm/mm/proc-sa1100.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-1100 and StrongARM-1110.
  15. *
  16. * Note that SA1100 and SA1110 share everything but their name and CPU ID.
  17. *
  18. * 12-jun-2000, Erik Mouw (J.A.K.Mouw@its.tudelft.nl):
  19. * Flush the read buffer at context switches
  20. */
  21. #include <linux/linkage.h>
  22. #include <linux/init.h>
  23. #include <asm/assembler.h>
  24. #include <asm/asm-offsets.h>
  25. #include <asm/hwcap.h>
  26. #include <mach/hardware.h>
  27. #include <asm/pgtable-hwdef.h>
  28. #include <asm/pgtable.h>
  29. #include "proc-macros.S"
  30. /*
  31. * the cache line size of the I and D cache
  32. */
  33. #define DCACHELINESIZE 32
  34. __INIT
  35. /*
  36. * cpu_sa1100_proc_init()
  37. */
  38. ENTRY(cpu_sa1100_proc_init)
  39. mov r0, #0
  40. mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
  41. mcr p15, 0, r0, c9, c0, 5 @ Allow read-buffer operations from userland
  42. mov pc, lr
  43. .section .text
  44. /*
  45. * cpu_sa1100_proc_fin()
  46. *
  47. * Prepare the CPU for reset:
  48. * - Disable interrupts
  49. * - Clean and turn off caches.
  50. */
  51. ENTRY(cpu_sa1100_proc_fin)
  52. mcr p15, 0, ip, c15, c2, 2 @ Disable clock switching
  53. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  54. bic r0, r0, #0x1000 @ ...i............
  55. bic r0, r0, #0x000e @ ............wca.
  56. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  57. mov pc, lr
  58. /*
  59. * cpu_sa1100_reset(loc)
  60. *
  61. * Perform a soft reset of the system. Put the CPU into the
  62. * same state as it would be if it had been reset, and branch
  63. * to what would be the reset vector.
  64. *
  65. * loc: location to jump to for soft reset
  66. */
  67. .align 5
  68. ENTRY(cpu_sa1100_reset)
  69. mov ip, #0
  70. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  71. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  72. #ifdef CONFIG_MMU
  73. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  74. #endif
  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. #ifdef CONFIG_MMU
  135. str lr, [sp, #-4]!
  136. bl v4wb_flush_kern_cache_all @ clears IP
  137. mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
  138. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  139. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  140. ldr pc, [sp], #4
  141. #else
  142. mov pc, lr
  143. #endif
  144. /*
  145. * cpu_sa1100_set_pte_ext(ptep, pte, ext)
  146. *
  147. * Set a PTE and flush it out
  148. */
  149. .align 5
  150. ENTRY(cpu_sa1100_set_pte_ext)
  151. #ifdef CONFIG_MMU
  152. armv3_set_pte_ext wc_disable=0
  153. mov r0, r0
  154. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  155. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  156. #endif
  157. mov pc, lr
  158. __INIT
  159. .type __sa1100_setup, #function
  160. __sa1100_setup:
  161. mov r0, #0
  162. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  163. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  164. #ifdef CONFIG_MMU
  165. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  166. #endif
  167. adr r5, sa1100_crval
  168. ldmia r5, {r5, r6}
  169. mrc p15, 0, r0, c1, c0 @ get control register v4
  170. bic r0, r0, r5
  171. orr r0, r0, r6
  172. mov pc, lr
  173. .size __sa1100_setup, . - __sa1100_setup
  174. /*
  175. * R
  176. * .RVI ZFRS BLDP WCAM
  177. * ..11 0001 ..11 1101
  178. *
  179. */
  180. .type sa1100_crval, #object
  181. sa1100_crval:
  182. crval clear=0x00003f3f, mmuset=0x0000313d, ucset=0x00001130
  183. __INITDATA
  184. /*
  185. * Purpose : Function pointers used to access above functions - all calls
  186. * come through these
  187. */
  188. /*
  189. * SA1100 and SA1110 share the same function calls
  190. */
  191. .type sa1100_processor_functions, #object
  192. ENTRY(sa1100_processor_functions)
  193. .word v4_early_abort
  194. .word legacy_pabort
  195. .word cpu_sa1100_proc_init
  196. .word cpu_sa1100_proc_fin
  197. .word cpu_sa1100_reset
  198. .word cpu_sa1100_do_idle
  199. .word cpu_sa1100_dcache_clean_area
  200. .word cpu_sa1100_switch_mm
  201. .word cpu_sa1100_set_pte_ext
  202. .size sa1100_processor_functions, . - sa1100_processor_functions
  203. .section ".rodata"
  204. .type cpu_arch_name, #object
  205. cpu_arch_name:
  206. .asciz "armv4"
  207. .size cpu_arch_name, . - cpu_arch_name
  208. .type cpu_elf_name, #object
  209. cpu_elf_name:
  210. .asciz "v4"
  211. .size cpu_elf_name, . - cpu_elf_name
  212. .type cpu_sa1100_name, #object
  213. cpu_sa1100_name:
  214. .asciz "StrongARM-1100"
  215. .size cpu_sa1100_name, . - cpu_sa1100_name
  216. .type cpu_sa1110_name, #object
  217. cpu_sa1110_name:
  218. .asciz "StrongARM-1110"
  219. .size cpu_sa1110_name, . - cpu_sa1110_name
  220. .align
  221. .section ".proc.info.init", #alloc, #execinstr
  222. .type __sa1100_proc_info,#object
  223. __sa1100_proc_info:
  224. .long 0x4401a110
  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. .long PMD_TYPE_SECT | \
  232. PMD_SECT_AP_WRITE | \
  233. PMD_SECT_AP_READ
  234. b __sa1100_setup
  235. .long cpu_arch_name
  236. .long cpu_elf_name
  237. .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
  238. .long cpu_sa1100_name
  239. .long sa1100_processor_functions
  240. .long v4wb_tlb_fns
  241. .long v4_mc_user_fns
  242. .long v4wb_cache_fns
  243. .size __sa1100_proc_info, . - __sa1100_proc_info
  244. .type __sa1110_proc_info,#object
  245. __sa1110_proc_info:
  246. .long 0x6901b110
  247. .long 0xfffffff0
  248. .long PMD_TYPE_SECT | \
  249. PMD_SECT_BUFFERABLE | \
  250. PMD_SECT_CACHEABLE | \
  251. PMD_SECT_AP_WRITE | \
  252. PMD_SECT_AP_READ
  253. .long PMD_TYPE_SECT | \
  254. PMD_SECT_AP_WRITE | \
  255. PMD_SECT_AP_READ
  256. b __sa1100_setup
  257. .long cpu_arch_name
  258. .long cpu_elf_name
  259. .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
  260. .long cpu_sa1110_name
  261. .long sa1100_processor_functions
  262. .long v4wb_tlb_fns
  263. .long v4_mc_user_fns
  264. .long v4wb_cache_fns
  265. .size __sa1110_proc_info, . - __sa1110_proc_info