proc-fa526.S 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 "proc-macros.S"
  26. #define CACHE_DLINESIZE 16
  27. .text
  28. /*
  29. * cpu_fa526_proc_init()
  30. */
  31. ENTRY(cpu_fa526_proc_init)
  32. ret lr
  33. /*
  34. * cpu_fa526_proc_fin()
  35. */
  36. ENTRY(cpu_fa526_proc_fin)
  37. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  38. bic r0, r0, #0x1000 @ ...i............
  39. bic r0, r0, #0x000e @ ............wca.
  40. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  41. nop
  42. nop
  43. ret lr
  44. /*
  45. * cpu_fa526_reset(loc)
  46. *
  47. * Perform a soft reset of the system. Put the CPU into the
  48. * same state as it would be if it had been reset, and branch
  49. * to what would be the reset vector.
  50. *
  51. * loc: location to jump to for soft reset
  52. */
  53. .align 4
  54. .pushsection .idmap.text, "ax"
  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. ret r0
  71. ENDPROC(cpu_fa526_reset)
  72. .popsection
  73. /*
  74. * cpu_fa526_do_idle()
  75. */
  76. .align 4
  77. ENTRY(cpu_fa526_do_idle)
  78. ret lr
  79. ENTRY(cpu_fa526_dcache_clean_area)
  80. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  81. add r0, r0, #CACHE_DLINESIZE
  82. subs r1, r1, #CACHE_DLINESIZE
  83. bhi 1b
  84. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  85. ret lr
  86. /* =============================== PageTable ============================== */
  87. /*
  88. * cpu_fa526_switch_mm(pgd)
  89. *
  90. * Set the translation base pointer to be as described by pgd.
  91. *
  92. * pgd: new page tables
  93. */
  94. .align 4
  95. ENTRY(cpu_fa526_switch_mm)
  96. #ifdef CONFIG_MMU
  97. mov ip, #0
  98. #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
  99. mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
  100. #else
  101. mcr p15, 0, ip, c7, c14, 0 @ clean and invalidate whole D cache
  102. #endif
  103. mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
  104. mcr p15, 0, ip, c7, c5, 6 @ invalidate BTB since mm changed
  105. mcr p15, 0, ip, c7, c10, 4 @ data write barrier
  106. mcr p15, 0, ip, c7, c5, 4 @ prefetch flush
  107. mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
  108. mcr p15, 0, ip, c8, c7, 0 @ invalidate UTLB
  109. #endif
  110. ret lr
  111. /*
  112. * cpu_fa526_set_pte_ext(ptep, pte, ext)
  113. *
  114. * Set a PTE and flush it out
  115. */
  116. .align 4
  117. ENTRY(cpu_fa526_set_pte_ext)
  118. #ifdef CONFIG_MMU
  119. armv3_set_pte_ext
  120. mov r0, r0
  121. mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  122. mov r0, #0
  123. mcr p15, 0, r0, c7, c10, 4 @ drain WB
  124. #endif
  125. ret lr
  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. ret 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. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  164. define_processor_functions fa526, dabort=v4_early_abort, pabort=legacy_pabort
  165. .section ".rodata"
  166. string cpu_arch_name, "armv4"
  167. string cpu_elf_name, "v4"
  168. string cpu_fa526_name, "FA526"
  169. .align
  170. .section ".proc.info.init", #alloc
  171. .type __fa526_proc_info,#object
  172. __fa526_proc_info:
  173. .long 0x66015261
  174. .long 0xff01fff1
  175. .long PMD_TYPE_SECT | \
  176. PMD_SECT_BUFFERABLE | \
  177. PMD_SECT_CACHEABLE | \
  178. PMD_BIT4 | \
  179. PMD_SECT_AP_WRITE | \
  180. PMD_SECT_AP_READ
  181. .long PMD_TYPE_SECT | \
  182. PMD_BIT4 | \
  183. PMD_SECT_AP_WRITE | \
  184. PMD_SECT_AP_READ
  185. initfn __fa526_setup, __fa526_proc_info
  186. .long cpu_arch_name
  187. .long cpu_elf_name
  188. .long HWCAP_SWP | HWCAP_HALF
  189. .long cpu_fa526_name
  190. .long fa526_processor_functions
  191. .long fa_tlb_fns
  192. .long fa_user_fns
  193. .long fa_cache_fns
  194. .size __fa526_proc_info, . - __fa526_proc_info