Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / arch / mips / mm / c-r4k.c
bloba124156b9a952527ed60939b44f90deca4d08b28
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
6 * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
7 * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Ralf Baechle (ralf@gnu.org)
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
9 */
10 #include <linux/hardirq.h>
11 #include <linux/init.h>
12 #include <linux/highmem.h>
13 #include <linux/kernel.h>
14 #include <linux/linkage.h>
15 #include <linux/sched.h>
16 #include <linux/mm.h>
17 #include <linux/bitops.h>
19 #include <asm/bcache.h>
20 #include <asm/bootinfo.h>
21 #include <asm/cache.h>
22 #include <asm/cacheops.h>
23 #include <asm/cpu.h>
24 #include <asm/cpu-features.h>
25 #include <asm/io.h>
26 #include <asm/page.h>
27 #include <asm/pgtable.h>
28 #include <asm/r4kcache.h>
29 #include <asm/sections.h>
30 #include <asm/system.h>
31 #include <asm/mmu_context.h>
32 #include <asm/war.h>
33 #include <asm/cacheflush.h> /* for run_uncached() */
37 * Special Variant of smp_call_function for use by cache functions:
39 * o No return value
40 * o collapses to normal function call on UP kernels
41 * o collapses to normal function call on systems with a single shared
42 * primary cache.
44 static inline void r4k_on_each_cpu(void (*func) (void *info), void *info,
45 int retry, int wait)
47 preempt_disable();
49 #if !defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_MIPS_MT_SMTC)
50 smp_call_function(func, info, retry, wait);
51 #endif
52 func(info);
53 preempt_enable();
57 * Must die.
59 static unsigned long icache_size __read_mostly;
60 static unsigned long dcache_size __read_mostly;
61 static unsigned long scache_size __read_mostly;
64 * Dummy cache handling routines for machines without boardcaches
66 static void cache_noop(void) {}
68 static struct bcache_ops no_sc_ops = {
69 .bc_enable = (void *)cache_noop,
70 .bc_disable = (void *)cache_noop,
71 .bc_wback_inv = (void *)cache_noop,
72 .bc_inv = (void *)cache_noop
75 struct bcache_ops *bcops = &no_sc_ops;
77 #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x00002010)
78 #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x00002020)
80 #define R4600_HIT_CACHEOP_WAR_IMPL \
81 do { \
82 if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x()) \
83 *(volatile unsigned long *)CKSEG1; \
84 if (R4600_V1_HIT_CACHEOP_WAR) \
85 __asm__ __volatile__("nop;nop;nop;nop"); \
86 } while (0)
88 static void (*r4k_blast_dcache_page)(unsigned long addr);
90 static inline void r4k_blast_dcache_page_dc32(unsigned long addr)
92 R4600_HIT_CACHEOP_WAR_IMPL;
93 blast_dcache32_page(addr);
96 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
97 static void __init r4k_blast_dcache_page_setup(void)
98 =======
99 static void __cpuinit r4k_blast_dcache_page_setup(void)
100 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
102 unsigned long dc_lsize = cpu_dcache_line_size();
104 if (dc_lsize == 0)
105 r4k_blast_dcache_page = (void *)cache_noop;
106 else if (dc_lsize == 16)
107 r4k_blast_dcache_page = blast_dcache16_page;
108 else if (dc_lsize == 32)
109 r4k_blast_dcache_page = r4k_blast_dcache_page_dc32;
112 static void (* r4k_blast_dcache_page_indexed)(unsigned long addr);
114 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
115 static void __init r4k_blast_dcache_page_indexed_setup(void)
116 =======
117 static void __cpuinit r4k_blast_dcache_page_indexed_setup(void)
118 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
120 unsigned long dc_lsize = cpu_dcache_line_size();
122 if (dc_lsize == 0)
123 r4k_blast_dcache_page_indexed = (void *)cache_noop;
124 else if (dc_lsize == 16)
125 r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed;
126 else if (dc_lsize == 32)
127 r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed;
130 static void (* r4k_blast_dcache)(void);
132 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
133 static void __init r4k_blast_dcache_setup(void)
134 =======
135 static void __cpuinit r4k_blast_dcache_setup(void)
136 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
138 unsigned long dc_lsize = cpu_dcache_line_size();
140 if (dc_lsize == 0)
141 r4k_blast_dcache = (void *)cache_noop;
142 else if (dc_lsize == 16)
143 r4k_blast_dcache = blast_dcache16;
144 else if (dc_lsize == 32)
145 r4k_blast_dcache = blast_dcache32;
148 /* force code alignment (used for TX49XX_ICACHE_INDEX_INV_WAR) */
149 #define JUMP_TO_ALIGN(order) \
150 __asm__ __volatile__( \
151 "b\t1f\n\t" \
152 ".align\t" #order "\n\t" \
153 "1:\n\t" \
155 #define CACHE32_UNROLL32_ALIGN JUMP_TO_ALIGN(10) /* 32 * 32 = 1024 */
156 #define CACHE32_UNROLL32_ALIGN2 JUMP_TO_ALIGN(11)
158 static inline void blast_r4600_v1_icache32(void)
160 unsigned long flags;
162 local_irq_save(flags);
163 blast_icache32();
164 local_irq_restore(flags);
167 static inline void tx49_blast_icache32(void)
169 unsigned long start = INDEX_BASE;
170 unsigned long end = start + current_cpu_data.icache.waysize;
171 unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
172 unsigned long ws_end = current_cpu_data.icache.ways <<
173 current_cpu_data.icache.waybit;
174 unsigned long ws, addr;
176 CACHE32_UNROLL32_ALIGN2;
177 /* I'm in even chunk. blast odd chunks */
178 for (ws = 0; ws < ws_end; ws += ws_inc)
179 for (addr = start + 0x400; addr < end; addr += 0x400 * 2)
180 cache32_unroll32(addr|ws, Index_Invalidate_I);
181 CACHE32_UNROLL32_ALIGN;
182 /* I'm in odd chunk. blast even chunks */
183 for (ws = 0; ws < ws_end; ws += ws_inc)
184 for (addr = start; addr < end; addr += 0x400 * 2)
185 cache32_unroll32(addr|ws, Index_Invalidate_I);
188 static inline void blast_icache32_r4600_v1_page_indexed(unsigned long page)
190 unsigned long flags;
192 local_irq_save(flags);
193 blast_icache32_page_indexed(page);
194 local_irq_restore(flags);
197 static inline void tx49_blast_icache32_page_indexed(unsigned long page)
199 unsigned long indexmask = current_cpu_data.icache.waysize - 1;
200 unsigned long start = INDEX_BASE + (page & indexmask);
201 unsigned long end = start + PAGE_SIZE;
202 unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
203 unsigned long ws_end = current_cpu_data.icache.ways <<
204 current_cpu_data.icache.waybit;
205 unsigned long ws, addr;
207 CACHE32_UNROLL32_ALIGN2;
208 /* I'm in even chunk. blast odd chunks */
209 for (ws = 0; ws < ws_end; ws += ws_inc)
210 for (addr = start + 0x400; addr < end; addr += 0x400 * 2)
211 cache32_unroll32(addr|ws, Index_Invalidate_I);
212 CACHE32_UNROLL32_ALIGN;
213 /* I'm in odd chunk. blast even chunks */
214 for (ws = 0; ws < ws_end; ws += ws_inc)
215 for (addr = start; addr < end; addr += 0x400 * 2)
216 cache32_unroll32(addr|ws, Index_Invalidate_I);
219 static void (* r4k_blast_icache_page)(unsigned long addr);
221 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
222 static void __init r4k_blast_icache_page_setup(void)
223 =======
224 static void __cpuinit r4k_blast_icache_page_setup(void)
225 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
227 unsigned long ic_lsize = cpu_icache_line_size();
229 if (ic_lsize == 0)
230 r4k_blast_icache_page = (void *)cache_noop;
231 else if (ic_lsize == 16)
232 r4k_blast_icache_page = blast_icache16_page;
233 else if (ic_lsize == 32)
234 r4k_blast_icache_page = blast_icache32_page;
235 else if (ic_lsize == 64)
236 r4k_blast_icache_page = blast_icache64_page;
240 static void (* r4k_blast_icache_page_indexed)(unsigned long addr);
242 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
243 static void __init r4k_blast_icache_page_indexed_setup(void)
244 =======
245 static void __cpuinit r4k_blast_icache_page_indexed_setup(void)
246 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
248 unsigned long ic_lsize = cpu_icache_line_size();
250 if (ic_lsize == 0)
251 r4k_blast_icache_page_indexed = (void *)cache_noop;
252 else if (ic_lsize == 16)
253 r4k_blast_icache_page_indexed = blast_icache16_page_indexed;
254 else if (ic_lsize == 32) {
255 if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x())
256 r4k_blast_icache_page_indexed =
257 blast_icache32_r4600_v1_page_indexed;
258 else if (TX49XX_ICACHE_INDEX_INV_WAR)
259 r4k_blast_icache_page_indexed =
260 tx49_blast_icache32_page_indexed;
261 else
262 r4k_blast_icache_page_indexed =
263 blast_icache32_page_indexed;
264 } else if (ic_lsize == 64)
265 r4k_blast_icache_page_indexed = blast_icache64_page_indexed;
268 static void (* r4k_blast_icache)(void);
270 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
271 static void __init r4k_blast_icache_setup(void)
272 =======
273 static void __cpuinit r4k_blast_icache_setup(void)
274 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
276 unsigned long ic_lsize = cpu_icache_line_size();
278 if (ic_lsize == 0)
279 r4k_blast_icache = (void *)cache_noop;
280 else if (ic_lsize == 16)
281 r4k_blast_icache = blast_icache16;
282 else if (ic_lsize == 32) {
283 if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x())
284 r4k_blast_icache = blast_r4600_v1_icache32;
285 else if (TX49XX_ICACHE_INDEX_INV_WAR)
286 r4k_blast_icache = tx49_blast_icache32;
287 else
288 r4k_blast_icache = blast_icache32;
289 } else if (ic_lsize == 64)
290 r4k_blast_icache = blast_icache64;
293 static void (* r4k_blast_scache_page)(unsigned long addr);
295 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
296 static void __init r4k_blast_scache_page_setup(void)
297 =======
298 static void __cpuinit r4k_blast_scache_page_setup(void)
299 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
301 unsigned long sc_lsize = cpu_scache_line_size();
303 if (scache_size == 0)
304 r4k_blast_scache_page = (void *)cache_noop;
305 else if (sc_lsize == 16)
306 r4k_blast_scache_page = blast_scache16_page;
307 else if (sc_lsize == 32)
308 r4k_blast_scache_page = blast_scache32_page;
309 else if (sc_lsize == 64)
310 r4k_blast_scache_page = blast_scache64_page;
311 else if (sc_lsize == 128)
312 r4k_blast_scache_page = blast_scache128_page;
315 static void (* r4k_blast_scache_page_indexed)(unsigned long addr);
317 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
318 static void __init r4k_blast_scache_page_indexed_setup(void)
319 =======
320 static void __cpuinit r4k_blast_scache_page_indexed_setup(void)
321 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
323 unsigned long sc_lsize = cpu_scache_line_size();
325 if (scache_size == 0)
326 r4k_blast_scache_page_indexed = (void *)cache_noop;
327 else if (sc_lsize == 16)
328 r4k_blast_scache_page_indexed = blast_scache16_page_indexed;
329 else if (sc_lsize == 32)
330 r4k_blast_scache_page_indexed = blast_scache32_page_indexed;
331 else if (sc_lsize == 64)
332 r4k_blast_scache_page_indexed = blast_scache64_page_indexed;
333 else if (sc_lsize == 128)
334 r4k_blast_scache_page_indexed = blast_scache128_page_indexed;
337 static void (* r4k_blast_scache)(void);
339 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
340 static void __init r4k_blast_scache_setup(void)
341 =======
342 static void __cpuinit r4k_blast_scache_setup(void)
343 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
345 unsigned long sc_lsize = cpu_scache_line_size();
347 if (scache_size == 0)
348 r4k_blast_scache = (void *)cache_noop;
349 else if (sc_lsize == 16)
350 r4k_blast_scache = blast_scache16;
351 else if (sc_lsize == 32)
352 r4k_blast_scache = blast_scache32;
353 else if (sc_lsize == 64)
354 r4k_blast_scache = blast_scache64;
355 else if (sc_lsize == 128)
356 r4k_blast_scache = blast_scache128;
359 static inline void local_r4k___flush_cache_all(void * args)
361 #if defined(CONFIG_CPU_LOONGSON2)
362 r4k_blast_scache();
363 return;
364 #endif
365 r4k_blast_dcache();
366 r4k_blast_icache();
368 switch (current_cpu_type()) {
369 case CPU_R4000SC:
370 case CPU_R4000MC:
371 case CPU_R4400SC:
372 case CPU_R4400MC:
373 case CPU_R10000:
374 case CPU_R12000:
375 case CPU_R14000:
376 r4k_blast_scache();
380 static void r4k___flush_cache_all(void)
382 r4k_on_each_cpu(local_r4k___flush_cache_all, NULL, 1, 1);
385 static inline int has_valid_asid(const struct mm_struct *mm)
387 #if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_MIPS_MT_SMTC)
388 int i;
390 for_each_online_cpu(i)
391 if (cpu_context(i, mm))
392 return 1;
394 return 0;
395 #else
396 return cpu_context(smp_processor_id(), mm);
397 #endif
400 static inline void local_r4k_flush_cache_range(void * args)
402 struct vm_area_struct *vma = args;
403 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
404 =======
405 int exec = vma->vm_flags & VM_EXEC;
406 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
408 if (!(has_valid_asid(vma->vm_mm)))
409 return;
411 r4k_blast_dcache();
412 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
413 =======
414 if (exec)
415 r4k_blast_icache();
416 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
419 static void r4k_flush_cache_range(struct vm_area_struct *vma,
420 unsigned long start, unsigned long end)
422 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
423 if (!cpu_has_dc_aliases)
424 return;
425 =======
426 int exec = vma->vm_flags & VM_EXEC;
427 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
429 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
430 r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1);
431 =======
432 if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc))
433 r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1);
434 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
437 static inline void local_r4k_flush_cache_mm(void * args)
439 struct mm_struct *mm = args;
441 if (!has_valid_asid(mm))
442 return;
445 * Kludge alert. For obscure reasons R4000SC and R4400SC go nuts if we
446 * only flush the primary caches but R10000 and R12000 behave sane ...
447 * R4000SC and R4400SC indexed S-cache ops also invalidate primary
448 * caches, so we can bail out early.
450 if (current_cpu_type() == CPU_R4000SC ||
451 current_cpu_type() == CPU_R4000MC ||
452 current_cpu_type() == CPU_R4400SC ||
453 current_cpu_type() == CPU_R4400MC) {
454 r4k_blast_scache();
455 return;
458 r4k_blast_dcache();
461 static void r4k_flush_cache_mm(struct mm_struct *mm)
463 if (!cpu_has_dc_aliases)
464 return;
466 r4k_on_each_cpu(local_r4k_flush_cache_mm, mm, 1, 1);
469 struct flush_cache_page_args {
470 struct vm_area_struct *vma;
471 unsigned long addr;
472 unsigned long pfn;
475 static inline void local_r4k_flush_cache_page(void *args)
477 struct flush_cache_page_args *fcp_args = args;
478 struct vm_area_struct *vma = fcp_args->vma;
479 unsigned long addr = fcp_args->addr;
480 struct page *page = pfn_to_page(fcp_args->pfn);
481 int exec = vma->vm_flags & VM_EXEC;
482 struct mm_struct *mm = vma->vm_mm;
483 pgd_t *pgdp;
484 pud_t *pudp;
485 pmd_t *pmdp;
486 pte_t *ptep;
487 void *vaddr;
490 * If ownes no valid ASID yet, cannot possibly have gotten
491 * this page into the cache.
493 if (!has_valid_asid(mm))
494 return;
496 addr &= PAGE_MASK;
497 pgdp = pgd_offset(mm, addr);
498 pudp = pud_offset(pgdp, addr);
499 pmdp = pmd_offset(pudp, addr);
500 ptep = pte_offset(pmdp, addr);
503 * If the page isn't marked valid, the page cannot possibly be
504 * in the cache.
506 if (!(pte_present(*ptep)))
507 return;
509 if ((mm == current->active_mm) && (pte_val(*ptep) & _PAGE_VALID))
510 vaddr = NULL;
511 else {
513 * Use kmap_coherent or kmap_atomic to do flushes for
514 * another ASID than the current one.
516 if (cpu_has_dc_aliases)
517 vaddr = kmap_coherent(page, addr);
518 else
519 vaddr = kmap_atomic(page, KM_USER0);
520 addr = (unsigned long)vaddr;
523 if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
524 r4k_blast_dcache_page(addr);
526 if (exec) {
527 if (vaddr && cpu_has_vtag_icache && mm == current->active_mm) {
528 int cpu = smp_processor_id();
530 if (cpu_context(cpu, mm) != 0)
531 drop_mmu_context(mm, cpu);
532 } else
533 r4k_blast_icache_page(addr);
536 if (vaddr) {
537 if (cpu_has_dc_aliases)
538 kunmap_coherent();
539 else
540 kunmap_atomic(vaddr, KM_USER0);
544 static void r4k_flush_cache_page(struct vm_area_struct *vma,
545 unsigned long addr, unsigned long pfn)
547 struct flush_cache_page_args args;
549 args.vma = vma;
550 args.addr = addr;
551 args.pfn = pfn;
553 r4k_on_each_cpu(local_r4k_flush_cache_page, &args, 1, 1);
556 static inline void local_r4k_flush_data_cache_page(void * addr)
558 r4k_blast_dcache_page((unsigned long) addr);
561 static void r4k_flush_data_cache_page(unsigned long addr)
563 if (in_atomic())
564 local_r4k_flush_data_cache_page((void *)addr);
565 else
566 r4k_on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr,
567 1, 1);
570 struct flush_icache_range_args {
571 unsigned long start;
572 unsigned long end;
575 static inline void local_r4k_flush_icache_range(void *args)
577 struct flush_icache_range_args *fir_args = args;
578 unsigned long start = fir_args->start;
579 unsigned long end = fir_args->end;
581 if (!cpu_has_ic_fills_f_dc) {
582 if (end - start >= dcache_size) {
583 r4k_blast_dcache();
584 } else {
585 R4600_HIT_CACHEOP_WAR_IMPL;
586 protected_blast_dcache_range(start, end);
590 if (end - start > icache_size)
591 r4k_blast_icache();
592 else
593 protected_blast_icache_range(start, end);
596 static void r4k_flush_icache_range(unsigned long start, unsigned long end)
598 struct flush_icache_range_args args;
600 args.start = start;
601 args.end = end;
603 r4k_on_each_cpu(local_r4k_flush_icache_range, &args, 1, 1);
604 instruction_hazard();
607 #ifdef CONFIG_DMA_NONCOHERENT
609 static void r4k_dma_cache_wback_inv(unsigned long addr, unsigned long size)
611 /* Catch bad driver code */
612 BUG_ON(size == 0);
614 if (cpu_has_inclusive_pcaches) {
615 if (size >= scache_size)
616 r4k_blast_scache();
617 else
618 blast_scache_range(addr, addr + size);
619 return;
623 * Either no secondary cache or the available caches don't have the
624 * subset property so we have to flush the primary caches
625 * explicitly
627 if (size >= dcache_size) {
628 r4k_blast_dcache();
629 } else {
630 R4600_HIT_CACHEOP_WAR_IMPL;
631 blast_dcache_range(addr, addr + size);
634 bc_wback_inv(addr, size);
637 static void r4k_dma_cache_inv(unsigned long addr, unsigned long size)
639 /* Catch bad driver code */
640 BUG_ON(size == 0);
642 if (cpu_has_inclusive_pcaches) {
643 if (size >= scache_size)
644 r4k_blast_scache();
645 else
646 blast_inv_scache_range(addr, addr + size);
647 return;
650 if (size >= dcache_size) {
651 r4k_blast_dcache();
652 } else {
653 R4600_HIT_CACHEOP_WAR_IMPL;
654 blast_inv_dcache_range(addr, addr + size);
657 bc_inv(addr, size);
659 #endif /* CONFIG_DMA_NONCOHERENT */
662 * While we're protected against bad userland addresses we don't care
663 * very much about what happens in that case. Usually a segmentation
664 * fault will dump the process later on anyway ...
666 static void local_r4k_flush_cache_sigtramp(void * arg)
668 unsigned long ic_lsize = cpu_icache_line_size();
669 unsigned long dc_lsize = cpu_dcache_line_size();
670 unsigned long sc_lsize = cpu_scache_line_size();
671 unsigned long addr = (unsigned long) arg;
673 R4600_HIT_CACHEOP_WAR_IMPL;
674 if (dc_lsize)
675 protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
676 if (!cpu_icache_snoops_remote_store && scache_size)
677 protected_writeback_scache_line(addr & ~(sc_lsize - 1));
678 if (ic_lsize)
679 protected_flush_icache_line(addr & ~(ic_lsize - 1));
680 if (MIPS4K_ICACHE_REFILL_WAR) {
681 __asm__ __volatile__ (
682 ".set push\n\t"
683 ".set noat\n\t"
684 ".set mips3\n\t"
685 #ifdef CONFIG_32BIT
686 "la $at,1f\n\t"
687 #endif
688 #ifdef CONFIG_64BIT
689 "dla $at,1f\n\t"
690 #endif
691 "cache %0,($at)\n\t"
692 "nop; nop; nop\n"
693 "1:\n\t"
694 ".set pop"
696 : "i" (Hit_Invalidate_I));
698 if (MIPS_CACHE_SYNC_WAR)
699 __asm__ __volatile__ ("sync");
702 static void r4k_flush_cache_sigtramp(unsigned long addr)
704 r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr, 1, 1);
707 static void r4k_flush_icache_all(void)
709 if (cpu_has_vtag_icache)
710 r4k_blast_icache();
713 static inline void rm7k_erratum31(void)
715 const unsigned long ic_lsize = 32;
716 unsigned long addr;
718 /* RM7000 erratum #31. The icache is screwed at startup. */
719 write_c0_taglo(0);
720 write_c0_taghi(0);
722 for (addr = INDEX_BASE; addr <= INDEX_BASE + 4096; addr += ic_lsize) {
723 __asm__ __volatile__ (
724 ".set push\n\t"
725 ".set noreorder\n\t"
726 ".set mips3\n\t"
727 "cache\t%1, 0(%0)\n\t"
728 "cache\t%1, 0x1000(%0)\n\t"
729 "cache\t%1, 0x2000(%0)\n\t"
730 "cache\t%1, 0x3000(%0)\n\t"
731 "cache\t%2, 0(%0)\n\t"
732 "cache\t%2, 0x1000(%0)\n\t"
733 "cache\t%2, 0x2000(%0)\n\t"
734 "cache\t%2, 0x3000(%0)\n\t"
735 "cache\t%1, 0(%0)\n\t"
736 "cache\t%1, 0x1000(%0)\n\t"
737 "cache\t%1, 0x2000(%0)\n\t"
738 "cache\t%1, 0x3000(%0)\n\t"
739 ".set pop\n"
741 : "r" (addr), "i" (Index_Store_Tag_I), "i" (Fill));
745 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
746 static char *way_string[] __initdata = { NULL, "direct mapped", "2-way",
747 =======
748 static char *way_string[] __cpuinitdata = { NULL, "direct mapped", "2-way",
749 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
750 "3-way", "4-way", "5-way", "6-way", "7-way", "8-way"
753 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
754 static void __init probe_pcache(void)
755 =======
756 static void __cpuinit probe_pcache(void)
757 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
759 struct cpuinfo_mips *c = &current_cpu_data;
760 unsigned int config = read_c0_config();
761 unsigned int prid = read_c0_prid();
762 unsigned long config1;
763 unsigned int lsize;
765 switch (c->cputype) {
766 case CPU_R4600: /* QED style two way caches? */
767 case CPU_R4700:
768 case CPU_R5000:
769 case CPU_NEVADA:
770 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
771 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
772 c->icache.ways = 2;
773 c->icache.waybit = __ffs(icache_size/2);
775 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
776 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
777 c->dcache.ways = 2;
778 c->dcache.waybit= __ffs(dcache_size/2);
780 c->options |= MIPS_CPU_CACHE_CDEX_P;
781 break;
783 case CPU_R5432:
784 case CPU_R5500:
785 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
786 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
787 c->icache.ways = 2;
788 c->icache.waybit= 0;
790 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
791 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
792 c->dcache.ways = 2;
793 c->dcache.waybit = 0;
795 c->options |= MIPS_CPU_CACHE_CDEX_P;
796 break;
798 case CPU_TX49XX:
799 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
800 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
801 c->icache.ways = 4;
802 c->icache.waybit= 0;
804 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
805 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
806 c->dcache.ways = 4;
807 c->dcache.waybit = 0;
809 c->options |= MIPS_CPU_CACHE_CDEX_P;
810 c->options |= MIPS_CPU_PREFETCH;
811 break;
813 case CPU_R4000PC:
814 case CPU_R4000SC:
815 case CPU_R4000MC:
816 case CPU_R4400PC:
817 case CPU_R4400SC:
818 case CPU_R4400MC:
819 case CPU_R4300:
820 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
821 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
822 c->icache.ways = 1;
823 c->icache.waybit = 0; /* doesn't matter */
825 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
826 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
827 c->dcache.ways = 1;
828 c->dcache.waybit = 0; /* does not matter */
830 c->options |= MIPS_CPU_CACHE_CDEX_P;
831 break;
833 case CPU_R10000:
834 case CPU_R12000:
835 case CPU_R14000:
836 icache_size = 1 << (12 + ((config & R10K_CONF_IC) >> 29));
837 c->icache.linesz = 64;
838 c->icache.ways = 2;
839 c->icache.waybit = 0;
841 dcache_size = 1 << (12 + ((config & R10K_CONF_DC) >> 26));
842 c->dcache.linesz = 32;
843 c->dcache.ways = 2;
844 c->dcache.waybit = 0;
846 c->options |= MIPS_CPU_PREFETCH;
847 break;
849 case CPU_VR4133:
850 write_c0_config(config & ~VR41_CONF_P4K);
851 case CPU_VR4131:
852 /* Workaround for cache instruction bug of VR4131 */
853 if (c->processor_id == 0x0c80U || c->processor_id == 0x0c81U ||
854 c->processor_id == 0x0c82U) {
855 config |= 0x00400000U;
856 if (c->processor_id == 0x0c80U)
857 config |= VR41_CONF_BP;
858 write_c0_config(config);
859 } else
860 c->options |= MIPS_CPU_CACHE_CDEX_P;
862 icache_size = 1 << (10 + ((config & CONF_IC) >> 9));
863 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
864 c->icache.ways = 2;
865 c->icache.waybit = __ffs(icache_size/2);
867 dcache_size = 1 << (10 + ((config & CONF_DC) >> 6));
868 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
869 c->dcache.ways = 2;
870 c->dcache.waybit = __ffs(dcache_size/2);
871 break;
873 case CPU_VR41XX:
874 case CPU_VR4111:
875 case CPU_VR4121:
876 case CPU_VR4122:
877 case CPU_VR4181:
878 case CPU_VR4181A:
879 icache_size = 1 << (10 + ((config & CONF_IC) >> 9));
880 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
881 c->icache.ways = 1;
882 c->icache.waybit = 0; /* doesn't matter */
884 dcache_size = 1 << (10 + ((config & CONF_DC) >> 6));
885 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
886 c->dcache.ways = 1;
887 c->dcache.waybit = 0; /* does not matter */
889 c->options |= MIPS_CPU_CACHE_CDEX_P;
890 break;
892 case CPU_RM7000:
893 rm7k_erratum31();
895 case CPU_RM9000:
896 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
897 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
898 c->icache.ways = 4;
899 c->icache.waybit = __ffs(icache_size / c->icache.ways);
901 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
902 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
903 c->dcache.ways = 4;
904 c->dcache.waybit = __ffs(dcache_size / c->dcache.ways);
906 #if !defined(CONFIG_SMP) || !defined(RM9000_CDEX_SMP_WAR)
907 c->options |= MIPS_CPU_CACHE_CDEX_P;
908 #endif
909 c->options |= MIPS_CPU_PREFETCH;
910 break;
912 case CPU_LOONGSON2:
913 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
914 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
915 if (prid & 0x3)
916 c->icache.ways = 4;
917 else
918 c->icache.ways = 2;
919 c->icache.waybit = 0;
921 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
922 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
923 if (prid & 0x3)
924 c->dcache.ways = 4;
925 else
926 c->dcache.ways = 2;
927 c->dcache.waybit = 0;
928 break;
930 default:
931 if (!(config & MIPS_CONF_M))
932 panic("Don't know how to probe P-caches on this cpu.");
935 * So we seem to be a MIPS32 or MIPS64 CPU
936 * So let's probe the I-cache ...
938 config1 = read_c0_config1();
940 if ((lsize = ((config1 >> 19) & 7)))
941 c->icache.linesz = 2 << lsize;
942 else
943 c->icache.linesz = lsize;
944 c->icache.sets = 64 << ((config1 >> 22) & 7);
945 c->icache.ways = 1 + ((config1 >> 16) & 7);
947 icache_size = c->icache.sets *
948 c->icache.ways *
949 c->icache.linesz;
950 c->icache.waybit = __ffs(icache_size/c->icache.ways);
952 if (config & 0x8) /* VI bit */
953 c->icache.flags |= MIPS_CACHE_VTAG;
956 * Now probe the MIPS32 / MIPS64 data cache.
958 c->dcache.flags = 0;
960 if ((lsize = ((config1 >> 10) & 7)))
961 c->dcache.linesz = 2 << lsize;
962 else
963 c->dcache.linesz= lsize;
964 c->dcache.sets = 64 << ((config1 >> 13) & 7);
965 c->dcache.ways = 1 + ((config1 >> 7) & 7);
967 dcache_size = c->dcache.sets *
968 c->dcache.ways *
969 c->dcache.linesz;
970 c->dcache.waybit = __ffs(dcache_size/c->dcache.ways);
972 c->options |= MIPS_CPU_PREFETCH;
973 break;
977 * Processor configuration sanity check for the R4000SC erratum
978 * #5. With page sizes larger than 32kB there is no possibility
979 * to get a VCE exception anymore so we don't care about this
980 * misconfiguration. The case is rather theoretical anyway;
981 * presumably no vendor is shipping his hardware in the "bad"
982 * configuration.
984 if ((prid & 0xff00) == PRID_IMP_R4000 && (prid & 0xff) < 0x40 &&
985 !(config & CONF_SC) && c->icache.linesz != 16 &&
986 PAGE_SIZE <= 0x8000)
987 panic("Improper R4000SC processor configuration detected");
989 /* compute a couple of other cache variables */
990 c->icache.waysize = icache_size / c->icache.ways;
991 c->dcache.waysize = dcache_size / c->dcache.ways;
993 c->icache.sets = c->icache.linesz ?
994 icache_size / (c->icache.linesz * c->icache.ways) : 0;
995 c->dcache.sets = c->dcache.linesz ?
996 dcache_size / (c->dcache.linesz * c->dcache.ways) : 0;
999 * R10000 and R12000 P-caches are odd in a positive way. They're 32kB
1000 * 2-way virtually indexed so normally would suffer from aliases. So
1001 * normally they'd suffer from aliases but magic in the hardware deals
1002 * with that for us so we don't need to take care ourselves.
1004 switch (c->cputype) {
1005 case CPU_20KC:
1006 case CPU_25KF:
1007 case CPU_SB1:
1008 case CPU_SB1A:
1009 c->dcache.flags |= MIPS_CACHE_PINDEX;
1010 break;
1012 case CPU_R10000:
1013 case CPU_R12000:
1014 case CPU_R14000:
1015 break;
1017 case CPU_24K:
1018 case CPU_34K:
1019 case CPU_74K:
1020 if ((read_c0_config7() & (1 << 16))) {
1021 /* effectively physically indexed dcache,
1022 thus no virtual aliases. */
1023 c->dcache.flags |= MIPS_CACHE_PINDEX;
1024 break;
1026 default:
1027 if (c->dcache.waysize > PAGE_SIZE)
1028 c->dcache.flags |= MIPS_CACHE_ALIASES;
1031 switch (c->cputype) {
1032 case CPU_20KC:
1034 * Some older 20Kc chips doesn't have the 'VI' bit in
1035 * the config register.
1037 c->icache.flags |= MIPS_CACHE_VTAG;
1038 break;
1040 case CPU_AU1000:
1041 case CPU_AU1500:
1042 case CPU_AU1100:
1043 case CPU_AU1550:
1044 case CPU_AU1200:
1045 case CPU_AU1210:
1046 case CPU_AU1250:
1047 c->icache.flags |= MIPS_CACHE_IC_F_DC;
1048 break;
1051 #ifdef CONFIG_CPU_LOONGSON2
1053 * LOONGSON2 has 4 way icache, but when using indexed cache op,
1054 * one op will act on all 4 ways
1056 c->icache.ways = 1;
1057 #endif
1059 printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n",
1060 icache_size >> 10,
1061 cpu_has_vtag_icache ? "VIVT" : "VIPT",
1062 way_string[c->icache.ways], c->icache.linesz);
1064 printk("Primary data cache %ldkB, %s, %s, %s, linesize %d bytes\n",
1065 dcache_size >> 10, way_string[c->dcache.ways],
1066 (c->dcache.flags & MIPS_CACHE_PINDEX) ? "PIPT" : "VIPT",
1067 (c->dcache.flags & MIPS_CACHE_ALIASES) ?
1068 "cache aliases" : "no aliases",
1069 c->dcache.linesz);
1073 * If you even _breathe_ on this function, look at the gcc output and make sure
1074 * it does not pop things on and off the stack for the cache sizing loop that
1075 * executes in KSEG1 space or else you will crash and burn badly. You have
1076 * been warned.
1078 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
1079 static int __init probe_scache(void)
1080 =======
1081 static int __cpuinit probe_scache(void)
1082 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
1084 unsigned long flags, addr, begin, end, pow2;
1085 unsigned int config = read_c0_config();
1086 struct cpuinfo_mips *c = &current_cpu_data;
1087 int tmp;
1089 if (config & CONF_SC)
1090 return 0;
1092 begin = (unsigned long) &_stext;
1093 begin &= ~((4 * 1024 * 1024) - 1);
1094 end = begin + (4 * 1024 * 1024);
1097 * This is such a bitch, you'd think they would make it easy to do
1098 * this. Away you daemons of stupidity!
1100 local_irq_save(flags);
1102 /* Fill each size-multiple cache line with a valid tag. */
1103 pow2 = (64 * 1024);
1104 for (addr = begin; addr < end; addr = (begin + pow2)) {
1105 unsigned long *p = (unsigned long *) addr;
1106 __asm__ __volatile__("nop" : : "r" (*p)); /* whee... */
1107 pow2 <<= 1;
1110 /* Load first line with zero (therefore invalid) tag. */
1111 write_c0_taglo(0);
1112 write_c0_taghi(0);
1113 __asm__ __volatile__("nop; nop; nop; nop;"); /* avoid the hazard */
1114 cache_op(Index_Store_Tag_I, begin);
1115 cache_op(Index_Store_Tag_D, begin);
1116 cache_op(Index_Store_Tag_SD, begin);
1118 /* Now search for the wrap around point. */
1119 pow2 = (128 * 1024);
1120 tmp = 0;
1121 for (addr = begin + (128 * 1024); addr < end; addr = begin + pow2) {
1122 cache_op(Index_Load_Tag_SD, addr);
1123 __asm__ __volatile__("nop; nop; nop; nop;"); /* hazard... */
1124 if (!read_c0_taglo())
1125 break;
1126 pow2 <<= 1;
1128 local_irq_restore(flags);
1129 addr -= begin;
1131 scache_size = addr;
1132 c->scache.linesz = 16 << ((config & R4K_CONF_SB) >> 22);
1133 c->scache.ways = 1;
1134 c->dcache.waybit = 0; /* does not matter */
1136 return 1;
1139 #if defined(CONFIG_CPU_LOONGSON2)
1140 static void __init loongson2_sc_init(void)
1142 struct cpuinfo_mips *c = &current_cpu_data;
1144 scache_size = 512*1024;
1145 c->scache.linesz = 32;
1146 c->scache.ways = 4;
1147 c->scache.waybit = 0;
1148 c->scache.waysize = scache_size / (c->scache.ways);
1149 c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways);
1150 pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n",
1151 scache_size >> 10, way_string[c->scache.ways], c->scache.linesz);
1153 c->options |= MIPS_CPU_INCLUSIVE_CACHES;
1155 #endif
1157 extern int r5k_sc_init(void);
1158 extern int rm7k_sc_init(void);
1159 extern int mips_sc_init(void);
1161 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
1162 static void __init setup_scache(void)
1163 =======
1164 static void __cpuinit setup_scache(void)
1165 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
1167 struct cpuinfo_mips *c = &current_cpu_data;
1168 unsigned int config = read_c0_config();
1169 int sc_present = 0;
1172 * Do the probing thing on R4000SC and R4400SC processors. Other
1173 * processors don't have a S-cache that would be relevant to the
1174 * Linux memory management.
1176 switch (c->cputype) {
1177 case CPU_R4000SC:
1178 case CPU_R4000MC:
1179 case CPU_R4400SC:
1180 case CPU_R4400MC:
1181 sc_present = run_uncached(probe_scache);
1182 if (sc_present)
1183 c->options |= MIPS_CPU_CACHE_CDEX_S;
1184 break;
1186 case CPU_R10000:
1187 case CPU_R12000:
1188 case CPU_R14000:
1189 scache_size = 0x80000 << ((config & R10K_CONF_SS) >> 16);
1190 c->scache.linesz = 64 << ((config >> 13) & 1);
1191 c->scache.ways = 2;
1192 c->scache.waybit= 0;
1193 sc_present = 1;
1194 break;
1196 case CPU_R5000:
1197 case CPU_NEVADA:
1198 #ifdef CONFIG_R5000_CPU_SCACHE
1199 r5k_sc_init();
1200 #endif
1201 return;
1203 case CPU_RM7000:
1204 case CPU_RM9000:
1205 #ifdef CONFIG_RM7000_CPU_SCACHE
1206 rm7k_sc_init();
1207 #endif
1208 return;
1210 #if defined(CONFIG_CPU_LOONGSON2)
1211 case CPU_LOONGSON2:
1212 loongson2_sc_init();
1213 return;
1214 #endif
1216 default:
1217 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
1218 c->isa_level == MIPS_CPU_ISA_M32R2 ||
1219 c->isa_level == MIPS_CPU_ISA_M64R1 ||
1220 c->isa_level == MIPS_CPU_ISA_M64R2) {
1221 #ifdef CONFIG_MIPS_CPU_SCACHE
1222 if (mips_sc_init ()) {
1223 scache_size = c->scache.ways * c->scache.sets * c->scache.linesz;
1224 printk("MIPS secondary cache %ldkB, %s, linesize %d bytes.\n",
1225 scache_size >> 10,
1226 way_string[c->scache.ways], c->scache.linesz);
1228 #else
1229 if (!(c->scache.flags & MIPS_CACHE_NOT_PRESENT))
1230 panic("Dunno how to handle MIPS32 / MIPS64 second level cache");
1231 #endif
1232 return;
1234 sc_present = 0;
1237 if (!sc_present)
1238 return;
1240 /* compute a couple of other cache variables */
1241 c->scache.waysize = scache_size / c->scache.ways;
1243 c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways);
1245 printk("Unified secondary cache %ldkB %s, linesize %d bytes.\n",
1246 scache_size >> 10, way_string[c->scache.ways], c->scache.linesz);
1248 c->options |= MIPS_CPU_INCLUSIVE_CACHES;
1251 void au1x00_fixup_config_od(void)
1254 * c0_config.od (bit 19) was write only (and read as 0)
1255 * on the early revisions of Alchemy SOCs. It disables the bus
1256 * transaction overlapping and needs to be set to fix various errata.
1258 switch (read_c0_prid()) {
1259 case 0x00030100: /* Au1000 DA */
1260 case 0x00030201: /* Au1000 HA */
1261 case 0x00030202: /* Au1000 HB */
1262 case 0x01030200: /* Au1500 AB */
1264 * Au1100 errata actually keeps silence about this bit, so we set it
1265 * just in case for those revisions that require it to be set according
1266 * to arch/mips/au1000/common/cputable.c
1268 case 0x02030200: /* Au1100 AB */
1269 case 0x02030201: /* Au1100 BA */
1270 case 0x02030202: /* Au1100 BC */
1271 set_c0_config(1 << 19);
1272 break;
1276 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
1277 static void __init coherency_setup(void)
1278 =======
1279 static void __cpuinit coherency_setup(void)
1280 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
1282 change_c0_config(CONF_CM_CMASK, CONF_CM_DEFAULT);
1285 * c0_status.cu=0 specifies that updates by the sc instruction use
1286 * the coherency mode specified by the TLB; 1 means cachable
1287 * coherent update on write will be used. Not all processors have
1288 * this bit and; some wire it to zero, others like Toshiba had the
1289 * silly idea of putting something else there ...
1291 switch (current_cpu_type()) {
1292 case CPU_R4000PC:
1293 case CPU_R4000SC:
1294 case CPU_R4000MC:
1295 case CPU_R4400PC:
1296 case CPU_R4400SC:
1297 case CPU_R4400MC:
1298 clear_c0_config(CONF_CU);
1299 break;
1301 * We need to catch the early Alchemy SOCs with
1302 * the write-only co_config.od bit and set it back to one...
1304 case CPU_AU1000: /* rev. DA, HA, HB */
1305 case CPU_AU1100: /* rev. AB, BA, BC ?? */
1306 case CPU_AU1500: /* rev. AB */
1307 au1x00_fixup_config_od();
1308 break;
1312 <<<<<<< HEAD:arch/mips/mm/c-r4k.c
1313 void __init r4k_cache_init(void)
1314 =======
1315 void __cpuinit r4k_cache_init(void)
1316 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/mips/mm/c-r4k.c
1318 extern void build_clear_page(void);
1319 extern void build_copy_page(void);
1320 extern char __weak except_vec2_generic;
1321 extern char __weak except_vec2_sb1;
1322 struct cpuinfo_mips *c = &current_cpu_data;
1324 switch (c->cputype) {
1325 case CPU_SB1:
1326 case CPU_SB1A:
1327 set_uncached_handler(0x100, &except_vec2_sb1, 0x80);
1328 break;
1330 default:
1331 set_uncached_handler(0x100, &except_vec2_generic, 0x80);
1332 break;
1335 probe_pcache();
1336 setup_scache();
1338 r4k_blast_dcache_page_setup();
1339 r4k_blast_dcache_page_indexed_setup();
1340 r4k_blast_dcache_setup();
1341 r4k_blast_icache_page_setup();
1342 r4k_blast_icache_page_indexed_setup();
1343 r4k_blast_icache_setup();
1344 r4k_blast_scache_page_setup();
1345 r4k_blast_scache_page_indexed_setup();
1346 r4k_blast_scache_setup();
1349 * Some MIPS32 and MIPS64 processors have physically indexed caches.
1350 * This code supports virtually indexed processors and will be
1351 * unnecessarily inefficient on physically indexed processors.
1353 if (c->dcache.linesz)
1354 shm_align_mask = max_t( unsigned long,
1355 c->dcache.sets * c->dcache.linesz - 1,
1356 PAGE_SIZE - 1);
1357 else
1358 shm_align_mask = PAGE_SIZE-1;
1359 flush_cache_all = cache_noop;
1360 __flush_cache_all = r4k___flush_cache_all;
1361 flush_cache_mm = r4k_flush_cache_mm;
1362 flush_cache_page = r4k_flush_cache_page;
1363 flush_cache_range = r4k_flush_cache_range;
1365 flush_cache_sigtramp = r4k_flush_cache_sigtramp;
1366 flush_icache_all = r4k_flush_icache_all;
1367 local_flush_data_cache_page = local_r4k_flush_data_cache_page;
1368 flush_data_cache_page = r4k_flush_data_cache_page;
1369 flush_icache_range = r4k_flush_icache_range;
1371 #ifdef CONFIG_DMA_NONCOHERENT
1372 _dma_cache_wback_inv = r4k_dma_cache_wback_inv;
1373 _dma_cache_wback = r4k_dma_cache_wback_inv;
1374 _dma_cache_inv = r4k_dma_cache_inv;
1375 #endif
1377 build_clear_page();
1378 build_copy_page();
1379 local_r4k___flush_cache_all(NULL);
1380 coherency_setup();