proc-fa526.S 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. /*
  2. * linux/arch/arm/mm/proc-fa526.S: MMU functions for FA526
  3. *
  4. * Written by : Luke Lee
  5. * Copyright (C) 2005 Faraday Corp.
  6. * Copyright (C) 2008-2009 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. *
  14. * These are the low level assembler for performing cache and TLB
  15. * functions on the fa526.
  16. */
  17. #include <linux/linkage.h>
  18. #include <linux/init.h>
  19. #include <asm/assembler.h>
  20. #include <asm/hwcap.h>
  21. #include <asm/pgtable-hwdef.h>
  22. #include <asm/pgtable.h>
  23. #include <asm/page.h>
  24. #include <asm/ptrace.h>
  25. #include <asm/system.h>
  26. #include "proc-macros.S"
  27. #define CACHE_DLINESIZE 16
  28. .text
  29. /*
  30. * cpu_fa526_proc_init()
  31. */
  32. ENTRY(cpu_fa526_proc_init)
  33. mov pc, lr
  34. /*
  35. * cpu_fa526_proc_fin()
  36. */
  37. ENTRY(cpu_fa526_proc_fin)
  38. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  39. bic r0, r0, #0x1000 @ ...i............
  40. bic r0, r0, #0x000e @ ............wca.
  41. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  42. nop
  43. nop
  44. mov pc, lr
  45. /*
  46. * cpu_fa526_reset(loc)
  47. *
  48. * Perform a soft reset of the system. Put the CPU into the
  49. * same state as it would be if it had been reset, and branch
  50. * to what would be the reset vector.
  51. *
  52. * loc: location to jump to for soft reset
  53. */
  54. .align 4
  55. ENTRY(cpu_fa526_reset)
  56. /* TODO: Use CP8 if possible... */
  57. mov ip, #0
  58. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  59. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  60. #ifdef CONFIG_MMU
  61. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  62. #endif
  63. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  64. bic ip, ip, #0x000f @ ............wcam
  65. bic ip, ip, #0x1100 @ ...i...s........
  66. bic ip, ip, #0x0800 @ BTB off
  67. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  68. nop
  69. nop
  70. mov pc, r0
  71. /*
  72. * cpu_fa526_do_idle()
  73. */
  74. .align 4
  75. ENTRY(cpu_fa526_do_idle)
  76. mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
  77. mov pc, lr
  78. ENTRY(cpu_fa526_dcache_clean_area)
  79. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  80. add r0, r0, #CACHE_DLINESIZE
  81. subs r1, r1, #CACHE_DLINESIZE
  82. bhi 1b
  83. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  84. mov pc, lr
  85. /* =============================== PageTable ============================== */
  86. /*
  87. * cpu_fa526_switch_mm(pgd)
  88. *
  89. * Set the translation base pointer to be as described by pgd.
  90. *
  91. * pgd: new page tables
  92. */
  93. .align 4
  94. ENTRY(cpu_fa526_switch_mm)
  95. #ifdef CONFIG_MMU
  96. mov ip, #0
  97. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  98. mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  99. #else
  100. mcr p15, 0, ip, c7, c14, 0 @ clean and invalidate whole D cache
  101. #endif
  102. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  103. mcr p15, 0, ip, c7, c5, 6 @ invalidate BTB since mm changed
  104. mcr p15, 0, ip, c7, c10, 4 @ data write barrier
  105. mcr p15, 0, ip, c7, c5, 4 @ prefetch flush
  106. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  107. mcr p15, 0, ip, c8, c7, 0 @ invalidate UTLB
  108. #endif
  109. mov pc, lr
  110. /*
  111. * cpu_fa526_set_pte_ext(ptep, pte, ext)
  112. *
  113. * Set a PTE and flush it out
  114. */
  115. .align 4
  116. ENTRY(cpu_fa526_set_pte_ext)
  117. #ifdef CONFIG_MMU
  118. armv3_set_pte_ext
  119. mov r0, r0
  120. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  121. mov r0, #0
  122. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  123. #endif
  124. mov pc, lr
  125. __INIT
  126. .type __fa526_setup, #function
  127. __fa526_setup:
  128. /* On return of this routine, r0 must carry correct flags for CFG register */
  129. mov r0, #0
  130. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  131. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  132. #ifdef CONFIG_MMU
  133. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  134. #endif
  135. mcr p15, 0, r0, c7, c5, 5 @ invalidate IScratchpad RAM
  136. mov r0, #1
  137. mcr p15, 0, r0, c1, c1, 0 @ turn-on ECR
  138. mov r0, #0
  139. mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB All
  140. mcr p15, 0, r0, c7, c10, 4 @ data write barrier
  141. mcr p15, 0, r0, c7, c5, 4 @ prefetch flush
  142. mov r0, #0x1f @ Domains 0, 1 = manager, 2 = client
  143. mcr p15, 0, r0, c3, c0 @ load domain access register
  144. mrc p15, 0, r0, c1, c0 @ get control register v4
  145. ldr r5, fa526_cr1_clear
  146. bic r0, r0, r5
  147. ldr r5, fa526_cr1_set
  148. orr r0, r0, r5
  149. mov pc, lr
  150. .size __fa526_setup, . - __fa526_setup
  151. /*
  152. * .RVI ZFRS BLDP WCAM
  153. * ..11 1001 .111 1101
  154. *
  155. */
  156. .type fa526_cr1_clear, #object
  157. .type fa526_cr1_set, #object
  158. fa526_cr1_clear:
  159. .word 0x3f3f
  160. fa526_cr1_set:
  161. .word 0x397D
  162. __INITDATA
  163. /*
  164. * Purpose : Function pointers used to access above functions - all calls
  165. * come through these
  166. */
  167. .type fa526_processor_functions, #object
  168. fa526_processor_functions:
  169. .word v4_early_abort
  170. .word legacy_pabort
  171. .word cpu_fa526_proc_init
  172. .word cpu_fa526_proc_fin
  173. .word cpu_fa526_reset
  174. .word cpu_fa526_do_idle
  175. .word cpu_fa526_dcache_clean_area
  176. .word cpu_fa526_switch_mm
  177. .word cpu_fa526_set_pte_ext
  178. .size fa526_processor_functions, . - fa526_processor_functions
  179. .section ".rodata"
  180. .type cpu_arch_name, #object
  181. cpu_arch_name:
  182. .asciz "armv4"
  183. .size cpu_arch_name, . - cpu_arch_name
  184. .type cpu_elf_name, #object
  185. cpu_elf_name:
  186. .asciz "v4"
  187. .size cpu_elf_name, . - cpu_elf_name
  188. .type cpu_fa526_name, #object
  189. cpu_fa526_name:
  190. .asciz "FA526"
  191. .size cpu_fa526_name, . - cpu_fa526_name
  192. .align
  193. .section ".proc.info.init", #alloc, #execinstr
  194. .type __fa526_proc_info,#object
  195. __fa526_proc_info:
  196. .long 0x66015261
  197. .long 0xff01fff1
  198. .long PMD_TYPE_SECT | \
  199. PMD_SECT_BUFFERABLE | \
  200. PMD_SECT_CACHEABLE | \
  201. PMD_BIT4 | \
  202. PMD_SECT_AP_WRITE | \
  203. PMD_SECT_AP_READ
  204. .long PMD_TYPE_SECT | \
  205. PMD_BIT4 | \
  206. PMD_SECT_AP_WRITE | \
  207. PMD_SECT_AP_READ
  208. b __fa526_setup
  209. .long cpu_arch_name
  210. .long cpu_elf_name
  211. .long HWCAP_SWP | HWCAP_HALF
  212. .long cpu_fa526_name
  213. .long fa526_processor_functions
  214. .long fa_tlb_fns
  215. .long fa_user_fns
  216. .long fa_cache_fns
  217. .size __fa526_proc_info, . - __fa526_proc_info