2 * linux/arch/arm/mm/proc-arm920.S: MMU functions for ARM920
4 * Copyright (C) 1999,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 arm920.
25 * CONFIG_CPU_ARM920_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/pgtable.h>
32 #include <asm/procinfo.h>
34 #include <asm/ptrace.h>
35 #include "proc-macros.S"
38 * The size of one data cache line.
40 #define CACHE_DLINESIZE 32
43 * The number of data cache segments.
45 #define CACHE_DSEGMENTS 8
48 * The number of lines in a cache segment.
50 #define CACHE_DENTRIES 64
53 * This is the size at which it becomes more efficient to
54 * clean the whole cache, rather than using the individual
55 * cache line maintainence instructions.
57 #define CACHE_DLIMIT 65536
62 * cpu_arm920_proc_init()
64 ENTRY(cpu_arm920_proc_init)
68 * cpu_arm920_proc_fin()
70 ENTRY(cpu_arm920_proc_fin)
72 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
74 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
75 bl arm920_flush_kern_cache_all
77 bl v4wt_flush_kern_cache_all
79 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
80 bic r0, r0, #0x1000 @ ...i............
81 bic r0, r0, #0x000e @ ............wca.
82 mcr p15, 0, r0, c1, c0, 0 @ disable caches
86 * cpu_arm920_reset(loc)
88 * Perform a soft reset of the system. Put the CPU into the
89 * same state as it would be if it had been reset, and branch
90 * to what would be the reset vector.
92 * loc: location to jump to for soft reset
95 ENTRY(cpu_arm920_reset)
97 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
98 mcr p15, 0, ip, c7, c10, 4 @ drain WB
99 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
100 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
101 bic ip, ip, #0x000f @ ............wcam
102 bic ip, ip, #0x1100 @ ...i...s........
103 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
107 * cpu_arm920_do_idle()
110 ENTRY(cpu_arm920_do_idle)
111 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
115 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
118 * flush_user_cache_all()
120 * Invalidate all cache entries in a particular address
123 ENTRY(arm920_flush_user_cache_all)
127 * flush_kern_cache_all()
129 * Clean and invalidate the entire cache.
131 ENTRY(arm920_flush_kern_cache_all)
135 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 8 segments
136 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
137 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index
138 subs r3, r3, #1 << 26
139 bcs 2b @ entries 63 to 0
141 bcs 1b @ segments 7 to 0
143 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
144 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
148 * flush_user_cache_range(start, end, flags)
150 * Invalidate a range of cache entries in the specified
153 * - start - start address (inclusive)
154 * - end - end address (exclusive)
155 * - flags - vm_flags for address space
157 ENTRY(arm920_flush_user_cache_range)
159 sub r3, r1, r0 @ calculate total size
160 cmp r3, #CACHE_DLIMIT
161 bhs __flush_whole_cache
163 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
165 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
166 add r0, r0, #CACHE_DLINESIZE
170 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
174 * coherent_kern_range(start, end)
176 * Ensure coherency between the Icache and the Dcache in the
177 * region described by start, end. If you have non-snooping
178 * Harvard caches, you need to implement this function.
180 * - start - virtual start address
181 * - end - virtual end address
183 ENTRY(arm920_coherent_kern_range)
187 * coherent_user_range(start, end)
189 * Ensure coherency between the Icache and the Dcache in the
190 * region described by start, end. 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(arm920_coherent_user_range)
197 bic r0, r0, #CACHE_DLINESIZE - 1
198 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
199 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
200 add r0, r0, #CACHE_DLINESIZE
203 mcr p15, 0, r0, c7, c10, 4 @ drain WB
207 * flush_kern_dcache_page(void *page)
209 * Ensure no D cache aliasing occurs, either with itself or
212 * - addr - page aligned address
214 ENTRY(arm920_flush_kern_dcache_page)
216 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
217 add r0, r0, #CACHE_DLINESIZE
221 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
222 mcr p15, 0, r0, 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(arm920_dma_inv_range)
239 tst r0, #CACHE_DLINESIZE - 1
240 bic r0, r0, #CACHE_DLINESIZE - 1
241 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
242 tst r1, #CACHE_DLINESIZE - 1
243 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
244 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
245 add r0, r0, #CACHE_DLINESIZE
248 mcr p15, 0, r0, c7, c10, 4 @ drain WB
252 * dma_clean_range(start, end)
254 * Clean the specified virtual address range.
256 * - start - virtual start address
257 * - end - virtual end address
261 ENTRY(arm920_dma_clean_range)
262 bic r0, r0, #CACHE_DLINESIZE - 1
263 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
264 add r0, r0, #CACHE_DLINESIZE
267 mcr p15, 0, r0, c7, c10, 4 @ drain WB
271 * dma_flush_range(start, end)
273 * Clean and invalidate the specified virtual address range.
275 * - start - virtual start address
276 * - end - virtual end address
278 ENTRY(arm920_dma_flush_range)
279 bic r0, r0, #CACHE_DLINESIZE - 1
280 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
281 add r0, r0, #CACHE_DLINESIZE
284 mcr p15, 0, r0, c7, c10, 4 @ drain WB
287 ENTRY(arm920_cache_fns)
288 .long arm920_flush_kern_cache_all
289 .long arm920_flush_user_cache_all
290 .long arm920_flush_user_cache_range
291 .long arm920_coherent_kern_range
292 .long arm920_coherent_user_range
293 .long arm920_flush_kern_dcache_page
294 .long arm920_dma_inv_range
295 .long arm920_dma_clean_range
296 .long arm920_dma_flush_range
301 ENTRY(cpu_arm920_dcache_clean_area)
302 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
303 add r0, r0, #CACHE_DLINESIZE
304 subs r1, r1, #CACHE_DLINESIZE
308 /* =============================== PageTable ============================== */
311 * cpu_arm920_switch_mm(pgd)
313 * Set the translation base pointer to be as described by pgd.
315 * pgd: new page tables
318 ENTRY(cpu_arm920_switch_mm)
320 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
321 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
323 @ && 'Clean & Invalidate whole DCache'
324 @ && Re-written to use Index Ops.
325 @ && Uses registers r1, r3 and ip
327 mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 8 segments
328 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries
329 2: mcr p15, 0, r3, c7, c14, 2 @ clean & invalidate D index
330 subs r3, r3, #1 << 26
331 bcs 2b @ entries 63 to 0
333 bcs 1b @ segments 7 to 0
335 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
336 mcr p15, 0, ip, c7, c10, 4 @ drain WB
337 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
338 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
342 * cpu_arm920_set_pte(ptep, pte)
344 * Set a PTE and flush it out
347 ENTRY(cpu_arm920_set_pte)
348 str r1, [r0], #-2048 @ linux version
350 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
352 bic r2, r1, #PTE_SMALL_AP_MASK
353 bic r2, r2, #PTE_TYPE_MASK
354 orr r2, r2, #PTE_TYPE_SMALL
356 tst r1, #L_PTE_USER @ User?
357 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
359 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
360 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
362 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
365 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
366 eor r3, r2, #0x0a @ C & small page?
370 str r2, [r0] @ hardware version
372 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
373 mcr p15, 0, r0, c7, c10, 4 @ drain WB
378 .type __arm920_setup, #function
381 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
382 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
383 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
384 mrc p15, 0, r0, c1, c0 @ get control register v4
385 ldr r5, arm920_cr1_clear
387 ldr r5, arm920_cr1_set
390 .size __arm920_setup, . - __arm920_setup
394 * .RVI ZFRS BLDP WCAM
395 * ..11 0001 ..11 0101
398 .type arm920_cr1_clear, #object
399 .type arm920_cr1_set, #object
408 * Purpose : Function pointers used to access above functions - all calls
411 .type arm920_processor_functions, #object
412 arm920_processor_functions:
413 .word v4t_early_abort
414 .word cpu_arm920_proc_init
415 .word cpu_arm920_proc_fin
416 .word cpu_arm920_reset
417 .word cpu_arm920_do_idle
418 .word cpu_arm920_dcache_clean_area
419 .word cpu_arm920_switch_mm
420 .word cpu_arm920_set_pte
421 .size arm920_processor_functions, . - arm920_processor_functions
425 .type cpu_arch_name, #object
428 .size cpu_arch_name, . - cpu_arch_name
430 .type cpu_elf_name, #object
433 .size cpu_elf_name, . - cpu_elf_name
435 .type cpu_arm920_name, #object
438 #ifndef CONFIG_CPU_ICACHE_DISABLE
441 #ifndef CONFIG_CPU_DCACHE_DISABLE
443 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
450 .size cpu_arm920_name, . - cpu_arm920_name
454 .section ".proc.info.init", #alloc, #execinstr
456 .type __arm920_proc_info,#object
460 .long PMD_TYPE_SECT | \
461 PMD_SECT_BUFFERABLE | \
462 PMD_SECT_CACHEABLE | \
464 PMD_SECT_AP_WRITE | \
469 .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB
470 .long cpu_arm920_name
471 .long arm920_processor_functions
474 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
475 .long arm920_cache_fns
479 .size __arm920_proc_info, . - __arm920_proc_info