proc-fa526.S 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. .pushsection .idmap.text, "ax"
  56. ENTRY(cpu_fa526_reset)
  57. /* TODO: Use CP8 if possible... */
  58. mov ip, #0
  59. mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
  60. mcr p15, 0, ip, c7, c10, 4 @ drain WB
  61. #ifdef CONFIG_MMU
  62. mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
  63. #endif
  64. mrc p15, 0, ip, c1, c0, 0 @ ctrl register
  65. bic ip, ip, #0x000f @ ............wcam
  66. bic ip, ip, #0x1100 @ ...i...s........
  67. bic ip, ip, #0x0800 @ BTB off
  68. mcr p15, 0, ip, c1, c0, 0 @ ctrl register
  69. nop
  70. nop
  71. mov pc, r0
  72. ENDPROC(cpu_fa526_reset)
  73. .popsection
  74. /*
  75. * cpu_fa526_do_idle()
  76. */
  77. .align 4
  78. ENTRY(cpu_fa526_do_idle)
  79. mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
  80. mov pc, lr
  81. ENTRY(cpu_fa526_dcache_clean_area)
  82. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  83. add r0, r0, #CACHE_DLINESIZE
  84. subs r1, r1, #CACHE_DLINESIZE
  85. bhi 1b
  86. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  87. mov pc, lr
  88. /* =============================== PageTable ============================== */
  89. /*
  90. * cpu_fa526_switch_mm(pgd)
  91. *
  92. * Set the translation base pointer to be as described by pgd.
  93. *
  94. * pgd: new page tables
  95. */
  96. .align 4
  97. ENTRY(cpu_fa526_switch_mm)
  98. #ifdef CONFIG_MMU
  99. mov ip, #0
  100. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  101. mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  102. #else
  103. mcr p15, 0, ip, c7, c14, 0 @ clean and invalidate whole D cache
  104. #endif
  105. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  106. mcr p15, 0, ip, c7, c5, 6 @ invalidate BTB since mm changed
  107. mcr p15, 0, ip, c7, c10, 4 @ data write barrier
  108. mcr p15, 0, ip, c7, c5, 4 @ prefetch flush
  109. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  110. mcr p15, 0, ip, c8, c7, 0 @ invalidate UTLB
  111. #endif
  112. mov pc, lr
  113. /*
  114. * cpu_fa526_set_pte_ext(ptep, pte, ext)
  115. *
  116. * Set a PTE and flush it out
  117. */
  118. .align 4
  119. ENTRY(cpu_fa526_set_pte_ext)
  120. #ifdef CONFIG_MMU
  121. armv3_set_pte_ext
  122. mov r0, r0
  123. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  124. mov r0, #0
  125. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  126. #endif
  127. mov pc, lr
  128. __CPUINIT
  129. .type __fa526_setup, #function
  130. __fa526_setup:
  131. /* On return of this routine, r0 must carry correct flags for CFG register */
  132. mov r0, #0
  133. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  134. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  135. #ifdef CONFIG_MMU
  136. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  137. #endif
  138. mcr p15, 0, r0, c7, c5, 5 @ invalidate IScratchpad RAM
  139. mov r0, #1
  140. mcr p15, 0, r0, c1, c1, 0 @ turn-on ECR
  141. mov r0, #0
  142. mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB All
  143. mcr p15, 0, r0, c7, c10, 4 @ data write barrier
  144. mcr p15, 0, r0, c7, c5, 4 @ prefetch flush
  145. mov r0, #0x1f @ Domains 0, 1 = manager, 2 = client
  146. mcr p15, 0, r0, c3, c0 @ load domain access register
  147. mrc p15, 0, r0, c1, c0 @ get control register v4
  148. ldr r5, fa526_cr1_clear
  149. bic r0, r0, r5
  150. ldr r5, fa526_cr1_set
  151. orr r0, r0, r5
  152. mov pc, lr
  153. .size __fa526_setup, . - __fa526_setup
  154. /*
  155. * .RVI ZFRS BLDP WCAM
  156. * ..11 1001 .111 1101
  157. *
  158. */
  159. .type fa526_cr1_clear, #object
  160. .type fa526_cr1_set, #object
  161. fa526_cr1_clear:
  162. .word 0x3f3f
  163. fa526_cr1_set:
  164. .word 0x397D
  165. __INITDATA
  166. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  167. define_processor_functions fa526, dabort=v4_early_abort, pabort=legacy_pabort
  168. .section ".rodata"
  169. string cpu_arch_name, "armv4"
  170. string cpu_elf_name, "v4"
  171. string cpu_fa526_name, "FA526"
  172. .align
  173. .section ".proc.info.init", #alloc, #execinstr
  174. .type __fa526_proc_info,#object
  175. __fa526_proc_info:
  176. .long 0x66015261
  177. .long 0xff01fff1
  178. .long PMD_TYPE_SECT | \
  179. PMD_SECT_BUFFERABLE | \
  180. PMD_SECT_CACHEABLE | \
  181. PMD_BIT4 | \
  182. PMD_SECT_AP_WRITE | \
  183. PMD_SECT_AP_READ
  184. .long PMD_TYPE_SECT | \
  185. PMD_BIT4 | \
  186. PMD_SECT_AP_WRITE | \
  187. PMD_SECT_AP_READ
  188. b __fa526_setup
  189. .long cpu_arch_name
  190. .long cpu_elf_name
  191. .long HWCAP_SWP | HWCAP_HALF
  192. .long cpu_fa526_name
  193. .long fa526_processor_functions
  194. .long fa_tlb_fns
  195. .long fa_user_fns
  196. .long fa_cache_fns
  197. .size __fa526_proc_info, . - __fa526_proc_info