proc-fa526.S 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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. mov pc, 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. mov pc, 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. mov pc, 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. mov pc, 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. mov pc, 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. mov pc, 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. mov pc, lr
  126. __CPUINIT
  127. .type __fa526_setup, #function
  128. __fa526_setup:
  129. /* On return of this routine, r0 must carry correct flags for CFG register */
  130. mov r0, #0
  131. mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
  132. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
  133. #ifdef CONFIG_MMU
  134. mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
  135. #endif
  136. mcr p15, 0, r0, c7, c5, 5 @ invalidate IScratchpad RAM
  137. mov r0, #1
  138. mcr p15, 0, r0, c1, c1, 0 @ turn-on ECR
  139. mov r0, #0
  140. mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB All
  141. mcr p15, 0, r0, c7, c10, 4 @ data write barrier
  142. mcr p15, 0, r0, c7, c5, 4 @ prefetch flush
  143. mov r0, #0x1f @ Domains 0, 1 = manager, 2 = client
  144. mcr p15, 0, r0, c3, c0 @ load domain access register
  145. mrc p15, 0, r0, c1, c0 @ get control register v4
  146. ldr r5, fa526_cr1_clear
  147. bic r0, r0, r5
  148. ldr r5, fa526_cr1_set
  149. orr r0, r0, r5
  150. mov pc, lr
  151. .size __fa526_setup, . - __fa526_setup
  152. /*
  153. * .RVI ZFRS BLDP WCAM
  154. * ..11 1001 .111 1101
  155. *
  156. */
  157. .type fa526_cr1_clear, #object
  158. .type fa526_cr1_set, #object
  159. fa526_cr1_clear:
  160. .word 0x3f3f
  161. fa526_cr1_set:
  162. .word 0x397D
  163. __INITDATA
  164. @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
  165. define_processor_functions fa526, dabort=v4_early_abort, pabort=legacy_pabort
  166. .section ".rodata"
  167. string cpu_arch_name, "armv4"
  168. string cpu_elf_name, "v4"
  169. string cpu_fa526_name, "FA526"
  170. .align
  171. .section ".proc.info.init", #alloc, #execinstr
  172. .type __fa526_proc_info,#object
  173. __fa526_proc_info:
  174. .long 0x66015261
  175. .long 0xff01fff1
  176. .long PMD_TYPE_SECT | \
  177. PMD_SECT_BUFFERABLE | \
  178. PMD_SECT_CACHEABLE | \
  179. PMD_BIT4 | \
  180. PMD_SECT_AP_WRITE | \
  181. PMD_SECT_AP_READ
  182. .long PMD_TYPE_SECT | \
  183. PMD_BIT4 | \
  184. PMD_SECT_AP_WRITE | \
  185. PMD_SECT_AP_READ
  186. b __fa526_setup
  187. .long cpu_arch_name
  188. .long cpu_elf_name
  189. .long HWCAP_SWP | HWCAP_HALF
  190. .long cpu_fa526_name
  191. .long fa526_processor_functions
  192. .long fa_tlb_fns
  193. .long fa_user_fns
  194. .long fa_cache_fns
  195. .size __fa526_proc_info, . - __fa526_proc_info