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.
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 ARM1022E.
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_arm1022_proc_init()
62 ENTRY(cpu_arm1022_proc_init)
66 * cpu_arm1022_proc_fin()
68 ENTRY(cpu_arm1022_proc_fin)
70 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
72 bl arm1022_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_arm1022_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_arm1022_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_arm1022_do_idle()
104 ENTRY(cpu_arm1022_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(arm1022_flush_user_cache_all)
120 * flush_kern_cache_all()
122 * Clean and invalidate the entire cache.
124 ENTRY(arm1022_flush_kern_cache_all)
128 #ifndef CONFIG_CPU_DCACHE_DISABLE
129 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments
130 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
131 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
132 subs r3, r3, #1 << 26
133 bcs 2b @ entries 63 to 0
135 bcs 1b @ segments 15 to 0
138 #ifndef CONFIG_CPU_ICACHE_DISABLE
139 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
141 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
145 * flush_user_cache_range(start, end, flags)
147 * Invalidate a range of cache entries in the specified
150 * - start - start address (inclusive)
151 * - end - end address (exclusive)
152 * - flags - vm_flags for this space
154 ENTRY(arm1022_flush_user_cache_range)
156 sub r3, r1, r0 @ calculate total size
157 cmp r3, #CACHE_DLIMIT
158 bhs __flush_whole_cache
160 #ifndef CONFIG_CPU_DCACHE_DISABLE
161 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
162 add r0, r0, #CACHE_DLINESIZE
167 #ifndef CONFIG_CPU_ICACHE_DISABLE
168 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
170 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
174 * coherent_kern_range(start, end)
176 * Ensure coherency between the Icache and the Dcache in the
177 * region described by start. If you have non-snooping
178 * Harvard caches, you need to implement this function.
180 * - start - virtual start address
181 * - end - virtual end address
183 ENTRY(arm1022_coherent_kern_range)
187 * coherent_user_range(start, end)
189 * Ensure coherency between the Icache and the Dcache in the
190 * region described by start. If you have non-snooping
191 * Harvard caches, you need to implement this function.
193 * - start - virtual start address
194 * - end - virtual end address
196 ENTRY(arm1022_coherent_user_range)
198 bic r0, r0, #CACHE_DLINESIZE - 1
200 #ifndef CONFIG_CPU_DCACHE_DISABLE
201 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
203 #ifndef CONFIG_CPU_ICACHE_DISABLE
204 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
206 add r0, r0, #CACHE_DLINESIZE
209 mcr p15, 0, ip, c7, c10, 4 @ drain WB
213 * flush_kern_dcache_page(void *page)
215 * Ensure no D cache aliasing occurs, either with itself or
218 * - page - page aligned address
220 ENTRY(arm1022_flush_kern_dcache_page)
222 #ifndef CONFIG_CPU_DCACHE_DISABLE
224 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
225 add r0, r0, #CACHE_DLINESIZE
229 mcr p15, 0, ip, c7, c10, 4 @ drain WB
233 * dma_inv_range(start, end)
235 * Invalidate (discard) the specified virtual address range.
236 * May not write back any entries. If 'start' or 'end'
237 * are not cache line aligned, those lines must be written
240 * - start - virtual start address
241 * - end - virtual end address
245 ENTRY(arm1022_dma_inv_range)
247 #ifndef CONFIG_CPU_DCACHE_DISABLE
248 tst r0, #CACHE_DLINESIZE - 1
249 bic r0, r0, #CACHE_DLINESIZE - 1
250 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
251 tst r1, #CACHE_DLINESIZE - 1
252 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
253 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
254 add r0, r0, #CACHE_DLINESIZE
258 mcr p15, 0, ip, c7, c10, 4 @ drain WB
262 * dma_clean_range(start, end)
264 * Clean the specified virtual address range.
266 * - start - virtual start address
267 * - end - virtual end address
271 ENTRY(arm1022_dma_clean_range)
273 #ifndef CONFIG_CPU_DCACHE_DISABLE
274 bic r0, r0, #CACHE_DLINESIZE - 1
275 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
276 add r0, r0, #CACHE_DLINESIZE
280 mcr p15, 0, ip, c7, c10, 4 @ drain WB
284 * dma_flush_range(start, end)
286 * Clean and invalidate the specified virtual address range.
288 * - start - virtual start address
289 * - end - virtual end address
291 ENTRY(arm1022_dma_flush_range)
293 #ifndef CONFIG_CPU_DCACHE_DISABLE
294 bic r0, r0, #CACHE_DLINESIZE - 1
295 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
296 add r0, r0, #CACHE_DLINESIZE
300 mcr p15, 0, ip, c7, c10, 4 @ drain WB
303 ENTRY(arm1022_cache_fns)
304 .long arm1022_flush_kern_cache_all
305 .long arm1022_flush_user_cache_all
306 .long arm1022_flush_user_cache_range
307 .long arm1022_coherent_kern_range
308 .long arm1022_coherent_user_range
309 .long arm1022_flush_kern_dcache_page
310 .long arm1022_dma_inv_range
311 .long arm1022_dma_clean_range
312 .long arm1022_dma_flush_range
315 ENTRY(cpu_arm1022_dcache_clean_area)
316 #ifndef CONFIG_CPU_DCACHE_DISABLE
318 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
319 add r0, r0, #CACHE_DLINESIZE
320 subs r1, r1, #CACHE_DLINESIZE
325 /* =============================== PageTable ============================== */
328 * cpu_arm1022_switch_mm(pgd)
330 * Set the translation base pointer to be as described by pgd.
332 * pgd: new page tables
335 ENTRY(cpu_arm1022_switch_mm)
336 #ifndef CONFIG_CPU_DCACHE_DISABLE
337 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments
338 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
339 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
340 subs r3, r3, #1 << 26
341 bcs 2b @ entries 63 to 0
343 bcs 1b @ segments 15 to 0
346 #ifndef CONFIG_CPU_ICACHE_DISABLE
347 mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
349 mcr p15, 0, r1, c7, c10, 4 @ drain WB
350 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
351 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
355 * cpu_arm1022_set_pte(ptep, pte)
357 * Set a PTE and flush it out
360 ENTRY(cpu_arm1022_set_pte)
361 str r1, [r0], #-2048 @ linux version
363 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
365 bic r2, r1, #PTE_SMALL_AP_MASK
366 bic r2, r2, #PTE_TYPE_MASK
367 orr r2, r2, #PTE_TYPE_SMALL
369 tst r1, #L_PTE_USER @ User?
370 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
372 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
373 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
375 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
378 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
379 eor r3, r1, #0x0a @ C & small page?
383 str r2, [r0] @ hardware version
385 #ifndef CONFIG_CPU_DCACHE_DISABLE
386 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
392 .type __arm1022_setup, #function
395 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
396 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
397 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
398 mrc p15, 0, r0, c1, c0 @ get control register v4
399 ldr r5, arm1022_cr1_clear
401 ldr r5, arm1022_cr1_set
403 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
404 orr r0, r0, #0x4000 @ .R..............
407 .size __arm1022_setup, . - __arm1022_setup
411 * .RVI ZFRS BLDP WCAM
412 * .011 1001 ..11 0101
415 .type arm1022_cr1_clear, #object
416 .type arm1022_cr1_set, #object
425 * Purpose : Function pointers used to access above functions - all calls
428 .type arm1022_processor_functions, #object
429 arm1022_processor_functions:
430 .word v4t_early_abort
431 .word cpu_arm1022_proc_init
432 .word cpu_arm1022_proc_fin
433 .word cpu_arm1022_reset
434 .word cpu_arm1022_do_idle
435 .word cpu_arm1022_dcache_clean_area
436 .word cpu_arm1022_switch_mm
437 .word cpu_arm1022_set_pte
438 .size arm1022_processor_functions, . - arm1022_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_arm1022_name, #object
455 #ifndef CONFIG_CPU_ICACHE_DISABLE
458 #ifndef CONFIG_CPU_DCACHE_DISABLE
460 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
466 #ifndef CONFIG_CPU_BPREDICT_DISABLE
469 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
473 .size cpu_arm1022_name, . - cpu_arm1022_name
477 .section ".proc.info.init", #alloc, #execinstr
479 .type __arm1022_proc_info,#object
481 .long 0x4105a220 @ ARM 1022E (v5TE)
483 .long PMD_TYPE_SECT | \
485 PMD_SECT_AP_WRITE | \
490 .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_EDSP
491 .long cpu_arm1022_name
492 .long arm1022_processor_functions
495 .long arm1022_cache_fns
496 .size __arm1022_proc_info, . - __arm1022_proc_info