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.
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 ARM1026EJ-S.
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_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
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_arm1026_do_idle()
106 ENTRY(cpu_arm1026_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(arm1026_flush_user_cache_all)
122 * flush_kern_cache_all()
124 * Clean and invalidate the entire cache.
126 ENTRY(arm1026_flush_kern_cache_all)
130 #ifndef CONFIG_CPU_DCACHE_DISABLE
131 1: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate
135 #ifndef CONFIG_CPU_ICACHE_DISABLE
136 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
138 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
142 * flush_user_cache_range(start, end, flags)
144 * Invalidate a range of cache entries in the specified
147 * - start - start address (inclusive)
148 * - end - end address (exclusive)
149 * - flags - vm_flags for this space
151 ENTRY(arm1026_flush_user_cache_range)
153 sub r3, r1, r0 @ calculate total size
154 cmp r3, #CACHE_DLIMIT
155 bhs __flush_whole_cache
157 #ifndef CONFIG_CPU_DCACHE_DISABLE
158 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
159 add r0, r0, #CACHE_DLINESIZE
164 #ifndef CONFIG_CPU_ICACHE_DISABLE
165 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
167 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
171 * coherent_kern_range(start, end)
173 * Ensure coherency between the Icache and the Dcache in the
174 * region described by start. If you have non-snooping
175 * Harvard caches, you need to implement this function.
177 * - start - virtual start address
178 * - end - virtual end address
180 ENTRY(arm1026_coherent_kern_range)
183 * coherent_user_range(start, end)
185 * Ensure coherency between the Icache and the Dcache in the
186 * region described by start. If you have non-snooping
187 * Harvard caches, you need to implement this function.
189 * - start - virtual start address
190 * - end - virtual end address
192 ENTRY(arm1026_coherent_user_range)
194 bic r0, r0, #CACHE_DLINESIZE - 1
196 #ifndef CONFIG_CPU_DCACHE_DISABLE
197 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
199 #ifndef CONFIG_CPU_ICACHE_DISABLE
200 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
202 add r0, r0, #CACHE_DLINESIZE
205 mcr p15, 0, ip, c7, c10, 4 @ drain WB
209 * flush_kern_dcache_page(void *page)
211 * Ensure no D cache aliasing occurs, either with itself or
214 * - page - page aligned address
216 ENTRY(arm1026_flush_kern_dcache_page)
218 #ifndef CONFIG_CPU_DCACHE_DISABLE
220 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
221 add r0, r0, #CACHE_DLINESIZE
225 mcr p15, 0, ip, c7, c10, 4 @ drain WB
229 * dma_inv_range(start, end)
231 * Invalidate (discard) the specified virtual address range.
232 * May not write back any entries. If 'start' or 'end'
233 * are not cache line aligned, those lines must be written
236 * - start - virtual start address
237 * - end - virtual end address
241 ENTRY(arm1026_dma_inv_range)
243 #ifndef CONFIG_CPU_DCACHE_DISABLE
244 tst r0, #CACHE_DLINESIZE - 1
245 bic r0, r0, #CACHE_DLINESIZE - 1
246 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
247 tst r1, #CACHE_DLINESIZE - 1
248 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
249 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
250 add r0, r0, #CACHE_DLINESIZE
254 mcr p15, 0, ip, c7, c10, 4 @ drain WB
258 * dma_clean_range(start, end)
260 * Clean the specified virtual address range.
262 * - start - virtual start address
263 * - end - virtual end address
267 ENTRY(arm1026_dma_clean_range)
269 #ifndef CONFIG_CPU_DCACHE_DISABLE
270 bic r0, r0, #CACHE_DLINESIZE - 1
271 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
272 add r0, r0, #CACHE_DLINESIZE
276 mcr p15, 0, ip, c7, c10, 4 @ drain WB
280 * dma_flush_range(start, end)
282 * Clean and invalidate the specified virtual address range.
284 * - start - virtual start address
285 * - end - virtual end address
287 ENTRY(arm1026_dma_flush_range)
289 #ifndef CONFIG_CPU_DCACHE_DISABLE
290 bic r0, r0, #CACHE_DLINESIZE - 1
291 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
292 add r0, r0, #CACHE_DLINESIZE
296 mcr p15, 0, ip, c7, c10, 4 @ drain WB
299 ENTRY(arm1026_cache_fns)
300 .long arm1026_flush_kern_cache_all
301 .long arm1026_flush_user_cache_all
302 .long arm1026_flush_user_cache_range
303 .long arm1026_coherent_kern_range
304 .long arm1026_coherent_user_range
305 .long arm1026_flush_kern_dcache_page
306 .long arm1026_dma_inv_range
307 .long arm1026_dma_clean_range
308 .long arm1026_dma_flush_range
311 ENTRY(cpu_arm1026_dcache_clean_area)
312 #ifndef CONFIG_CPU_DCACHE_DISABLE
314 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
315 add r0, r0, #CACHE_DLINESIZE
316 subs r1, r1, #CACHE_DLINESIZE
321 /* =============================== PageTable ============================== */
324 * cpu_arm1026_switch_mm(pgd)
326 * Set the translation base pointer to be as described by pgd.
328 * pgd: new page tables
331 ENTRY(cpu_arm1026_switch_mm)
334 #ifndef CONFIG_CPU_DCACHE_DISABLE
335 1: mrc p15, 0, r15, c7, c14, 3 @ test, clean, invalidate
338 #ifndef CONFIG_CPU_ICACHE_DISABLE
339 mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
341 mcr p15, 0, r1, c7, c10, 4 @ drain WB
342 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
343 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
348 * cpu_arm1026_set_pte(ptep, pte)
350 * Set a PTE and flush it out
353 ENTRY(cpu_arm1026_set_pte)
355 str r1, [r0], #-2048 @ linux version
357 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
359 bic r2, r1, #PTE_SMALL_AP_MASK
360 bic r2, r2, #PTE_TYPE_MASK
361 orr r2, r2, #PTE_TYPE_SMALL
363 tst r1, #L_PTE_USER @ User?
364 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
366 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
367 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
369 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
372 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
373 eor r3, r1, #0x0a @ C & small page?
377 str r2, [r0] @ hardware version
379 #ifndef CONFIG_CPU_DCACHE_DISABLE
380 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
382 #endif /* CONFIG_MMU */
388 .type __arm1026_setup, #function
391 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
392 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
394 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
395 mcr p15, 0, r4, c2, c0 @ load page table pointer
397 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
398 mov r0, #4 @ explicitly disable writeback
399 mcr p15, 7, r0, c15, c0, 0
401 adr r5, arm1026_crval
403 mrc p15, 0, r0, c1, c0 @ get control register v4
406 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
407 orr r0, r0, #0x4000 @ .R.. .... .... ....
410 .size __arm1026_setup, . - __arm1026_setup
414 * .RVI ZFRS BLDP WCAM
415 * .011 1001 ..11 0101
418 .type arm1026_crval, #object
420 crval clear=0x00007f3f, mmuset=0x00003935, ucset=0x00001934
425 * Purpose : Function pointers used to access above functions - all calls
428 .type arm1026_processor_functions, #object
429 arm1026_processor_functions:
430 .word v5t_early_abort
431 .word cpu_arm1026_proc_init
432 .word cpu_arm1026_proc_fin
433 .word cpu_arm1026_reset
434 .word cpu_arm1026_do_idle
435 .word cpu_arm1026_dcache_clean_area
436 .word cpu_arm1026_switch_mm
437 .word cpu_arm1026_set_pte
438 .size arm1026_processor_functions, . - arm1026_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
453 .type cpu_arm1026_name, #object
456 .size cpu_arm1026_name, . - cpu_arm1026_name
460 .section ".proc.info.init", #alloc, #execinstr
462 .type __arm1026_proc_info,#object
464 .long 0x4106a260 @ ARM 1026EJ-S (v5TEJ)
466 .long PMD_TYPE_SECT | \
468 PMD_SECT_AP_WRITE | \
470 .long PMD_TYPE_SECT | \
472 PMD_SECT_AP_WRITE | \
477 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP|HWCAP_JAVA
478 .long cpu_arm1026_name
479 .long arm1026_processor_functions
482 .long arm1026_cache_fns
483 .size __arm1026_proc_info, . - __arm1026_proc_info