1 Index: linux-2.6.22-rc6/arch/mips/kernel/genex.S
2 ===================================================================
3 --- linux-2.6.22-rc6.orig/arch/mips/kernel/genex.S 2007-07-04 01:52:47.812492000 +0200
4 +++ linux-2.6.22-rc6/arch/mips/kernel/genex.S 2007-07-04 01:53:01.585352750 +0200
6 NESTED(except_vec3_generic, 0, sp)
9 +#ifdef CONFIG_BCM947XX
13 #if R5432_CP0_INTERRUPT_WAR
16 Index: linux-2.6.22-rc6/arch/mips/mm/c-r4k.c
17 ===================================================================
18 --- linux-2.6.22-rc6.orig/arch/mips/mm/c-r4k.c 2007-07-04 01:53:01.545350250 +0200
19 +++ linux-2.6.22-rc6/arch/mips/mm/c-r4k.c 2007-07-04 02:17:11.435962750 +0200
21 #include <asm/cacheflush.h> /* for run_uncached() */
24 +/* For enabling BCM4710 cache workarounds */
28 * Special Variant of smp_call_function for use by cache functions:
32 unsigned long dc_lsize = cpu_dcache_line_size();
35 + r4k_blast_dcache_page = blast_dcache_page;
38 r4k_blast_dcache_page = (void *)cache_noop;
39 else if (dc_lsize == 16)
42 unsigned long dc_lsize = cpu_dcache_line_size();
45 + r4k_blast_dcache_page_indexed = blast_dcache_page_indexed;
48 r4k_blast_dcache_page_indexed = (void *)cache_noop;
49 else if (dc_lsize == 16)
52 unsigned long dc_lsize = cpu_dcache_line_size();
55 + r4k_blast_dcache = blast_dcache;
58 r4k_blast_dcache = (void *)cache_noop;
59 else if (dc_lsize == 16)
63 protected_blast_icache_range(start, end);
66 + r4k_flush_cache_all();
69 static void r4k_flush_icache_range(unsigned long start, unsigned long end)
71 unsigned long addr = (unsigned long) arg;
73 R4600_HIT_CACHEOP_WAR_IMPL;
74 + BCM4710_PROTECTED_FILL_TLB(addr);
75 + BCM4710_PROTECTED_FILL_TLB(addr + 4);
77 protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
78 if (!cpu_icache_snoops_remote_store && scache_size)
79 @@ -1144,6 +1161,17 @@
80 * silly idea of putting something else there ...
82 switch (current_cpu_data.cputype) {
86 + cm = read_c0_diag();
97 @@ -1174,6 +1202,15 @@
98 /* Default cache error handler for R4000 and R5000 family */
99 set_uncached_handler (0x100, &except_vec2_generic, 0x80);
101 + /* Check if special workarounds are required */
102 +#ifdef CONFIG_BCM947XX
103 + if (current_cpu_data.cputype == CPU_BCM4710 && (current_cpu_data.processor_id & 0xff) == 0) {
104 + printk("Enabling BCM4710A0 cache workarounds.\n");
113 @@ -1219,5 +1256,13 @@
116 local_r4k___flush_cache_all(NULL);
117 +#ifdef CONFIG_BCM947XX
119 + static void (*_coherency_setup)(void);
120 + _coherency_setup = (void (*)(void)) KSEG1ADDR(coherency_setup);
121 + _coherency_setup();
127 Index: linux-2.6.22-rc6/arch/mips/mm/tlbex.c
128 ===================================================================
129 --- linux-2.6.22-rc6.orig/arch/mips/mm/tlbex.c 2007-07-04 01:53:01.193328250 +0200
130 +++ linux-2.6.22-rc6/arch/mips/mm/tlbex.c 2007-07-04 02:17:26.112880000 +0200
131 @@ -1229,6 +1229,10 @@
135 +#ifdef CONFIG_BCM947XX
139 static void __init build_r4000_tlb_refill_handler(void)
141 u32 *p = tlb_handler;
142 @@ -1243,6 +1247,11 @@
143 memset(relocs, 0, sizeof(relocs));
144 memset(final_handler, 0, sizeof(final_handler));
146 +#ifdef CONFIG_BCM947XX
147 + if (current_cpu_data.cputype == CPU_BCM3302)
152 * create the plain linear handler
154 Index: linux-2.6.22-rc6/include/asm-mips/r4kcache.h
155 ===================================================================
156 --- linux-2.6.22-rc6.orig/include/asm-mips/r4kcache.h 2007-07-04 01:52:47.840493750 +0200
157 +++ linux-2.6.22-rc6/include/asm-mips/r4kcache.h 2007-07-04 01:53:01.673358250 +0200
159 #include <asm/cpu-features.h>
160 #include <asm/mipsmtregs.h>
162 +#ifdef CONFIG_BCM947XX
163 +#include <asm/paccess.h>
164 +#include <linux/ssb/ssb.h>
165 +#define BCM4710_DUMMY_RREG() ((void) *((u8 *) KSEG1ADDR(SSB_ENUM_BASE + SSB_IMSTATE)))
167 +#define BCM4710_FILL_TLB(addr) (*(volatile unsigned long *)(addr))
168 +#define BCM4710_PROTECTED_FILL_TLB(addr) ({ unsigned long x; get_dbe(x, (volatile unsigned long *)(addr)); })
170 +#define BCM4710_DUMMY_RREG()
172 +#define BCM4710_FILL_TLB(addr)
173 +#define BCM4710_PROTECTED_FILL_TLB(addr)
177 * This macro return a properly sign-extended address suitable as base address
178 * for indexed cache operations. Two issues here:
180 static inline void flush_dcache_line_indexed(unsigned long addr)
183 + BCM4710_DUMMY_RREG();
184 cache_op(Index_Writeback_Inv_D, addr);
188 static inline void flush_dcache_line(unsigned long addr)
191 + BCM4710_DUMMY_RREG();
192 cache_op(Hit_Writeback_Inv_D, addr);
196 static inline void invalidate_dcache_line(unsigned long addr)
199 + BCM4710_DUMMY_RREG();
200 cache_op(Hit_Invalidate_D, addr);
205 static inline void protected_flush_icache_line(unsigned long addr)
207 + BCM4710_DUMMY_RREG();
208 protected_cache_op(Hit_Invalidate_I, addr);
213 static inline void protected_writeback_dcache_line(unsigned long addr)
215 + BCM4710_DUMMY_RREG();
216 protected_cache_op(Hit_Writeback_Inv_D, addr);
223 +static inline void blast_dcache(void)
225 + unsigned long start = KSEG0;
226 + unsigned long dcache_size = current_cpu_data.dcache.waysize * current_cpu_data.dcache.ways;
227 + unsigned long end = (start + dcache_size);
230 + BCM4710_DUMMY_RREG();
231 + cache_op(Index_Writeback_Inv_D, start);
232 + start += current_cpu_data.dcache.linesz;
233 + } while(start < end);
236 +static inline void blast_dcache_page(unsigned long page)
238 + unsigned long start = page;
239 + unsigned long end = start + PAGE_SIZE;
241 + BCM4710_FILL_TLB(start);
243 + BCM4710_DUMMY_RREG();
244 + cache_op(Hit_Writeback_Inv_D, start);
245 + start += current_cpu_data.dcache.linesz;
246 + } while(start < end);
249 +static inline void blast_dcache_page_indexed(unsigned long page)
251 + unsigned long start = page;
252 + unsigned long end = start + PAGE_SIZE;
253 + unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
254 + unsigned long ws_end = current_cpu_data.dcache.ways <<
255 + current_cpu_data.dcache.waybit;
256 + unsigned long ws, addr;
257 + for (ws = 0; ws < ws_end; ws += ws_inc) {
259 + for (addr = start; addr < end; addr += current_cpu_data.dcache.linesz) {
260 + BCM4710_DUMMY_RREG();
261 + cache_op(Index_Writeback_Inv_D, addr);
267 /* build blast_xxx, blast_xxx_page, blast_xxx_page_indexed */
268 -#define __BUILD_BLAST_CACHE(pfx, desc, indexop, hitop, lsize) \
269 +#define __BUILD_BLAST_CACHE(pfx, desc, indexop, hitop, lsize, war) \
270 static inline void blast_##pfx##cache##lsize(void) \
272 unsigned long start = INDEX_BASE; \
275 __##pfx##flush_prologue \
278 for (ws = 0; ws < ws_end; ws += ws_inc) \
279 for (addr = start; addr < end; addr += lsize * 32) \
280 cache##lsize##_unroll32(addr|ws,indexop); \
283 __##pfx##flush_prologue \
287 cache##lsize##_unroll32(start,hitop); \
288 start += lsize * 32; \
290 current_cpu_data.desc.waybit; \
291 unsigned long ws, addr; \
295 __##pfx##flush_prologue \
297 for (ws = 0; ws < ws_end; ws += ws_inc) \
298 @@ -393,28 +460,30 @@
299 __##pfx##flush_epilogue \
302 -__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16)
303 -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16)
304 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16)
305 -__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32)
306 -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32)
307 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32)
308 -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64)
309 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64)
310 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128)
311 +__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16, )
312 +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16, BCM4710_FILL_TLB(start);)
313 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16, )
314 +__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32, )
315 +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32, BCM4710_FILL_TLB(start);)
316 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32, )
317 +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64, BCM4710_FILL_TLB(start);)
318 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64, )
319 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128, )
321 /* build blast_xxx_range, protected_blast_xxx_range */
322 -#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot) \
323 +#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot, war, war2) \
324 static inline void prot##blast_##pfx##cache##_range(unsigned long start, \
327 unsigned long lsize = cpu_##desc##_line_size(); \
328 unsigned long addr = start & ~(lsize - 1); \
329 unsigned long aend = (end - 1) & ~(lsize - 1); \
332 __##pfx##flush_prologue \
336 prot##cache_op(hitop, addr); \
339 @@ -424,13 +493,13 @@
340 __##pfx##flush_epilogue \
343 -__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_)
344 -__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_)
345 -__BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_)
346 -__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, )
347 -__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, )
348 +__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_, BCM4710_PROTECTED_FILL_TLB(addr); BCM4710_PROTECTED_FILL_TLB(aend);, BCM4710_DUMMY_RREG();)
349 +__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_,, )
350 +__BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_,, )
351 +__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D,, BCM4710_FILL_TLB(addr); BCM4710_FILL_TLB(aend);, BCM4710_DUMMY_RREG();)
352 +__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD,,, )
353 /* blast_inv_dcache_range */
354 -__BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D, )
355 -__BUILD_BLAST_CACHE_RANGE(inv_s, scache, Hit_Invalidate_SD, )
356 +__BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D,,,BCM4710_DUMMY_RREG();)
357 +__BUILD_BLAST_CACHE_RANGE(inv_s, scache, Hit_Invalidate_SD,,, )
359 #endif /* _ASM_R4KCACHE_H */
360 Index: linux-2.6.22-rc6/include/asm-mips/stackframe.h
361 ===================================================================
362 --- linux-2.6.22-rc6.orig/include/asm-mips/stackframe.h 2007-07-04 01:52:47.852494500 +0200
363 +++ linux-2.6.22-rc6/include/asm-mips/stackframe.h 2007-07-04 01:53:01.697359750 +0200
365 .macro RESTORE_SP_AND_RET
366 LONG_L sp, PT_R29(sp)
368 +#ifdef CONFIG_BCM947XX