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.h>
32 #include <asm/procinfo.h>
33 #include <asm/hardware.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)
65 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
67 bl arm926_flush_kern_cache_all
68 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
69 bic r0, r0, #0x1000 @ ...i............
70 bic r0, r0, #0x000e @ ............wca.
71 mcr p15, 0, r0, c1, c0, 0 @ disable caches
75 * cpu_arm926_reset(loc)
77 * Perform a soft reset of the system. Put the CPU into the
78 * same state as it would be if it had been reset, and branch
79 * to what would be the reset vector.
81 * loc: location to jump to for soft reset
84 ENTRY(cpu_arm926_reset)
86 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
87 mcr p15, 0, ip, c7, c10, 4 @ drain WB
88 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
89 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
90 bic ip, ip, #0x000f @ ............wcam
91 bic ip, ip, #0x1100 @ ...i...s........
92 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
96 * cpu_arm926_do_idle()
98 * Called with IRQs disabled
101 ENTRY(cpu_arm926_do_idle)
103 mrc p15, 0, r1, c1, c0, 0 @ Read control register
104 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
106 mcr p15, 0, r2, c1, c0, 0 @ Disable I cache
107 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
108 mcr p15, 0, r1, c1, c0, 0 @ Restore ICache enable
112 * flush_user_cache_all()
114 * Clean and invalidate all cache entries in a particular
117 ENTRY(arm926_flush_user_cache_all)
121 * flush_kern_cache_all()
123 * Clean and invalidate the entire cache.
125 ENTRY(arm926_flush_kern_cache_all)
129 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
130 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
132 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
136 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
137 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
141 * flush_user_cache_range(start, end, flags)
143 * Clean and invalidate a range of cache entries in the
144 * specified address range.
146 * - start - start address (inclusive)
147 * - end - end address (exclusive)
148 * - flags - vm_flags describing address space
150 ENTRY(arm926_flush_user_cache_range)
152 sub r3, r1, r0 @ calculate total size
153 cmp r3, #CACHE_DLIMIT
154 bgt __flush_whole_cache
156 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
157 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
158 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
159 add r0, r0, #CACHE_DLINESIZE
160 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
161 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
162 add r0, r0, #CACHE_DLINESIZE
164 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
165 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
166 add r0, r0, #CACHE_DLINESIZE
167 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
168 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
169 add r0, r0, #CACHE_DLINESIZE
174 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
178 * coherent_kern_range(start, end)
180 * Ensure coherency between the Icache and the Dcache in the
181 * region described by start, end. If you have non-snooping
182 * Harvard caches, you need to implement this function.
184 * - start - virtual start address
185 * - end - virtual end address
187 ENTRY(arm926_coherent_kern_range)
191 * coherent_user_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_user_range)
201 bic r0, r0, #CACHE_DLINESIZE - 1
202 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
203 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
204 add r0, r0, #CACHE_DLINESIZE
207 mcr p15, 0, r0, c7, c10, 4 @ drain WB
211 * flush_kern_dcache_page(void *page)
213 * Ensure no D cache aliasing occurs, either with itself or
216 * - addr - page aligned address
218 ENTRY(arm926_flush_kern_dcache_page)
220 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
221 add r0, r0, #CACHE_DLINESIZE
225 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
226 mcr p15, 0, r0, c7, c10, 4 @ drain WB
230 * dma_inv_range(start, end)
232 * Invalidate (discard) the specified virtual address range.
233 * May not write back any entries. If 'start' or 'end'
234 * are not cache line aligned, those lines must be written
237 * - start - virtual start address
238 * - end - virtual end address
242 ENTRY(arm926_dma_inv_range)
243 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
244 tst r0, #CACHE_DLINESIZE - 1
245 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
246 tst r1, #CACHE_DLINESIZE - 1
247 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
249 bic r0, r0, #CACHE_DLINESIZE - 1
250 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
251 add r0, r0, #CACHE_DLINESIZE
254 mcr p15, 0, r0, c7, c10, 4 @ drain WB
258 * dma_clean_range(start, end)
260 * Clean the specified virtual address range.
262 * - start - virtual start address
263 * - end - virtual end address
267 ENTRY(arm926_dma_clean_range)
268 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
269 bic r0, r0, #CACHE_DLINESIZE - 1
270 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
271 add r0, r0, #CACHE_DLINESIZE
275 mcr p15, 0, r0, c7, c10, 4 @ drain WB
279 * dma_flush_range(start, end)
281 * Clean and invalidate the specified virtual address range.
283 * - start - virtual start address
284 * - end - virtual end address
286 ENTRY(arm926_dma_flush_range)
287 bic r0, r0, #CACHE_DLINESIZE - 1
289 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
290 mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
292 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
294 add r0, r0, #CACHE_DLINESIZE
297 mcr p15, 0, r0, c7, c10, 4 @ drain WB
300 ENTRY(arm926_cache_fns)
301 .long arm926_flush_kern_cache_all
302 .long arm926_flush_user_cache_all
303 .long arm926_flush_user_cache_range
304 .long arm926_coherent_kern_range
305 .long arm926_coherent_user_range
306 .long arm926_flush_kern_dcache_page
307 .long arm926_dma_inv_range
308 .long arm926_dma_clean_range
309 .long arm926_dma_flush_range
311 ENTRY(cpu_arm926_dcache_clean_area)
312 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
313 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
314 add r0, r0, #CACHE_DLINESIZE
315 subs r1, r1, #CACHE_DLINESIZE
318 mcr p15, 0, r0, c7, c10, 4 @ drain WB
321 /* =============================== PageTable ============================== */
324 * cpu_arm926_switch_mm(pgd)
326 * Set the translation base pointer to be as described by pgd.
328 * pgd: new page tables
331 ENTRY(cpu_arm926_switch_mm)
333 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
334 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
336 @ && 'Clean & Invalidate whole DCache'
337 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
340 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
341 mcr p15, 0, ip, c7, c10, 4 @ drain WB
342 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
343 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
347 * cpu_arm926_set_pte(ptep, pte)
349 * Set a PTE and flush it out
352 ENTRY(cpu_arm926_set_pte)
353 str r1, [r0], #-2048 @ linux version
355 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
357 bic r2, r1, #PTE_SMALL_AP_MASK
358 bic r2, r2, #PTE_TYPE_MASK
359 orr r2, r2, #PTE_TYPE_SMALL
361 tst r1, #L_PTE_USER @ User?
362 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
364 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
365 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
367 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
370 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
371 eor r3, r2, #0x0a @ C & small page?
375 str r2, [r0] @ hardware version
377 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
378 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
380 mcr p15, 0, r0, c7, c10, 4 @ drain WB
385 .type __arm926_setup, #function
388 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
389 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
390 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
393 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
394 mov r0, #4 @ disable write-back on caches explicitly
395 mcr p15, 7, r0, c15, c0, 0
398 mrc p15, 0, r0, c1, c0 @ get control register v4
399 ldr r5, arm926_cr1_clear
401 ldr r5, arm926_cr1_set
403 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
404 orr r0, r0, #0x4000 @ .1.. .... .... ....
407 .size __arm926_setup, . - __arm926_setup
411 * .RVI ZFRS BLDP WCAM
412 * .011 0001 ..11 0101
415 .type arm926_cr1_clear, #object
416 .type arm926_cr1_set, #object
425 * Purpose : Function pointers used to access above functions - all calls
428 .type arm926_processor_functions, #object
429 arm926_processor_functions:
430 .word v5tj_early_abort
431 .word cpu_arm926_proc_init
432 .word cpu_arm926_proc_fin
433 .word cpu_arm926_reset
434 .word cpu_arm926_do_idle
435 .word cpu_arm926_dcache_clean_area
436 .word cpu_arm926_switch_mm
437 .word cpu_arm926_set_pte
438 .size arm926_processor_functions, . - arm926_processor_functions
442 .type cpu_arch_name, #object
445 .size cpu_arch_name, . - cpu_arch_name
447 .type cpu_elf_name, #object
450 .size cpu_elf_name, . - cpu_elf_name
452 .type cpu_arm926_name, #object
455 #ifndef CONFIG_CPU_ICACHE_DISABLE
458 #ifndef CONFIG_CPU_DCACHE_DISABLE
460 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
465 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
470 .size cpu_arm926_name, . - cpu_arm926_name
474 .section ".proc.info.init", #alloc, #execinstr
476 .type __arm926_proc_info,#object
478 .long 0x41069260 @ ARM926EJ-S (v5TEJ)
480 .long PMD_TYPE_SECT | \
481 PMD_SECT_BUFFERABLE | \
482 PMD_SECT_CACHEABLE | \
484 PMD_SECT_AP_WRITE | \
489 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
490 .long cpu_arm926_name
491 .long arm926_processor_functions
494 .long arm926_cache_fns
495 .size __arm926_proc_info, . - __arm926_proc_info