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.
6 * hacked for non-paged-MM by Hyok S. Choi, 2003.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * These are the low level assembler for performing cache and TLB
24 * functions on the arm926.
26 * CONFIG_CPU_ARM926_CPU_IDLE -> nohlt
28 #include <linux/linkage.h>
29 #include <linux/init.h>
30 #include <asm/assembler.h>
31 #include <asm/hwcap.h>
32 #include <asm/pgtable-hwdef.h>
33 #include <asm/pgtable.h>
35 #include <asm/ptrace.h>
36 #include "proc-macros.S"
39 * This is the maximum size of an area which will be invalidated
40 * using the single invalidate entry instructions. Anything larger
41 * than this, and we go for the whole cache.
43 * This value should be chosen such that we choose the cheapest
46 #define CACHE_DLIMIT 16384
49 * the cache line size of the I and D cache
51 #define CACHE_DLINESIZE 32
55 * cpu_arm926_proc_init()
57 ENTRY(cpu_arm926_proc_init)
61 * cpu_arm926_proc_fin()
63 ENTRY(cpu_arm926_proc_fin)
64 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
65 bic r0, r0, #0x1000 @ ...i............
66 bic r0, r0, #0x000e @ ............wca.
67 mcr p15, 0, r0, c1, c0, 0 @ disable caches
71 * cpu_arm926_reset(loc)
73 * Perform a soft reset of the system. Put the CPU into the
74 * same state as it would be if it had been reset, and branch
75 * to what would be the reset vector.
77 * loc: location to jump to for soft reset
80 ENTRY(cpu_arm926_reset)
82 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
83 mcr p15, 0, ip, c7, c10, 4 @ drain WB
85 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
87 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
88 bic ip, ip, #0x000f @ ............wcam
89 bic ip, ip, #0x1100 @ ...i...s........
90 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
94 * cpu_arm926_do_idle()
96 * Called with IRQs disabled
99 ENTRY(cpu_arm926_do_idle)
101 mrc p15, 0, r1, c1, c0, 0 @ Read control register
102 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
104 mrs r3, cpsr @ Disable FIQs while Icache
105 orr ip, r3, #PSR_F_BIT @ is disabled
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
110 msr cpsr_c, r3 @ Restore FIQ state
116 * Unconditionally clean and invalidate the entire icache.
118 ENTRY(arm926_flush_icache_all)
120 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
122 ENDPROC(arm926_flush_icache_all)
125 * flush_user_cache_all()
127 * Clean and invalidate all cache entries in a particular
130 ENTRY(arm926_flush_user_cache_all)
134 * flush_kern_cache_all()
136 * Clean and invalidate the entire cache.
138 ENTRY(arm926_flush_kern_cache_all)
142 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
143 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
145 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
149 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
150 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
154 * flush_user_cache_range(start, end, flags)
156 * Clean and invalidate a range of cache entries in the
157 * specified address range.
159 * - start - start address (inclusive)
160 * - end - end address (exclusive)
161 * - flags - vm_flags describing address space
163 ENTRY(arm926_flush_user_cache_range)
165 sub r3, r1, r0 @ calculate total size
166 cmp r3, #CACHE_DLIMIT
167 bgt __flush_whole_cache
169 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
170 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
171 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
172 add r0, r0, #CACHE_DLINESIZE
173 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
174 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
175 add r0, r0, #CACHE_DLINESIZE
177 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
178 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
179 add r0, r0, #CACHE_DLINESIZE
180 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
181 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
182 add r0, r0, #CACHE_DLINESIZE
187 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
191 * coherent_kern_range(start, end)
193 * Ensure coherency between the Icache and the Dcache in the
194 * region described by start, end. If you have non-snooping
195 * Harvard caches, you need to implement this function.
197 * - start - virtual start address
198 * - end - virtual end address
200 ENTRY(arm926_coherent_kern_range)
204 * coherent_user_range(start, end)
206 * Ensure coherency between the Icache and the Dcache in the
207 * region described by start, end. If you have non-snooping
208 * Harvard caches, you need to implement this function.
210 * - start - virtual start address
211 * - end - virtual end address
213 ENTRY(arm926_coherent_user_range)
214 bic r0, r0, #CACHE_DLINESIZE - 1
215 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
216 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
217 add r0, r0, #CACHE_DLINESIZE
220 mcr p15, 0, r0, c7, c10, 4 @ drain WB
224 * flush_kern_dcache_area(void *addr, size_t size)
226 * Ensure no D cache aliasing occurs, either with itself or
229 * - addr - kernel address
230 * - size - region size
232 ENTRY(arm926_flush_kern_dcache_area)
234 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
235 add r0, r0, #CACHE_DLINESIZE
239 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
240 mcr p15, 0, r0, c7, c10, 4 @ drain WB
244 * dma_inv_range(start, end)
246 * Invalidate (discard) the specified virtual address range.
247 * May not write back any entries. If 'start' or 'end'
248 * are not cache line aligned, those lines must be written
251 * - start - virtual start address
252 * - end - virtual end address
256 arm926_dma_inv_range:
257 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
258 tst r0, #CACHE_DLINESIZE - 1
259 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
260 tst r1, #CACHE_DLINESIZE - 1
261 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
263 bic r0, r0, #CACHE_DLINESIZE - 1
264 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
265 add r0, r0, #CACHE_DLINESIZE
268 mcr p15, 0, r0, c7, c10, 4 @ drain WB
272 * dma_clean_range(start, end)
274 * Clean the specified virtual address range.
276 * - start - virtual start address
277 * - end - virtual end address
281 arm926_dma_clean_range:
282 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
283 bic r0, r0, #CACHE_DLINESIZE - 1
284 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
285 add r0, r0, #CACHE_DLINESIZE
289 mcr p15, 0, r0, c7, c10, 4 @ drain WB
293 * dma_flush_range(start, end)
295 * Clean and invalidate the specified virtual address range.
297 * - start - virtual start address
298 * - end - virtual end address
300 ENTRY(arm926_dma_flush_range)
301 bic r0, r0, #CACHE_DLINESIZE - 1
303 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
304 mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
306 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
308 add r0, r0, #CACHE_DLINESIZE
311 mcr p15, 0, r0, c7, c10, 4 @ drain WB
315 * dma_map_area(start, size, dir)
316 * - start - kernel virtual start address
317 * - size - size of region
318 * - dir - DMA direction
320 ENTRY(arm926_dma_map_area)
322 cmp r2, #DMA_TO_DEVICE
323 beq arm926_dma_clean_range
324 bcs arm926_dma_inv_range
325 b arm926_dma_flush_range
326 ENDPROC(arm926_dma_map_area)
329 * dma_unmap_area(start, size, dir)
330 * - start - kernel virtual start address
331 * - size - size of region
332 * - dir - DMA direction
334 ENTRY(arm926_dma_unmap_area)
336 ENDPROC(arm926_dma_unmap_area)
338 ENTRY(arm926_cache_fns)
339 .long arm926_flush_icache_all
340 .long arm926_flush_kern_cache_all
341 .long arm926_flush_user_cache_all
342 .long arm926_flush_user_cache_range
343 .long arm926_coherent_kern_range
344 .long arm926_coherent_user_range
345 .long arm926_flush_kern_dcache_area
346 .long arm926_dma_map_area
347 .long arm926_dma_unmap_area
348 .long arm926_dma_flush_range
350 ENTRY(cpu_arm926_dcache_clean_area)
351 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
352 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
353 add r0, r0, #CACHE_DLINESIZE
354 subs r1, r1, #CACHE_DLINESIZE
357 mcr p15, 0, r0, c7, c10, 4 @ drain WB
360 /* =============================== PageTable ============================== */
363 * cpu_arm926_switch_mm(pgd)
365 * Set the translation base pointer to be as described by pgd.
367 * pgd: new page tables
370 ENTRY(cpu_arm926_switch_mm)
373 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
374 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
376 @ && 'Clean & Invalidate whole DCache'
377 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
380 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
381 mcr p15, 0, ip, c7, c10, 4 @ drain WB
382 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
383 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
388 * cpu_arm926_set_pte_ext(ptep, pte, ext)
390 * Set a PTE and flush it out
393 ENTRY(cpu_arm926_set_pte_ext)
397 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
398 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
400 mcr p15, 0, r0, c7, c10, 4 @ drain WB
404 /* Suspend/resume support: taken from arch/arm/plat-s3c24xx/sleep.S */
405 .globl cpu_arm926_suspend_size
406 .equ cpu_arm926_suspend_size, 4 * 3
408 ENTRY(cpu_arm926_do_suspend)
409 stmfd sp!, {r4 - r7, lr}
410 mrc p15, 0, r4, c13, c0, 0 @ PID
411 mrc p15, 0, r5, c3, c0, 0 @ Domain ID
412 mrc p15, 0, r6, c2, c0, 0 @ TTB address
413 mrc p15, 0, r7, c1, c0, 0 @ Control register
415 ldmfd sp!, {r4 - r7, pc}
416 ENDPROC(cpu_arm926_do_suspend)
418 ENTRY(cpu_arm926_do_resume)
420 mcr p15, 0, ip, c8, c7, 0 @ invalidate I+D TLBs
421 mcr p15, 0, ip, c7, c7, 0 @ invalidate I+D caches
423 mcr p15, 0, r4, c13, c0, 0 @ PID
424 mcr p15, 0, r5, c3, c0, 0 @ Domain ID
425 mcr p15, 0, r6, c2, c0, 0 @ TTB address
426 mov r0, r7 @ control register
427 mov r2, r6, lsr #14 @ get TTB0 base
429 ldr r3, =PMD_TYPE_SECT | PMD_SECT_BUFFERABLE | \
430 PMD_SECT_CACHEABLE | PMD_BIT4 | PMD_SECT_AP_WRITE
432 ENDPROC(cpu_arm926_do_resume)
434 #define cpu_arm926_do_suspend 0
435 #define cpu_arm926_do_resume 0
440 .type __arm926_setup, #function
443 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
444 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
446 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
450 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
451 mov r0, #4 @ disable write-back on caches explicitly
452 mcr p15, 7, r0, c15, c0, 0
457 mrc p15, 0, r0, c1, c0 @ get control register v4
460 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
461 orr r0, r0, #0x4000 @ .1.. .... .... ....
464 .size __arm926_setup, . - __arm926_setup
468 * .RVI ZFRS BLDP WCAM
469 * .011 0001 ..11 0101
472 .type arm926_crval, #object
474 crval clear=0x00007f3f, mmuset=0x00003135, ucset=0x00001134
479 * Purpose : Function pointers used to access above functions - all calls
482 .type arm926_processor_functions, #object
483 arm926_processor_functions:
484 .word v5tj_early_abort
486 .word cpu_arm926_proc_init
487 .word cpu_arm926_proc_fin
488 .word cpu_arm926_reset
489 .word cpu_arm926_do_idle
490 .word cpu_arm926_dcache_clean_area
491 .word cpu_arm926_switch_mm
492 .word cpu_arm926_set_pte_ext
493 .word cpu_arm926_suspend_size
494 .word cpu_arm926_do_suspend
495 .word cpu_arm926_do_resume
496 .size arm926_processor_functions, . - arm926_processor_functions
500 .type cpu_arch_name, #object
503 .size cpu_arch_name, . - cpu_arch_name
505 .type cpu_elf_name, #object
508 .size cpu_elf_name, . - cpu_elf_name
510 .type cpu_arm926_name, #object
513 .size cpu_arm926_name, . - cpu_arm926_name
517 .section ".proc.info.init", #alloc, #execinstr
519 .type __arm926_proc_info,#object
521 .long 0x41069260 @ ARM926EJ-S (v5TEJ)
523 .long PMD_TYPE_SECT | \
524 PMD_SECT_BUFFERABLE | \
525 PMD_SECT_CACHEABLE | \
527 PMD_SECT_AP_WRITE | \
529 .long PMD_TYPE_SECT | \
531 PMD_SECT_AP_WRITE | \
536 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
537 .long cpu_arm926_name
538 .long arm926_processor_functions
541 .long arm926_cache_fns
542 .size __arm926_proc_info, . - __arm926_proc_info