2 * linux/arch/arm/mm/proc-mohawk.S: MMU functions for Marvell PJ1 core
4 * PJ1 (codename Mohawk) is a hybrid of the xscale3 and Marvell's own core.
6 * Heavily based on proc-arm926.S and proc-xsc3.S
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/linkage.h>
24 #include <linux/init.h>
25 #include <asm/assembler.h>
26 #include <asm/hwcap.h>
27 #include <asm/pgtable-hwdef.h>
28 #include <asm/pgtable.h>
30 #include <asm/ptrace.h>
31 #include "proc-macros.S"
34 * This is the maximum size of an area which will be flushed. If the
35 * area is larger than this, then we flush the whole cache.
37 #define CACHE_DLIMIT 32768
40 * The cache line size of the L1 D cache.
42 #define CACHE_DLINESIZE 32
45 * cpu_mohawk_proc_init()
47 ENTRY(cpu_mohawk_proc_init)
51 * cpu_mohawk_proc_fin()
53 ENTRY(cpu_mohawk_proc_fin)
54 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
55 bic r0, r0, #0x1800 @ ...iz...........
56 bic r0, r0, #0x0006 @ .............ca.
57 mcr p15, 0, r0, c1, c0, 0 @ disable caches
61 * cpu_mohawk_reset(loc)
63 * Perform a soft reset of the system. Put the CPU into the
64 * same state as it would be if it had been reset, and branch
65 * to what would be the reset vector.
67 * loc: location to jump to for soft reset
72 ENTRY(cpu_mohawk_reset)
74 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
75 mcr p15, 0, ip, c7, c10, 4 @ drain WB
76 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
77 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
78 bic ip, ip, #0x0007 @ .............cam
79 bic ip, ip, #0x1100 @ ...i...s........
80 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
84 * cpu_mohawk_do_idle()
86 * Called with IRQs disabled
89 ENTRY(cpu_mohawk_do_idle)
91 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
92 mcr p15, 0, r0, c7, c0, 4 @ wait for interrupt
96 * flush_user_cache_all()
98 * Clean and invalidate all cache entries in a particular
101 ENTRY(mohawk_flush_user_cache_all)
105 * flush_kern_cache_all()
107 * Clean and invalidate the entire cache.
109 ENTRY(mohawk_flush_kern_cache_all)
113 mcr p15, 0, ip, c7, c14, 0 @ clean & invalidate all D cache
115 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
116 mcrne p15, 0, ip, c7, c10, 0 @ drain write buffer
120 * flush_user_cache_range(start, end, flags)
122 * Clean and invalidate a range of cache entries in the
123 * specified address range.
125 * - start - start address (inclusive)
126 * - end - end address (exclusive)
127 * - flags - vm_flags describing address space
131 ENTRY(mohawk_flush_user_cache_range)
133 sub r3, r1, r0 @ calculate total size
134 cmp r3, #CACHE_DLIMIT
135 bgt __flush_whole_cache
137 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
138 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
139 add r0, r0, #CACHE_DLINESIZE
140 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
141 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
142 add r0, r0, #CACHE_DLINESIZE
146 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
150 * coherent_kern_range(start, end)
152 * Ensure coherency between the Icache and the Dcache in the
153 * region described by start, end. If you have non-snooping
154 * Harvard caches, you need to implement this function.
156 * - start - virtual start address
157 * - end - virtual end address
159 ENTRY(mohawk_coherent_kern_range)
163 * coherent_user_range(start, end)
165 * Ensure coherency between the Icache and the Dcache in the
166 * region described by start, end. If you have non-snooping
167 * Harvard caches, you need to implement this function.
169 * - start - virtual start address
170 * - end - virtual end address
174 ENTRY(mohawk_coherent_user_range)
175 bic r0, r0, #CACHE_DLINESIZE - 1
176 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
177 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
178 add r0, r0, #CACHE_DLINESIZE
181 mcr p15, 0, r0, c7, c10, 4 @ drain WB
185 * flush_kern_dcache_area(void *addr, size_t size)
187 * Ensure no D cache aliasing occurs, either with itself or
190 * - addr - kernel address
191 * - size - region size
193 ENTRY(mohawk_flush_kern_dcache_area)
195 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
196 add r0, r0, #CACHE_DLINESIZE
200 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
201 mcr p15, 0, r0, c7, c10, 4 @ drain WB
205 * dma_inv_range(start, end)
207 * Invalidate (discard) the specified virtual address range.
208 * May not write back any entries. If 'start' or 'end'
209 * are not cache line aligned, those lines must be written
212 * - start - virtual start address
213 * - end - virtual end address
217 mohawk_dma_inv_range:
218 tst r0, #CACHE_DLINESIZE - 1
219 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
220 tst r1, #CACHE_DLINESIZE - 1
221 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
222 bic r0, r0, #CACHE_DLINESIZE - 1
223 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
224 add r0, r0, #CACHE_DLINESIZE
227 mcr p15, 0, r0, c7, c10, 4 @ drain WB
231 * dma_clean_range(start, end)
233 * Clean the specified virtual address range.
235 * - start - virtual start address
236 * - end - virtual end address
240 mohawk_dma_clean_range:
241 bic r0, r0, #CACHE_DLINESIZE - 1
242 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
243 add r0, r0, #CACHE_DLINESIZE
246 mcr p15, 0, r0, c7, c10, 4 @ drain WB
250 * dma_flush_range(start, end)
252 * Clean and invalidate the specified virtual address range.
254 * - start - virtual start address
255 * - end - virtual end address
257 ENTRY(mohawk_dma_flush_range)
258 bic r0, r0, #CACHE_DLINESIZE - 1
260 mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
261 add r0, r0, #CACHE_DLINESIZE
264 mcr p15, 0, r0, c7, c10, 4 @ drain WB
268 * dma_map_area(start, size, dir)
269 * - start - kernel virtual start address
270 * - size - size of region
271 * - dir - DMA direction
273 ENTRY(mohawk_dma_map_area)
275 cmp r2, #DMA_TO_DEVICE
276 beq mohawk_dma_clean_range
277 bcs mohawk_dma_inv_range
278 b mohawk_dma_flush_range
279 ENDPROC(mohawk_dma_map_area)
282 * dma_unmap_area(start, size, dir)
283 * - start - kernel virtual start address
284 * - size - size of region
285 * - dir - DMA direction
287 ENTRY(mohawk_dma_unmap_area)
289 ENDPROC(mohawk_dma_unmap_area)
291 ENTRY(mohawk_cache_fns)
292 .long mohawk_flush_kern_cache_all
293 .long mohawk_flush_user_cache_all
294 .long mohawk_flush_user_cache_range
295 .long mohawk_coherent_kern_range
296 .long mohawk_coherent_user_range
297 .long mohawk_flush_kern_dcache_area
298 .long mohawk_dma_map_area
299 .long mohawk_dma_unmap_area
300 .long mohawk_dma_flush_range
302 ENTRY(cpu_mohawk_dcache_clean_area)
303 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
304 add r0, r0, #CACHE_DLINESIZE
305 subs r1, r1, #CACHE_DLINESIZE
307 mcr p15, 0, r0, c7, c10, 4 @ drain WB
311 * cpu_mohawk_switch_mm(pgd)
313 * Set the translation base pointer to be as described by pgd.
315 * pgd: new page tables
318 ENTRY(cpu_mohawk_switch_mm)
320 mcr p15, 0, ip, c7, c14, 0 @ clean & invalidate all D cache
321 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
322 mcr p15, 0, ip, c7, c10, 4 @ drain WB
323 orr r0, r0, #0x18 @ cache the page table in L2
324 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
325 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
329 * cpu_mohawk_set_pte_ext(ptep, pte, ext)
331 * Set a PTE and flush it out
334 ENTRY(cpu_mohawk_set_pte_ext)
337 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
338 mcr p15, 0, r0, c7, c10, 4 @ drain WB
343 .type __mohawk_setup, #function
346 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches
347 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
348 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs
349 orr r4, r4, #0x18 @ cache the page table in L2
350 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
352 mov r0, #0 @ don't allow CP access
353 mcr p15, 0, r0, c15, c1, 0 @ write CP access register
357 mrc p15, 0, r0, c1, c0 @ get control register
362 .size __mohawk_setup, . - __mohawk_setup
366 * .RVI ZFRS BLDP WCAM
367 * .011 1001 ..00 0101
370 .type mohawk_crval, #object
372 crval clear=0x00007f3f, mmuset=0x00003905, ucset=0x00001134
377 * Purpose : Function pointers used to access above functions - all calls
380 .type mohawk_processor_functions, #object
381 mohawk_processor_functions:
382 .word v5t_early_abort
384 .word cpu_mohawk_proc_init
385 .word cpu_mohawk_proc_fin
386 .word cpu_mohawk_reset
387 .word cpu_mohawk_do_idle
388 .word cpu_mohawk_dcache_clean_area
389 .word cpu_mohawk_switch_mm
390 .word cpu_mohawk_set_pte_ext
394 .size mohawk_processor_functions, . - mohawk_processor_functions
398 .type cpu_arch_name, #object
401 .size cpu_arch_name, . - cpu_arch_name
403 .type cpu_elf_name, #object
406 .size cpu_elf_name, . - cpu_elf_name
408 .type cpu_mohawk_name, #object
410 .asciz "Marvell 88SV331x"
411 .size cpu_mohawk_name, . - cpu_mohawk_name
415 .section ".proc.info.init", #alloc, #execinstr
417 .type __88sv331x_proc_info,#object
418 __88sv331x_proc_info:
419 .long 0x56158000 @ Marvell 88SV331x (MOHAWK)
421 .long PMD_TYPE_SECT | \
422 PMD_SECT_BUFFERABLE | \
423 PMD_SECT_CACHEABLE | \
425 PMD_SECT_AP_WRITE | \
427 .long PMD_TYPE_SECT | \
429 PMD_SECT_AP_WRITE | \
434 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
435 .long cpu_mohawk_name
436 .long mohawk_processor_functions
439 .long mohawk_cache_fns
440 .size __88sv331x_proc_info, . - __88sv331x_proc_info