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
98 * Unconditionally clean and invalidate the entire icache.
100 ENTRY(mohawk_flush_icache_all)
102 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
104 ENDPROC(mohawk_flush_icache_all)
107 * flush_user_cache_all()
109 * Clean and invalidate all cache entries in a particular
112 ENTRY(mohawk_flush_user_cache_all)
116 * flush_kern_cache_all()
118 * Clean and invalidate the entire cache.
120 ENTRY(mohawk_flush_kern_cache_all)
124 mcr p15, 0, ip, c7, c14, 0 @ clean & invalidate all D cache
126 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
127 mcrne p15, 0, ip, c7, c10, 0 @ drain write buffer
131 * flush_user_cache_range(start, end, flags)
133 * Clean and invalidate a range of cache entries in the
134 * specified address range.
136 * - start - start address (inclusive)
137 * - end - end address (exclusive)
138 * - flags - vm_flags describing address space
142 ENTRY(mohawk_flush_user_cache_range)
144 sub r3, r1, r0 @ calculate total size
145 cmp r3, #CACHE_DLIMIT
146 bgt __flush_whole_cache
148 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
149 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
150 add r0, r0, #CACHE_DLINESIZE
151 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
152 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
153 add r0, r0, #CACHE_DLINESIZE
157 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
161 * coherent_kern_range(start, end)
163 * Ensure coherency between the Icache and the Dcache in the
164 * region described by start, end. If you have non-snooping
165 * Harvard caches, you need to implement this function.
167 * - start - virtual start address
168 * - end - virtual end address
170 ENTRY(mohawk_coherent_kern_range)
174 * coherent_user_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
185 ENTRY(mohawk_coherent_user_range)
186 bic r0, r0, #CACHE_DLINESIZE - 1
187 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
188 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
189 add r0, r0, #CACHE_DLINESIZE
192 mcr p15, 0, r0, c7, c10, 4 @ drain WB
196 * flush_kern_dcache_area(void *addr, size_t size)
198 * Ensure no D cache aliasing occurs, either with itself or
201 * - addr - kernel address
202 * - size - region size
204 ENTRY(mohawk_flush_kern_dcache_area)
206 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
207 add r0, r0, #CACHE_DLINESIZE
211 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
212 mcr p15, 0, r0, c7, c10, 4 @ drain WB
216 * dma_inv_range(start, end)
218 * Invalidate (discard) the specified virtual address range.
219 * May not write back any entries. If 'start' or 'end'
220 * are not cache line aligned, those lines must be written
223 * - start - virtual start address
224 * - end - virtual end address
228 mohawk_dma_inv_range:
229 tst r0, #CACHE_DLINESIZE - 1
230 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
231 tst r1, #CACHE_DLINESIZE - 1
232 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
233 bic r0, r0, #CACHE_DLINESIZE - 1
234 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
235 add r0, r0, #CACHE_DLINESIZE
238 mcr p15, 0, r0, c7, c10, 4 @ drain WB
242 * dma_clean_range(start, end)
244 * Clean the specified virtual address range.
246 * - start - virtual start address
247 * - end - virtual end address
251 mohawk_dma_clean_range:
252 bic r0, r0, #CACHE_DLINESIZE - 1
253 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
254 add r0, r0, #CACHE_DLINESIZE
257 mcr p15, 0, r0, c7, c10, 4 @ drain WB
261 * dma_flush_range(start, end)
263 * Clean and invalidate the specified virtual address range.
265 * - start - virtual start address
266 * - end - virtual end address
268 ENTRY(mohawk_dma_flush_range)
269 bic r0, r0, #CACHE_DLINESIZE - 1
271 mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
272 add r0, r0, #CACHE_DLINESIZE
275 mcr p15, 0, r0, c7, c10, 4 @ drain WB
279 * dma_map_area(start, size, dir)
280 * - start - kernel virtual start address
281 * - size - size of region
282 * - dir - DMA direction
284 ENTRY(mohawk_dma_map_area)
286 cmp r2, #DMA_TO_DEVICE
287 beq mohawk_dma_clean_range
288 bcs mohawk_dma_inv_range
289 b mohawk_dma_flush_range
290 ENDPROC(mohawk_dma_map_area)
293 * dma_unmap_area(start, size, dir)
294 * - start - kernel virtual start address
295 * - size - size of region
296 * - dir - DMA direction
298 ENTRY(mohawk_dma_unmap_area)
300 ENDPROC(mohawk_dma_unmap_area)
302 @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
303 define_cache_functions mohawk
305 ENTRY(cpu_mohawk_dcache_clean_area)
306 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
307 add r0, r0, #CACHE_DLINESIZE
308 subs r1, r1, #CACHE_DLINESIZE
310 mcr p15, 0, r0, c7, c10, 4 @ drain WB
314 * cpu_mohawk_switch_mm(pgd)
316 * Set the translation base pointer to be as described by pgd.
318 * pgd: new page tables
321 ENTRY(cpu_mohawk_switch_mm)
323 mcr p15, 0, ip, c7, c14, 0 @ clean & invalidate all D cache
324 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
325 mcr p15, 0, ip, c7, c10, 4 @ drain WB
326 orr r0, r0, #0x18 @ cache the page table in L2
327 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
328 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
332 * cpu_mohawk_set_pte_ext(ptep, pte, ext)
334 * Set a PTE and flush it out
337 ENTRY(cpu_mohawk_set_pte_ext)
340 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
341 mcr p15, 0, r0, c7, c10, 4 @ drain WB
346 .type __mohawk_setup, #function
349 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches
350 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
351 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs
352 orr r4, r4, #0x18 @ cache the page table in L2
353 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
355 mov r0, #0 @ don't allow CP access
356 mcr p15, 0, r0, c15, c1, 0 @ write CP access register
360 mrc p15, 0, r0, c1, c0 @ get control register
365 .size __mohawk_setup, . - __mohawk_setup
369 * .RVI ZFRS BLDP WCAM
370 * .011 1001 ..00 0101
373 .type mohawk_crval, #object
375 crval clear=0x00007f3f, mmuset=0x00003905, ucset=0x00001134
379 @ define struct processor (see <asm/proc-fns.h> and proc-macros.S)
380 define_processor_functions mohawk, dabort=v5t_early_abort, pabort=legacy_pabort
384 string cpu_arch_name, "armv5te"
385 string cpu_elf_name, "v5"
386 string cpu_mohawk_name, "Marvell 88SV331x"
390 .section ".proc.info.init", #alloc, #execinstr
392 .type __88sv331x_proc_info,#object
393 __88sv331x_proc_info:
394 .long 0x56158000 @ Marvell 88SV331x (MOHAWK)
396 .long PMD_TYPE_SECT | \
397 PMD_SECT_BUFFERABLE | \
398 PMD_SECT_CACHEABLE | \
400 PMD_SECT_AP_WRITE | \
402 .long PMD_TYPE_SECT | \
404 PMD_SECT_AP_WRITE | \
409 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
410 .long cpu_mohawk_name
411 .long mohawk_processor_functions
414 .long mohawk_cache_fns
415 .size __88sv331x_proc_info, . - __88sv331x_proc_info