2 * linux/arch/arm/mm/proc-feroceon.S: MMU functions for Feroceon
4 * Heavily based on proc-arm926.S
5 * Maintainer: Assaf Hoffman <hoffman@marvell.com>
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 #include <linux/linkage.h>
23 #include <linux/init.h>
24 #include <asm/assembler.h>
26 #include <asm/pgtable-hwdef.h>
27 #include <asm/pgtable.h>
29 #include <asm/ptrace.h>
30 #include "proc-macros.S"
33 * This is the maximum size of an area which will be invalidated
34 * using the single invalidate entry instructions. Anything larger
35 * than this, and we go for the whole cache.
37 * This value should be chosen such that we choose the cheapest
40 #define CACHE_DLIMIT 16384
43 * the cache line size of the I and D cache
45 #define CACHE_DLINESIZE 32
49 * cpu_feroceon_proc_init()
51 ENTRY(cpu_feroceon_proc_init)
55 * cpu_feroceon_proc_fin()
57 ENTRY(cpu_feroceon_proc_fin)
59 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
61 bl feroceon_flush_kern_cache_all
62 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
63 bic r0, r0, #0x1000 @ ...i............
64 bic r0, r0, #0x000e @ ............wca.
65 mcr p15, 0, r0, c1, c0, 0 @ disable caches
69 * cpu_feroceon_reset(loc)
71 * Perform a soft reset of the system. Put the CPU into the
72 * same state as it would be if it had been reset, and branch
73 * to what would be the reset vector.
75 * loc: location to jump to for soft reset
78 ENTRY(cpu_feroceon_reset)
80 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
81 mcr p15, 0, ip, c7, c10, 4 @ drain WB
83 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
85 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
86 bic ip, ip, #0x000f @ ............wcam
87 bic ip, ip, #0x1100 @ ...i...s........
88 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
92 * cpu_feroceon_do_idle()
94 * Called with IRQs disabled
97 ENTRY(cpu_feroceon_do_idle)
99 mcr p15, 0, r0, c7, c10, 4 @ Drain write buffer
100 mcr p15, 0, r0, c7, c0, 4 @ Wait for interrupt
104 * flush_user_cache_all()
106 * Clean and invalidate all cache entries in a particular
109 ENTRY(feroceon_flush_user_cache_all)
113 * flush_kern_cache_all()
115 * Clean and invalidate the entire cache.
117 ENTRY(feroceon_flush_kern_cache_all)
121 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
122 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
124 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
128 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
129 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
133 * flush_user_cache_range(start, end, flags)
135 * Clean and invalidate a range of cache entries in the
136 * specified address range.
138 * - start - start address (inclusive)
139 * - end - end address (exclusive)
140 * - flags - vm_flags describing address space
142 ENTRY(feroceon_flush_user_cache_range)
144 sub r3, r1, r0 @ calculate total size
145 cmp r3, #CACHE_DLIMIT
146 bgt __flush_whole_cache
148 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
149 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
150 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
151 add r0, r0, #CACHE_DLINESIZE
152 mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
153 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
154 add r0, r0, #CACHE_DLINESIZE
156 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
157 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
158 add r0, r0, #CACHE_DLINESIZE
159 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
160 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
161 add r0, r0, #CACHE_DLINESIZE
166 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
170 * coherent_kern_range(start, end)
172 * Ensure coherency between the Icache and the Dcache in the
173 * region described by start, end. If you have non-snooping
174 * Harvard caches, you need to implement this function.
176 * - start - virtual start address
177 * - end - virtual end address
179 ENTRY(feroceon_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, end. 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(feroceon_coherent_user_range)
193 bic r0, r0, #CACHE_DLINESIZE - 1
194 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
195 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
196 add r0, r0, #CACHE_DLINESIZE
199 mcr p15, 0, r0, c7, c10, 4 @ drain WB
203 * flush_kern_dcache_page(void *page)
205 * Ensure no D cache aliasing occurs, either with itself or
208 * - addr - page aligned address
210 ENTRY(feroceon_flush_kern_dcache_page)
212 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
213 add r0, r0, #CACHE_DLINESIZE
217 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
218 mcr p15, 0, r0, c7, c10, 4 @ drain WB
222 * dma_inv_range(start, end)
224 * Invalidate (discard) the specified virtual address range.
225 * May not write back any entries. If 'start' or 'end'
226 * are not cache line aligned, those lines must be written
229 * - start - virtual start address
230 * - end - virtual end address
234 ENTRY(feroceon_dma_inv_range)
235 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
236 tst r0, #CACHE_DLINESIZE - 1
237 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
238 tst r1, #CACHE_DLINESIZE - 1
239 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
241 bic r0, r0, #CACHE_DLINESIZE - 1
242 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
243 add r0, r0, #CACHE_DLINESIZE
246 mcr p15, 0, r0, c7, c10, 4 @ drain WB
250 * dma_clean_range(start, end)
252 * Clean the specified virtual address range.
254 * - start - virtual start address
255 * - end - virtual end address
259 ENTRY(feroceon_dma_clean_range)
260 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
261 bic r0, r0, #CACHE_DLINESIZE - 1
262 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
263 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(feroceon_dma_flush_range)
279 bic r0, r0, #CACHE_DLINESIZE - 1
281 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
282 mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
284 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
286 add r0, r0, #CACHE_DLINESIZE
289 mcr p15, 0, r0, c7, c10, 4 @ drain WB
292 ENTRY(feroceon_cache_fns)
293 .long feroceon_flush_kern_cache_all
294 .long feroceon_flush_user_cache_all
295 .long feroceon_flush_user_cache_range
296 .long feroceon_coherent_kern_range
297 .long feroceon_coherent_user_range
298 .long feroceon_flush_kern_dcache_page
299 .long feroceon_dma_inv_range
300 .long feroceon_dma_clean_range
301 .long feroceon_dma_flush_range
303 ENTRY(cpu_feroceon_dcache_clean_area)
304 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
305 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
306 add r0, r0, #CACHE_DLINESIZE
307 subs r1, r1, #CACHE_DLINESIZE
310 mcr p15, 0, r0, c7, c10, 4 @ drain WB
313 /* =============================== PageTable ============================== */
316 * cpu_feroceon_switch_mm(pgd)
318 * Set the translation base pointer to be as described by pgd.
320 * pgd: new page tables
323 ENTRY(cpu_feroceon_switch_mm)
326 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
327 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
329 @ && 'Clean & Invalidate whole DCache'
330 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
333 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
334 mcr p15, 0, ip, c7, c10, 4 @ drain WB
335 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
336 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
341 * cpu_feroceon_set_pte_ext(ptep, pte, ext)
343 * Set a PTE and flush it out
346 ENTRY(cpu_feroceon_set_pte_ext)
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 #ifndef CONFIG_CPU_DCACHE_WRITETHROUGH
373 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
375 mcr p15, 0, r0, c7, c10, 4 @ drain WB
381 .type __feroceon_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
387 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
391 #ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
392 mov r0, #4 @ disable write-back on caches explicitly
393 mcr p15, 7, r0, c15, c0, 0
396 adr r5, feroceon_crval
398 mrc p15, 0, r0, c1, c0 @ get control register v4
401 #ifdef CONFIG_CPU_CACHE_ROUND_ROBIN
402 orr r0, r0, #0x4000 @ .1.. .... .... ....
405 .size __feroceon_setup, . - __feroceon_setup
409 * .RVI ZFRS BLDP WCAM
410 * .011 0001 ..11 0101
413 .type feroceon_crval, #object
415 crval clear=0x00007f3f, mmuset=0x00003135, ucset=0x00001134
420 * Purpose : Function pointers used to access above functions - all calls
423 .type feroceon_processor_functions, #object
424 feroceon_processor_functions:
425 .word v5t_early_abort
426 .word cpu_feroceon_proc_init
427 .word cpu_feroceon_proc_fin
428 .word cpu_feroceon_reset
429 .word cpu_feroceon_do_idle
430 .word cpu_feroceon_dcache_clean_area
431 .word cpu_feroceon_switch_mm
432 .word cpu_feroceon_set_pte_ext
433 .size feroceon_processor_functions, . - feroceon_processor_functions
437 .type cpu_arch_name, #object
440 .size cpu_arch_name, . - cpu_arch_name
442 .type cpu_elf_name, #object
445 .size cpu_elf_name, . - cpu_elf_name
447 .type cpu_feroceon_name, #object
450 .size cpu_feroceon_name, . - cpu_feroceon_name
454 .section ".proc.info.init", #alloc, #execinstr
456 #ifdef CONFIG_CPU_FEROCEON_OLD_ID
457 .type __feroceon_old_id_proc_info,#object
458 __feroceon_old_id_proc_info:
461 .long PMD_TYPE_SECT | \
462 PMD_SECT_BUFFERABLE | \
463 PMD_SECT_CACHEABLE | \
465 PMD_SECT_AP_WRITE | \
467 .long PMD_TYPE_SECT | \
469 PMD_SECT_AP_WRITE | \
474 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
475 .long cpu_feroceon_name
476 .long feroceon_processor_functions
479 .long feroceon_cache_fns
480 .size __feroceon_old_id_proc_info, . - __feroceon_old_id_proc_info
483 .type __feroceon_proc_info,#object
484 __feroceon_proc_info:
487 .long PMD_TYPE_SECT | \
488 PMD_SECT_BUFFERABLE | \
489 PMD_SECT_CACHEABLE | \
491 PMD_SECT_AP_WRITE | \
493 .long PMD_TYPE_SECT | \
495 PMD_SECT_AP_WRITE | \
500 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
501 .long cpu_feroceon_name
502 .long feroceon_processor_functions
505 .long feroceon_cache_fns
506 .size __feroceon_proc_info, . - __feroceon_proc_info