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
110 ENTRY(feroceon_flush_user_cache_all)
114 * flush_kern_cache_all()
116 * Clean and invalidate the entire cache.
118 ENTRY(feroceon_flush_kern_cache_all)
122 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
125 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
126 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
130 * flush_user_cache_range(start, end, flags)
132 * Clean and invalidate a range of cache entries in the
133 * specified address range.
135 * - start - start address (inclusive)
136 * - end - end address (exclusive)
137 * - flags - vm_flags describing address space
140 ENTRY(feroceon_flush_user_cache_range)
142 sub r3, r1, r0 @ calculate total size
143 cmp r3, #CACHE_DLIMIT
144 bgt __flush_whole_cache
146 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
147 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
148 add r0, r0, #CACHE_DLINESIZE
149 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
150 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
151 add r0, r0, #CACHE_DLINESIZE
155 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
159 * coherent_kern_range(start, end)
161 * Ensure coherency between the Icache and the Dcache in the
162 * region described by start, end. If you have non-snooping
163 * Harvard caches, you need to implement this function.
165 * - start - virtual start address
166 * - end - virtual end address
169 ENTRY(feroceon_coherent_kern_range)
173 * coherent_user_range(start, end)
175 * Ensure coherency between the Icache and the Dcache in the
176 * region described by start, end. If you have non-snooping
177 * Harvard caches, you need to implement this function.
179 * - start - virtual start address
180 * - end - virtual end address
182 ENTRY(feroceon_coherent_user_range)
183 bic r0, r0, #CACHE_DLINESIZE - 1
184 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
185 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
186 add r0, r0, #CACHE_DLINESIZE
189 mcr p15, 0, r0, c7, c10, 4 @ drain WB
193 * flush_kern_dcache_page(void *page)
195 * Ensure no D cache aliasing occurs, either with itself or
198 * - addr - page aligned address
201 ENTRY(feroceon_flush_kern_dcache_page)
203 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
204 add r0, r0, #CACHE_DLINESIZE
208 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
209 mcr p15, 0, r0, c7, c10, 4 @ drain WB
213 * dma_inv_range(start, end)
215 * Invalidate (discard) the specified virtual address range.
216 * May not write back any entries. If 'start' or 'end'
217 * are not cache line aligned, those lines must be written
220 * - start - virtual start address
221 * - end - virtual end address
226 ENTRY(feroceon_dma_inv_range)
227 tst r0, #CACHE_DLINESIZE - 1
228 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
229 tst r1, #CACHE_DLINESIZE - 1
230 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
231 bic r0, r0, #CACHE_DLINESIZE - 1
232 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
233 add r0, r0, #CACHE_DLINESIZE
236 mcr p15, 0, r0, c7, c10, 4 @ drain WB
240 * dma_clean_range(start, end)
242 * Clean the specified virtual address range.
244 * - start - virtual start address
245 * - end - virtual end address
250 ENTRY(feroceon_dma_clean_range)
251 bic r0, r0, #CACHE_DLINESIZE - 1
252 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
253 add r0, r0, #CACHE_DLINESIZE
256 mcr p15, 0, r0, c7, c10, 4 @ drain WB
260 * dma_flush_range(start, end)
262 * Clean and invalidate the specified virtual address range.
264 * - start - virtual start address
265 * - end - virtual end address
268 ENTRY(feroceon_dma_flush_range)
269 bic r0, r0, #CACHE_DLINESIZE - 1
270 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
271 add r0, r0, #CACHE_DLINESIZE
274 mcr p15, 0, r0, c7, c10, 4 @ drain WB
277 ENTRY(feroceon_cache_fns)
278 .long feroceon_flush_kern_cache_all
279 .long feroceon_flush_user_cache_all
280 .long feroceon_flush_user_cache_range
281 .long feroceon_coherent_kern_range
282 .long feroceon_coherent_user_range
283 .long feroceon_flush_kern_dcache_page
284 .long feroceon_dma_inv_range
285 .long feroceon_dma_clean_range
286 .long feroceon_dma_flush_range
289 ENTRY(cpu_feroceon_dcache_clean_area)
290 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
291 add r0, r0, #CACHE_DLINESIZE
292 subs r1, r1, #CACHE_DLINESIZE
294 mcr p15, 0, r0, c7, c10, 4 @ drain WB
297 /* =============================== PageTable ============================== */
300 * cpu_feroceon_switch_mm(pgd)
302 * Set the translation base pointer to be as described by pgd.
304 * pgd: new page tables
307 ENTRY(cpu_feroceon_switch_mm)
310 @ && 'Clean & Invalidate whole DCache'
311 1: mrc p15, 0, r15, c7, c14, 3 @ test,clean,invalidate
313 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
314 mcr p15, 0, ip, c7, c10, 4 @ drain WB
315 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
316 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
321 * cpu_feroceon_set_pte_ext(ptep, pte, ext)
323 * Set a PTE and flush it out
326 ENTRY(cpu_feroceon_set_pte_ext)
328 str r1, [r0], #-2048 @ linux version
330 eor r1, r1, #L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_WRITE | L_PTE_DIRTY
332 bic r2, r1, #PTE_SMALL_AP_MASK
333 bic r2, r2, #PTE_TYPE_MASK
334 orr r2, r2, #PTE_TYPE_SMALL
336 tst r1, #L_PTE_USER @ User?
337 orrne r2, r2, #PTE_SMALL_AP_URO_SRW
339 tst r1, #L_PTE_WRITE | L_PTE_DIRTY @ Write and Dirty?
340 orreq r2, r2, #PTE_SMALL_AP_UNO_SRW
342 tst r1, #L_PTE_PRESENT | L_PTE_YOUNG @ Present and Young?
345 str r2, [r0] @ hardware version
347 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
348 mcr p15, 0, r0, c7, c10, 4 @ drain WB
354 .type __feroceon_setup, #function
357 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches on v4
358 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer on v4
360 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs on v4
363 adr r5, feroceon_crval
365 mrc p15, 0, r0, c1, c0 @ get control register v4
369 .size __feroceon_setup, . - __feroceon_setup
373 * .RVI ZFRS BLDP WCAM
374 * .011 0001 ..11 0101
377 .type feroceon_crval, #object
379 crval clear=0x00007f3f, mmuset=0x00003135, ucset=0x00001134
384 * Purpose : Function pointers used to access above functions - all calls
387 .type feroceon_processor_functions, #object
388 feroceon_processor_functions:
389 .word v5t_early_abort
391 .word cpu_feroceon_proc_init
392 .word cpu_feroceon_proc_fin
393 .word cpu_feroceon_reset
394 .word cpu_feroceon_do_idle
395 .word cpu_feroceon_dcache_clean_area
396 .word cpu_feroceon_switch_mm
397 .word cpu_feroceon_set_pte_ext
398 .size feroceon_processor_functions, . - feroceon_processor_functions
402 .type cpu_arch_name, #object
405 .size cpu_arch_name, . - cpu_arch_name
407 .type cpu_elf_name, #object
410 .size cpu_elf_name, . - cpu_elf_name
412 .type cpu_feroceon_name, #object
415 .size cpu_feroceon_name, . - cpu_feroceon_name
419 .section ".proc.info.init", #alloc, #execinstr
421 #ifdef CONFIG_CPU_FEROCEON_OLD_ID
422 .type __feroceon_old_id_proc_info,#object
423 __feroceon_old_id_proc_info:
426 .long PMD_TYPE_SECT | \
427 PMD_SECT_BUFFERABLE | \
428 PMD_SECT_CACHEABLE | \
430 PMD_SECT_AP_WRITE | \
432 .long PMD_TYPE_SECT | \
434 PMD_SECT_AP_WRITE | \
439 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
440 .long cpu_feroceon_name
441 .long feroceon_processor_functions
443 .long feroceon_user_fns
444 .long feroceon_cache_fns
445 .size __feroceon_old_id_proc_info, . - __feroceon_old_id_proc_info
448 .type __feroceon_proc_info,#object
449 __feroceon_proc_info:
452 .long PMD_TYPE_SECT | \
453 PMD_SECT_BUFFERABLE | \
454 PMD_SECT_CACHEABLE | \
456 PMD_SECT_AP_WRITE | \
458 .long PMD_TYPE_SECT | \
460 PMD_SECT_AP_WRITE | \
465 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
466 .long cpu_feroceon_name
467 .long feroceon_processor_functions
469 .long feroceon_user_fns
470 .long feroceon_cache_fns
471 .size __feroceon_proc_info, . - __feroceon_proc_info