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/linkage.h>
13 #include <asm/assembler.h>
14 #include <asm/asm-offsets.h>
16 #include <asm/pgtable-hwdef.h>
17 #include <asm/pgtable.h>
19 #include "proc-macros.S"
21 #define TTB_C (1 << 0)
22 #define TTB_S (1 << 1)
23 #define TTB_RGN_OC_WT (2 << 3)
24 #define TTB_RGN_OC_WB (3 << 3)
26 ENTRY(cpu_v7_proc_init)
29 ENTRY(cpu_v7_proc_fin)
35 * Perform a soft reset of the system. Put the CPU into the
36 * same state as it would be if it had been reset, and branch
37 * to what would be the reset vector.
39 * - loc - location to jump to for soft reset
50 * Idle the processor (eg, wait for interrupt).
52 * IRQs are already disabled.
55 .long 0xe320f003 @ ARM V7 WFI instruction
58 ENTRY(cpu_v7_dcache_clean_area)
59 #ifndef TLB_CAN_READ_FROM_L1_CACHE
60 dcache_line_size r2, r3
61 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
70 * cpu_v7_switch_mm(pgd_phys, tsk)
72 * Set the translation table base pointer to be pgd_phys
74 * - pgd_phys - physical address of new TTB
77 * - we are not using split page tables
79 ENTRY(cpu_v7_switch_mm)
81 ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
82 orr r0, r0, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB
83 mcr p15, 0, r2, c13, c0, 1 @ set reserved context ID
85 1: mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
87 mcr p15, 0, r1, c13, c0, 1 @ set context ID
92 * cpu_v7_set_pte_ext(ptep, pte)
94 * Set a level 2 translation table entry.
96 * - ptep - pointer to level 2 translation table entry
97 * (hardware version is stored at -1024 bytes)
98 * - pte - PTE value to store
99 * - ext - value for extended PTE bits
102 * YUWD APX AP1 AP0 SVC User
103 * 0xxx 0 0 0 no acc no acc
104 * 100x 1 0 1 r/o no acc
105 * 10x0 1 0 1 r/o no acc
106 * 1011 0 0 1 r/w no acc
111 ENTRY(cpu_v7_set_pte_ext)
112 str r1, [r0], #-2048 @ linux version
114 bic r3, r1, #0x000003f0
115 bic r3, r3, #0x00000003
117 orr r3, r3, #PTE_EXT_AP0 | 2
120 tstne r1, #L_PTE_DIRTY
121 orreq r3, r3, #PTE_EXT_APX
124 orrne r3, r3, #PTE_EXT_AP1
125 tstne r3, #PTE_EXT_APX
126 bicne r3, r3, #PTE_EXT_APX | PTE_EXT_AP0
129 biceq r3, r3, #PTE_EXT_APX | PTE_EXT_AP_MASK
132 orreq r3, r3, #PTE_EXT_XN
134 tst r1, #L_PTE_PRESENT
138 mcr p15, 0, r0, c7, c10, 1 @ flush_pte
142 .ascii "ARMv7 Processor"
145 .section ".text.init", #alloc, #execinstr
150 * Initialise TLB, Caches, and MMU state ready to switch the MMU
151 * on. Return in r0 the new CP15 C1 control register setting.
153 * We automatically detect if we have a Harvard cache, and use the
154 * Harvard cache control instructions insead of the unified cache
155 * control instructions.
157 * This should be able to cover all ARMv7 cores.
159 * It is assumed that:
160 * - cache type register is implemented
163 adr r12, __v7_setup_stack @ the local stack
164 stmia r12, {r0-r5, r7, r9, r11, lr}
165 bl v7_flush_dcache_all
166 ldmia r12, {r0-r5, r7, r9, r11, lr}
169 mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
172 mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
173 mcr p15, 0, r10, c2, c0, 2 @ TTB control register
174 orr r4, r4, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB
175 mcr p15, 0, r4, c2, c0, 0 @ load TTB0
176 mcr p15, 0, r4, c2, c0, 1 @ load TTB1
177 mov r10, #0x1f @ domains 0, 1 = manager
178 mcr p15, 0, r10, c3, c0, 0 @ load domain access register
179 #ifndef CONFIG_CPU_L2CACHE_DISABLE
180 @ L2 cache configuration in the L2 aux control register
181 mrc p15, 1, r10, c9, c0, 2
182 bic r10, r10, #(1 << 16) @ L2 outer cache
183 mcr p15, 1, r10, c9, c0, 2
184 @ L2 cache is enabled in the aux control register
185 mrc p15, 0, r10, c1, c0, 1
187 mcr p15, 0, r10, c1, c0, 1
189 mrc p15, 0, r0, c1, c0, 0 @ read control register
190 ldr r10, cr1_clear @ get mask for bits to clear
191 bic r0, r0, r10 @ clear bits them
192 ldr r10, cr1_set @ get mask for bits to set
193 orr r0, r0, r10 @ set them
194 mov pc, lr @ return to head.S:__ret
198 * .... ...E PUI. .T.T 4RVI ZFRS BLDP WCAM
199 * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
200 * 0 110 0011 1.00 .111 1101 < we want
202 .type cr1_clear, #object
203 .type cr1_set, #object
210 .space 4 * 11 @ 11 registers
212 .type v7_processor_functions, #object
213 ENTRY(v7_processor_functions)
215 .word cpu_v7_proc_init
216 .word cpu_v7_proc_fin
219 .word cpu_v7_dcache_clean_area
220 .word cpu_v7_switch_mm
221 .word cpu_v7_set_pte_ext
222 .size v7_processor_functions, . - v7_processor_functions
224 .type cpu_arch_name, #object
227 .size cpu_arch_name, . - cpu_arch_name
229 .type cpu_elf_name, #object
232 .size cpu_elf_name, . - cpu_elf_name
235 .section ".proc.info.init", #alloc, #execinstr
238 * Match any ARMv7 processor core.
240 .type __v7_proc_info, #object
242 .long 0x000f0000 @ Required ID value
243 .long 0x000f0000 @ Mask for ID
244 .long PMD_TYPE_SECT | \
245 PMD_SECT_BUFFERABLE | \
246 PMD_SECT_CACHEABLE | \
247 PMD_SECT_AP_WRITE | \
249 .long PMD_TYPE_SECT | \
251 PMD_SECT_AP_WRITE | \
256 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
258 .long v7_processor_functions
262 .size __v7_proc_info, . - __v7_proc_info