10 #include <linux/kernel.h>
12 #include <linux/bitops.h>
14 #include <asm/addrspace.h>
18 #include <asm/processor.h>
19 #include <asm/sections.h>
20 #include <asm/cacheflush.h>
24 #define tc_pagesize (32*128)
27 #define scache_size (256*1024)
33 static unsigned long tcache_size;
37 static int rm7k_tcache_init;
43 static void rm7k_sc_wback_inv(
unsigned long addr,
unsigned long size)
47 pr_debug(
"rm7k_sc_wback_inv[%08lx,%08lx]", addr, size);
52 blast_scache_range(addr, addr + size);
54 if (!rm7k_tcache_init)
60 invalidate_tcache_page(a);
67 static void rm7k_sc_inv(
unsigned long addr,
unsigned long size)
71 pr_debug(
"rm7k_sc_inv[%08lx,%08lx]", addr, size);
76 blast_inv_scache_range(addr, addr + size);
78 if (!rm7k_tcache_init)
84 invalidate_tcache_page(a);
91 static void blast_rm7k_tcache(
void)
94 unsigned long end = start + tcache_size;
107 static __cpuinit void __rm7k_tc_enable(
void)
116 for (i = 0; i < tcache_size; i +=
tc_lsize)
120 static __cpuinit void rm7k_tc_enable(
void)
133 static __cpuinit void __rm7k_sc_enable(
void)
146 static __cpuinit void rm7k_sc_enable(
void)
151 pr_info(
"Enabling secondary cache...\n");
154 if (rm7k_tcache_init)
158 static void rm7k_tc_disable(
void)
168 static void rm7k_sc_disable(
void)
172 if (rm7k_tcache_init)
177 .bc_enable = rm7k_sc_enable,
178 .bc_disable = rm7k_sc_disable,
179 .bc_wback_inv = rm7k_sc_wback_inv,
180 .bc_inv = rm7k_sc_inv
187 static __cpuinit void __probe_tcache(
void)
191 begin = (
unsigned long) &_stext;
192 begin &= ~((8 * 1024 * 1024) - 1);
193 end = begin + (8 * 1024 * 1024);
201 for (addr = begin; addr <=
end; addr = (begin + pow2)) {
202 unsigned long *
p = (
unsigned long *) addr;
203 __asm__ __volatile__(
"nop" : :
"r" (*p));
214 for (addr = begin + (512 * 1024); addr <=
end; addr = begin + pow2) {
248 bcops = &rm7k_sc_ops;
254 rm7k_tcache_init = 0;
266 rm7k_tcache_init = 1;
269 pr_info(
"Tertiary cache size %ldK.\n", (tcache_size >> 10));