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/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
94 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
96 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
97 bic ip, ip, #0x000f @ ............wcam
98 bic ip, ip, #0x1100 @ ...i...s........
99 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
103 * cpu_arm1022_do_idle()
106 ENTRY(cpu_arm1022_do_idle)
107 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
110 /* ================================= CACHE ================================ */
114 * flush_user_cache_all()
116 * Invalidate all cache entries in a particular address
119 ENTRY(arm1022_flush_user_cache_all)
122 * flush_kern_cache_all()
124 * Clean and invalidate the entire cache.
126 ENTRY(arm1022_flush_kern_cache_all)
130 #ifndef CONFIG_CPU_DCACHE_DISABLE
131 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments
132 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
133 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
134 subs r3, r3, #1 << 26
135 bcs 2b @ entries 63 to 0
137 bcs 1b @ segments 15 to 0
140 #ifndef CONFIG_CPU_ICACHE_DISABLE
141 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
143 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
147 * flush_user_cache_range(start, end, flags)
149 * Invalidate a range of cache entries in the specified
152 * - start - start address (inclusive)
153 * - end - end address (exclusive)
154 * - flags - vm_flags for this space
156 ENTRY(arm1022_flush_user_cache_range)
158 sub r3, r1, r0 @ calculate total size
159 cmp r3, #CACHE_DLIMIT
160 bhs __flush_whole_cache
162 #ifndef CONFIG_CPU_DCACHE_DISABLE
163 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
164 add r0, r0, #CACHE_DLINESIZE
169 #ifndef CONFIG_CPU_ICACHE_DISABLE
170 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
172 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
176 * coherent_kern_range(start, end)
178 * Ensure coherency between the Icache and the Dcache in the
179 * region described by start. If you have non-snooping
180 * Harvard caches, you need to implement this function.
182 * - start - virtual start address
183 * - end - virtual end address
185 ENTRY(arm1022_coherent_kern_range)
189 * coherent_user_range(start, end)
191 * Ensure coherency between the Icache and the Dcache in the
192 * region described by start. If you have non-snooping
193 * Harvard caches, you need to implement this function.
195 * - start - virtual start address
196 * - end - virtual end address
198 ENTRY(arm1022_coherent_user_range)
200 bic r0, r0, #CACHE_DLINESIZE - 1
202 #ifndef CONFIG_CPU_DCACHE_DISABLE
203 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
205 #ifndef CONFIG_CPU_ICACHE_DISABLE
206 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
208 add r0, r0, #CACHE_DLINESIZE
211 mcr p15, 0, ip, c7, c10, 4 @ drain WB
215 * flush_kern_dcache_page(void *page)
217 * Ensure no D cache aliasing occurs, either with itself or
220 * - page - page aligned address
222 ENTRY(arm1022_flush_kern_dcache_page)
224 #ifndef CONFIG_CPU_DCACHE_DISABLE
226 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
227 add r0, r0, #CACHE_DLINESIZE
231 mcr p15, 0, ip, c7, c10, 4 @ drain WB
235 * dma_inv_range(start, end)
237 * Invalidate (discard) the specified virtual address range.
238 * May not write back any entries. If 'start' or 'end'
239 * are not cache line aligned, those lines must be written
242 * - start - virtual start address
243 * - end - virtual end address
247 ENTRY(arm1022_dma_inv_range)
249 #ifndef CONFIG_CPU_DCACHE_DISABLE
250 tst r0, #CACHE_DLINESIZE - 1
251 bic r0, r0, #CACHE_DLINESIZE - 1
252 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
253 tst r1, #CACHE_DLINESIZE - 1
254 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
255 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
256 add r0, r0, #CACHE_DLINESIZE
260 mcr p15, 0, ip, c7, c10, 4 @ drain WB
264 * dma_clean_range(start, end)
266 * Clean the specified virtual address range.
268 * - start - virtual start address
269 * - end - virtual end address
273 ENTRY(arm1022_dma_clean_range)
275 #ifndef CONFIG_CPU_DCACHE_DISABLE
276 bic r0, r0, #CACHE_DLINESIZE - 1
277 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
278 add r0, r0, #CACHE_DLINESIZE
282 mcr p15, 0, ip, c7, c10, 4 @ drain WB
286 * dma_flush_range(start, end)
288 * Clean and invalidate the specified virtual address range.
290 * - start - virtual start address
291 * - end - virtual end address
293 ENTRY(arm1022_dma_flush_range)
295 #ifndef CONFIG_CPU_DCACHE_DISABLE
296 bic r0, r0, #CACHE_DLINESIZE - 1
297 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
298 add r0, r0, #CACHE_DLINESIZE
302 mcr p15, 0, ip, c7, c10, 4 @ drain WB
305 ENTRY(arm1022_cache_fns)
306 .long arm1022_flush_kern_cache_all
307 .long arm1022_flush_user_cache_all
308 .long arm1022_flush_user_cache_range
309 .long arm1022_coherent_kern_range
310 .long arm1022_coherent_user_range
311 .long arm1022_flush_kern_dcache_page
312 .long arm1022_dma_inv_range
313 .long arm1022_dma_clean_range
314 .long arm1022_dma_flush_range
317 ENTRY(cpu_arm1022_dcache_clean_area)
318 #ifndef CONFIG_CPU_DCACHE_DISABLE
320 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
321 add r0, r0, #CACHE_DLINESIZE
322 subs r1, r1, #CACHE_DLINESIZE
327 /* =============================== PageTable ============================== */
330 * cpu_arm1022_switch_mm(pgd)
332 * Set the translation base pointer to be as described by pgd.
334 * pgd: new page tables
337 ENTRY(cpu_arm1022_switch_mm)
339 #ifndef CONFIG_CPU_DCACHE_DISABLE
340 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments
341 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
342 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
343 subs r3, r3, #1 << 26
344 bcs 2b @ entries 63 to 0
346 bcs 1b @ segments 15 to 0
349 #ifndef CONFIG_CPU_ICACHE_DISABLE
350 mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
352 mcr p15, 0, r1, c7, c10, 4 @ drain WB
353 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
354 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
359 * cpu_arm1022_set_pte(ptep, pte)
361 * Set a PTE and flush it out
364 ENTRY(cpu_arm1022_set_pte)
366 str r1, [r0], #-2048 @ linux version
368 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
370 bic r2, r1, #PTE_SMALL_AP_MASK
371 bic r2, r2, #PTE_TYPE_MASK
372 orr r2, r2, #PTE_TYPE_SMALL
374 tst r1, #L_PTE_USER @ User?
375 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
377 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
378 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
380 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
383 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
384 eor r3, r1, #0x0a @ C & small page?
388 str r2, [r0] @ hardware version
390 #ifndef CONFIG_CPU_DCACHE_DISABLE
391 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
393 #endif /* CONFIG_MMU */
398 .type __arm1022_setup, #function
401 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
402 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
404 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
406 mrc p15, 0, r0, c1, c0 @ get control register v4
407 ldr r5, arm1022_cr1_clear
409 ldr r5, arm1022_cr1_set
411 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
412 orr r0, r0, #0x4000 @ .R..............
415 .size __arm1022_setup, . - __arm1022_setup
419 * .RVI ZFRS BLDP WCAM
420 * .011 1001 ..11 0101
423 .type arm1022_cr1_clear, #object
424 .type arm1022_cr1_set, #object
433 * Purpose : Function pointers used to access above functions - all calls
436 .type arm1022_processor_functions, #object
437 arm1022_processor_functions:
438 .word v4t_early_abort
439 .word cpu_arm1022_proc_init
440 .word cpu_arm1022_proc_fin
441 .word cpu_arm1022_reset
442 .word cpu_arm1022_do_idle
443 .word cpu_arm1022_dcache_clean_area
444 .word cpu_arm1022_switch_mm
445 .word cpu_arm1022_set_pte
446 .size arm1022_processor_functions, . - arm1022_processor_functions
450 .type cpu_arch_name, #object
453 .size cpu_arch_name, . - cpu_arch_name
455 .type cpu_elf_name, #object
458 .size cpu_elf_name, . - cpu_elf_name
460 .type cpu_arm1022_name, #object
463 #ifndef CONFIG_CPU_ICACHE_DISABLE
466 #ifndef CONFIG_CPU_DCACHE_DISABLE
468 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
474 #ifndef CONFIG_CPU_BPREDICT_DISABLE
477 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
481 .size cpu_arm1022_name, . - cpu_arm1022_name
485 .section ".proc.info.init", #alloc, #execinstr
487 .type __arm1022_proc_info,#object
489 .long 0x4105a220 @ ARM 1022E (v5TE)
491 .long PMD_TYPE_SECT | \
493 PMD_SECT_AP_WRITE | \
498 .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_EDSP
499 .long cpu_arm1022_name
500 .long arm1022_processor_functions
503 .long arm1022_cache_fns
504 .size __arm1022_proc_info, . - __arm1022_proc_info