root/src/linux/ar531x/linux-2.6.23/arch/mips/mm/c-r4k.c

Revision 11387, 34.1 kB (checked in by BrainSlayer, 10 months ago)

patches from linux-mips

Line 
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.
5  *
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/init.h>
11 #include <linux/kernel.h>
12 #include <linux/sched.h>
13 #include <linux/mm.h>
14 #include <linux/bitops.h>
15
16 #include <asm/bcache.h>
17 #include <asm/bootinfo.h>
18 #include <asm/cache.h>
19 #include <asm/cacheops.h>
20 #include <asm/cpu.h>
21 #include <asm/cpu-features.h>
22 #include <asm/io.h>
23 #include <asm/page.h>
24 #include <asm/pgtable.h>
25 #include <asm/r4kcache.h>
26 #include <asm/sections.h>
27 #include <asm/system.h>
28 #include <asm/mmu_context.h>
29 #include <asm/war.h>
30 #include <asm/cacheflush.h> /* for run_uncached() */
31
32
33 /*
34  * Special Variant of smp_call_function for use by cache functions:
35  *
36  *  o No return value
37  *  o collapses to normal function call on UP kernels
38  *  o collapses to normal function call on systems with a single shared
39  *    primary cache.
40  */
41 static inline void r4k_on_each_cpu(void (*func) (void *info), void *info,
42                                    int retry, int wait)
43 {
44         preempt_disable();
45
46 #if !defined(CONFIG_MIPS_MT_SMP) && !defined(CONFIG_MIPS_MT_SMTC)
47         smp_call_function(func, info, retry, wait);
48 #endif
49         func(info);
50         preempt_enable();
51 }
52
53 /*
54  * Must die.
55  */
56 static unsigned long icache_size __read_mostly;
57 static unsigned long dcache_size __read_mostly;
58 static unsigned long scache_size __read_mostly;
59
60 /*
61  * Dummy cache handling routines for machines without boardcaches
62  */
63 static void cache_noop(void) {}
64
65 static struct bcache_ops no_sc_ops = {
66         .bc_enable = (void *)cache_noop,
67         .bc_disable = (void *)cache_noop,
68         .bc_wback_inv = (void *)cache_noop,
69         .bc_inv = (void *)cache_noop
70 };
71
72 struct bcache_ops *bcops = &no_sc_ops;
73
74 #define cpu_is_r4600_v1_x()     ((read_c0_prid() & 0xfffffff0) == 0x00002010)
75 #define cpu_is_r4600_v2_x()     ((read_c0_prid() & 0xfffffff0) == 0x00002020)
76
77 #define R4600_HIT_CACHEOP_WAR_IMPL                                      \
78 do {                                                                    \
79         if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())            \
80                 *(volatile unsigned long *)CKSEG1;                      \
81         if (R4600_V1_HIT_CACHEOP_WAR)                                   \
82                 __asm__ __volatile__("nop;nop;nop;nop");                \
83 } while (0)
84
85 static void (*r4k_blast_dcache_page)(unsigned long addr);
86
87 static inline void r4k_blast_dcache_page_dc32(unsigned long addr)
88 {
89         R4600_HIT_CACHEOP_WAR_IMPL;
90         blast_dcache32_page(addr);
91 }
92
93 static void __init r4k_blast_dcache_page_setup(void)
94 {
95         unsigned long  dc_lsize = cpu_dcache_line_size();
96
97         if (dc_lsize == 0)
98                 r4k_blast_dcache_page = (void *)cache_noop;
99         else if (dc_lsize == 16)
100                 r4k_blast_dcache_page = blast_dcache16_page;
101         else if (dc_lsize == 32)
102                 r4k_blast_dcache_page = r4k_blast_dcache_page_dc32;
103 }
104
105 static void (* r4k_blast_dcache_page_indexed)(unsigned long addr);
106
107 static void __init r4k_blast_dcache_page_indexed_setup(void)
108 {
109         unsigned long dc_lsize = cpu_dcache_line_size();
110
111         if (dc_lsize == 0)
112                 r4k_blast_dcache_page_indexed = (void *)cache_noop;
113         else if (dc_lsize == 16)
114                 r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed;
115         else if (dc_lsize == 32)
116                 r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed;
117 }
118
119 static void (* r4k_blast_dcache)(void);
120
121 static void __init r4k_blast_dcache_setup(void)
122 {
123         unsigned long dc_lsize = cpu_dcache_line_size();
124
125         if (dc_lsize == 0)
126                 r4k_blast_dcache = (void *)cache_noop;
127         else if (dc_lsize == 16)
128                 r4k_blast_dcache = blast_dcache16;
129         else if (dc_lsize == 32)
130                 r4k_blast_dcache = blast_dcache32;
131 }
132
133 /* force code alignment (used for TX49XX_ICACHE_INDEX_INV_WAR) */
134 #define JUMP_TO_ALIGN(order) \
135         __asm__ __volatile__( \
136                 "b\t1f\n\t" \
137                 ".align\t" #order "\n\t" \
138                 "1:\n\t" \
139                 )
140 #define CACHE32_UNROLL32_ALIGN  JUMP_TO_ALIGN(10) /* 32 * 32 = 1024 */
141 #define CACHE32_UNROLL32_ALIGN2 JUMP_TO_ALIGN(11)
142
143 static inline void blast_r4600_v1_icache32(void)
144 {
145         unsigned long flags;
146
147         local_irq_save(flags);
148         blast_icache32();
149         local_irq_restore(flags);
150 }
151
152 static inline void tx49_blast_icache32(void)
153 {
154         unsigned long start = INDEX_BASE;
155         unsigned long end = start + current_cpu_data.icache.waysize;
156         unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
157         unsigned long ws_end = current_cpu_data.icache.ways <<
158                                current_cpu_data.icache.waybit;
159         unsigned long ws, addr;
160
161         CACHE32_UNROLL32_ALIGN2;
162         /* I'm in even chunk.  blast odd chunks */
163         for (ws = 0; ws < ws_end; ws += ws_inc)
164                 for (addr = start + 0x400; addr < end; addr += 0x400 * 2)
165                         cache32_unroll32(addr|ws,Index_Invalidate_I);
166         CACHE32_UNROLL32_ALIGN;
167         /* I'm in odd chunk.  blast even chunks */
168         for (ws = 0; ws < ws_end; ws += ws_inc)
169                 for (addr = start; addr < end; addr += 0x400 * 2)
170                         cache32_unroll32(addr|ws,Index_Invalidate_I);
171 }
172
173 static inline void blast_icache32_r4600_v1_page_indexed(unsigned long page)
174 {
175         unsigned long flags;
176
177         local_irq_save(flags);
178         blast_icache32_page_indexed(page);
179         local_irq_restore(flags);
180 }
181
182 static inline void tx49_blast_icache32_page_indexed(unsigned long page)
183 {
184         unsigned long indexmask = current_cpu_data.icache.waysize - 1;
185         unsigned long start = INDEX_BASE + (page & indexmask);
186         unsigned long end = start + PAGE_SIZE;
187         unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
188         unsigned long ws_end = current_cpu_data.icache.ways <<
189                                current_cpu_data.icache.waybit;
190         unsigned long ws, addr;
191
192         CACHE32_UNROLL32_ALIGN2;
193         /* I'm in even chunk.  blast odd chunks */
194         for (ws = 0; ws < ws_end; ws += ws_inc)
195                 for (addr = start + 0x400; addr < end; addr += 0x400 * 2)
196                         cache32_unroll32(addr|ws,Index_Invalidate_I);
197         CACHE32_UNROLL32_ALIGN;
198         /* I'm in odd chunk.  blast even chunks */
199         for (ws = 0; ws < ws_end; ws += ws_inc)
200                 for (addr = start; addr < end; addr += 0x400 * 2)
201                         cache32_unroll32(addr|ws,Index_Invalidate_I);
202 }
203
204 static void (* r4k_blast_icache_page)(unsigned long addr);
205
206 static void __init r4k_blast_icache_page_setup(void)
207 {
208         unsigned long ic_lsize = cpu_icache_line_size();
209
210         if (ic_lsize == 0)
211                 r4k_blast_icache_page = (void *)cache_noop;
212         else if (ic_lsize == 16)
213                 r4k_blast_icache_page = blast_icache16_page;
214         else if (ic_lsize == 32)
215                 r4k_blast_icache_page = blast_icache32_page;
216         else if (ic_lsize == 64)
217                 r4k_blast_icache_page = blast_icache64_page;
218 }
219
220
221 static void (* r4k_blast_icache_page_indexed)(unsigned long addr);
222
223 static void __init r4k_blast_icache_page_indexed_setup(void)
224 {
225         unsigned long ic_lsize = cpu_icache_line_size();
226
227         if (ic_lsize == 0)
228                 r4k_blast_icache_page_indexed = (void *)cache_noop;
229         else if (ic_lsize == 16)
230                 r4k_blast_icache_page_indexed = blast_icache16_page_indexed;
231         else if (ic_lsize == 32) {
232                 if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x())
233                         r4k_blast_icache_page_indexed =
234                                 blast_icache32_r4600_v1_page_indexed;
235                 else if (TX49XX_ICACHE_INDEX_INV_WAR)
236                         r4k_blast_icache_page_indexed =
237                                 tx49_blast_icache32_page_indexed;
238                 else
239                         r4k_blast_icache_page_indexed =
240                                 blast_icache32_page_indexed;
241         } else if (ic_lsize == 64)
242                 r4k_blast_icache_page_indexed = blast_icache64_page_indexed;
243 }
244
245 static void (* r4k_blast_icache)(void);
246
247 static void __init r4k_blast_icache_setup(void)
248 {
249         unsigned long ic_lsize = cpu_icache_line_size();
250
251         if (ic_lsize == 0)
252                 r4k_blast_icache = (void *)cache_noop;
253         else if (ic_lsize == 16)
254                 r4k_blast_icache = blast_icache16;
255         else if (ic_lsize == 32) {
256                 if (R4600_V1_INDEX_ICACHEOP_WAR && cpu_is_r4600_v1_x())
257                         r4k_blast_icache = blast_r4600_v1_icache32;
258                 else if (TX49XX_ICACHE_INDEX_INV_WAR)
259                         r4k_blast_icache = tx49_blast_icache32;
260                 else
261                         r4k_blast_icache = blast_icache32;
262         } else if (ic_lsize == 64)
263                 r4k_blast_icache = blast_icache64;
264 }
265
266 static void (* r4k_blast_scache_page)(unsigned long addr);
267
268 static void __init r4k_blast_scache_page_setup(void)
269 {
270         unsigned long sc_lsize = cpu_scache_line_size();
271
272         if (scache_size == 0)
273                 r4k_blast_scache_page = (void *)cache_noop;
274         else if (sc_lsize == 16)
275                 r4k_blast_scache_page = blast_scache16_page;
276         else if (sc_lsize == 32)
277                 r4k_blast_scache_page = blast_scache32_page;
278         else if (sc_lsize == 64)
279                 r4k_blast_scache_page = blast_scache64_page;
280         else if (sc_lsize == 128)
281                 r4k_blast_scache_page = blast_scache128_page;
282 }
283
284 static void (* r4k_blast_scache_page_indexed)(unsigned long addr);
285
286 static void __init r4k_blast_scache_page_indexed_setup(void)
287 {
288         unsigned long sc_lsize = cpu_scache_line_size();
289
290         if (scache_size == 0)
291                 r4k_blast_scache_page_indexed = (void *)cache_noop;
292         else if (sc_lsize == 16)
293                 r4k_blast_scache_page_indexed = blast_scache16_page_indexed;
294         else if (sc_lsize == 32)
295                 r4k_blast_scache_page_indexed = blast_scache32_page_indexed;
296         else if (sc_lsize == 64)
297                 r4k_blast_scache_page_indexed = blast_scache64_page_indexed;
298         else if (sc_lsize == 128)
299                 r4k_blast_scache_page_indexed = blast_scache128_page_indexed;
300 }
301
302 static void (* r4k_blast_scache)(void);
303
304 static void __init r4k_blast_scache_setup(void)
305 {
306         unsigned long sc_lsize = cpu_scache_line_size();
307
308         if (scache_size == 0)
309                 r4k_blast_scache = (void *)cache_noop;
310         else if (sc_lsize == 16)
311                 r4k_blast_scache = blast_scache16;
312         else if (sc_lsize == 32)
313                 r4k_blast_scache = blast_scache32;
314         else if (sc_lsize == 64)
315                 r4k_blast_scache = blast_scache64;
316         else if (sc_lsize == 128)
317                 r4k_blast_scache = blast_scache128;
318 }
319
320 /*
321  * This is former mm's flush_cache_all() which really should be
322  * flush_cache_vunmap these days ...
323  */
324 static inline void local_r4k_flush_cache_all(void * args)
325 {
326         r4k_blast_dcache();
327 }
328
329 static void r4k_flush_cache_all(void)
330 {
331         if (!cpu_has_dc_aliases)
332                 return;
333
334         r4k_on_each_cpu(local_r4k_flush_cache_all, NULL, 1, 1);
335 }
336
337 static inline void local_r4k___flush_cache_all(void * args)
338 {
339 #if defined(CONFIG_CPU_LOONGSON2)
340         r4k_blast_scache();
341         return;
342 #endif
343         r4k_blast_dcache();
344         r4k_blast_icache();
345
346         switch (current_cpu_data.cputype) {
347         case CPU_R4000SC:
348         case CPU_R4000MC:
349         case CPU_R4400SC:
350         case CPU_R4400MC:
351         case CPU_R10000:
352         case CPU_R12000:
353         case CPU_R14000:
354                 r4k_blast_scache();
355         }
356 }
357
358 static void r4k___flush_cache_all(void)
359 {
360         r4k_on_each_cpu(local_r4k___flush_cache_all, NULL, 1, 1);
361 }
362
363 static inline int has_valid_asid(const struct mm_struct *mm)
364 {
365 #if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_MIPS_MT_SMTC)
366         int i;
367
368         for_each_online_cpu(i)
369                 if (cpu_context(i, mm))
370                         return 1;
371
372         return 0;
373 #else
374         return cpu_context(smp_processor_id(), mm);
375 #endif
376 }
377
378 static inline void local_r4k_flush_cache_range(void * args)
379 {
380         struct vm_area_struct *vma = args;
381         int exec = vma->vm_flags & VM_EXEC;
382
383         if (!(has_valid_asid(vma->vm_mm)))
384                 return;
385
386         r4k_blast_dcache();
387         if (exec)
388                 r4k_blast_icache();
389 }
390
391 static void r4k_flush_cache_range(struct vm_area_struct *vma,
392         unsigned long start, unsigned long end)
393 {
394         int exec = vma->vm_flags & VM_EXEC;
395
396         if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc))
397                 r4k_on_each_cpu(local_r4k_flush_cache_range, vma, 1, 1);
398 }
399
400 static inline void local_r4k_flush_cache_mm(void * args)
401 {
402         struct mm_struct *mm = args;
403
404         if (!has_valid_asid(mm))
405                 return;
406
407         /*
408          * Kludge alert.  For obscure reasons R4000SC and R4400SC go nuts if we
409          * only flush the primary caches but R10000 and R12000 behave sane ...
410          * R4000SC and R4400SC indexed S-cache ops also invalidate primary
411          * caches, so we can bail out early.
412          */
413         if (current_cpu_data.cputype == CPU_R4000SC ||
414             current_cpu_data.cputype == CPU_R4000MC ||
415             current_cpu_data.cputype == CPU_R4400SC ||
416             current_cpu_data.cputype == CPU_R4400MC) {
417                 r4k_blast_scache();
418                 return;
419         }
420
421         r4k_blast_dcache();
422 }
423
424 static void r4k_flush_cache_mm(struct mm_struct *mm)
425 {
426         if (!cpu_has_dc_aliases)
427                 return;
428
429         r4k_on_each_cpu(local_r4k_flush_cache_mm, mm, 1, 1);
430 }
431
432 struct flush_cache_page_args {
433         struct vm_area_struct *vma;
434         unsigned long addr;
435         unsigned long pfn;
436 };
437
438 static inline void local_r4k_flush_cache_page(void *args)
439 {
440         struct flush_cache_page_args *fcp_args = args;
441         struct vm_area_struct *vma = fcp_args->vma;
442         unsigned long addr = fcp_args->addr;
443         unsigned long paddr = fcp_args->pfn << PAGE_SHIFT;
444         int exec = vma->vm_flags & VM_EXEC;
445         struct mm_struct *mm = vma->vm_mm;
446         pgd_t *pgdp;
447         pud_t *pudp;
448         pmd_t *pmdp;
449         pte_t *ptep;
450
451         /*
452          * If ownes no valid ASID yet, cannot possibly have gotten
453          * this page into the cache.
454          */
455         if (!has_valid_asid(mm))
456                 return;
457
458         addr &= PAGE_MASK;
459         pgdp = pgd_offset(mm, addr);
460         pudp = pud_offset(pgdp, addr);
461         pmdp = pmd_offset(pudp, addr);
462         ptep = pte_offset(pmdp, addr);
463
464         /*
465          * If the page isn't marked valid, the page cannot possibly be
466          * in the cache.
467          */
468         if (!(pte_val(*ptep) & _PAGE_PRESENT))
469                 return;
470
471         /*
472          * Doing flushes for another ASID than the current one is
473          * too difficult since stupid R4k caches do a TLB translation
474          * for every cache flush operation.  So we do indexed flushes
475          * in that case, which doesn't overly flush the cache too much.
476          */
477         if ((mm == current->active_mm) && (pte_val(*ptep) & _PAGE_VALID)) {
478                 if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
479                         r4k_blast_dcache_page(addr);
480                         if (exec && !cpu_icache_snoops_remote_store)
481                                 r4k_blast_scache_page(addr);
482                 }
483                 if (exec)
484                         r4k_blast_icache_page(addr);
485
486                 return;
487         }
488
489         /*
490          * Do indexed flush, too much work to get the (possible) TLB refills
491          * to work correctly.
492          */
493         if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) {
494                 r4k_blast_dcache_page_indexed(cpu_has_pindexed_dcache ?
495                                               paddr : addr);
496                 if (exec && !cpu_icache_snoops_remote_store) {
497                         r4k_blast_scache_page_indexed(paddr);
498                 }
499         }
500         if (exec) {
501                 if (cpu_has_vtag_icache && mm == current->active_mm) {
502                         int cpu = smp_processor_id();
503
504                         if (cpu_context(cpu, mm) != 0)
505                                 drop_mmu_context(mm, cpu);
506                 } else
507                         r4k_blast_icache_page_indexed(addr);
508         }
509 }
510
511 static void r4k_flush_cache_page(struct vm_area_struct *vma,
512         unsigned long addr, unsigned long pfn)
513 {
514         struct flush_cache_page_args args;
515
516         args.vma = vma;
517         args.addr = addr;
518         args.pfn = pfn;
519
520         r4k_on_each_cpu(local_r4k_flush_cache_page, &args, 1, 1);
521 }
522
523 static inline void local_r4k_flush_data_cache_page(void * addr)
524 {
525         r4k_blast_dcache_page((unsigned long) addr);
526 }
527
528 static void r4k_flush_data_cache_page(unsigned long addr)
529 {
530         r4k_on_each_cpu(local_r4k_flush_data_cache_page, (void *) addr, 1, 1);
531 }
532
533 struct flush_icache_range_args {
534         unsigned long start;
535         unsigned long end;
536 };
537
538 static inline void local_r4k_flush_icache_range(void *args)
539 {
540         struct flush_icache_range_args *fir_args = args;
541         unsigned long start = fir_args->start;
542         unsigned long end = fir_args->end;
543
544         if (!cpu_has_ic_fills_f_dc) {
545                 if (end - start >= dcache_size) {
546                         r4k_blast_dcache();
547                 } else {
548                         R4600_HIT_CACHEOP_WAR_IMPL;
549                         protected_blast_dcache_range(start, end);
550                 }
551
552                 if (!cpu_icache_snoops_remote_store && scache_size) {
553                         if (end - start > scache_size)
554                                 r4k_blast_scache();
555                         else
556                                 protected_blast_scache_range(start, end);
557                 }
558         }
559
560         if (end - start > icache_size)
561                 r4k_blast_icache();
562         else
563                 protected_blast_icache_range(start, end);
564 }
565
566 static void r4k_flush_icache_range(unsigned long start, unsigned long end)
567 {
568         struct flush_icache_range_args args;
569
570         args.start = start;
571         args.end = end;
572
573         r4k_on_each_cpu(local_r4k_flush_icache_range, &args, 1, 1);
574         instruction_hazard();
575 }
576
577 #ifdef CONFIG_DMA_NONCOHERENT
578
579 static void r4k_dma_cache_wback_inv(unsigned long addr, unsigned long size)
580 {
581         /* Catch bad driver code */
582         BUG_ON(size == 0);
583
584         if (cpu_has_inclusive_pcaches) {
585                 if (size >= scache_size)
586                         r4k_blast_scache();
587                 else
588                         blast_scache_range(addr, addr + size);
589                 return;
590         }
591
592         /*
593          * Either no secondary cache or the available caches don't have the
594          * subset property so we have to flush the primary caches
595          * explicitly
596          */
597         if (size >= dcache_size) {
598                 r4k_blast_dcache();
599         } else {
600                 R4600_HIT_CACHEOP_WAR_IMPL;
601                 blast_dcache_range(addr, addr + size);
602         }
603
604         bc_wback_inv(addr, size);
605 }
606
607 static void r4k_dma_cache_inv(unsigned long addr, unsigned long size)
608 {
609         /* Catch bad driver code */
610         BUG_ON(size == 0);
611
612         if (cpu_has_inclusive_pcaches) {
613                 if (size >= scache_size)
614                         r4k_blast_scache();
615                 else
616                         blast_scache_range(addr, addr + size);
617                 return;
618         }
619
620         if (size >= dcache_size) {
621                 r4k_blast_dcache();
622         } else {
623                 R4600_HIT_CACHEOP_WAR_IMPL;
624                 blast_dcache_range(addr, addr + size);
625         }
626
627         bc_inv(addr, size);
628 }
629 #endif /* CONFIG_DMA_NONCOHERENT */
630
631 /*
632  * While we're protected against bad userland addresses we don't care
633  * very much about what happens in that case.  Usually a segmentation
634  * fault will dump the process later on anyway ...
635  */
636 static void local_r4k_flush_cache_sigtramp(void * arg)
637 {
638         unsigned long ic_lsize = cpu_icache_line_size();
639         unsigned long dc_lsize = cpu_dcache_line_size();
640         unsigned long sc_lsize = cpu_scache_line_size();
641         unsigned long addr = (unsigned long) arg;
642
643         R4600_HIT_CACHEOP_WAR_IMPL;
644         if (dc_lsize)
645                 protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
646         if (!cpu_icache_snoops_remote_store && scache_size)
647                 protected_writeback_scache_line(addr & ~(sc_lsize - 1));
648         if (ic_lsize)
649                 protected_flush_icache_line(addr & ~(ic_lsize - 1));
650         if (MIPS4K_ICACHE_REFILL_WAR) {
651                 __asm__ __volatile__ (
652                         ".set push\n\t"
653                         ".set noat\n\t"
654                         ".set mips3\n\t"
655 #ifdef CONFIG_32BIT
656                         "la     $at,1f\n\t"
657 #endif
658 #ifdef CONFIG_64BIT
659                         "dla    $at,1f\n\t"
660 #endif
661                         "cache  %0,($at)\n\t"
662                         "nop; nop; nop\n"
663                         "1:\n\t"
664                         ".set pop"
665                         :
666                         : "i" (Hit_Invalidate_I));
667         }
668         if (MIPS_CACHE_SYNC_WAR)
669                 __asm__ __volatile__ ("sync");
670 }
671
672 static void r4k_flush_cache_sigtramp(unsigned long addr)
673 {
674         r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr, 1, 1);
675 }
676
677 static void r4k_flush_icache_all(void)
678 {
679         if (cpu_has_vtag_icache)
680                 r4k_blast_icache();
681 }
682
683 static inline void rm7k_erratum31(void)
684 {
685         const unsigned long ic_lsize = 32;
686         unsigned long addr;
687
688         /* RM7000 erratum #31. The icache is screwed at startup. */
689         write_c0_taglo(0);
690         write_c0_taghi(0);
691
692         for (addr = INDEX_BASE; addr <= INDEX_BASE + 4096; addr += ic_lsize) {
693                 __asm__ __volatile__ (
694                         ".set push\n\t"
695                         ".set noreorder\n\t"
696                         ".set mips3\n\t"
697                         "cache\t%1, 0(%0)\n\t"
698                         "cache\t%1, 0x1000(%0)\n\t"
699                         "cache\t%1, 0x2000(%0)\n\t"
700                         "cache\t%1, 0x3000(%0)\n\t"
701                         "cache\t%2, 0(%0)\n\t"
702                         "cache\t%2, 0x1000(%0)\n\t"
703                         "cache\t%2, 0x2000(%0)\n\t"
704                         "cache\t%2, 0x3000(%0)\n\t"
705                         "cache\t%1, 0(%0)\n\t"
706                         "cache\t%1, 0x1000(%0)\n\t"
707                         "cache\t%1, 0x2000(%0)\n\t"
708                         "cache\t%1, 0x3000(%0)\n\t"
709                         ".set pop\n"
710                         :
711                         : "r" (addr), "i" (Index_Store_Tag_I), "i" (Fill));
712         }
713 }
714
715 static char *way_string[] __initdata = { NULL, "direct mapped", "2-way",
716         "3-way", "4-way", "5-way", "6-way", "7-way", "8-way"
717 };
718
719 static void __init probe_pcache(void)
720 {
721         struct cpuinfo_mips *c = &current_cpu_data;
722         unsigned int config = read_c0_config();
723         unsigned int prid = read_c0_prid();
724         unsigned long config1;
725         unsigned int lsize;
726
727         switch (c->cputype) {
728         case CPU_R4600:                 /* QED style two way caches? */
729         case CPU_R4700:
730         case CPU_R5000:
731         case CPU_NEVADA:
732                 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
733                 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
734                 c->icache.ways = 2;
735                 c->icache.waybit = __ffs(icache_size/2);
736
737                 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
738                 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
739                 c->dcache.ways = 2;
740                 c->dcache.waybit= __ffs(dcache_size/2);
741
742                 c->options |= MIPS_CPU_CACHE_CDEX_P;
743                 break;
744
745         case CPU_R5432:
746         case CPU_R5500:
747                 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
748                 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
749                 c->icache.ways = 2;
750                 c->icache.waybit= 0;
751
752                 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
753                 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
754                 c->dcache.ways = 2;
755                 c->dcache.waybit = 0;
756
757                 c->options |= MIPS_CPU_CACHE_CDEX_P;
758                 break;
759
760         case CPU_TX49XX:
761                 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
762                 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
763                 c->icache.ways = 4;
764                 c->icache.waybit= 0;
765
766                 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
767                 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
768                 c->dcache.ways = 4;
769                 c->dcache.waybit = 0;
770
771                 c->options |= MIPS_CPU_CACHE_CDEX_P;
772                 c->options |= MIPS_CPU_PREFETCH;
773                 break;
774
775         case CPU_R4000PC:
776         case CPU_R4000SC:
777         case CPU_R4000MC:
778         case CPU_R4400PC:
779         case CPU_R4400SC:
780         case CPU_R4400MC:
781         case CPU_R4300:
782                 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
783                 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
784                 c->icache.ways = 1;
785                 c->icache.waybit = 0;   /* doesn't matter */
786
787                 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
788                 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
789                 c->dcache.ways = 1;
790                 c->dcache.waybit = 0;   /* does not matter */
791
792                 c->options |= MIPS_CPU_CACHE_CDEX_P;
793                 break;
794
795         case CPU_R10000:
796         case CPU_R12000:
797         case CPU_R14000:
798                 icache_size = 1 << (12 + ((config & R10K_CONF_IC) >> 29));
799                 c->icache.linesz = 64;
800                 c->icache.ways = 2;
801                 c->icache.waybit = 0;
802
803                 dcache_size = 1 << (12 + ((config & R10K_CONF_DC) >> 26));
804                 c->dcache.linesz = 32;
805                 c->dcache.ways = 2;
806                 c->dcache.waybit = 0;
807
808                 c->options |= MIPS_CPU_PREFETCH;
809                 break;
810
811         case CPU_VR4133:
812                 write_c0_config(config & ~VR41_CONF_P4K);
813         case CPU_VR4131:
814                 /* Workaround for cache instruction bug of VR4131 */
815                 if (c->processor_id == 0x0c80U || c->processor_id == 0x0c81U ||
816                     c->processor_id == 0x0c82U) {
817                         config |= 0x00400000U;
818                         if (c->processor_id == 0x0c80U)
819                                 config |= VR41_CONF_BP;
820                         write_c0_config(config);
821                 } else
822                         c->options |= MIPS_CPU_CACHE_CDEX_P;
823
824                 icache_size = 1 << (10 + ((config & CONF_IC) >> 9));
825                 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
826                 c->icache.ways = 2;
827                 c->icache.waybit = __ffs(icache_size/2);
828
829                 dcache_size = 1 << (10 + ((config & CONF_DC) >> 6));
830                 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
831                 c->dcache.ways = 2;
832                 c->dcache.waybit = __ffs(dcache_size/2);
833                 break;
834
835         case CPU_VR41XX:
836         case CPU_VR4111:
837         case CPU_VR4121:
838         case CPU_VR4122:
839         case CPU_VR4181:
840         case CPU_VR4181A:
841                 icache_size = 1 << (10 + ((config & CONF_IC) >> 9));
842                 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
843                 c->icache.ways = 1;
844                 c->icache.waybit = 0;   /* doesn't matter */
845
846                 dcache_size = 1 << (10 + ((config & CONF_DC) >> 6));
847                 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
848                 c->dcache.ways = 1;
849                 c->dcache.waybit = 0;   /* does not matter */
850
851                 c->options |= MIPS_CPU_CACHE_CDEX_P;
852                 break;
853
854         case CPU_RM7000:
855                 rm7k_erratum31();
856
857         case CPU_RM9000:
858                 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
859                 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
860                 c->icache.ways = 4;
861                 c->icache.waybit = __ffs(icache_size / c->icache.ways);
862
863                 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
864                 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
865                 c->dcache.ways = 4;
866                 c->dcache.waybit = __ffs(dcache_size / c->dcache.ways);
867
868 #if !defined(CONFIG_SMP) || !defined(RM9000_CDEX_SMP_WAR)
869                 c->options |= MIPS_CPU_CACHE_CDEX_P;
870 #endif
871                 c->options |= MIPS_CPU_PREFETCH;
872                 break;
873
874         case CPU_LOONGSON2:
875                 icache_size = 1 << (12 + ((config & CONF_IC) >> 9));
876                 c->icache.linesz = 16 << ((config & CONF_IB) >> 5);
877                 if (prid & 0x3)
878                         c->icache.ways = 4;
879                 else
880                         c->icache.ways = 2;
881                 c->icache.waybit = 0;
882
883                 dcache_size = 1 << (12 + ((config & CONF_DC) >> 6));
884                 c->dcache.linesz = 16 << ((config & CONF_DB) >> 4);
885                 if (prid & 0x3)
886                         c->dcache.ways = 4;
887                 else
888                         c->dcache.ways = 2;
889                 c->dcache.waybit = 0;
890                 break;
891
892         default:
893                 if (!(config & MIPS_CONF_M))
894                         panic("Don't know how to probe P-caches on this cpu.");
895
896                 /*
897                  * So we seem to be a MIPS32 or MIPS64 CPU
898                  * So let's probe the I-cache ...
899                  */
900                 config1 = read_c0_config1();
901
902                 if ((lsize = ((config1 >> 19) & 7)))
903                         c->icache.linesz = 2 << lsize;
904                 else
905                         c->icache.linesz = lsize;
906                 c->icache.sets = 64 << ((config1 >> 22) & 7);
907                 c->icache.ways = 1 + ((config1 >> 16) & 7);
908
909                 icache_size = c->icache.sets *
910                               c->icache.ways *
911                               c->icache.linesz;
912                 c->icache.waybit = __ffs(icache_size/c->icache.ways);
913
914                 if (config & 0x8)               /* VI bit */
915                         c->icache.flags |= MIPS_CACHE_VTAG;
916
917                 /*
918                  * Now probe the MIPS32 / MIPS64 data cache.
919                  */
920                 c->dcache.flags = 0;
921
922                 if ((lsize = ((config1 >> 10) & 7)))
923                         c->dcache.linesz = 2 << lsize;
924                 else
925                         c->dcache.linesz= lsize;
926                 c->dcache.sets = 64 << ((config1 >> 13) & 7);
927                 c->dcache.ways = 1 + ((config1 >> 7) & 7);
928
929                 dcache_size = c->dcache.sets *
930                               c->dcache.ways *
931                               c->dcache.linesz;
932                 c->dcache.waybit = __ffs(dcache_size/c->dcache.ways);
933
934                 c->options |= MIPS_CPU_PREFETCH;
935                 break;
936         }
937
938         /*
939          * Processor configuration sanity check for the R4000SC erratum
940          * #5.  With page sizes larger than 32kB there is no possibility
941          * to get a VCE exception anymore so we don't care about this
942          * misconfiguration.  The case is rather theoretical anyway;
943          * presumably no vendor is shipping his hardware in the "bad"
944          * configuration.
945          */
946         if ((prid & 0xff00) == PRID_IMP_R4000 && (prid & 0xff) < 0x40 &&
947             !(config & CONF_SC) && c->icache.linesz != 16 &&
948             PAGE_SIZE <= 0x8000)
949                 panic("Improper R4000SC processor configuration detected");
950
951         /* compute a couple of other cache variables */
952         c->icache.waysize = icache_size / c->icache.ways;
953         c->dcache.waysize = dcache_size / c->dcache.ways;
954
955         c->icache.sets = c->icache.linesz ?
956                 icache_size / (c->icache.linesz * c->icache.ways) : 0;
957         c->dcache.sets = c->dcache.linesz ?
958                 dcache_size / (c->dcache.linesz * c->dcache.ways) : 0;
959
960         /*
961          * R10000 and R12000 P-caches are odd in a positive way.  They're 32kB
962          * 2-way virtually indexed so normally would suffer from aliases.  So
963          * normally they'd suffer from aliases but magic in the hardware deals
964          * with that for us so we don't need to take care ourselves.
965          */
966         switch (c->cputype) {
967         case CPU_20KC:
968         case CPU_25KF:
969                 c->dcache.flags |= MIPS_CACHE_PINDEX;
970         case CPU_R10000:
971         case CPU_R12000:
972         case CPU_R14000:
973         case CPU_SB1:
974                 break;
975         case CPU_24K:
976         case CPU_34K:
977         case CPU_74K:
978                 if ((read_c0_config7() & (1 << 16))) {
979                         /* effectively physically indexed dcache,
980                            thus no virtual aliases. */
981                         c->dcache.flags |= MIPS_CACHE_PINDEX;
982                         break;
983                 }
984         default:
985                 if (c->dcache.waysize > PAGE_SIZE)
986                         c->dcache.flags |= MIPS_CACHE_ALIASES;
987         }
988
989         switch (c->cputype) {
990         case CPU_20KC:
991                 /*
992                  * Some older 20Kc chips doesn't have the 'VI' bit in
993                  * the config register.
994                  */
995                 c->icache.flags |= MIPS_CACHE_VTAG;
996                 break;
997
998         case CPU_AU1000:
999         case CPU_AU1500:
1000         case CPU_AU1100:
1001         case CPU_AU1550:
1002         case CPU_AU1200:
1003                 c->icache.flags |= MIPS_CACHE_IC_F_DC;
1004                 break;
1005         }
1006
1007 #ifdef  CONFIG_CPU_LOONGSON2
1008         /*
1009          * LOONGSON2 has 4 way icache, but when using indexed cache op,
1010          * one op will act on all 4 ways
1011          */
1012         c->icache.ways = 1;
1013 #endif
1014
1015         printk("Primary instruction cache %ldkB, %s, %s, linesize %d bytes.\n",
1016                icache_size >> 10,
1017                cpu_has_vtag_icache ? "virtually tagged" : "physically tagged",
1018                way_string[c->icache.ways], c->icache.linesz);
1019
1020         printk("Primary data cache %ldkB, %s, linesize %d bytes.\n",
1021                dcache_size >> 10, way_string[c->dcache.ways], c->dcache.linesz);
1022 }
1023
1024 /*
1025  * If you even _breathe_ on this function, look at the gcc output and make sure
1026  * it does not pop things on and off the stack for the cache sizing loop that
1027  * executes in KSEG1 space or else you will crash and burn badly.  You have
1028  * been warned.
1029  */
1030 static int __init probe_scache(void)
1031 {
1032         unsigned long flags, addr, begin, end, pow2;
1033         unsigned int config = read_c0_config();
1034         struct cpuinfo_mips *c = &current_cpu_data;
1035         int tmp;
1036
1037         if (config & CONF_SC)
1038                 return 0;
1039
1040         begin = (unsigned long) &_stext;
1041         begin &= ~((4 * 1024 * 1024) - 1);
1042         end = begin + (4 * 1024 * 1024);
1043
1044         /*
1045          * This is such a bitch, you'd think they would make it easy to do
1046          * this.  Away you daemons of stupidity!
1047          */
1048         local_irq_save(flags);
1049
1050         /* Fill each size-multiple cache line with a valid tag. */
1051         pow2 = (64 * 1024);
1052         for (addr = begin; addr < end; addr = (begin + pow2)) {
1053                 unsigned long *p = (unsigned long *) addr;
1054                 __asm__ __volatile__("nop" : : "r" (*p)); /* whee... */
1055                 pow2 <<= 1;
1056         }
1057
1058         /* Load first line with zero (therefore invalid) tag. */
1059         write_c0_taglo(0);
1060         write_c0_taghi(0);
1061         __asm__ __volatile__("nop; nop; nop; nop;"); /* avoid the hazard */
1062         cache_op(Index_Store_Tag_I, begin);
1063         cache_op(Index_Store_Tag_D, begin);
1064         cache_op(Index_Store_Tag_SD, begin);
1065
1066         /* Now search for the wrap around point. */
1067         pow2 = (128 * 1024);
1068         tmp = 0;
1069         for (addr = begin + (128 * 1024); addr < end; addr = begin + pow2) {
1070                 cache_op(Index_Load_Tag_SD, addr);
1071                 __asm__ __volatile__("nop; nop; nop; nop;"); /* hazard... */
1072                 if (!read_c0_taglo())
1073                         break;
1074                 pow2 <<= 1;
1075         }
1076         local_irq_restore(flags);
1077         addr -= begin;
1078
1079         scache_size = addr;
1080         c->scache.linesz = 16 << ((config & R4K_CONF_SB) >> 22);
1081         c->scache.ways = 1;
1082         c->dcache.waybit = 0;           /* does not matter */
1083
1084         return 1;
1085 }
1086
1087 #if defined(CONFIG_CPU_LOONGSON2)
1088 static void __init loongson2_sc_init(void)
1089 {
1090         struct cpuinfo_mips *c = &current_cpu_data;
1091
1092         scache_size = 512*1024;
1093         c->scache.linesz = 32;
1094         c->scache.ways = 4;
1095         c->scache.waybit = 0;
1096         c->scache.waysize = scache_size / (c->scache.ways);
1097         c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways);
1098         pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n",
1099                scache_size >> 10, way_string[c->scache.ways], c->scache.linesz);
1100
1101         c->options |= MIPS_CPU_INCLUSIVE_CACHES;
1102 }
1103 #endif
1104
1105 extern int r5k_sc_init(void);
1106 extern int rm7k_sc_init(void);
1107 extern int mips_sc_init(void);
1108
1109 static void __init setup_scache(void)
1110 {
1111         struct cpuinfo_mips *c = &current_cpu_data;
1112         unsigned int config = read_c0_config();
1113         int sc_present = 0;
1114
1115         /*
1116          * Do the probing thing on R4000SC and R4400SC processors.  Other
1117          * processors don't have a S-cache that would be relevant to the
1118          * Linux memory managment.
1119          */
1120         switch (c->cputype) {
1121         case CPU_R4000SC:
1122         case CPU_R4000MC:
1123         case CPU_R4400SC:
1124         case CPU_R4400MC:
1125                 sc_present = run_uncached(probe_scache);
1126                 if (sc_present)
1127                         c->options |= MIPS_CPU_CACHE_CDEX_S;
1128                 break;
1129
1130         case CPU_R10000:
1131         case CPU_R12000:
1132         case CPU_R14000:
1133                 scache_size = 0x80000 << ((config & R10K_CONF_SS) >> 16);
1134                 c->scache.linesz = 64 << ((config >> 13) & 1);
1135                 c->scache.ways = 2;
1136                 c->scache.waybit= 0;
1137                 sc_present = 1;
1138                 break;
1139
1140         case CPU_R5000:
1141         case CPU_NEVADA:
1142 #ifdef CONFIG_R5000_CPU_SCACHE
1143                 r5k_sc_init();
1144 #endif
1145                 return;
1146
1147         case CPU_RM7000:
1148         case CPU_RM9000:
1149 #ifdef CONFIG_RM7000_CPU_SCACHE
1150                 rm7k_sc_init();
1151 #endif
1152                 return;
1153
1154 #if defined(CONFIG_CPU_LOONGSON2)
1155         case CPU_LOONGSON2:
1156                 loongson2_sc_init();
1157                 return;
1158 #endif
1159
1160         default:
1161                 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
1162                     c->isa_level == MIPS_CPU_ISA_M32R2 ||
1163                     c->isa_level == MIPS_CPU_ISA_M64R1 ||
1164                     c->isa_level == MIPS_CPU_ISA_M64R2) {
1165 #ifdef CONFIG_MIPS_CPU_SCACHE
1166                         if (mips_sc_init ()) {
1167                                 scache_size = c->scache.ways * c->scache.sets * c->scache.linesz;
1168                                 printk("MIPS secondary cache %ldkB, %s, linesize %d bytes.\n",
1169                                        scache_size >> 10,
1170                                        way_string[c->scache.ways], c->scache.linesz);
1171                         }
1172 #else
1173                         if (!(c->scache.flags & MIPS_CACHE_NOT_PRESENT))
1174                                 panic("Dunno how to handle MIPS32 / MIPS64 second level cache");
1175 #endif
1176                         return;
1177                 }
1178                 sc_present = 0;
1179         }
1180
1181         if (!sc_present)
1182                 return;
1183
1184         /* compute a couple of other cache variables */
1185         c->scache.waysize = scache_size / c->scache.ways;
1186
1187         c->scache.sets = scache_size / (c->scache.linesz * c->scache.ways);
1188
1189         printk("Unified secondary cache %ldkB %s, linesize %d bytes.\n",
1190                scache_size >> 10, way_string[c->scache.ways], c->scache.linesz);
1191
1192         c->options |= MIPS_CPU_INCLUSIVE_CACHES;
1193 }
1194
1195 void au1x00_fixup_config_od(void)
1196 {
1197         /*
1198          * c0_config.od (bit 19) was write only (and read as 0)
1199          * on the early revisions of Alchemy SOCs.  It disables the bus
1200          * transaction overlapping and needs to be set to fix various errata.
1201          */
1202         switch (read_c0_prid()) {
1203         case 0x00030100: /* Au1000 DA */
1204         case 0x00030201: /* Au1000 HA */
1205         case 0x00030202: /* Au1000 HB */
1206         case 0x01030200: /* Au1500 AB */
1207         /*
1208          * Au1100 errata actually keeps silence about this bit, so we set it
1209          * just in case for those revisions that require it to be set according
1210          * to arch/mips/au1000/common/cputable.c
1211          */
1212         case 0x02030200: /* Au1100 AB */
1213         case 0x02030201: /* Au1100 BA */
1214         case 0x02030202: /* Au1100 BC */
1215                 set_c0_config(1 << 19);
1216                 break;
1217         }
1218 }
1219
1220 static void __init coherency_setup(void)
1221 {
1222         change_c0_config(CONF_CM_CMASK, CONF_CM_DEFAULT);
1223
1224         /*
1225          * c0_status.cu=0 specifies that updates by the sc instruction use
1226          * the coherency mode specified by the TLB; 1 means cachable
1227          * coherent update on write will be used.  Not all processors have
1228          * this bit and; some wire it to zero, others like Toshiba had the
1229          * silly idea of putting something else there ...
1230          */
1231         switch (current_cpu_data.cputype) {
1232         case CPU_R4000PC:
1233         case CPU_R4000SC:
1234         case CPU_R4000MC:
1235         case CPU_R4400PC:
1236         case CPU_R4400SC:
1237         case CPU_R4400MC:
1238                 clear_c0_config(CONF_CU);
1239                 break;
1240         /*
1241          * We need to catch the early Alchemy SOCs with
1242          * the write-only co_config.od bit and set it back to one...
1243          */
1244         case CPU_AU1000: /* rev. DA, HA, HB */
1245         case CPU_AU1100: /* rev. AB, BA, BC ?? */
1246         case CPU_AU1500: /* rev. AB */
1247                 au1x00_fixup_config_od();
1248                 break;
1249         }
1250 }
1251
1252 void __init r4k_cache_init(void)
1253 {
1254         extern void build_clear_page(void);
1255         extern void build_copy_page(void);
1256         extern char except_vec2_generic;
1257         struct cpuinfo_mips *c = &current_cpu_data;
1258
1259         /* Default cache error handler for R4000 and R5000 family */
1260         set_uncached_handler (0x100, &except_vec2_generic, 0x80);
1261
1262         probe_pcache();
1263         setup_scache();
1264
1265         r4k_blast_dcache_page_setup();
1266         r4k_blast_dcache_page_indexed_setup();
1267         r4k_blast_dcache_setup();
1268         r4k_blast_icache_page_setup();
1269         r4k_blast_icache_page_indexed_setup();
1270         r4k_blast_icache_setup();
1271         r4k_blast_scache_page_setup();
1272         r4k_blast_scache_page_indexed_setup();
1273         r4k_blast_scache_setup();
1274
1275         /*
1276          * Some MIPS32 and MIPS64 processors have physically indexed caches.
1277          * This code supports virtually indexed processors and will be
1278          * unnecessarily inefficient on physically indexed processors.
1279          */
1280         if (c->dcache.linesz)
1281                 shm_align_mask = max_t( unsigned long,
1282                                         c->dcache.sets * c->dcache.linesz - 1,
1283                                         PAGE_SIZE - 1);
1284         else
1285                 shm_align_mask = PAGE_SIZE-1;
1286         flush_cache_all         = r4k_flush_cache_all;
1287         __flush_cache_all       = r4k___flush_cache_all;
1288         flush_cache_mm          = r4k_flush_cache_mm;
1289         flush_cache_page        = r4k_flush_cache_page;
1290         flush_cache_range       = r4k_flush_cache_range;
1291
1292         flush_cache_sigtramp    = r4k_flush_cache_sigtramp;
1293         flush_icache_all        = r4k_flush_icache_all;
1294         local_flush_data_cache_page     = local_r4k_flush_data_cache_page;
1295         flush_data_cache_page   = r4k_flush_data_cache_page;
1296         flush_icache_range      = r4k_flush_icache_range;
1297
1298 #ifdef CONFIG_DMA_NONCOHERENT
1299         _dma_cache_wback_inv    = r4k_dma_cache_wback_inv;
1300         _dma_cache_wback        = r4k_dma_cache_wback_inv;
1301         _dma_cache_inv          = r4k_dma_cache_inv;
1302 #endif
1303
1304         build_clear_page();
1305         build_copy_page();
1306         local_r4k___flush_cache_all(NULL);
1307         coherency_setup();
1308 }
Note: See TracBrowser for help on using the browser.