2 * linux/arch/arm/mm/proc-v7.S
4 * Copyright (C) 2001 Deep Blue Solutions Ltd.
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.
10 * This is the "shell" of the ARMv7 processor support.
12 #include <linux/init.h>
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>
20 #include "proc-macros.S"
22 #define TTB_C (1 << 0)
23 #define TTB_S (1 << 1)
24 #define TTB_RGN_NC (0 << 3)
25 #define TTB_RGN_OC_WBWA (1 << 3)
26 #define TTB_RGN_OC_WT (2 << 3)
27 #define TTB_RGN_OC_WB (3 << 3)
30 #define TTB_FLAGS TTB_C|TTB_RGN_OC_WB @ mark PTWs cacheable, outer WB
32 #define TTB_FLAGS TTB_C|TTB_S|TTB_RGN_OC_WBWA @ mark PTWs cacheable and shared, outer WBWA
35 ENTRY(cpu_v7_proc_init)
37 ENDPROC(cpu_v7_proc_init)
39 ENTRY(cpu_v7_proc_fin)
41 ENDPROC(cpu_v7_proc_fin)
46 * Perform a soft reset of the system. Put the CPU into the
47 * same state as it would be if it had been reset, and branch
48 * to what would be the reset vector.
50 * - loc - location to jump to for soft reset
62 * Idle the processor (eg, wait for interrupt).
64 * IRQs are already disabled.
67 dsb @ WFI may enter a low-power mode
70 ENDPROC(cpu_v7_do_idle)
72 ENTRY(cpu_v7_dcache_clean_area)
73 #ifndef TLB_CAN_READ_FROM_L1_CACHE
74 dcache_line_size r2, r3
75 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
82 ENDPROC(cpu_v7_dcache_clean_area)
85 * cpu_v7_switch_mm(pgd_phys, tsk)
87 * Set the translation table base pointer to be pgd_phys
89 * - pgd_phys - physical address of new TTB
92 * - we are not using split page tables
94 ENTRY(cpu_v7_switch_mm)
97 ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
98 orr r0, r0, #TTB_FLAGS
99 #ifdef CONFIG_ARM_ERRATA_430973
100 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB
102 mcr p15, 0, r2, c13, c0, 1 @ set reserved context ID
104 1: mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
106 mcr p15, 0, r1, c13, c0, 1 @ set context ID
110 ENDPROC(cpu_v7_switch_mm)
113 * cpu_v7_set_pte_ext(ptep, pte)
115 * Set a level 2 translation table entry.
117 * - ptep - pointer to level 2 translation table entry
118 * (hardware version is stored at -1024 bytes)
119 * - pte - PTE value to store
120 * - ext - value for extended PTE bits
122 ENTRY(cpu_v7_set_pte_ext)
124 str r1, [r0], #-2048 @ linux version
126 bic r3, r1, #0x000003f0
127 bic r3, r3, #PTE_TYPE_MASK
129 orr r3, r3, #PTE_EXT_AP0 | 2
132 orrne r3, r3, #PTE_EXT_TEX(1)
135 tstne r1, #L_PTE_DIRTY
136 orreq r3, r3, #PTE_EXT_APX
139 orrne r3, r3, #PTE_EXT_AP1
140 tstne r3, #PTE_EXT_APX
141 bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
144 orreq r3, r3, #PTE_EXT_XN
147 tstne r1, #L_PTE_PRESENT
151 mcr p15, 0, r0, c7, c10, 1 @ flush_pte
154 ENDPROC(cpu_v7_set_pte_ext)
157 .ascii "ARMv7 Processor"
165 * Initialise TLB, Caches, and MMU state ready to switch the MMU
166 * on. Return in r0 the new CP15 C1 control register setting.
168 * We automatically detect if we have a Harvard cache, and use the
169 * Harvard cache control instructions insead of the unified cache
170 * control instructions.
172 * This should be able to cover all ARMv7 cores.
174 * It is assumed that:
175 * - cache type register is implemented
179 mrc p15, 0, r0, c1, c0, 1 @ Enable SMP/nAMP mode
180 orr r0, r0, #(0x1 << 6)
181 mcr p15, 0, r0, c1, c0, 1
183 adr r12, __v7_setup_stack @ the local stack
184 stmia r12, {r0-r5, r7, r9, r11, lr}
185 bl v7_flush_dcache_all
186 ldmia r12, {r0-r5, r7, r9, r11, lr}
188 mrc p15, 0, r0, c0, c0, 0 @ read main ID register
189 and r10, r0, #0xff000000 @ ARM?
192 and r5, r0, #0x00f00000 @ variant
193 and r6, r0, #0x0000000f @ revision
194 orr r0, r6, r5, lsr #20-4 @ combine variant and revision
196 #ifdef CONFIG_ARM_ERRATA_430973
197 teq r5, #0x00100000 @ only present in r1p*
198 mrceq p15, 0, r10, c1, c0, 1 @ read aux control register
199 orreq r10, r10, #(1 << 6) @ set IBE to 1
200 mcreq p15, 0, r10, c1, c0, 1 @ write aux control register
202 #ifdef CONFIG_ARM_ERRATA_458693
203 teq r0, #0x20 @ only present in r2p0
204 mrceq p15, 0, r10, c1, c0, 1 @ read aux control register
205 orreq r10, r10, #(1 << 5) @ set L1NEON to 1
206 orreq r10, r10, #(1 << 9) @ set PLDNOP to 1
207 mcreq p15, 0, r10, c1, c0, 1 @ write aux control register
209 #ifdef CONFIG_ARM_ERRATA_460075
210 teq r0, #0x20 @ only present in r2p0
211 mrceq p15, 1, r10, c9, c0, 2 @ read L2 cache aux ctrl register
213 orreq r10, r10, #(1 << 22) @ set the Write Allocate disable bit
214 mcreq p15, 1, r10, c9, c0, 2 @ write the L2 cache aux ctrl register
219 mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
223 mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
224 mcr p15, 0, r10, c2, c0, 2 @ TTB control register
225 orr r4, r4, #TTB_FLAGS
226 mcr p15, 0, r4, c2, c0, 1 @ load TTB1
227 mov r10, #0x1f @ domains 0, 1 = manager
228 mcr p15, 0, r10, c3, c0, 0 @ load domain access register
232 mcr p15, 0, r5, c10, c2, 0 @ write PRRR
233 mcr p15, 0, r6, c10, c2, 1 @ write NMRR
236 mrc p15, 0, r0, c1, c0, 0 @ read control register
237 bic r0, r0, r5 @ clear bits them
238 orr r0, r0, r6 @ set them
239 mov pc, lr @ return to head.S:__ret
244 * .EEE ..EE PUI. .T.T 4RVI ZFRS BLDP WCAM
245 * rxxx rrxx xxx0 0101 xxxx xxxx x111 xxxx < forced
246 * 1 0 110 0011 1.00 .111 1101 < we want
248 .type v7_crval, #object
250 crval clear=0x0120c302, mmuset=0x10c0387d, ucset=0x00c0187c
253 .space 4 * 11 @ 11 registers
255 .type v7_processor_functions, #object
256 ENTRY(v7_processor_functions)
259 .word cpu_v7_proc_init
260 .word cpu_v7_proc_fin
263 .word cpu_v7_dcache_clean_area
264 .word cpu_v7_switch_mm
265 .word cpu_v7_set_pte_ext
266 .size v7_processor_functions, . - v7_processor_functions
268 .type cpu_arch_name, #object
271 .size cpu_arch_name, . - cpu_arch_name
273 .type cpu_elf_name, #object
276 .size cpu_elf_name, . - cpu_elf_name
279 .section ".proc.info.init", #alloc, #execinstr
282 * Match any ARMv7 processor core.
284 .type __v7_proc_info, #object
286 .long 0x000f0000 @ Required ID value
287 .long 0x000f0000 @ Mask for ID
288 .long PMD_TYPE_SECT | \
289 PMD_SECT_BUFFERABLE | \
290 PMD_SECT_CACHEABLE | \
291 PMD_SECT_AP_WRITE | \
293 .long PMD_TYPE_SECT | \
295 PMD_SECT_AP_WRITE | \
300 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
302 .long v7_processor_functions
306 .size __v7_proc_info, . - __v7_proc_info