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/constants.h>
32 #include <asm/pgtable.h>
33 #include <asm/procinfo.h>
34 #include <asm/ptrace.h>
35 #include <asm/hardware.h>
38 * This is the maximum size of an area which will be invalidated
39 * using the single invalidate entry instructions. Anything larger
40 * than this, and we go for the whole cache.
42 * This value should be chosen such that we choose the cheapest
45 #define MAX_AREA_SIZE 32768
48 * The size of one data cache line.
50 #define CACHE_DLINESIZE 32
53 * The number of data cache segments.
55 #define CACHE_DSEGMENTS 16
58 * The number of lines in a cache segment.
60 #define CACHE_DENTRIES 64
63 * This is the size at which it becomes more efficient to
64 * clean the whole cache, rather than using the individual
65 * cache line maintainence instructions.
67 #define CACHE_DLIMIT 32768
71 * cpu_arm1020e_proc_init()
73 ENTRY(cpu_arm1020e_proc_init)
77 * cpu_arm1020e_proc_fin()
79 ENTRY(cpu_arm1020e_proc_fin)
81 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
83 bl arm1020e_flush_kern_cache_all
84 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
85 bic r0, r0, #0x1000 @ ...i............
86 bic r0, r0, #0x000e @ ............wca.
87 mcr p15, 0, r0, c1, c0, 0 @ disable caches
91 * cpu_arm1020e_reset(loc)
93 * Perform a soft reset of the system. Put the CPU into the
94 * same state as it would be if it had been reset, and branch
95 * to what would be the reset vector.
97 * loc: location to jump to for soft reset
100 ENTRY(cpu_arm1020e_reset)
102 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
103 mcr p15, 0, ip, c7, c10, 4 @ drain WB
104 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
105 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
106 bic ip, ip, #0x000f @ ............wcam
107 bic ip, ip, #0x1100 @ ...i...s........
108 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
112 * cpu_arm1020e_do_idle()
115 ENTRY(cpu_arm1020e_do_idle)
116 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
119 /* ================================= CACHE ================================ */
123 * flush_user_cache_all()
125 * Invalidate all cache entries in a particular address
128 ENTRY(arm1020e_flush_user_cache_all)
131 * flush_kern_cache_all()
133 * Clean and invalidate the entire cache.
135 ENTRY(arm1020e_flush_kern_cache_all)
139 #ifndef CONFIG_CPU_DCACHE_DISABLE
140 mcr p15, 0, ip, c7, c10, 4 @ drain WB
141 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 16 segments
142 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
143 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
144 subs r3, r3, #1 << 26
145 bcs 2b @ entries 63 to 0
147 bcs 1b @ segments 15 to 0
150 #ifndef CONFIG_CPU_ICACHE_DISABLE
151 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
153 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
157 * flush_user_cache_range(start, end, flags)
159 * Invalidate a range of cache entries in the specified
162 * - start - start address (inclusive)
163 * - end - end address (exclusive)
164 * - flags - vm_flags for this space
166 ENTRY(arm1020e_flush_user_cache_range)
168 sub r3, r1, r0 @ calculate total size
169 cmp r3, #CACHE_DLIMIT
170 bhs __flush_whole_cache
172 #ifndef CONFIG_CPU_DCACHE_DISABLE
173 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
174 add r0, r0, #CACHE_DLINESIZE
179 #ifndef CONFIG_CPU_ICACHE_DISABLE
180 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
182 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
186 * coherent_kern_range(start, end)
188 * Ensure coherency between the Icache and the Dcache in the
189 * region described by start. If you have non-snooping
190 * Harvard caches, you need to implement this function.
192 * - start - virtual start address
193 * - end - virtual end address
195 ENTRY(arm1020e_coherent_kern_range)
198 * coherent_user_range(start, end)
200 * Ensure coherency between the Icache and the Dcache in the
201 * region described by start. If you have non-snooping
202 * Harvard caches, you need to implement this function.
204 * - start - virtual start address
205 * - end - virtual end address
207 ENTRY(arm1020e_coherent_user_range)
209 bic r0, r0, #CACHE_DLINESIZE - 1
211 #ifndef CONFIG_CPU_DCACHE_DISABLE
212 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
214 #ifndef CONFIG_CPU_ICACHE_DISABLE
215 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
217 add r0, r0, #CACHE_DLINESIZE
220 mcr p15, 0, ip, c7, c10, 4 @ drain WB
224 * flush_kern_dcache_page(void *page)
226 * Ensure no D cache aliasing occurs, either with itself or
229 * - page - page aligned address
231 ENTRY(arm1020e_flush_kern_dcache_page)
233 #ifndef CONFIG_CPU_DCACHE_DISABLE
235 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
236 add r0, r0, #CACHE_DLINESIZE
240 mcr p15, 0, ip, c7, c10, 4 @ drain WB
244 * dma_inv_range(start, end)
246 * Invalidate (discard) the specified virtual address range.
247 * May not write back any entries. If 'start' or 'end'
248 * are not cache line aligned, those lines must be written
251 * - start - virtual start address
252 * - end - virtual end address
256 ENTRY(arm1020e_dma_inv_range)
258 #ifndef CONFIG_CPU_DCACHE_DISABLE
259 tst r0, #CACHE_DLINESIZE - 1
260 bic r0, r0, #CACHE_DLINESIZE - 1
261 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
262 tst r1, #CACHE_DLINESIZE - 1
263 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
264 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
265 add r0, r0, #CACHE_DLINESIZE
269 mcr p15, 0, ip, c7, c10, 4 @ drain WB
273 * dma_clean_range(start, end)
275 * Clean the specified virtual address range.
277 * - start - virtual start address
278 * - end - virtual end address
282 ENTRY(arm1020e_dma_clean_range)
284 #ifndef CONFIG_CPU_DCACHE_DISABLE
285 bic r0, r0, #CACHE_DLINESIZE - 1
286 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
287 add r0, r0, #CACHE_DLINESIZE
291 mcr p15, 0, ip, c7, c10, 4 @ drain WB
295 * dma_flush_range(start, end)
297 * Clean and invalidate the specified virtual address range.
299 * - start - virtual start address
300 * - end - virtual end address
302 ENTRY(arm1020e_dma_flush_range)
304 #ifndef CONFIG_CPU_DCACHE_DISABLE
305 bic r0, r0, #CACHE_DLINESIZE - 1
306 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
307 add r0, r0, #CACHE_DLINESIZE
311 mcr p15, 0, ip, c7, c10, 4 @ drain WB
314 ENTRY(arm1020e_cache_fns)
315 .long arm1020e_flush_kern_cache_all
316 .long arm1020e_flush_user_cache_all
317 .long arm1020e_flush_user_cache_range
318 .long arm1020e_coherent_kern_range
319 .long arm1020e_coherent_user_range
320 .long arm1020e_flush_kern_dcache_page
321 .long arm1020e_dma_inv_range
322 .long arm1020e_dma_clean_range
323 .long arm1020e_dma_flush_range
326 ENTRY(cpu_arm1020e_dcache_clean_area)
327 #ifndef CONFIG_CPU_DCACHE_DISABLE
329 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
330 add r0, r0, #CACHE_DLINESIZE
331 subs r1, r1, #CACHE_DLINESIZE
336 /* =============================== PageTable ============================== */
339 * cpu_arm1020e_switch_mm(pgd)
341 * Set the translation base pointer to be as described by pgd.
343 * pgd: new page tables
346 ENTRY(cpu_arm1020e_switch_mm)
347 #ifndef CONFIG_CPU_DCACHE_DISABLE
348 mcr p15, 0, r3, c7, c10, 4
349 mov r1, #0xF @ 16 segments
350 1: mov r3, #0x3F @ 64 entries
351 2: mov ip, r3, LSL #26 @ shift up entry
352 orr ip, ip, r1, LSL #5 @ shift in/up index
353 mcr p15, 0, ip, c7, c14, 2 @ Clean & Inval DCache entry
357 bge 2b @ entries 3F to 0
360 bge 1b @ segments 15 to 0
364 #ifndef CONFIG_CPU_ICACHE_DISABLE
365 mcr p15, 0, r1, c7, c5, 0 @ invalidate I cache
367 mcr p15, 0, r1, c7, c10, 4 @ drain WB
368 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
369 mcr p15, 0, r1, c8, c7, 0 @ invalidate I & D TLBs
373 * cpu_arm1020e_set_pte(ptep, pte)
375 * Set a PTE and flush it out
378 ENTRY(cpu_arm1020e_set_pte)
379 str r1, [r0], #-2048 @ linux version
381 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
383 bic r2, r1, #PTE_SMALL_AP_MASK
384 bic r2, r2, #PTE_TYPE_MASK
385 orr r2, r2, #PTE_TYPE_SMALL
387 tst r1, #L_PTE_USER @ User?
388 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
390 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
391 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
393 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
396 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
397 eor r3, r1, #0x0a @ C & small page?
401 str r2, [r0] @ hardware version
403 #ifndef CONFIG_CPU_DCACHE_DISABLE
404 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
410 .type __arm1020e_setup, #function
413 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
414 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
415 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
416 mrc p15, 0, r0, c1, c0 @ get control register v4
417 ldr r5, arm1020e_cr1_clear
419 ldr r5, arm1020e_cr1_set
421 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
422 orr r0, r0, #0x4000 @ .R.. .... .... ....
425 .size __arm1020e_setup, . - __arm1020e_setup
429 * .RVI ZFRS BLDP WCAM
430 * .011 1001 ..11 0101
432 .type arm1020e_cr1_clear, #object
433 .type arm1020e_cr1_set, #object
442 * Purpose : Function pointers used to access above functions - all calls
445 .type arm1020e_processor_functions, #object
446 arm1020e_processor_functions:
447 .word v4t_early_abort
448 .word cpu_arm1020e_proc_init
449 .word cpu_arm1020e_proc_fin
450 .word cpu_arm1020e_reset
451 .word cpu_arm1020e_do_idle
452 .word cpu_arm1020e_dcache_clean_area
453 .word cpu_arm1020e_switch_mm
454 .word cpu_arm1020e_set_pte
455 .size arm1020e_processor_functions, . - arm1020e_processor_functions
459 .type cpu_arch_name, #object
462 .size cpu_arch_name, . - cpu_arch_name
464 .type cpu_elf_name, #object
467 .size cpu_elf_name, . - cpu_elf_name
469 .type cpu_arm1020e_name, #object
472 #ifndef CONFIG_CPU_ICACHE_DISABLE
475 #ifndef CONFIG_CPU_DCACHE_DISABLE
477 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
483 #ifndef CONFIG_CPU_BPREDICT_DISABLE
486 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
490 .size cpu_arm1020e_name, . - cpu_arm1020e_name
494 .section ".proc.info", #alloc, #execinstr
496 .type __arm1020e_proc_info,#object
497 __arm1020e_proc_info:
498 .long 0x4105a200 @ ARM 1020TE (Architecture v5TE)
500 .long PMD_TYPE_SECT | \
502 PMD_SECT_AP_WRITE | \
507 .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB | HWCAP_EDSP
508 .long cpu_arm1020e_name
509 .long arm1020e_processor_functions
512 .long arm1020e_cache_fns
513 .size __arm1020e_proc_info, . - __arm1020e_proc_info