2 * linux/arch/arm/mm/proc-arm1020e.S: MMU functions for ARM1020
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.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * These are the low level assembler for performing cache and TLB
23 * functions on the arm1020e.
25 * CONFIG_CPU_ARM1020_CPU_IDLE -> nohlt
27 #include <linux/linkage.h>
28 #include <linux/config.h>
29 #include <linux/init.h>
30 #include <asm/assembler.h>
31 #include <asm/asm-offsets.h>
32 #include <asm/pgtable-hwdef.h>
33 #include <asm/pgtable.h>
34 #include <asm/procinfo.h>
35 #include <asm/ptrace.h>
36 #include <asm/hardware.h>
39 * This is the maximum size of an area which will be invalidated
40 * using the single invalidate entry instructions. Anything larger
41 * than this, and we go for the whole cache.
43 * This value should be chosen such that we choose the cheapest
46 #define MAX_AREA_SIZE 32768
49 * The size of one data cache line.
51 #define CACHE_DLINESIZE 32
54 * The number of data cache segments.
56 #define CACHE_DSEGMENTS 16
59 * The number of lines in a cache segment.
61 #define CACHE_DENTRIES 64
64 * This is the size at which it becomes more efficient to
65 * clean the whole cache, rather than using the individual
66 * cache line maintainence instructions.
68 #define CACHE_DLIMIT 32768
72 * cpu_arm1020e_proc_init()
74 ENTRY(cpu_arm1020e_proc_init)
78 * cpu_arm1020e_proc_fin()
80 ENTRY(cpu_arm1020e_proc_fin)
82 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
84 bl arm1020e_flush_kern_cache_all
85 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
86 bic r0, r0, #0x1000 @ ...i............
87 bic r0, r0, #0x000e @ ............wca.
88 mcr p15, 0, r0, c1, c0, 0 @ disable caches
92 * cpu_arm1020e_reset(loc)
94 * Perform a soft reset of the system. Put the CPU into the
95 * same state as it would be if it had been reset, and branch
96 * to what would be the reset vector.
98 * loc: location to jump to for soft reset
101 ENTRY(cpu_arm1020e_reset)
103 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
104 mcr p15, 0, ip, c7, c10, 4 @ drain WB
105 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
106 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
107 bic ip, ip, #0x000f @ ............wcam
108 bic ip, ip, #0x1100 @ ...i...s........
109 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
113 * cpu_arm1020e_do_idle()
116 ENTRY(cpu_arm1020e_do_idle)
117 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
120 /* ================================= CACHE ================================ */
124 * flush_user_cache_all()
126 * Invalidate all cache entries in a particular address
129 ENTRY(arm1020e_flush_user_cache_all)
132 * flush_kern_cache_all()
134 * Clean and invalidate the entire cache.
136 ENTRY(arm1020e_flush_kern_cache_all)
140 #ifndef CONFIG_CPU_DCACHE_DISABLE
141 mcr p15, 0, ip, c7, c10, 4 @ drain WB
142 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments
143 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
144 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
145 subs r3, r3, #1 << 26
146 bcs 2b @ entries 63 to 0
148 bcs 1b @ segments 15 to 0
151 #ifndef CONFIG_CPU_ICACHE_DISABLE
152 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
154 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
158 * flush_user_cache_range(start, end, flags)
160 * Invalidate a range of cache entries in the specified
163 * - start - start address (inclusive)
164 * - end - end address (exclusive)
165 * - flags - vm_flags for this space
167 ENTRY(arm1020e_flush_user_cache_range)
169 sub r3, r1, r0 @ calculate total size
170 cmp r3, #CACHE_DLIMIT
171 bhs __flush_whole_cache
173 #ifndef CONFIG_CPU_DCACHE_DISABLE
174 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
175 add r0, r0, #CACHE_DLINESIZE
180 #ifndef CONFIG_CPU_ICACHE_DISABLE
181 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
183 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
187 * coherent_kern_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(arm1020e_coherent_kern_range)
199 * coherent_user_range(start, end)
201 * Ensure coherency between the Icache and the Dcache in the
202 * region described by start. If you have non-snooping
203 * Harvard caches, you need to implement this function.
205 * - start - virtual start address
206 * - end - virtual end address
208 ENTRY(arm1020e_coherent_user_range)
210 bic r0, r0, #CACHE_DLINESIZE - 1
212 #ifndef CONFIG_CPU_DCACHE_DISABLE
213 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
215 #ifndef CONFIG_CPU_ICACHE_DISABLE
216 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
218 add r0, r0, #CACHE_DLINESIZE
221 mcr p15, 0, ip, c7, c10, 4 @ drain WB
225 * flush_kern_dcache_page(void *page)
227 * Ensure no D cache aliasing occurs, either with itself or
230 * - page - page aligned address
232 ENTRY(arm1020e_flush_kern_dcache_page)
234 #ifndef CONFIG_CPU_DCACHE_DISABLE
236 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
237 add r0, r0, #CACHE_DLINESIZE
241 mcr p15, 0, ip, c7, c10, 4 @ drain WB
245 * dma_inv_range(start, end)
247 * Invalidate (discard) the specified virtual address range.
248 * May not write back any entries. If 'start' or 'end'
249 * are not cache line aligned, those lines must be written
252 * - start - virtual start address
253 * - end - virtual end address
257 ENTRY(arm1020e_dma_inv_range)
259 #ifndef CONFIG_CPU_DCACHE_DISABLE
260 tst r0, #CACHE_DLINESIZE - 1
261 bic r0, r0, #CACHE_DLINESIZE - 1
262 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
263 tst r1, #CACHE_DLINESIZE - 1
264 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
265 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
266 add r0, r0, #CACHE_DLINESIZE
270 mcr p15, 0, ip, c7, c10, 4 @ drain WB
274 * dma_clean_range(start, end)
276 * Clean the specified virtual address range.
278 * - start - virtual start address
279 * - end - virtual end address
283 ENTRY(arm1020e_dma_clean_range)
285 #ifndef CONFIG_CPU_DCACHE_DISABLE
286 bic r0, r0, #CACHE_DLINESIZE - 1
287 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
288 add r0, r0, #CACHE_DLINESIZE
292 mcr p15, 0, ip, c7, c10, 4 @ drain WB
296 * dma_flush_range(start, end)
298 * Clean and invalidate the specified virtual address range.
300 * - start - virtual start address
301 * - end - virtual end address
303 ENTRY(arm1020e_dma_flush_range)
305 #ifndef CONFIG_CPU_DCACHE_DISABLE
306 bic r0, r0, #CACHE_DLINESIZE - 1
307 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
308 add r0, r0, #CACHE_DLINESIZE
312 mcr p15, 0, ip, c7, c10, 4 @ drain WB
315 ENTRY(arm1020e_cache_fns)
316 .long arm1020e_flush_kern_cache_all
317 .long arm1020e_flush_user_cache_all
318 .long arm1020e_flush_user_cache_range
319 .long arm1020e_coherent_kern_range
320 .long arm1020e_coherent_user_range
321 .long arm1020e_flush_kern_dcache_page
322 .long arm1020e_dma_inv_range
323 .long arm1020e_dma_clean_range
324 .long arm1020e_dma_flush_range
327 ENTRY(cpu_arm1020e_dcache_clean_area)
328 #ifndef CONFIG_CPU_DCACHE_DISABLE
330 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
331 add r0, r0, #CACHE_DLINESIZE
332 subs r1, r1, #CACHE_DLINESIZE
337 /* =============================== PageTable ============================== */
340 * cpu_arm1020e_switch_mm(pgd)
342 * Set the translation base pointer to be as described by pgd.
344 * pgd: new page tables
347 ENTRY(cpu_arm1020e_switch_mm)
348 #ifndef CONFIG_CPU_DCACHE_DISABLE
349 mcr p15, 0, r3, c7, c10, 4
350 mov r1, #0xF @ 16 segments
351 1: mov r3, #0x3F @ 64 entries
352 2: mov ip, r3, LSL #26 @ shift up entry
353 orr ip, ip, r1, LSL #5 @ shift in/up index
354 mcr p15, 0, ip, c7, c14, 2 @ Clean & Inval DCache entry
358 bge 2b @ entries 3F to 0
361 bge 1b @ segments 15 to 0
365 #ifndef CONFIG_CPU_ICACHE_DISABLE
366 mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
368 mcr p15, 0, r1, c7, c10, 4 @ drain WB
369 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
370 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
374 * cpu_arm1020e_set_pte(ptep, pte)
376 * Set a PTE and flush it out
379 ENTRY(cpu_arm1020e_set_pte)
380 str r1, [r0], #-2048 @ linux version
382 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
384 bic r2, r1, #PTE_SMALL_AP_MASK
385 bic r2, r2, #PTE_TYPE_MASK
386 orr r2, r2, #PTE_TYPE_SMALL
388 tst r1, #L_PTE_USER @ User?
389 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
391 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
392 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
394 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
397 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
398 eor r3, r1, #0x0a @ C & small page?
402 str r2, [r0] @ hardware version
404 #ifndef CONFIG_CPU_DCACHE_DISABLE
405 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
411 .type __arm1020e_setup, #function
414 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
415 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
416 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
417 mrc p15, 0, r0, c1, c0 @ get control register v4
418 ldr r5, arm1020e_cr1_clear
420 ldr r5, arm1020e_cr1_set
422 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
423 orr r0, r0, #0x4000 @ .R.. .... .... ....
426 .size __arm1020e_setup, . - __arm1020e_setup
430 * .RVI ZFRS BLDP WCAM
431 * .011 1001 ..11 0101
433 .type arm1020e_cr1_clear, #object
434 .type arm1020e_cr1_set, #object
443 * Purpose : Function pointers used to access above functions - all calls
446 .type arm1020e_processor_functions, #object
447 arm1020e_processor_functions:
448 .word v4t_early_abort
449 .word cpu_arm1020e_proc_init
450 .word cpu_arm1020e_proc_fin
451 .word cpu_arm1020e_reset
452 .word cpu_arm1020e_do_idle
453 .word cpu_arm1020e_dcache_clean_area
454 .word cpu_arm1020e_switch_mm
455 .word cpu_arm1020e_set_pte
456 .size arm1020e_processor_functions, . - arm1020e_processor_functions
460 .type cpu_arch_name, #object
463 .size cpu_arch_name, . - cpu_arch_name
465 .type cpu_elf_name, #object
468 .size cpu_elf_name, . - cpu_elf_name
470 .type cpu_arm1020e_name, #object
473 #ifndef CONFIG_CPU_ICACHE_DISABLE
476 #ifndef CONFIG_CPU_DCACHE_DISABLE
478 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
484 #ifndef CONFIG_CPU_BPREDICT_DISABLE
487 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
491 .size cpu_arm1020e_name, . - cpu_arm1020e_name
495 .section ".proc.info.init", #alloc, #execinstr
497 .type __arm1020e_proc_info,#object
498 __arm1020e_proc_info:
499 .long 0x4105a200 @ ARM 1020TE (Architecture v5TE)
501 .long PMD_TYPE_SECT | \
503 PMD_SECT_AP_WRITE | \
508 .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_EDSP
509 .long cpu_arm1020e_name
510 .long arm1020e_processor_functions
513 .long arm1020e_cache_fns
514 .size __arm1020e_proc_info, . - __arm1020e_proc_info