2 * linux/arch/arm/mm/proc-arm1026.S: MMU functions for ARM1026EJ-S
4 * Copyright (C) 2000 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.
13 * These are the low level assembler for performing cache and TLB
14 * functions on the ARM1026EJ-S.
16 #include <linux/linkage.h>
17 #include <linux/config.h>
18 #include <linux/init.h>
19 #include <asm/assembler.h>
20 #include <asm/asm-offsets.h>
21 #include <asm/pgtable-hwdef.h>
22 #include <asm/pgtable.h>
23 #include <asm/procinfo.h>
24 #include <asm/ptrace.h>
27 * This is the maximum size of an area which will be invalidated
28 * using the single invalidate entry instructions. Anything larger
29 * than this, and we go for the whole cache.
31 * This value should be chosen such that we choose the cheapest
34 #define MAX_AREA_SIZE 32768
37 * The size of one data cache line.
39 #define CACHE_DLINESIZE 32
42 * The number of data cache segments.
44 #define CACHE_DSEGMENTS 16
47 * The number of lines in a cache segment.
49 #define CACHE_DENTRIES 64
52 * This is the size at which it becomes more efficient to
53 * clean the whole cache, rather than using the individual
54 * cache line maintainence instructions.
56 #define CACHE_DLIMIT 32768
60 * cpu_arm1026_proc_init()
62 ENTRY(cpu_arm1026_proc_init)
66 * cpu_arm1026_proc_fin()
68 ENTRY(cpu_arm1026_proc_fin)
70 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
72 bl arm1026_flush_kern_cache_all
73 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
74 bic r0, r0, #0x1000 @ ...i............
75 bic r0, r0, #0x000e @ ............wca.
76 mcr p15, 0, r0, c1, c0, 0 @ disable caches
80 * cpu_arm1026_reset(loc)
82 * Perform a soft reset of the system. Put the CPU into the
83 * same state as it would be if it had been reset, and branch
84 * to what would be the reset vector.
86 * loc: location to jump to for soft reset
89 ENTRY(cpu_arm1026_reset)
91 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
92 mcr p15, 0, ip, c7, c10, 4 @ drain WB
93 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
94 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
95 bic ip, ip, #0x000f @ ............wcam
96 bic ip, ip, #0x1100 @ ...i...s........
97 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
101 * cpu_arm1026_do_idle()
104 ENTRY(cpu_arm1026_do_idle)
105 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
108 /* ================================= CACHE ================================ */
112 * flush_user_cache_all()
114 * Invalidate all cache entries in a particular address
117 ENTRY(arm1026_flush_user_cache_all)
120 * flush_kern_cache_all()
122 * Clean and invalidate the entire cache.
124 ENTRY(arm1026_flush_kern_cache_all)
128 #ifndef CONFIG_CPU_DCACHE_DISABLE
129 1: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate
133 #ifndef CONFIG_CPU_ICACHE_DISABLE
134 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
136 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
140 * flush_user_cache_range(start, end, flags)
142 * Invalidate a range of cache entries in the specified
145 * - start - start address (inclusive)
146 * - end - end address (exclusive)
147 * - flags - vm_flags for this space
149 ENTRY(arm1026_flush_user_cache_range)
151 sub r3, r1, r0 @ calculate total size
152 cmp r3, #CACHE_DLIMIT
153 bhs __flush_whole_cache
155 #ifndef CONFIG_CPU_DCACHE_DISABLE
156 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
157 add r0, r0, #CACHE_DLINESIZE
162 #ifndef CONFIG_CPU_ICACHE_DISABLE
163 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
165 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
169 * coherent_kern_range(start, end)
171 * Ensure coherency between the Icache and the Dcache in the
172 * region described by start. If you have non-snooping
173 * Harvard caches, you need to implement this function.
175 * - start - virtual start address
176 * - end - virtual end address
178 ENTRY(arm1026_coherent_kern_range)
181 * coherent_user_range(start, end)
183 * Ensure coherency between the Icache and the Dcache in the
184 * region described by start. If you have non-snooping
185 * Harvard caches, you need to implement this function.
187 * - start - virtual start address
188 * - end - virtual end address
190 ENTRY(arm1026_coherent_user_range)
192 bic r0, r0, #CACHE_DLINESIZE - 1
194 #ifndef CONFIG_CPU_DCACHE_DISABLE
195 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
197 #ifndef CONFIG_CPU_ICACHE_DISABLE
198 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
200 add r0, r0, #CACHE_DLINESIZE
203 mcr p15, 0, ip, c7, c10, 4 @ drain WB
207 * flush_kern_dcache_page(void *page)
209 * Ensure no D cache aliasing occurs, either with itself or
212 * - page - page aligned address
214 ENTRY(arm1026_flush_kern_dcache_page)
216 #ifndef CONFIG_CPU_DCACHE_DISABLE
218 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
219 add r0, r0, #CACHE_DLINESIZE
223 mcr p15, 0, ip, c7, c10, 4 @ drain WB
227 * dma_inv_range(start, end)
229 * Invalidate (discard) the specified virtual address range.
230 * May not write back any entries. If 'start' or 'end'
231 * are not cache line aligned, those lines must be written
234 * - start - virtual start address
235 * - end - virtual end address
239 ENTRY(arm1026_dma_inv_range)
241 #ifndef CONFIG_CPU_DCACHE_DISABLE
242 tst r0, #CACHE_DLINESIZE - 1
243 bic r0, r0, #CACHE_DLINESIZE - 1
244 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
245 tst r1, #CACHE_DLINESIZE - 1
246 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
247 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
248 add r0, r0, #CACHE_DLINESIZE
252 mcr p15, 0, ip, c7, c10, 4 @ drain WB
256 * dma_clean_range(start, end)
258 * Clean the specified virtual address range.
260 * - start - virtual start address
261 * - end - virtual end address
265 ENTRY(arm1026_dma_clean_range)
267 #ifndef CONFIG_CPU_DCACHE_DISABLE
268 bic r0, r0, #CACHE_DLINESIZE - 1
269 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
270 add r0, r0, #CACHE_DLINESIZE
274 mcr p15, 0, ip, c7, c10, 4 @ drain WB
278 * dma_flush_range(start, end)
280 * Clean and invalidate the specified virtual address range.
282 * - start - virtual start address
283 * - end - virtual end address
285 ENTRY(arm1026_dma_flush_range)
287 #ifndef CONFIG_CPU_DCACHE_DISABLE
288 bic r0, r0, #CACHE_DLINESIZE - 1
289 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
290 add r0, r0, #CACHE_DLINESIZE
294 mcr p15, 0, ip, c7, c10, 4 @ drain WB
297 ENTRY(arm1026_cache_fns)
298 .long arm1026_flush_kern_cache_all
299 .long arm1026_flush_user_cache_all
300 .long arm1026_flush_user_cache_range
301 .long arm1026_coherent_kern_range
302 .long arm1026_coherent_user_range
303 .long arm1026_flush_kern_dcache_page
304 .long arm1026_dma_inv_range
305 .long arm1026_dma_clean_range
306 .long arm1026_dma_flush_range
309 ENTRY(cpu_arm1026_dcache_clean_area)
310 #ifndef CONFIG_CPU_DCACHE_DISABLE
312 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
313 add r0, r0, #CACHE_DLINESIZE
314 subs r1, r1, #CACHE_DLINESIZE
319 /* =============================== PageTable ============================== */
322 * cpu_arm1026_switch_mm(pgd)
324 * Set the translation base pointer to be as described by pgd.
326 * pgd: new page tables
329 ENTRY(cpu_arm1026_switch_mm)
331 #ifndef CONFIG_CPU_DCACHE_DISABLE
332 1: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate
335 #ifndef CONFIG_CPU_ICACHE_DISABLE
336 mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
338 mcr p15, 0, r1, c7, c10, 4 @ drain WB
339 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
340 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
344 * cpu_arm1026_set_pte(ptep, pte)
346 * Set a PTE and flush it out
349 ENTRY(cpu_arm1026_set_pte)
350 str r1, [r0], #-2048 @ linux version
352 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
354 bic r2, r1, #PTE_SMALL_AP_MASK
355 bic r2, r2, #PTE_TYPE_MASK
356 orr r2, r2, #PTE_TYPE_SMALL
358 tst r1, #L_PTE_USER @ User?
359 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
361 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
362 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
364 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
367 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
368 eor r3, r1, #0x0a @ C & small page?
372 str r2, [r0] @ hardware version
374 #ifndef CONFIG_CPU_DCACHE_DISABLE
375 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
382 .type __arm1026_setup, #function
385 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
386 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
387 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
388 mcr p15, 0, r4, c2, c0 @ load page table pointer
389 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
390 mov r0, #4 @ explicitly disable writeback
391 mcr p15, 7, r0, c15, c0, 0
393 mrc p15, 0, r0, c1, c0 @ get control register v4
394 ldr r5, arm1026_cr1_clear
396 ldr r5, arm1026_cr1_set
398 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
399 orr r0, r0, #0x4000 @ .R.. .... .... ....
402 .size __arm1026_setup, . - __arm1026_setup
406 * .RVI ZFRS BLDP WCAM
407 * .011 1001 ..11 0101
410 .type arm1026_cr1_clear, #object
411 .type arm1026_cr1_set, #object
420 * Purpose : Function pointers used to access above functions - all calls
423 .type arm1026_processor_functions, #object
424 arm1026_processor_functions:
425 .word v5t_early_abort
426 .word cpu_arm1026_proc_init
427 .word cpu_arm1026_proc_fin
428 .word cpu_arm1026_reset
429 .word cpu_arm1026_do_idle
430 .word cpu_arm1026_dcache_clean_area
431 .word cpu_arm1026_switch_mm
432 .word cpu_arm1026_set_pte
433 .size arm1026_processor_functions, . - arm1026_processor_functions
437 .type cpu_arch_name, #object
440 .size cpu_arch_name, . - cpu_arch_name
442 .type cpu_elf_name, #object
445 .size cpu_elf_name, . - cpu_elf_name
448 .type cpu_arm1026_name, #object
451 #ifndef CONFIG_CPU_ICACHE_DISABLE
454 #ifndef CONFIG_CPU_DCACHE_DISABLE
456 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
462 #ifndef CONFIG_CPU_BPREDICT_DISABLE
465 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
469 .size cpu_arm1026_name, . - cpu_arm1026_name
473 .section ".proc.info.init", #alloc, #execinstr
475 .type __arm1026_proc_info,#object
477 .long 0x4106a260 @ ARM 1026EJ-S (v5TEJ)
479 .long PMD_TYPE_SECT | \
481 PMD_SECT_AP_WRITE | \
486 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
487 .long cpu_arm1026_name
488 .long arm1026_processor_functions
491 .long arm1026_cache_fns
492 .size __arm1026_proc_info, . - __arm1026_proc_info