2 * linux/arch/arm/mm/proc-arm926.S: MMU functions for ARM926EJ-S
4 * Copyright (C) 1999-2001 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * These are the low level assembler for performing cache and TLB
23 * functions on the arm926.
25 * CONFIG_CPU_ARM926_CPU_IDLE -> nohlt
27 #include <linux/linkage.h>
28 #include <linux/config.h>
29 #include <linux/init.h>
30 #include <asm/assembler.h>
31 #include <asm/pgtable-hwdef.h>
32 #include <asm/pgtable.h>
33 #include <asm/procinfo.h>
34 #include <asm/hardware.h>
36 #include <asm/ptrace.h>
37 #include "proc-macros.S"
40 * This is the maximum size of an area which will be invalidated
41 * using the single invalidate entry instructions. Anything larger
42 * than this, and we go for the whole cache.
44 * This value should be chosen such that we choose the cheapest
47 #define CACHE_DLIMIT 16384
50 * the cache line size of the I and D cache
52 #define CACHE_DLINESIZE 32
56 * cpu_arm926_proc_init()
58 ENTRY(cpu_arm926_proc_init)
62 * cpu_arm926_proc_fin()
64 ENTRY(cpu_arm926_proc_fin)
66 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
68 bl arm926_flush_kern_cache_all
69 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
70 bic r0, r0, #0x1000 @ ...i............
71 bic r0, r0, #0x000e @ ............wca.
72 mcr p15, 0, r0, c1, c0, 0 @ disable caches
76 * cpu_arm926_reset(loc)
78 * Perform a soft reset of the system. Put the CPU into the
79 * same state as it would be if it had been reset, and branch
80 * to what would be the reset vector.
82 * loc: location to jump to for soft reset
85 ENTRY(cpu_arm926_reset)
87 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
88 mcr p15, 0, ip, c7, c10, 4 @ drain WB
89 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
90 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
91 bic ip, ip, #0x000f @ ............wcam
92 bic ip, ip, #0x1100 @ ...i...s........
93 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
97 * cpu_arm926_do_idle()
99 * Called with IRQs disabled
102 ENTRY(cpu_arm926_do_idle)
104 mrc p15, 0, r1, c1, c0, 0 @ Read control register
105 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
107 mcr p15, 0, r2, c1, c0, 0 @ Disable I cache
108 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
109 mcr p15, 0, r1, c1, c0, 0 @ Restore ICache enable
113 * flush_user_cache_all()
115 * Clean and invalidate all cache entries in a particular
118 ENTRY(arm926_flush_user_cache_all)
122 * flush_kern_cache_all()
124 * Clean and invalidate the entire cache.
126 ENTRY(arm926_flush_kern_cache_all)
130 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
131 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
133 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
137 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
138 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
142 * flush_user_cache_range(start, end, flags)
144 * Clean and invalidate a range of cache entries in the
145 * specified address range.
147 * - start - start address (inclusive)
148 * - end - end address (exclusive)
149 * - flags - vm_flags describing address space
151 ENTRY(arm926_flush_user_cache_range)
153 sub r3, r1, r0 @ calculate total size
154 cmp r3, #CACHE_DLIMIT
155 bgt __flush_whole_cache
157 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
158 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
159 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
160 add r0, r0, #CACHE_DLINESIZE
161 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
162 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
163 add r0, r0, #CACHE_DLINESIZE
165 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
166 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
167 add r0, r0, #CACHE_DLINESIZE
168 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
169 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
170 add r0, r0, #CACHE_DLINESIZE
175 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
179 * coherent_kern_range(start, end)
181 * Ensure coherency between the Icache and the Dcache in the
182 * region described by start, end. If you have non-snooping
183 * Harvard caches, you need to implement this function.
185 * - start - virtual start address
186 * - end - virtual end address
188 ENTRY(arm926_coherent_kern_range)
192 * coherent_user_range(start, end)
194 * Ensure coherency between the Icache and the Dcache in the
195 * region described by start, end. If you have non-snooping
196 * Harvard caches, you need to implement this function.
198 * - start - virtual start address
199 * - end - virtual end address
201 ENTRY(arm926_coherent_user_range)
202 bic r0, r0, #CACHE_DLINESIZE - 1
203 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
204 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
205 add r0, r0, #CACHE_DLINESIZE
208 mcr p15, 0, r0, c7, c10, 4 @ drain WB
212 * flush_kern_dcache_page(void *page)
214 * Ensure no D cache aliasing occurs, either with itself or
217 * - addr - page aligned address
219 ENTRY(arm926_flush_kern_dcache_page)
221 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
222 add r0, r0, #CACHE_DLINESIZE
226 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
227 mcr p15, 0, r0, c7, c10, 4 @ drain WB
231 * dma_inv_range(start, end)
233 * Invalidate (discard) the specified virtual address range.
234 * May not write back any entries. If 'start' or 'end'
235 * are not cache line aligned, those lines must be written
238 * - start - virtual start address
239 * - end - virtual end address
243 ENTRY(arm926_dma_inv_range)
244 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
245 tst r0, #CACHE_DLINESIZE - 1
246 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
247 tst r1, #CACHE_DLINESIZE - 1
248 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
250 bic r0, r0, #CACHE_DLINESIZE - 1
251 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
252 add r0, r0, #CACHE_DLINESIZE
255 mcr p15, 0, r0, c7, c10, 4 @ drain WB
259 * dma_clean_range(start, end)
261 * Clean the specified virtual address range.
263 * - start - virtual start address
264 * - end - virtual end address
268 ENTRY(arm926_dma_clean_range)
269 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
270 bic r0, r0, #CACHE_DLINESIZE - 1
271 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
272 add r0, r0, #CACHE_DLINESIZE
276 mcr p15, 0, r0, c7, c10, 4 @ drain WB
280 * dma_flush_range(start, end)
282 * Clean and invalidate the specified virtual address range.
284 * - start - virtual start address
285 * - end - virtual end address
287 ENTRY(arm926_dma_flush_range)
288 bic r0, r0, #CACHE_DLINESIZE - 1
290 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
291 mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
293 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
295 add r0, r0, #CACHE_DLINESIZE
298 mcr p15, 0, r0, c7, c10, 4 @ drain WB
301 ENTRY(arm926_cache_fns)
302 .long arm926_flush_kern_cache_all
303 .long arm926_flush_user_cache_all
304 .long arm926_flush_user_cache_range
305 .long arm926_coherent_kern_range
306 .long arm926_coherent_user_range
307 .long arm926_flush_kern_dcache_page
308 .long arm926_dma_inv_range
309 .long arm926_dma_clean_range
310 .long arm926_dma_flush_range
312 ENTRY(cpu_arm926_dcache_clean_area)
313 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
314 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
315 add r0, r0, #CACHE_DLINESIZE
316 subs r1, r1, #CACHE_DLINESIZE
319 mcr p15, 0, r0, c7, c10, 4 @ drain WB
322 /* =============================== PageTable ============================== */
325 * cpu_arm926_switch_mm(pgd)
327 * Set the translation base pointer to be as described by pgd.
329 * pgd: new page tables
332 ENTRY(cpu_arm926_switch_mm)
334 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
335 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
337 @ && 'Clean & Invalidate whole DCache'
338 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
341 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
342 mcr p15, 0, ip, c7, c10, 4 @ drain WB
343 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
344 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
348 * cpu_arm926_set_pte(ptep, pte)
350 * Set a PTE and flush it out
353 ENTRY(cpu_arm926_set_pte)
354 str r1, [r0], #-2048 @ linux version
356 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
358 bic r2, r1, #PTE_SMALL_AP_MASK
359 bic r2, r2, #PTE_TYPE_MASK
360 orr r2, r2, #PTE_TYPE_SMALL
362 tst r1, #L_PTE_USER @ User?
363 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
365 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
366 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
368 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
371 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
372 eor r3, r2, #0x0a @ C & small page?
376 str r2, [r0] @ hardware version
378 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
379 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
381 mcr p15, 0, r0, c7, c10, 4 @ drain WB
386 .type __arm926_setup, #function
389 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
390 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
391 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
394 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
395 mov r0, #4 @ disable write-back on caches explicitly
396 mcr p15, 7, r0, c15, c0, 0
399 mrc p15, 0, r0, c1, c0 @ get control register v4
400 ldr r5, arm926_cr1_clear
402 ldr r5, arm926_cr1_set
404 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
405 orr r0, r0, #0x4000 @ .1.. .... .... ....
408 .size __arm926_setup, . - __arm926_setup
412 * .RVI ZFRS BLDP WCAM
413 * .011 0001 ..11 0101
416 .type arm926_cr1_clear, #object
417 .type arm926_cr1_set, #object
426 * Purpose : Function pointers used to access above functions - all calls
429 .type arm926_processor_functions, #object
430 arm926_processor_functions:
431 .word v5tj_early_abort
432 .word cpu_arm926_proc_init
433 .word cpu_arm926_proc_fin
434 .word cpu_arm926_reset
435 .word cpu_arm926_do_idle
436 .word cpu_arm926_dcache_clean_area
437 .word cpu_arm926_switch_mm
438 .word cpu_arm926_set_pte
439 .size arm926_processor_functions, . - arm926_processor_functions
443 .type cpu_arch_name, #object
446 .size cpu_arch_name, . - cpu_arch_name
448 .type cpu_elf_name, #object
451 .size cpu_elf_name, . - cpu_elf_name
453 .type cpu_arm926_name, #object
456 #ifndef CONFIG_CPU_ICACHE_DISABLE
459 #ifndef CONFIG_CPU_DCACHE_DISABLE
461 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
466 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
471 .size cpu_arm926_name, . - cpu_arm926_name
475 .section ".proc.info.init", #alloc, #execinstr
477 .type __arm926_proc_info,#object
479 .long 0x41069260 @ ARM926EJ-S (v5TEJ)
481 .long PMD_TYPE_SECT | \
482 PMD_SECT_BUFFERABLE | \
483 PMD_SECT_CACHEABLE | \
485 PMD_SECT_AP_WRITE | \
490 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
491 .long cpu_arm926_name
492 .long arm926_processor_functions
495 .long arm926_cache_fns
496 .size __arm926_proc_info, . - __arm926_proc_info