2 * Copyright (C) 1997, 2001 Ralf Baechle (ralf@gnu.org),
3 * derived from r4xx0.c by David S. Miller (dm@engr.sgi.com).
5 #include <linux/init.h>
6 #include <linux/kernel.h>
7 #include <linux/sched.h>
10 #include <asm/mipsregs.h>
11 #include <asm/bcache.h>
12 #include <asm/cacheops.h>
14 #include <asm/pgtable.h>
15 #include <asm/system.h>
16 #include <asm/mmu_context.h>
18 /* Secondary cache size in bytes, if present. */
19 static unsigned long scache_size
;
22 #define SC_PAGE (128*SC_LINE)
24 #define cache_op(base,op) \
25 __asm__ __volatile__(" \
35 static inline void blast_r5000_scache(void)
37 unsigned long start
= KSEG0
;
38 unsigned long end
= KSEG0
+ scache_size
;
41 cache_op(start
, R5K_Page_Invalidate_S
);
46 static void r5k_dma_cache_inv_sc(unsigned long addr
, unsigned long size
)
50 if (size
>= scache_size
) {
55 /* On the R5000 secondary cache we cannot
56 * invalidate less than a page at a time.
57 * The secondary cache is physically indexed, write-through.
59 a
= addr
& ~(SC_PAGE
- 1);
60 end
= (addr
+ size
- 1) & ~(SC_PAGE
- 1);
62 cache_op(a
, R5K_Page_Invalidate_S
);
67 static void r5k_sc_enable(void)
71 local_irq_save(flags
);
72 change_c0_config(R5K_CONF_SE
, R5K_CONF_SE
);
74 local_irq_restore(flags
);
77 static void r5k_sc_disable(void)
81 local_irq_save(flags
);
83 change_c0_config(R5K_CONF_SE
, 0);
84 local_irq_restore(flags
);
87 static inline int __init
r5k_sc_probe(void)
89 unsigned long config
= read_c0_config();
94 scache_size
= (512 * 1024) << ((config
& R5K_CONF_SS
) >> 20);
96 printk("R5000 SCACHE size %ldkB, linesize 32 bytes.\n",
102 static struct bcache_ops r5k_sc_ops
= {
103 .bc_enable
= r5k_sc_enable
,
104 .bc_disable
= r5k_sc_disable
,
105 .bc_wback_inv
= r5k_dma_cache_inv_sc
,
106 .bc_inv
= r5k_dma_cache_inv_sc
109 void __init
r5k_sc_init(void)
111 if (r5k_sc_probe()) {