proc-v7.S 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. * linux/arch/arm/mm/proc-v7.S
  3. *
  4. * Copyright (C) 2001 Deep Blue Solutions Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * This is the "shell" of the ARMv7 processor support.
  11. */
  12. #include <linux/linkage.h>
  13. #include <asm/assembler.h>
  14. #include <asm/asm-offsets.h>
  15. #include <asm/elf.h>
  16. #include <asm/pgtable-hwdef.h>
  17. #include <asm/pgtable.h>
  18. #include "proc-macros.S"
  19. #define TTB_C (1 << 0)
  20. #define TTB_S (1 << 1)
  21. #define TTB_RGN_OC_WT (2 << 3)
  22. #define TTB_RGN_OC_WB (3 << 3)
  23. ENTRY(cpu_v7_proc_init)
  24. mov pc, lr
  25. ENTRY(cpu_v7_proc_fin)
  26. mov pc, lr
  27. /*
  28. * cpu_v7_reset(loc)
  29. *
  30. * Perform a soft reset of the system. Put the CPU into the
  31. * same state as it would be if it had been reset, and branch
  32. * to what would be the reset vector.
  33. *
  34. * - loc - location to jump to for soft reset
  35. *
  36. * It is assumed that:
  37. */
  38. .align 5
  39. ENTRY(cpu_v7_reset)
  40. mov pc, r0
  41. /*
  42. * cpu_v7_do_idle()
  43. *
  44. * Idle the processor (eg, wait for interrupt).
  45. *
  46. * IRQs are already disabled.
  47. */
  48. ENTRY(cpu_v7_do_idle)
  49. .long 0xe320f003 @ ARM V7 WFI instruction
  50. mov pc, lr
  51. ENTRY(cpu_v7_dcache_clean_area)
  52. #ifndef TLB_CAN_READ_FROM_L1_CACHE
  53. dcache_line_size r2, r3
  54. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  55. add r0, r0, r2
  56. subs r1, r1, r2
  57. bhi 1b
  58. dsb
  59. #endif
  60. mov pc, lr
  61. /*
  62. * cpu_v7_switch_mm(pgd_phys, tsk)
  63. *
  64. * Set the translation table base pointer to be pgd_phys
  65. *
  66. * - pgd_phys - physical address of new TTB
  67. *
  68. * It is assumed that:
  69. * - we are not using split page tables
  70. */
  71. ENTRY(cpu_v7_switch_mm)
  72. #ifdef CONFIG_MMU
  73. mov r2, #0
  74. ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
  75. orr r0, r0, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB
  76. mcr p15, 0, r2, c13, c0, 1 @ set reserved context ID
  77. isb
  78. 1: mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
  79. isb
  80. mcr p15, 0, r1, c13, c0, 1 @ set context ID
  81. isb
  82. #endif
  83. mov pc, lr
  84. /*
  85. * cpu_v7_set_pte_ext(ptep, pte)
  86. *
  87. * Set a level 2 translation table entry.
  88. *
  89. * - ptep - pointer to level 2 translation table entry
  90. * (hardware version is stored at -1024 bytes)
  91. * - pte - PTE value to store
  92. * - ext - value for extended PTE bits
  93. */
  94. armv6_mt_table cpu_v7
  95. ENTRY(cpu_v7_set_pte_ext)
  96. #ifdef CONFIG_MMU
  97. armv6_set_pte_ext cpu_v7
  98. #endif
  99. mov pc, lr
  100. cpu_v7_name:
  101. .ascii "ARMv7 Processor"
  102. .align
  103. .section ".text.init", #alloc, #execinstr
  104. /*
  105. * __v7_setup
  106. *
  107. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  108. * on. Return in r0 the new CP15 C1 control register setting.
  109. *
  110. * We automatically detect if we have a Harvard cache, and use the
  111. * Harvard cache control instructions insead of the unified cache
  112. * control instructions.
  113. *
  114. * This should be able to cover all ARMv7 cores.
  115. *
  116. * It is assumed that:
  117. * - cache type register is implemented
  118. */
  119. __v7_setup:
  120. adr r12, __v7_setup_stack @ the local stack
  121. stmia r12, {r0-r5, r7, r9, r11, lr}
  122. bl v7_flush_dcache_all
  123. ldmia r12, {r0-r5, r7, r9, r11, lr}
  124. mov r10, #0
  125. #ifdef HARVARD_CACHE
  126. mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
  127. #endif
  128. dsb
  129. #ifdef CONFIG_MMU
  130. mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
  131. mcr p15, 0, r10, c2, c0, 2 @ TTB control register
  132. orr r4, r4, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB
  133. mcr p15, 0, r4, c2, c0, 0 @ load TTB0
  134. mcr p15, 0, r4, c2, c0, 1 @ load TTB1
  135. mov r10, #0x1f @ domains 0, 1 = manager
  136. mcr p15, 0, r10, c3, c0, 0 @ load domain access register
  137. #endif
  138. adr r5, v7_crval
  139. ldmia r5, {r5, r6}
  140. mrc p15, 0, r0, c1, c0, 0 @ read control register
  141. bic r0, r0, r5 @ clear bits them
  142. orr r0, r0, r6 @ set them
  143. mov pc, lr @ return to head.S:__ret
  144. /*
  145. * V X F I D LR
  146. * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM
  147. * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
  148. * 0 110 0011 1.00 .111 1101 < we want
  149. */
  150. .type v7_crval, #object
  151. v7_crval:
  152. crval clear=0x0120c302, mmuset=0x00c0387d, ucset=0x00c0187c
  153. __v7_setup_stack:
  154. .space 4 * 11 @ 11 registers
  155. .type v7_processor_functions, #object
  156. ENTRY(v7_processor_functions)
  157. .word v7_early_abort
  158. .word pabort_ifar
  159. .word cpu_v7_proc_init
  160. .word cpu_v7_proc_fin
  161. .word cpu_v7_reset
  162. .word cpu_v7_do_idle
  163. .word cpu_v7_dcache_clean_area
  164. .word cpu_v7_switch_mm
  165. .word cpu_v7_set_pte_ext
  166. .size v7_processor_functions, . - v7_processor_functions
  167. .type cpu_arch_name, #object
  168. cpu_arch_name:
  169. .asciz "armv7"
  170. .size cpu_arch_name, . - cpu_arch_name
  171. .type cpu_elf_name, #object
  172. cpu_elf_name:
  173. .asciz "v7"
  174. .size cpu_elf_name, . - cpu_elf_name
  175. .align
  176. .section ".proc.info.init", #alloc, #execinstr
  177. /*
  178. * Match any ARMv7 processor core.
  179. */
  180. .type __v7_proc_info, #object
  181. __v7_proc_info:
  182. .long 0x000f0000 @ Required ID value
  183. .long 0x000f0000 @ Mask for ID
  184. .long PMD_TYPE_SECT | \
  185. PMD_SECT_BUFFERABLE | \
  186. PMD_SECT_CACHEABLE | \
  187. PMD_SECT_AP_WRITE | \
  188. PMD_SECT_AP_READ
  189. .long PMD_TYPE_SECT | \
  190. PMD_SECT_XN | \
  191. PMD_SECT_AP_WRITE | \
  192. PMD_SECT_AP_READ
  193. b __v7_setup
  194. .long cpu_arch_name
  195. .long cpu_elf_name
  196. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  197. .long cpu_v7_name
  198. .long v7_processor_functions
  199. .long v7wbi_tlb_fns
  200. .long v6_user_fns
  201. .long v7_cache_fns
  202. .size __v7_proc_info, . - __v7_proc_info