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)
55 mov ip, #PSR_F_BIT | PSR_I_BIT | SVC_MODE
57 bl mohawk_flush_kern_cache_all
58 mrc p15, 0, r0, c1, c0, 0 @ ctrl register
59 bic r0, r0, #0x1800 @ ...iz...........
60 bic r0, r0, #0x0006 @ .............ca.
61 mcr p15, 0, r0, c1, c0, 0 @ disable caches
65 * cpu_mohawk_reset(loc)
67 * Perform a soft reset of the system. Put the CPU into the
68 * same state as it would be if it had been reset, and branch
69 * to what would be the reset vector.
71 * loc: location to jump to for soft reset
76 ENTRY(cpu_mohawk_reset)
78 mcr p15, 0, ip, c7, c7, 0 @ invalidate I,D caches
79 mcr p15, 0, ip, c7, c10, 4 @ drain WB
80 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
81 mrc p15, 0, ip, c1, c0, 0 @ ctrl register
82 bic ip, ip, #0x0007 @ .............cam
83 bic ip, ip, #0x1100 @ ...i...s........
84 mcr p15, 0, ip, c1, c0, 0 @ ctrl register
88 * cpu_mohawk_do_idle()
90 * Called with IRQs disabled
93 ENTRY(cpu_mohawk_do_idle)
95 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
96 mcr p15, 0, r0, c7, c0, 4 @ wait for interrupt
100 * flush_user_cache_all()
102 * Clean and invalidate all cache entries in a particular
105 ENTRY(mohawk_flush_user_cache_all)
109 * flush_kern_cache_all()
111 * Clean and invalidate the entire cache.
113 ENTRY(mohawk_flush_kern_cache_all)
117 mcr p15, 0, ip, c7, c14, 0 @ clean & invalidate all D cache
119 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
120 mcrne p15, 0, ip, c7, c10, 0 @ drain write buffer
124 * flush_user_cache_range(start, end, flags)
126 * Clean and invalidate a range of cache entries in the
127 * specified address range.
129 * - start - start address (inclusive)
130 * - end - end address (exclusive)
131 * - flags - vm_flags describing address space
135 ENTRY(mohawk_flush_user_cache_range)
137 sub r3, r1, r0 @ calculate total size
138 cmp r3, #CACHE_DLIMIT
139 bgt __flush_whole_cache
141 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
142 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
143 add r0, r0, #CACHE_DLINESIZE
144 mcr p15, 0, r0, c7, c14, 1 @ clean and invalidate D entry
145 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
146 add r0, r0, #CACHE_DLINESIZE
150 mcrne p15, 0, ip, c7, c10, 4 @ drain WB
154 * coherent_kern_range(start, end)
156 * Ensure coherency between the Icache and the Dcache in the
157 * region described by start, end. If you have non-snooping
158 * Harvard caches, you need to implement this function.
160 * - start - virtual start address
161 * - end - virtual end address
163 ENTRY(mohawk_coherent_kern_range)
167 * coherent_user_range(start, end)
169 * Ensure coherency between the Icache and the Dcache in the
170 * region described by start, end. If you have non-snooping
171 * Harvard caches, you need to implement this function.
173 * - start - virtual start address
174 * - end - virtual end address
178 ENTRY(mohawk_coherent_user_range)
179 bic r0, r0, #CACHE_DLINESIZE - 1
180 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
181 mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
182 add r0, r0, #CACHE_DLINESIZE
185 mcr p15, 0, r0, c7, c10, 4 @ drain WB
189 * flush_kern_dcache_area(void *addr, size_t size)
191 * Ensure no D cache aliasing occurs, either with itself or
194 * - addr - kernel address
195 * - size - region size
197 ENTRY(mohawk_flush_kern_dcache_area)
199 1: mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
200 add r0, r0, #CACHE_DLINESIZE
204 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
205 mcr p15, 0, r0, c7, c10, 4 @ drain WB
209 * dma_inv_range(start, end)
211 * Invalidate (discard) the specified virtual address range.
212 * May not write back any entries. If 'start' or 'end'
213 * are not cache line aligned, those lines must be written
216 * - start - virtual start address
217 * - end - virtual end address
221 ENTRY(mohawk_dma_inv_range)
222 tst r0, #CACHE_DLINESIZE - 1
223 mcrne p15, 0, r0, c7, c10, 1 @ clean D entry
224 tst r1, #CACHE_DLINESIZE - 1
225 mcrne p15, 0, r1, c7, c10, 1 @ clean D entry
226 bic r0, r0, #CACHE_DLINESIZE - 1
227 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
228 add r0, r0, #CACHE_DLINESIZE
231 mcr p15, 0, r0, c7, c10, 4 @ drain WB
235 * dma_clean_range(start, end)
237 * Clean the specified virtual address range.
239 * - start - virtual start address
240 * - end - virtual end address
244 ENTRY(mohawk_dma_clean_range)
245 bic r0, r0, #CACHE_DLINESIZE - 1
246 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
247 add r0, r0, #CACHE_DLINESIZE
250 mcr p15, 0, r0, c7, c10, 4 @ drain WB
254 * dma_flush_range(start, end)
256 * Clean and invalidate the specified virtual address range.
258 * - start - virtual start address
259 * - end - virtual end address
261 ENTRY(mohawk_dma_flush_range)
262 bic r0, r0, #CACHE_DLINESIZE - 1
264 mcr p15, 0, r0, c7, c14, 1 @ clean+invalidate D entry
265 add r0, r0, #CACHE_DLINESIZE
268 mcr p15, 0, r0, c7, c10, 4 @ drain WB
271 ENTRY(mohawk_cache_fns)
272 .long mohawk_flush_kern_cache_all
273 .long mohawk_flush_user_cache_all
274 .long mohawk_flush_user_cache_range
275 .long mohawk_coherent_kern_range
276 .long mohawk_coherent_user_range
277 .long mohawk_flush_kern_dcache_area
278 .long mohawk_dma_inv_range
279 .long mohawk_dma_clean_range
280 .long mohawk_dma_flush_range
282 ENTRY(cpu_mohawk_dcache_clean_area)
283 1: mcr p15, 0, r0, c7, c10, 1 @ clean D entry
284 add r0, r0, #CACHE_DLINESIZE
285 subs r1, r1, #CACHE_DLINESIZE
287 mcr p15, 0, r0, c7, c10, 4 @ drain WB
291 * cpu_mohawk_switch_mm(pgd)
293 * Set the translation base pointer to be as described by pgd.
295 * pgd: new page tables
298 ENTRY(cpu_mohawk_switch_mm)
300 mcr p15, 0, ip, c7, c14, 0 @ clean & invalidate all D cache
301 mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache
302 mcr p15, 0, ip, c7, c10, 4 @ drain WB
303 orr r0, r0, #0x18 @ cache the page table in L2
304 mcr p15, 0, r0, c2, c0, 0 @ load page table pointer
305 mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs
309 * cpu_mohawk_set_pte_ext(ptep, pte, ext)
311 * Set a PTE and flush it out
314 ENTRY(cpu_mohawk_set_pte_ext)
317 mcr p15, 0, r0, c7, c10, 1 @ clean D entry
318 mcr p15, 0, r0, c7, c10, 4 @ drain WB
323 .type __mohawk_setup, #function
326 mcr p15, 0, r0, c7, c7 @ invalidate I,D caches
327 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
328 mcr p15, 0, r0, c8, c7 @ invalidate I,D TLBs
329 orr r4, r4, #0x18 @ cache the page table in L2
330 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
332 mov r0, #0 @ don't allow CP access
333 mcr p15, 0, r0, c15, c1, 0 @ write CP access register
337 mrc p15, 0, r0, c1, c0 @ get control register
342 .size __mohawk_setup, . - __mohawk_setup
346 * .RVI ZFRS BLDP WCAM
347 * .011 1001 ..00 0101
350 .type mohawk_crval, #object
352 crval clear=0x00007f3f, mmuset=0x00003905, ucset=0x00001134
357 * Purpose : Function pointers used to access above functions - all calls
360 .type mohawk_processor_functions, #object
361 mohawk_processor_functions:
362 .word v5t_early_abort
364 .word cpu_mohawk_proc_init
365 .word cpu_mohawk_proc_fin
366 .word cpu_mohawk_reset
367 .word cpu_mohawk_do_idle
368 .word cpu_mohawk_dcache_clean_area
369 .word cpu_mohawk_switch_mm
370 .word cpu_mohawk_set_pte_ext
371 .size mohawk_processor_functions, . - mohawk_processor_functions
375 .type cpu_arch_name, #object
378 .size cpu_arch_name, . - cpu_arch_name
380 .type cpu_elf_name, #object
383 .size cpu_elf_name, . - cpu_elf_name
385 .type cpu_mohawk_name, #object
387 .asciz "Marvell 88SV331x"
388 .size cpu_mohawk_name, . - cpu_mohawk_name
392 .section ".proc.info.init", #alloc, #execinstr
394 .type __88sv331x_proc_info,#object
395 __88sv331x_proc_info:
396 .long 0x56158000 @ Marvell 88SV331x (MOHAWK)
398 .long PMD_TYPE_SECT | \
399 PMD_SECT_BUFFERABLE | \
400 PMD_SECT_CACHEABLE | \
402 PMD_SECT_AP_WRITE | \
404 .long PMD_TYPE_SECT | \
406 PMD_SECT_AP_WRITE | \
411 .long HWCAP_SWP|HWCAP_HALF|HWCAP_THUMB|HWCAP_FAST_MULT|HWCAP_EDSP
412 .long cpu_mohawk_name
413 .long mohawk_processor_functions
416 .long mohawk_cache_fns
417 .size __88sv331x_proc_info, . - __88sv331x_proc_info