proc-fa526.S 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. stmfd sp!, {lr}
  39. mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
  40. msr cpsr_c, ip
  41. bl fa_flush_kern_cache_all
  42. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  43. bic r0, r0, #0x1000 @ ...i............
  44. bic r0, r0, #0x000e @ ............wca.
  45. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  46. nop
  47. nop
  48. ldmfd sp!, {pc}
  49. /*
  50. * cpu_fa526_reset(loc)
  51. *
  52. * Perform a soft reset of the system. Put the CPU into the
  53. * same state as it would be if it had been reset, and branch
  54. * to what would be the reset vector.
  55. *
  56. * loc: location to jump to for soft reset
  57. */
  58. .align 4
  59. ENTRY(cpu_fa526_reset)
  60. /* TODO: Use CP8 if possible... */
  61. mov ip, #0
  62. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  63. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  64. #ifdef CONFIG_MMU
  65. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  66. #endif
  67. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  68. bic ip, ip, #0x000f @ ............wcam
  69. bic ip, ip, #0x1100 @ ...i...s........
  70. bic ip, ip, #0x0800 @ BTB off
  71. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  72. nop
  73. nop
  74. mov pc, r0
  75. /*
  76. * cpu_fa526_do_idle()
  77. */
  78. .align 4
  79. ENTRY(cpu_fa526_do_idle)
  80. mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
  81. mov pc, lr
  82. ENTRY(cpu_fa526_dcache_clean_area)
  83. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  84. add r0, r0, #CACHE_DLINESIZE
  85. subs r1, r1, #CACHE_DLINESIZE
  86. bhi 1b
  87. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  88. mov pc, lr
  89. /* =============================== PageTable ============================== */
  90. /*
  91. * cpu_fa526_switch_mm(pgd)
  92. *
  93. * Set the translation base pointer to be as described by pgd.
  94. *
  95. * pgd: new page tables
  96. */
  97. .align 4
  98. ENTRY(cpu_fa526_switch_mm)
  99. #ifdef CONFIG_MMU
  100. mov ip, #0
  101. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  102. mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  103. #else
  104. mcr p15, 0, ip, c7, c14, 0 @ clean and invalidate whole D cache
  105. #endif
  106. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  107. mcr p15, 0, ip, c7, c5, 6 @ invalidate BTB since mm changed
  108. mcr p15, 0, ip, c7, c10, 4 @ data write barrier
  109. mcr p15, 0, ip, c7, c5, 4 @ prefetch flush
  110. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  111. mcr p15, 0, ip, c8, c7, 0 @ invalidate UTLB
  112. #endif
  113. mov pc, lr
  114. /*
  115. * cpu_fa526_set_pte_ext(ptep, pte, ext)
  116. *
  117. * Set a PTE and flush it out
  118. */
  119. .align 4
  120. ENTRY(cpu_fa526_set_pte_ext)
  121. #ifdef CONFIG_MMU
  122. armv3_set_pte_ext
  123. mov r0, r0
  124. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  125. mov r0, #0
  126. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  127. #endif
  128. mov pc, lr
  129. __INIT
  130. .type __fa526_setup, #function
  131. __fa526_setup:
  132. /* On return of this routine, r0 must carry correct flags for CFG register */
  133. mov r0, #0
  134. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  135. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  136. #ifdef CONFIG_MMU
  137. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  138. #endif
  139. mcr p15, 0, r0, c7, c5, 5 @ invalidate IScratchpad RAM
  140. mov r0, #1
  141. mcr p15, 0, r0, c1, c1, 0 @ turn-on ECR
  142. mov r0, #0
  143. mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB All
  144. mcr p15, 0, r0, c7, c10, 4 @ data write barrier
  145. mcr p15, 0, r0, c7, c5, 4 @ prefetch flush
  146. mov r0, #0x1f @ Domains 0, 1 = manager, 2 = client
  147. mcr p15, 0, r0, c3, c0 @ load domain access register
  148. mrc p15, 0, r0, c1, c0 @ get control register v4
  149. ldr r5, fa526_cr1_clear
  150. bic r0, r0, r5
  151. ldr r5, fa526_cr1_set
  152. orr r0, r0, r5
  153. mov pc, lr
  154. .size __fa526_setup, . - __fa526_setup
  155. /*
  156. * .RVI ZFRS BLDP WCAM
  157. * ..11 1001 .111 1101
  158. *
  159. */
  160. .type fa526_cr1_clear, #object
  161. .type fa526_cr1_set, #object
  162. fa526_cr1_clear:
  163. .word 0x3f3f
  164. fa526_cr1_set:
  165. .word 0x397D
  166. __INITDATA
  167. /*
  168. * Purpose : Function pointers used to access above functions - all calls
  169. * come through these
  170. */
  171. .type fa526_processor_functions, #object
  172. fa526_processor_functions:
  173. .word v4_early_abort
  174. .word pabort_noifar
  175. .word cpu_fa526_proc_init
  176. .word cpu_fa526_proc_fin
  177. .word cpu_fa526_reset
  178. .word cpu_fa526_do_idle
  179. .word cpu_fa526_dcache_clean_area
  180. .word cpu_fa526_switch_mm
  181. .word cpu_fa526_set_pte_ext
  182. .size fa526_processor_functions, . - fa526_processor_functions
  183. .section ".rodata"
  184. .type cpu_arch_name, #object
  185. cpu_arch_name:
  186. .asciz "armv4"
  187. .size cpu_arch_name, . - cpu_arch_name
  188. .type cpu_elf_name, #object
  189. cpu_elf_name:
  190. .asciz "v4"
  191. .size cpu_elf_name, . - cpu_elf_name
  192. .type cpu_fa526_name, #object
  193. cpu_fa526_name:
  194. .asciz "FA526"
  195. .size cpu_fa526_name, . - cpu_fa526_name
  196. .align
  197. .section ".proc.info.init", #alloc, #execinstr
  198. .type __fa526_proc_info,#object
  199. __fa526_proc_info:
  200. .long 0x66015261
  201. .long 0xff01fff1
  202. .long PMD_TYPE_SECT | \
  203. PMD_SECT_BUFFERABLE | \
  204. PMD_SECT_CACHEABLE | \
  205. PMD_BIT4 | \
  206. PMD_SECT_AP_WRITE | \
  207. PMD_SECT_AP_READ
  208. .long PMD_TYPE_SECT | \
  209. PMD_BIT4 | \
  210. PMD_SECT_AP_WRITE | \
  211. PMD_SECT_AP_READ
  212. b __fa526_setup
  213. .long cpu_arch_name
  214. .long cpu_elf_name
  215. .long HWCAP_SWP | HWCAP_HALF
  216. .long cpu_fa526_name
  217. .long fa526_processor_functions
  218. .long fa_tlb_fns
  219. .long fa_user_fns
  220. .long fa_cache_fns
  221. .size __fa526_proc_info, . - __fa526_proc_info