2 * linux/arch/arm/mm/proc-arm1022.S: MMU functions for ARM1022E
4 * Copyright (C) 2000 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.
14 * These are the low level assembler for performing cache and TLB
15 * functions on the ARM1022E.
17 #include <linux/linkage.h>
18 #include <linux/config.h>
19 #include <linux/init.h>
20 #include <asm/assembler.h>
21 #include <asm/asm-offsets.h>
22 #include <asm/pgtable-hwdef.h>
23 #include <asm/pgtable.h>
24 #include <asm/procinfo.h>
25 #include <asm/ptrace.h>
28 * This is the maximum size of an area which will be invalidated
29 * using the single invalidate entry instructions. Anything larger
30 * than this, and we go for the whole cache.
32 * This value should be chosen such that we choose the cheapest
35 #define MAX_AREA_SIZE 32768
38 * The size of one data cache line.
40 #define CACHE_DLINESIZE 32
43 * The number of data cache segments.
45 #define CACHE_DSEGMENTS 16
48 * The number of lines in a cache segment.
50 #define CACHE_DENTRIES 64
53 * This is the size at which it becomes more efficient to
54 * clean the whole cache, rather than using the individual
55 * cache line maintainence instructions.
57 #define CACHE_DLIMIT 32768
61 * cpu_arm1022_proc_init()
63 ENTRY(cpu_arm1022_proc_init)
67 * cpu_arm1022_proc_fin()
69 ENTRY(cpu_arm1022_proc_fin)
71 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
73 bl arm1022_flush_kern_cache_all
74 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
75 bic r0, r0, #0x1000 @ ...i............
76 bic r0, r0, #0x000e @ ............wca.
77 mcr p15, 0, r0, c1, c0, 0 @ disable caches
81 * cpu_arm1022_reset(loc)
83 * Perform a soft reset of the system. Put the CPU into the
84 * same state as it would be if it had been reset, and branch
85 * to what would be the reset vector.
87 * loc: location to jump to for soft reset
90 ENTRY(cpu_arm1022_reset)
92 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
93 mcr p15, 0, ip, c7, c10, 4 @ drain WB
95 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
97 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
98 bic ip, ip, #0x000f @ ............wcam
99 bic ip, ip, #0x1100 @ ...i...s........
100 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
104 * cpu_arm1022_do_idle()
107 ENTRY(cpu_arm1022_do_idle)
108 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
111 /* ================================= CACHE ================================ */
115 * flush_user_cache_all()
117 * Invalidate all cache entries in a particular address
120 ENTRY(arm1022_flush_user_cache_all)
123 * flush_kern_cache_all()
125 * Clean and invalidate the entire cache.
127 ENTRY(arm1022_flush_kern_cache_all)
131 #ifndef CONFIG_CPU_DCACHE_DISABLE
132 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments
133 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
134 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
135 subs r3, r3, #1 << 26
136 bcs 2b @ entries 63 to 0
138 bcs 1b @ segments 15 to 0
141 #ifndef CONFIG_CPU_ICACHE_DISABLE
142 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
144 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
148 * flush_user_cache_range(start, end, flags)
150 * Invalidate a range of cache entries in the specified
153 * - start - start address (inclusive)
154 * - end - end address (exclusive)
155 * - flags - vm_flags for this space
157 ENTRY(arm1022_flush_user_cache_range)
159 sub r3, r1, r0 @ calculate total size
160 cmp r3, #CACHE_DLIMIT
161 bhs __flush_whole_cache
163 #ifndef CONFIG_CPU_DCACHE_DISABLE
164 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
165 add r0, r0, #CACHE_DLINESIZE
170 #ifndef CONFIG_CPU_ICACHE_DISABLE
171 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
173 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
177 * coherent_kern_range(start, end)
179 * Ensure coherency between the Icache and the Dcache in the
180 * region described by start. If you have non-snooping
181 * Harvard caches, you need to implement this function.
183 * - start - virtual start address
184 * - end - virtual end address
186 ENTRY(arm1022_coherent_kern_range)
190 * coherent_user_range(start, end)
192 * Ensure coherency between the Icache and the Dcache in the
193 * region described by start. If you have non-snooping
194 * Harvard caches, you need to implement this function.
196 * - start - virtual start address
197 * - end - virtual end address
199 ENTRY(arm1022_coherent_user_range)
201 bic r0, r0, #CACHE_DLINESIZE - 1
203 #ifndef CONFIG_CPU_DCACHE_DISABLE
204 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
206 #ifndef CONFIG_CPU_ICACHE_DISABLE
207 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
209 add r0, r0, #CACHE_DLINESIZE
212 mcr p15, 0, ip, c7, c10, 4 @ drain WB
216 * flush_kern_dcache_page(void *page)
218 * Ensure no D cache aliasing occurs, either with itself or
221 * - page - page aligned address
223 ENTRY(arm1022_flush_kern_dcache_page)
225 #ifndef CONFIG_CPU_DCACHE_DISABLE
227 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
228 add r0, r0, #CACHE_DLINESIZE
232 mcr p15, 0, ip, c7, c10, 4 @ drain WB
236 * dma_inv_range(start, end)
238 * Invalidate (discard) the specified virtual address range.
239 * May not write back any entries. If 'start' or 'end'
240 * are not cache line aligned, those lines must be written
243 * - start - virtual start address
244 * - end - virtual end address
248 ENTRY(arm1022_dma_inv_range)
250 #ifndef CONFIG_CPU_DCACHE_DISABLE
251 tst r0, #CACHE_DLINESIZE - 1
252 bic r0, r0, #CACHE_DLINESIZE - 1
253 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
254 tst r1, #CACHE_DLINESIZE - 1
255 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
256 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
257 add r0, r0, #CACHE_DLINESIZE
261 mcr p15, 0, ip, c7, c10, 4 @ drain WB
265 * dma_clean_range(start, end)
267 * Clean the specified virtual address range.
269 * - start - virtual start address
270 * - end - virtual end address
274 ENTRY(arm1022_dma_clean_range)
276 #ifndef CONFIG_CPU_DCACHE_DISABLE
277 bic r0, r0, #CACHE_DLINESIZE - 1
278 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
279 add r0, r0, #CACHE_DLINESIZE
283 mcr p15, 0, ip, c7, c10, 4 @ drain WB
287 * dma_flush_range(start, end)
289 * Clean and invalidate the specified virtual address range.
291 * - start - virtual start address
292 * - end - virtual end address
294 ENTRY(arm1022_dma_flush_range)
296 #ifndef CONFIG_CPU_DCACHE_DISABLE
297 bic r0, r0, #CACHE_DLINESIZE - 1
298 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
299 add r0, r0, #CACHE_DLINESIZE
303 mcr p15, 0, ip, c7, c10, 4 @ drain WB
306 ENTRY(arm1022_cache_fns)
307 .long arm1022_flush_kern_cache_all
308 .long arm1022_flush_user_cache_all
309 .long arm1022_flush_user_cache_range
310 .long arm1022_coherent_kern_range
311 .long arm1022_coherent_user_range
312 .long arm1022_flush_kern_dcache_page
313 .long arm1022_dma_inv_range
314 .long arm1022_dma_clean_range
315 .long arm1022_dma_flush_range
318 ENTRY(cpu_arm1022_dcache_clean_area)
319 #ifndef CONFIG_CPU_DCACHE_DISABLE
321 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
322 add r0, r0, #CACHE_DLINESIZE
323 subs r1, r1, #CACHE_DLINESIZE
328 /* =============================== PageTable ============================== */
331 * cpu_arm1022_switch_mm(pgd)
333 * Set the translation base pointer to be as described by pgd.
335 * pgd: new page tables
338 ENTRY(cpu_arm1022_switch_mm)
340 #ifndef CONFIG_CPU_DCACHE_DISABLE
341 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments
342 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
343 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
344 subs r3, r3, #1 << 26
345 bcs 2b @ entries 63 to 0
347 bcs 1b @ segments 15 to 0
350 #ifndef CONFIG_CPU_ICACHE_DISABLE
351 mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
353 mcr p15, 0, r1, c7, c10, 4 @ drain WB
354 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
355 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
360 * cpu_arm1022_set_pte(ptep, pte)
362 * Set a PTE and flush it out
365 ENTRY(cpu_arm1022_set_pte)
367 str r1, [r0], #-2048 @ linux version
369 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
371 bic r2, r1, #PTE_SMALL_AP_MASK
372 bic r2, r2, #PTE_TYPE_MASK
373 orr r2, r2, #PTE_TYPE_SMALL
375 tst r1, #L_PTE_USER @ User?
376 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
378 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
379 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
381 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
384 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
385 eor r3, r1, #0x0a @ C & small page?
389 str r2, [r0] @ hardware version
391 #ifndef CONFIG_CPU_DCACHE_DISABLE
392 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
394 #endif /* CONFIG_MMU */
399 .type __arm1022_setup, #function
402 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
403 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
405 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
407 mrc p15, 0, r0, c1, c0 @ get control register v4
408 ldr r5, arm1022_cr1_clear
410 ldr r5, arm1022_cr1_set
412 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
413 orr r0, r0, #0x4000 @ .R..............
416 .size __arm1022_setup, . - __arm1022_setup
420 * .RVI ZFRS BLDP WCAM
421 * .011 1001 ..11 0101
424 .type arm1022_cr1_clear, #object
425 .type arm1022_cr1_set, #object
434 * Purpose : Function pointers used to access above functions - all calls
437 .type arm1022_processor_functions, #object
438 arm1022_processor_functions:
439 .word v4t_early_abort
440 .word cpu_arm1022_proc_init
441 .word cpu_arm1022_proc_fin
442 .word cpu_arm1022_reset
443 .word cpu_arm1022_do_idle
444 .word cpu_arm1022_dcache_clean_area
445 .word cpu_arm1022_switch_mm
446 .word cpu_arm1022_set_pte
447 .size arm1022_processor_functions, . - arm1022_processor_functions
451 .type cpu_arch_name, #object
454 .size cpu_arch_name, . - cpu_arch_name
456 .type cpu_elf_name, #object
459 .size cpu_elf_name, . - cpu_elf_name
461 .type cpu_arm1022_name, #object
464 #ifndef CONFIG_CPU_ICACHE_DISABLE
467 #ifndef CONFIG_CPU_DCACHE_DISABLE
469 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
475 #ifndef CONFIG_CPU_BPREDICT_DISABLE
478 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
482 .size cpu_arm1022_name, . - cpu_arm1022_name
486 .section ".proc.info.init", #alloc, #execinstr
488 .type __arm1022_proc_info,#object
490 .long 0x4105a220 @ ARM 1022E (v5TE)
492 .long PMD_TYPE_SECT | \
494 PMD_SECT_AP_WRITE | \
499 .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_EDSP
500 .long cpu_arm1022_name
501 .long arm1022_processor_functions
504 .long arm1022_cache_fns
505 .size __arm1022_proc_info, . - __arm1022_proc_info