proc-sa1100.S 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * linux/arch/arm/mm/proc-sa1100.S
  4. *
  5. * Copyright (C) 1997-2002 Russell King
  6. * hacked for non-paged-MM by Hyok S. Choi, 2003.
  7. *
  8. * MMU functions for SA110
  9. *
  10. * These are the low level assembler for performing cache and TLB
  11. * functions on the StrongARM-1100 and StrongARM-1110.
  12. *
  13. * Note that SA1100 and SA1110 share everything but their name and CPU ID.
  14. *
  15. * 12-jun-2000, Erik Mouw (J.A.K.Mouw@its.tudelft.nl):
  16. * Flush the read buffer at context switches
  17. */
  18. #include <linux/linkage.h>
  19. #include <linux/init.h>
  20. #include <linux/cfi_types.h>
  21. #include <linux/pgtable.h>
  22. #include <asm/assembler.h>
  23. #include <asm/asm-offsets.h>
  24. #include <asm/hwcap.h>
  25. #include <mach/hardware.h>
  26. #include <asm/pgtable-hwdef.h>
  27. #include "proc-macros.S"
  28. /*
  29. * the cache line size of the I and D cache
  30. */
  31. #define DCACHELINESIZE 32
  32. .section .text
  33. /*
  34. * cpu_sa1100_proc_init()
  35. */
  36. SYM_TYPED_FUNC_START(cpu_sa1100_proc_init)
  37. mov r0, #0
  38. mcr p15, 0, r0, c15, c1, 2 @ Enable clock switching
  39. mcr p15, 0, r0, c9, c0, 5 @ Allow read-buffer operations from userland
  40. ret lr
  41. SYM_FUNC_END(cpu_sa1100_proc_init)
  42. /*
  43. * cpu_sa1100_proc_fin()
  44. *
  45. * Prepare the CPU for reset:
  46. * - Disable interrupts
  47. * - Clean and turn off caches.
  48. */
  49. SYM_TYPED_FUNC_START(cpu_sa1100_proc_fin)
  50. mcr p15, 0, ip, c15, c2, 2 @ Disable clock switching
  51. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  52. bic r0, r0, #0x1000 @ ...i............
  53. bic r0, r0, #0x000e @ ............wca.
  54. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  55. ret lr
  56. SYM_FUNC_END(cpu_sa1100_proc_fin)
  57. /*
  58. * cpu_sa1100_reset(loc)
  59. *
  60. * Perform a soft reset of the system. Put the CPU into the
  61. * same state as it would be if it had been reset, and branch
  62. * to what would be the reset vector.
  63. *
  64. * loc: location to jump to for soft reset
  65. */
  66. .align 5
  67. .pushsection .idmap.text, "ax"
  68. SYM_TYPED_FUNC_START(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. ret r0
  80. SYM_FUNC_END(cpu_sa1100_reset)
  81. .popsection
  82. /*
  83. * cpu_sa1100_do_idle(type)
  84. *
  85. * Cause the processor to idle
  86. *
  87. * type: call type:
  88. * 0 = slow idle
  89. * 1 = fast idle
  90. * 2 = switch to slow processor clock
  91. * 3 = switch to fast processor clock
  92. */
  93. .align 5
  94. SYM_TYPED_FUNC_START(cpu_sa1100_do_idle)
  95. mov r0, r0 @ 4 nop padding
  96. mov r0, r0
  97. mov r0, r0
  98. mov r0, r0 @ 4 nop padding
  99. mov r0, r0
  100. mov r0, r0
  101. mov r0, #0
  102. ldr r1, =UNCACHEABLE_ADDR @ ptr to uncacheable address
  103. @ --- aligned to a cache line
  104. mcr p15, 0, r0, c15, c2, 2 @ disable clock switching
  105. ldr r1, [r1, #0] @ force switch to MCLK
  106. mcr p15, 0, r0, c15, c8, 2 @ wait for interrupt
  107. mov r0, r0 @ safety
  108. mcr p15, 0, r0, c15, c1, 2 @ enable clock switching
  109. ret lr
  110. SYM_FUNC_END(cpu_sa1100_do_idle)
  111. /* ================================= CACHE ================================ */
  112. /*
  113. * cpu_sa1100_dcache_clean_area(addr,sz)
  114. *
  115. * Clean the specified entry of any caches such that the MMU
  116. * translation fetches will obtain correct data.
  117. *
  118. * addr: cache-unaligned virtual address
  119. */
  120. .align 5
  121. SYM_TYPED_FUNC_START(cpu_sa1100_dcache_clean_area)
  122. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  123. add r0, r0, #DCACHELINESIZE
  124. subs r1, r1, #DCACHELINESIZE
  125. bhi 1b
  126. ret lr
  127. SYM_FUNC_END(cpu_sa1100_dcache_clean_area)
  128. /* =============================== PageTable ============================== */
  129. /*
  130. * cpu_sa1100_switch_mm(pgd)
  131. *
  132. * Set the translation base pointer to be as described by pgd.
  133. *
  134. * pgd: new page tables
  135. */
  136. .align 5
  137. SYM_TYPED_FUNC_START(cpu_sa1100_switch_mm)
  138. #ifdef CONFIG_MMU
  139. str lr, [sp, #-4]!
  140. bl v4wb_flush_kern_cache_all @ clears IP
  141. mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
  142. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  143. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  144. ldr pc, [sp], #4
  145. #else
  146. ret lr
  147. #endif
  148. SYM_FUNC_END(cpu_sa1100_switch_mm)
  149. /*
  150. * cpu_sa1100_set_pte_ext(ptep, pte, ext)
  151. *
  152. * Set a PTE and flush it out
  153. */
  154. .align 5
  155. SYM_TYPED_FUNC_START(cpu_sa1100_set_pte_ext)
  156. #ifdef CONFIG_MMU
  157. armv3_set_pte_ext wc_disable=0
  158. mov r0, r0
  159. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  160. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  161. #endif
  162. ret lr
  163. SYM_FUNC_END(cpu_sa1100_set_pte_ext)
  164. .globl cpu_sa1100_suspend_size
  165. .equ cpu_sa1100_suspend_size, 4 * 3
  166. #ifdef CONFIG_ARM_CPU_SUSPEND
  167. SYM_TYPED_FUNC_START(cpu_sa1100_do_suspend)
  168. stmfd sp!, {r4 - r6, lr}
  169. mrc p15, 0, r4, c3, c0, 0 @ domain ID
  170. mrc p15, 0, r5, c13, c0, 0 @ PID
  171. mrc p15, 0, r6, c1, c0, 0 @ control reg
  172. stmia r0, {r4 - r6} @ store cp regs
  173. ldmfd sp!, {r4 - r6, pc}
  174. SYM_FUNC_END(cpu_sa1100_do_suspend)
  175. SYM_TYPED_FUNC_START(cpu_sa1100_do_resume)
  176. ldmia r0, {r4 - r6} @ load cp regs
  177. mov ip, #0
  178. mcr p15, 0, ip, c8, c7, 0 @ flush I+D TLBs
  179. mcr p15, 0, ip, c7, c7, 0 @ flush I&D cache
  180. mcr p15, 0, ip, c9, c0, 0 @ invalidate RB
  181. mcr p15, 0, ip, c9, c0, 5 @ allow user space to use RB
  182. mcr p15, 0, r4, c3, c0, 0 @ domain ID
  183. mcr p15, 0, r1, c2, c0, 0 @ translation table base addr
  184. mcr p15, 0, r5, c13, c0, 0 @ PID
  185. mov r0, r6 @ control register
  186. b cpu_resume_mmu
  187. SYM_FUNC_END(cpu_sa1100_do_resume)
  188. #endif
  189. .type __sa1100_setup, #function
  190. __sa1100_setup:
  191. mov r0, #0
  192. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  193. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  194. #ifdef CONFIG_MMU
  195. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  196. #endif
  197. adr r5, sa1100_crval
  198. ldmia r5, {r5, r6}
  199. mrc p15, 0, r0, c1, c0 @ get control register v4
  200. bic r0, r0, r5
  201. orr r0, r0, r6
  202. ret lr
  203. .size __sa1100_setup, . - __sa1100_setup
  204. /*
  205. * R
  206. * .RVI ZFRS BLDP WCAM
  207. * ..11 0001 ..11 1101
  208. *
  209. */
  210. .type sa1100_crval, #object
  211. sa1100_crval:
  212. crval clear=0x00003f3f, mmuset=0x0000313d, ucset=0x00001130
  213. __INITDATA
  214. /*
  215. * SA1100 and SA1110 share the same function calls
  216. */
  217. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  218. define_processor_functions sa1100, dabort=v4_early_abort, pabort=legacy_pabort, suspend=1
  219. .section ".rodata"
  220. string cpu_arch_name, "armv4"
  221. string cpu_elf_name, "v4"
  222. string cpu_sa1100_name, "StrongARM-1100"
  223. string cpu_sa1110_name, "StrongARM-1110"
  224. .align
  225. .section ".proc.info.init", "a"
  226. .macro sa1100_proc_info name:req, cpu_val:req, cpu_mask:req, cpu_name:req
  227. .type __\name\()_proc_info,#object
  228. __\name\()_proc_info:
  229. .long \cpu_val
  230. .long \cpu_mask
  231. .long PMD_TYPE_SECT | \
  232. PMD_SECT_BUFFERABLE | \
  233. PMD_SECT_CACHEABLE | \
  234. PMD_SECT_AP_WRITE | \
  235. PMD_SECT_AP_READ
  236. .long PMD_TYPE_SECT | \
  237. PMD_SECT_AP_WRITE | \
  238. PMD_SECT_AP_READ
  239. initfn __sa1100_setup, __\name\()_proc_info
  240. .long cpu_arch_name
  241. .long cpu_elf_name
  242. .long HWCAP_SWP | HWCAP_HALF | HWCAP_26BIT | HWCAP_FAST_MULT
  243. .long \cpu_name
  244. .long sa1100_processor_functions
  245. .long v4wb_tlb_fns
  246. .long v4_mc_user_fns
  247. .long v4wb_cache_fns
  248. .size __\name\()_proc_info, . - __\name\()_proc_info
  249. .endm
  250. sa1100_proc_info sa1100, 0x4401a110, 0xfffffff0, cpu_sa1100_name
  251. sa1100_proc_info sa1110, 0x6901b110, 0xfffffff0, cpu_sa1110_name