proc-v6.S 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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/init.h>
  14. #include <linux/linkage.h>
  15. #include <asm/assembler.h>
  16. #include <asm/asm-offsets.h>
  17. #include <asm/hwcap.h>
  18. #include <asm/pgtable-hwdef.h>
  19. #include <asm/pgtable.h>
  20. #include "proc-macros.S"
  21. #define D_CACHE_LINE_SIZE 32
  22. #define TTB_C (1 << 0)
  23. #define TTB_S (1 << 1)
  24. #define TTB_IMP (1 << 2)
  25. #define TTB_RGN_NC (0 << 3)
  26. #define TTB_RGN_WBWA (1 << 3)
  27. #define TTB_RGN_WT (2 << 3)
  28. #define TTB_RGN_WB (3 << 3)
  29. #ifndef CONFIG_SMP
  30. #define TTB_FLAGS TTB_RGN_WBWA
  31. #define PMD_FLAGS PMD_SECT_WB
  32. #else
  33. #define TTB_FLAGS TTB_RGN_WBWA|TTB_S
  34. #define PMD_FLAGS PMD_SECT_WBWA|PMD_SECT_S
  35. #endif
  36. ENTRY(cpu_v6_proc_init)
  37. mov pc, lr
  38. ENTRY(cpu_v6_proc_fin)
  39. stmfd sp!, {lr}
  40. cpsid if @ disable interrupts
  41. bl v6_flush_kern_cache_all
  42. mrc p15, 0, r0, c1, c0, 0 @ ctrl register
  43. bic r0, r0, #0x1000 @ ...i............
  44. bic r0, r0, #0x0006 @ .............ca.
  45. mcr p15, 0, r0, c1, c0, 0 @ disable caches
  46. ldmfd sp!, {pc}
  47. /*
  48. * cpu_v6_reset(loc)
  49. *
  50. * Perform a soft reset of the system. Put the CPU into the
  51. * same state as it would be if it had been reset, and branch
  52. * to what would be the reset vector.
  53. *
  54. * - loc - location to jump to for soft reset
  55. *
  56. * It is assumed that:
  57. */
  58. .align 5
  59. ENTRY(cpu_v6_reset)
  60. mov pc, r0
  61. /*
  62. * cpu_v6_do_idle()
  63. *
  64. * Idle the processor (eg, wait for interrupt).
  65. *
  66. * IRQs are already disabled.
  67. */
  68. ENTRY(cpu_v6_do_idle)
  69. mov r1, #0
  70. mcr p15, 0, r1, c7, c10, 4 @ DWB - WFI may enter a low-power mode
  71. mcr p15, 0, r1, c7, c0, 4 @ wait for interrupt
  72. mov pc, lr
  73. ENTRY(cpu_v6_dcache_clean_area)
  74. #ifndef TLB_CAN_READ_FROM_L1_CACHE
  75. 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
  76. add r0, r0, #D_CACHE_LINE_SIZE
  77. subs r1, r1, #D_CACHE_LINE_SIZE
  78. bhi 1b
  79. #endif
  80. mov pc, lr
  81. /*
  82. * cpu_arm926_switch_mm(pgd_phys, tsk)
  83. *
  84. * Set the translation table base pointer to be pgd_phys
  85. *
  86. * - pgd_phys - physical address of new TTB
  87. *
  88. * It is assumed that:
  89. * - we are not using split page tables
  90. */
  91. ENTRY(cpu_v6_switch_mm)
  92. #ifdef CONFIG_MMU
  93. mov r2, #0
  94. ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
  95. orr r0, r0, #TTB_FLAGS
  96. mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
  97. mcr p15, 0, r2, c7, c10, 4 @ drain write buffer
  98. mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
  99. mcr p15, 0, r1, c13, c0, 1 @ set context ID
  100. #endif
  101. mov pc, lr
  102. /*
  103. * cpu_v6_set_pte_ext(ptep, pte, ext)
  104. *
  105. * Set a level 2 translation table entry.
  106. *
  107. * - ptep - pointer to level 2 translation table entry
  108. * (hardware version is stored at -1024 bytes)
  109. * - pte - PTE value to store
  110. * - ext - value for extended PTE bits
  111. */
  112. armv6_mt_table cpu_v6
  113. ENTRY(cpu_v6_set_pte_ext)
  114. #ifdef CONFIG_MMU
  115. armv6_set_pte_ext cpu_v6
  116. #endif
  117. mov pc, lr
  118. .type cpu_v6_name, #object
  119. cpu_v6_name:
  120. .asciz "ARMv6-compatible processor"
  121. .size cpu_v6_name, . - cpu_v6_name
  122. .type cpu_pj4_name, #object
  123. cpu_pj4_name:
  124. .asciz "Marvell PJ4 processor"
  125. .size cpu_pj4_name, . - cpu_pj4_name
  126. .align
  127. __INIT
  128. /*
  129. * __v6_setup
  130. *
  131. * Initialise TLB, Caches, and MMU state ready to switch the MMU
  132. * on. Return in r0 the new CP15 C1 control register setting.
  133. *
  134. * We automatically detect if we have a Harvard cache, and use the
  135. * Harvard cache control instructions insead of the unified cache
  136. * control instructions.
  137. *
  138. * This should be able to cover all ARMv6 cores.
  139. *
  140. * It is assumed that:
  141. * - cache type register is implemented
  142. */
  143. __v6_setup:
  144. #ifdef CONFIG_SMP
  145. mrc p15, 0, r0, c1, c0, 1 @ Enable SMP/nAMP mode
  146. orr r0, r0, #0x20
  147. mcr p15, 0, r0, c1, c0, 1
  148. #endif
  149. mov r0, #0
  150. mcr p15, 0, r0, c7, c14, 0 @ clean+invalidate D cache
  151. mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
  152. mcr p15, 0, r0, c7, c15, 0 @ clean+invalidate cache
  153. mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
  154. #ifdef CONFIG_MMU
  155. mcr p15, 0, r0, c8, c7, 0 @ invalidate I + D TLBs
  156. mcr p15, 0, r0, c2, c0, 2 @ TTB control register
  157. orr r4, r4, #TTB_FLAGS
  158. mcr p15, 0, r4, c2, c0, 1 @ load TTB1
  159. #endif /* CONFIG_MMU */
  160. adr r5, v6_crval
  161. ldmia r5, {r5, r6}
  162. #ifdef CONFIG_CPU_ENDIAN_BE8
  163. orr r6, r6, #1 << 25 @ big-endian page tables
  164. #endif
  165. mrc p15, 0, r0, c1, c0, 0 @ read control register
  166. bic r0, r0, r5 @ clear bits them
  167. orr r0, r0, r6 @ set them
  168. mov pc, lr @ return to head.S:__ret
  169. /*
  170. * V X F I D LR
  171. * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM
  172. * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
  173. * 0 110 0011 1.00 .111 1101 < we want
  174. */
  175. .type v6_crval, #object
  176. v6_crval:
  177. crval clear=0x01e0fb7f, mmuset=0x00c0387d, ucset=0x00c0187c
  178. .type v6_processor_functions, #object
  179. ENTRY(v6_processor_functions)
  180. .word v6_early_abort
  181. .word v6_pabort
  182. .word cpu_v6_proc_init
  183. .word cpu_v6_proc_fin
  184. .word cpu_v6_reset
  185. .word cpu_v6_do_idle
  186. .word cpu_v6_dcache_clean_area
  187. .word cpu_v6_switch_mm
  188. .word cpu_v6_set_pte_ext
  189. .size v6_processor_functions, . - v6_processor_functions
  190. .type cpu_arch_name, #object
  191. cpu_arch_name:
  192. .asciz "armv6"
  193. .size cpu_arch_name, . - cpu_arch_name
  194. .type cpu_elf_name, #object
  195. cpu_elf_name:
  196. .asciz "v6"
  197. .size cpu_elf_name, . - cpu_elf_name
  198. .align
  199. .section ".proc.info.init", #alloc, #execinstr
  200. /*
  201. * Match any ARMv6 processor core.
  202. */
  203. .type __v6_proc_info, #object
  204. __v6_proc_info:
  205. .long 0x0007b000
  206. .long 0x0007f000
  207. .long PMD_TYPE_SECT | \
  208. PMD_SECT_AP_WRITE | \
  209. PMD_SECT_AP_READ | \
  210. PMD_FLAGS
  211. .long PMD_TYPE_SECT | \
  212. PMD_SECT_XN | \
  213. PMD_SECT_AP_WRITE | \
  214. PMD_SECT_AP_READ
  215. b __v6_setup
  216. .long cpu_arch_name
  217. .long cpu_elf_name
  218. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
  219. .long cpu_v6_name
  220. .long v6_processor_functions
  221. .long v6wbi_tlb_fns
  222. .long v6_user_fns
  223. .long v6_cache_fns
  224. .size __v6_proc_info, . - __v6_proc_info
  225. .type __pj4_v6_proc_info, #object
  226. __pj4_v6_proc_info:
  227. .long 0x560f5810
  228. .long 0xff0ffff0
  229. .long PMD_TYPE_SECT | \
  230. PMD_SECT_AP_WRITE | \
  231. PMD_SECT_AP_READ | \
  232. PMD_FLAGS
  233. .long PMD_TYPE_SECT | \
  234. PMD_SECT_XN | \
  235. PMD_SECT_AP_WRITE | \
  236. PMD_SECT_AP_READ
  237. b __v6_setup
  238. .long cpu_arch_name
  239. .long cpu_elf_name
  240. .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
  241. .long cpu_pj4_name
  242. .long v6_processor_functions
  243. .long v6wbi_tlb_fns
  244. .long v6_user_fns
  245. .long v6_cache_fns
  246. .size __pj4_v6_proc_info, . - __pj4_v6_proc_info