proc-v6.S 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /*
  2. * linux/arch/arm/mm/proc-v6.S
  3. *
  4. * Copyright (C) 2001 Deep Blue Solutions Ltd.
  5. * Modified by Catalin Marinas for noMMU support
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This is the "shell" of the ARMv6 processor support.
  12. */
  13. #include <linux/linkage.h>
  14. #include <asm/assembler.h>
  15. #include <asm/asm-offsets.h>
  16. #include <asm/hwcap.h>
  17. #include <asm/pgtable-hwdef.h>
  18. #include <asm/pgtable.h>
  19. #include "proc-macros.S"
  20. #define D_CACHE_LINE_SIZE 32
  21. #define TTB_C (1 << 0)
  22. #define TTB_S (1 << 1)
  23. #define TTB_IMP (1 << 2)
  24. #define TTB_RGN_NC (0 << 3)
  25. #define TTB_RGN_WBWA (1 << 3)
  26. #define TTB_RGN_WT (2 << 3)
  27. #define TTB_RGN_WB (3 << 3)
  28. #ifndef CONFIG_SMP
  29. #define TTB_FLAGS TTB_RGN_WBWA
  30. #else
  31. #define TTB_FLAGS TTB_RGN_WBWA|TTB_S
  32. #endif
  33. ENTRY(cpu_v6_proc_init)
  34. mov pc, lr
  35. ENTRY(cpu_v6_proc_fin)
  36. stmfd sp!, {lr}
  37. cpsid if @ disable interrupts
  38. bl v6_flush_kern_cache_all
  39. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  40. bic r0, r0, #0x1000 @ ...i............
  41. bic r0, r0, #0x0006 @ .............ca.
  42. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  43. ldmfd sp!, {pc}
  44. /*
  45. * cpu_v6_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. * It is assumed that:
  54. */
  55. .align 5
  56. ENTRY(cpu_v6_reset)
  57. mov pc, r0
  58. /*
  59. * cpu_v6_do_idle()
  60. *
  61. * Idle the processor (eg, wait for interrupt).
  62. *
  63. * IRQs are already disabled.
  64. */
  65. ENTRY(cpu_v6_do_idle)
  66. mcr p15, 0, r1, c7, c0, 4 @ wait for interrupt
  67. mov pc, lr
  68. ENTRY(cpu_v6_dcache_clean_area)
  69. #ifndef TLB_CAN_READ_FROM_L1_CACHE
  70. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  71. add r0, r0, #D_CACHE_LINE_SIZE
  72. subs r1, r1, #D_CACHE_LINE_SIZE
  73. bhi 1b
  74. #endif
  75. mov pc, lr
  76. /*
  77. * cpu_arm926_switch_mm(pgd_phys, tsk)
  78. *
  79. * Set the translation table base pointer to be pgd_phys
  80. *
  81. * - pgd_phys - physical address of new TTB
  82. *
  83. * It is assumed that:
  84. * - we are not using split page tables
  85. */
  86. ENTRY(cpu_v6_switch_mm)
  87. #ifdef CONFIG_MMU
  88. mov r2, #0
  89. ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
  90. orr r0, r0, #TTB_FLAGS
  91. mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
  92. mcr p15, 0, r2, c7, c10, 4 @ drain write buffer
  93. mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
  94. mcr p15, 0, r1, c13, c0, 1 @ set context ID
  95. #endif
  96. mov pc, lr
  97. /*
  98. * cpu_v6_set_pte_ext(ptep, pte, ext)
  99. *
  100. * Set a level 2 translation table entry.
  101. *
  102. * - ptep - pointer to level 2 translation table entry
  103. * (hardware version is stored at -1024 bytes)
  104. * - pte - PTE value to store
  105. * - ext - value for extended PTE bits
  106. */
  107. armv6_mt_table cpu_v6
  108. ENTRY(cpu_v6_set_pte_ext)
  109. #ifdef CONFIG_MMU
  110. armv6_set_pte_ext cpu_v6
  111. #endif
  112. mov pc, lr
  113. cpu_v6_name:
  114. .asciz "ARMv6-compatible processor"
  115. .align
  116. .section ".text.init", #alloc, #execinstr
  117. /*
  118. * __v6_setup
  119. *
  120. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  121. * on. Return in r0 the new CP15 C1 control register setting.
  122. *
  123. * We automatically detect if we have a Harvard cache, and use the
  124. * Harvard cache control instructions insead of the unified cache
  125. * control instructions.
  126. *
  127. * This should be able to cover all ARMv6 cores.
  128. *
  129. * It is assumed that:
  130. * - cache type register is implemented
  131. */
  132. __v6_setup:
  133. #ifdef CONFIG_SMP
  134. mrc p15, 0, r0, c1, c0, 1 @ Enable SMP/nAMP mode
  135. orr r0, r0, #0x20
  136. mcr p15, 0, r0, c1, c0, 1
  137. #endif
  138. mov r0, #0
  139. mcr p15, 0, r0, c7, c14, 0 @ clean+invalidate D cache
  140. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  141. mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache
  142. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  143. #ifdef CONFIG_MMU
  144. mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs
  145. mcr p15, 0, r0, c2, c0, 2 @ TTB control register
  146. orr r4, r4, #TTB_FLAGS
  147. mcr p15, 0, r4, c2, c0, 1 @ load TTB1
  148. #endif /* CONFIG_MMU */
  149. adr r5, v6_crval
  150. ldmia r5, {r5, r6}
  151. mrc p15, 0, r0, c1, c0, 0 @ read control register
  152. bic r0, r0, r5 @ clear bits them
  153. orr r0, r0, r6 @ set them
  154. mov pc, lr @ return to head.S:__ret
  155. /*
  156. * V X F I D LR
  157. * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM
  158. * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
  159. * 0 110 0011 1.00 .111 1101 < we want
  160. */
  161. .type v6_crval, #object
  162. v6_crval:
  163. crval clear=0x01e0fb7f, mmuset=0x00c0387d, ucset=0x00c0187c
  164. .type v6_processor_functions, #object
  165. ENTRY(v6_processor_functions)
  166. .word v6_early_abort
  167. .word pabort_noifar
  168. .word cpu_v6_proc_init
  169. .word cpu_v6_proc_fin
  170. .word cpu_v6_reset
  171. .word cpu_v6_do_idle
  172. .word cpu_v6_dcache_clean_area
  173. .word cpu_v6_switch_mm
  174. .word cpu_v6_set_pte_ext
  175. .size v6_processor_functions, . - v6_processor_functions
  176. .type cpu_arch_name, #object
  177. cpu_arch_name:
  178. .asciz "armv6"
  179. .size cpu_arch_name, . - cpu_arch_name
  180. .type cpu_elf_name, #object
  181. cpu_elf_name:
  182. .asciz "v6"
  183. .size cpu_elf_name, . - cpu_elf_name
  184. .align
  185. .section ".proc.info.init", #alloc, #execinstr
  186. /*
  187. * Match any ARMv6 processor core.
  188. */
  189. .type __v6_proc_info, #object
  190. __v6_proc_info:
  191. .long 0x0007b000
  192. .long 0x0007f000
  193. .long PMD_TYPE_SECT | \
  194. PMD_SECT_BUFFERABLE | \
  195. PMD_SECT_CACHEABLE | \
  196. PMD_SECT_AP_WRITE | \
  197. PMD_SECT_AP_READ
  198. .long PMD_TYPE_SECT | \
  199. PMD_SECT_XN | \
  200. PMD_SECT_AP_WRITE | \
  201. PMD_SECT_AP_READ
  202. b __v6_setup
  203. .long cpu_arch_name
  204. .long cpu_elf_name
  205. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
  206. .long cpu_v6_name
  207. .long v6_processor_functions
  208. .long v6wbi_tlb_fns
  209. .long v6_user_fns
  210. .long v6_cache_fns
  211. .size __v6_proc_info, . - __v6_proc_info