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.h>
22 #include <asm/procinfo.h>
23 #include <asm/ptrace.h>
26 * This is the maximum size of an area which will be invalidated
27 * using the single invalidate entry instructions. Anything larger
28 * than this, and we go for the whole cache.
30 * This value should be chosen such that we choose the cheapest
33 #define MAX_AREA_SIZE 32768
36 * The size of one data cache line.
38 #define CACHE_DLINESIZE 32
41 * The number of data cache segments.
43 #define CACHE_DSEGMENTS 16
46 * The number of lines in a cache segment.
48 #define CACHE_DENTRIES 64
51 * This is the size at which it becomes more efficient to
52 * clean the whole cache, rather than using the individual
53 * cache line maintainence instructions.
55 #define CACHE_DLIMIT 32768
59 * cpu_arm1026_proc_init()
61 ENTRY(cpu_arm1026_proc_init)
65 * cpu_arm1026_proc_fin()
67 ENTRY(cpu_arm1026_proc_fin)
69 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
71 bl arm1026_flush_kern_cache_all
72 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
73 bic r0, r0, #0x1000 @ ...i............
74 bic r0, r0, #0x000e @ ............wca.
75 mcr p15, 0, r0, c1, c0, 0 @ disable caches
79 * cpu_arm1026_reset(loc)
81 * Perform a soft reset of the system. Put the CPU into the
82 * same state as it would be if it had been reset, and branch
83 * to what would be the reset vector.
85 * loc: location to jump to for soft reset
88 ENTRY(cpu_arm1026_reset)
90 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
91 mcr p15, 0, ip, c7, c10, 4 @ drain WB
92 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
93 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
94 bic ip, ip, #0x000f @ ............wcam
95 bic ip, ip, #0x1100 @ ...i...s........
96 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
100 * cpu_arm1026_do_idle()
103 ENTRY(cpu_arm1026_do_idle)
104 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
107 /* ================================= CACHE ================================ */
111 * flush_user_cache_all()
113 * Invalidate all cache entries in a particular address
116 ENTRY(arm1026_flush_user_cache_all)
119 * flush_kern_cache_all()
121 * Clean and invalidate the entire cache.
123 ENTRY(arm1026_flush_kern_cache_all)
127 #ifndef CONFIG_CPU_DCACHE_DISABLE
128 1: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate
132 #ifndef CONFIG_CPU_ICACHE_DISABLE
133 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
135 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
139 * flush_user_cache_range(start, end, flags)
141 * Invalidate a range of cache entries in the specified
144 * - start - start address (inclusive)
145 * - end - end address (exclusive)
146 * - flags - vm_flags for this space
148 ENTRY(arm1026_flush_user_cache_range)
150 sub r3, r1, r0 @ calculate total size
151 cmp r3, #CACHE_DLIMIT
152 bhs __flush_whole_cache
154 #ifndef CONFIG_CPU_DCACHE_DISABLE
155 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
156 add r0, r0, #CACHE_DLINESIZE
161 #ifndef CONFIG_CPU_ICACHE_DISABLE
162 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
164 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
168 * coherent_kern_range(start, end)
170 * Ensure coherency between the Icache and the Dcache in the
171 * region described by start. If you have non-snooping
172 * Harvard caches, you need to implement this function.
174 * - start - virtual start address
175 * - end - virtual end address
177 ENTRY(arm1026_coherent_kern_range)
180 * coherent_user_range(start, end)
182 * Ensure coherency between the Icache and the Dcache in the
183 * region described by start. If you have non-snooping
184 * Harvard caches, you need to implement this function.
186 * - start - virtual start address
187 * - end - virtual end address
189 ENTRY(arm1026_coherent_user_range)
191 bic r0, r0, #CACHE_DLINESIZE - 1
193 #ifndef CONFIG_CPU_DCACHE_DISABLE
194 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
196 #ifndef CONFIG_CPU_ICACHE_DISABLE
197 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
199 add r0, r0, #CACHE_DLINESIZE
202 mcr p15, 0, ip, c7, c10, 4 @ drain WB
206 * flush_kern_dcache_page(void *page)
208 * Ensure no D cache aliasing occurs, either with itself or
211 * - page - page aligned address
213 ENTRY(arm1026_flush_kern_dcache_page)
215 #ifndef CONFIG_CPU_DCACHE_DISABLE
217 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
218 add r0, r0, #CACHE_DLINESIZE
222 mcr p15, 0, ip, c7, c10, 4 @ drain WB
226 * dma_inv_range(start, end)
228 * Invalidate (discard) the specified virtual address range.
229 * May not write back any entries. If 'start' or 'end'
230 * are not cache line aligned, those lines must be written
233 * - start - virtual start address
234 * - end - virtual end address
238 ENTRY(arm1026_dma_inv_range)
240 #ifndef CONFIG_CPU_DCACHE_DISABLE
241 tst r0, #CACHE_DLINESIZE - 1
242 bic r0, r0, #CACHE_DLINESIZE - 1
243 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
244 tst r1, #CACHE_DLINESIZE - 1
245 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
246 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
247 add r0, r0, #CACHE_DLINESIZE
251 mcr p15, 0, ip, c7, c10, 4 @ drain WB
255 * dma_clean_range(start, end)
257 * Clean the specified virtual address range.
259 * - start - virtual start address
260 * - end - virtual end address
264 ENTRY(arm1026_dma_clean_range)
266 #ifndef CONFIG_CPU_DCACHE_DISABLE
267 bic r0, r0, #CACHE_DLINESIZE - 1
268 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
269 add r0, r0, #CACHE_DLINESIZE
273 mcr p15, 0, ip, c7, c10, 4 @ drain WB
277 * dma_flush_range(start, end)
279 * Clean and invalidate the specified virtual address range.
281 * - start - virtual start address
282 * - end - virtual end address
284 ENTRY(arm1026_dma_flush_range)
286 #ifndef CONFIG_CPU_DCACHE_DISABLE
287 bic r0, r0, #CACHE_DLINESIZE - 1
288 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
289 add r0, r0, #CACHE_DLINESIZE
293 mcr p15, 0, ip, c7, c10, 4 @ drain WB
296 ENTRY(arm1026_cache_fns)
297 .long arm1026_flush_kern_cache_all
298 .long arm1026_flush_user_cache_all
299 .long arm1026_flush_user_cache_range
300 .long arm1026_coherent_kern_range
301 .long arm1026_coherent_user_range
302 .long arm1026_flush_kern_dcache_page
303 .long arm1026_dma_inv_range
304 .long arm1026_dma_clean_range
305 .long arm1026_dma_flush_range
308 ENTRY(cpu_arm1026_dcache_clean_area)
309 #ifndef CONFIG_CPU_DCACHE_DISABLE
311 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
312 add r0, r0, #CACHE_DLINESIZE
313 subs r1, r1, #CACHE_DLINESIZE
318 /* =============================== PageTable ============================== */
321 * cpu_arm1026_switch_mm(pgd)
323 * Set the translation base pointer to be as described by pgd.
325 * pgd: new page tables
328 ENTRY(cpu_arm1026_switch_mm)
330 #ifndef CONFIG_CPU_DCACHE_DISABLE
331 1: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate
334 #ifndef CONFIG_CPU_ICACHE_DISABLE
335 mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
337 mcr p15, 0, r1, c7, c10, 4 @ drain WB
338 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
339 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
343 * cpu_arm1026_set_pte(ptep, pte)
345 * Set a PTE and flush it out
348 ENTRY(cpu_arm1026_set_pte)
349 str r1, [r0], #-2048 @ linux version
351 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
353 bic r2, r1, #PTE_SMALL_AP_MASK
354 bic r2, r2, #PTE_TYPE_MASK
355 orr r2, r2, #PTE_TYPE_SMALL
357 tst r1, #L_PTE_USER @ User?
358 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
360 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
361 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
363 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
366 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
367 eor r3, r1, #0x0a @ C & small page?
371 str r2, [r0] @ hardware version
373 #ifndef CONFIG_CPU_DCACHE_DISABLE
374 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
381 .type __arm1026_setup, #function
384 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
385 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
386 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
387 mcr p15, 0, r4, c2, c0 @ load page table pointer
388 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
389 mov r0, #4 @ explicitly disable writeback
390 mcr p15, 7, r0, c15, c0, 0
392 mrc p15, 0, r0, c1, c0 @ get control register v4
393 ldr r5, arm1026_cr1_clear
395 ldr r5, arm1026_cr1_set
397 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
398 orr r0, r0, #0x4000 @ .R.. .... .... ....
401 .size __arm1026_setup, . - __arm1026_setup
405 * .RVI ZFRS BLDP WCAM
406 * .011 1001 ..11 0101
409 .type arm1026_cr1_clear, #object
410 .type arm1026_cr1_set, #object
419 * Purpose : Function pointers used to access above functions - all calls
422 .type arm1026_processor_functions, #object
423 arm1026_processor_functions:
424 .word v5t_early_abort
425 .word cpu_arm1026_proc_init
426 .word cpu_arm1026_proc_fin
427 .word cpu_arm1026_reset
428 .word cpu_arm1026_do_idle
429 .word cpu_arm1026_dcache_clean_area
430 .word cpu_arm1026_switch_mm
431 .word cpu_arm1026_set_pte
432 .size arm1026_processor_functions, . - arm1026_processor_functions
436 .type cpu_arch_name, #object
439 .size cpu_arch_name, . - cpu_arch_name
441 .type cpu_elf_name, #object
444 .size cpu_elf_name, . - cpu_elf_name
447 .type cpu_arm1026_name, #object
450 #ifndef CONFIG_CPU_ICACHE_DISABLE
453 #ifndef CONFIG_CPU_DCACHE_DISABLE
455 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
461 #ifndef CONFIG_CPU_BPREDICT_DISABLE
464 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
468 .size cpu_arm1026_name, . - cpu_arm1026_name
472 .section ".proc.info.init", #alloc, #execinstr
474 .type __arm1026_proc_info,#object
476 .long 0x4106a260 @ ARM 1026EJ-S (v5TEJ)
478 .long PMD_TYPE_SECT | \
480 PMD_SECT_AP_WRITE | \
485 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
486 .long cpu_arm1026_name
487 .long arm1026_processor_functions
490 .long arm1026_cache_fns
491 .size __arm1026_proc_info, . - __arm1026_proc_info