1 diff -Nur linux-2.6.17/arch/mips/kernel/genex.S linux-2.6.17-owrt/arch/mips/kernel/genex.S
2 --- linux-2.6.17/arch/mips/kernel/genex.S 2006-06-18 03:49:35.000000000 +0200
3 +++ linux-2.6.17-owrt/arch/mips/kernel/genex.S 2006-06-18 15:36:58.000000000 +0200
15 diff -Nur linux-2.6.17/arch/mips/mm/c-r4k.c linux-2.6.17-owrt/arch/mips/mm/c-r4k.c
16 --- linux-2.6.17/arch/mips/mm/c-r4k.c 2006-06-18 03:49:35.000000000 +0200
17 +++ linux-2.6.17-owrt/arch/mips/mm/c-r4k.c 2006-06-18 15:36:58.000000000 +0200
20 #include <linux/bitops.h>
22 +#ifdef CONFIG_BCM4710
23 +#include "../bcm947xx/include/typedefs.h"
24 +#include "../bcm947xx/include/sbconfig.h"
25 +#include <asm/paccess.h>
28 #include <asm/bcache.h>
29 #include <asm/bootinfo.h>
30 #include <asm/cache.h>
32 #include <asm/cacheflush.h> /* for run_uncached() */
35 +/* For enabling BCM4710 cache workarounds */
39 * Special Variant of smp_call_function for use by cache functions:
43 unsigned long dc_lsize = cpu_dcache_line_size();
47 + r4k_blast_dcache_page = blast_dcache_page;
48 + else if (dc_lsize == 16)
49 r4k_blast_dcache_page = blast_dcache16_page;
50 else if (dc_lsize == 32)
51 r4k_blast_dcache_page = r4k_blast_dcache_page_dc32;
54 unsigned long dc_lsize = cpu_dcache_line_size();
58 + r4k_blast_dcache_page_indexed = blast_dcache_page_indexed;
59 + else if (dc_lsize == 16)
60 r4k_blast_dcache_page_indexed = blast_dcache16_page_indexed;
61 else if (dc_lsize == 32)
62 r4k_blast_dcache_page_indexed = blast_dcache32_page_indexed;
65 unsigned long dc_lsize = cpu_dcache_line_size();
69 + r4k_blast_dcache = blast_dcache;
70 + else if (dc_lsize == 16)
71 r4k_blast_dcache = blast_dcache16;
72 else if (dc_lsize == 32)
73 r4k_blast_dcache = blast_dcache32;
75 unsigned long addr = (unsigned long) arg;
77 R4600_HIT_CACHEOP_WAR_IMPL;
78 + BCM4710_PROTECTED_FILL_TLB(addr);
79 + BCM4710_PROTECTED_FILL_TLB(addr + 4);
80 protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
81 if (!cpu_icache_snoops_remote_store && scache_size)
82 protected_writeback_scache_line(addr & ~(sc_lsize - 1));
83 @@ -1189,6 +1206,16 @@
84 static inline void coherency_setup(void)
86 change_c0_config(CONF_CM_CMASK, CONF_CM_DEFAULT);
87 +#if defined(CONFIG_BCM4310) || defined(CONFIG_BCM4704) || defined(CONFIG_BCM5365)
88 + if (BCM330X(current_cpu_data.processor_id)) {
89 + __u32 cm = read_c0_diag();
99 * c0_status.cu=0 specifies that updates by the sc instruction use
100 @@ -1227,6 +1254,15 @@
102 /* Default cache error handler for R4000 and R5000 family */
103 set_uncached_handler (0x100, &except_vec2_generic, 0x80);
105 + /* Check if special workarounds are required */
106 +#ifdef CONFIG_BCM4710
107 + if (current_cpu_data.cputype == CPU_BCM4710 && (current_cpu_data.processor_id & 0xff) == 0) {
108 + printk("Enabling BCM4710A0 cache workarounds.\n");
116 diff -Nur linux-2.6.17/arch/mips/mm/tlbex.c linux-2.6.17-owrt/arch/mips/mm/tlbex.c
117 --- linux-2.6.17/arch/mips/mm/tlbex.c 2006-06-18 15:34:19.000000000 +0200
118 +++ linux-2.6.17-owrt/arch/mips/mm/tlbex.c 2006-06-18 15:36:58.000000000 +0200
121 /* #define DEBUG_TLB */
123 +#ifdef CONFIG_BCM4710
127 static __init int __attribute__((unused)) r45k_bvahwbug(void)
129 /* XXX: We should probe for the presence of this bug, but we don't. */
130 @@ -1184,6 +1188,12 @@
131 memset(relocs, 0, sizeof(relocs));
132 memset(final_handler, 0, sizeof(final_handler));
134 +#ifdef CONFIG_BCM4710
141 * create the plain linear handler
143 diff -Nur linux-2.6.17/include/asm-mips/r4kcache.h linux-2.6.17-owrt/include/asm-mips/r4kcache.h
144 --- linux-2.6.17/include/asm-mips/r4kcache.h 2006-06-18 03:49:35.000000000 +0200
145 +++ linux-2.6.17-owrt/include/asm-mips/r4kcache.h 2006-06-18 15:56:57.000000000 +0200
147 #include <asm/cpu-features.h>
148 #include <asm/mipsmtregs.h>
150 +#ifdef CONFIG_BCM4710
151 +#define BCM4710_DUMMY_RREG() (((sbconfig_t *)(KSEG1ADDR(SB_ENUM_BASE + SBCONFIGOFF)))->sbimstate)
153 +#define BCM4710_FILL_TLB(addr) (*(volatile unsigned long *)(addr))
154 +#define BCM4710_PROTECTED_FILL_TLB(addr) ({ unsigned long x; get_dbe(x, (volatile unsigned long *)(addr)); })
156 +#define BCM4710_DUMMY_RREG()
158 +#define BCM4710_FILL_TLB(addr)
159 +#define BCM4710_PROTECTED_FILL_TLB(addr)
163 * This macro return a properly sign-extended address suitable as base address
164 * for indexed cache operations. Two issues here:
166 static inline void flush_dcache_line_indexed(unsigned long addr)
169 + BCM4710_DUMMY_RREG();
170 cache_op(Index_Writeback_Inv_D, addr);
174 static inline void flush_dcache_line(unsigned long addr)
177 + BCM4710_DUMMY_RREG();
178 cache_op(Hit_Writeback_Inv_D, addr);
182 static inline void invalidate_dcache_line(unsigned long addr)
185 + BCM4710_DUMMY_RREG();
186 cache_op(Hit_Invalidate_D, addr);
191 static inline void protected_flush_icache_line(unsigned long addr)
193 + BCM4710_DUMMY_RREG();
194 protected_cache_op(Hit_Invalidate_I, addr);
199 static inline void protected_writeback_dcache_line(unsigned long addr)
201 + BCM4710_DUMMY_RREG();
202 protected_cache_op(Hit_Writeback_Inv_D, addr);
209 +static inline void blast_dcache(void)
211 + unsigned long start = KSEG0;
212 + unsigned long dcache_size = current_cpu_data.dcache.waysize * current_cpu_data.dcache.ways;
213 + unsigned long end = (start + dcache_size);
216 + BCM4710_DUMMY_RREG();
217 + cache_op(Index_Writeback_Inv_D, start);
218 + start += current_cpu_data.dcache.linesz;
219 + } while(start < end);
222 +static inline void blast_dcache_page(unsigned long page)
224 + unsigned long start = page;
225 + unsigned long end = start + PAGE_SIZE;
227 + BCM4710_FILL_TLB(start);
229 + BCM4710_DUMMY_RREG();
230 + cache_op(Hit_Writeback_Inv_D, start);
231 + start += current_cpu_data.dcache.linesz;
232 + } while(start < end);
235 +static inline void blast_dcache_page_indexed(unsigned long page)
237 + unsigned long start = page;
238 + unsigned long end = start + PAGE_SIZE;
239 + unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
240 + unsigned long ws_end = current_cpu_data.dcache.ways <<
241 + current_cpu_data.dcache.waybit;
242 + unsigned long ws, addr;
243 + for (ws = 0; ws < ws_end; ws += ws_inc) {
245 + for (addr = start; addr < end; addr += current_cpu_data.dcache.linesz) {
246 + BCM4710_DUMMY_RREG();
247 + cache_op(Index_Writeback_Inv_D, addr);
253 /* build blast_xxx, blast_xxx_page, blast_xxx_page_indexed */
254 -#define __BUILD_BLAST_CACHE(pfx, desc, indexop, hitop, lsize) \
255 +#define __BUILD_BLAST_CACHE(pfx, desc, indexop, hitop, lsize, war) \
256 static inline void blast_##pfx##cache##lsize(void) \
258 unsigned long start = INDEX_BASE; \
261 __##pfx##flush_prologue \
264 for (ws = 0; ws < ws_end; ws += ws_inc) \
265 for (addr = start; addr < end; addr += lsize * 32) \
266 cache##lsize##_unroll32(addr|ws,indexop); \
269 __##pfx##flush_prologue \
273 cache##lsize##_unroll32(start,hitop); \
274 start += lsize * 32; \
276 current_cpu_data.desc.waybit; \
277 unsigned long ws, addr; \
281 __##pfx##flush_prologue \
283 for (ws = 0; ws < ws_end; ws += ws_inc) \
284 @@ -393,24 +458,25 @@
285 __##pfx##flush_epilogue \
288 -__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16)
289 -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16)
290 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16)
291 -__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32)
292 -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32)
293 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32)
294 -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64)
295 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64)
296 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128)
297 +__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16, )
298 +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16, BCM4710_FILL_TLB(start);)
299 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16, )
300 +__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32, )
301 +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32, BCM4710_FILL_TLB(start);)
302 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32, )
303 +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64, BCM4710_FILL_TLB(start);)
304 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64, )
305 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128, )
307 /* build blast_xxx_range, protected_blast_xxx_range */
308 -#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot) \
309 +#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot, war) \
310 static inline void prot##blast_##pfx##cache##_range(unsigned long start, \
313 unsigned long lsize = cpu_##desc##_line_size(); \
314 unsigned long addr = start & ~(lsize - 1); \
315 unsigned long aend = (end - 1) & ~(lsize - 1); \
318 __##pfx##flush_prologue \
320 @@ -424,13 +490,13 @@
321 __##pfx##flush_epilogue \
324 -__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_)
325 -__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_)
326 -__BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_)
327 -__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, )
328 -__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, )
329 +__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_, BCM4710_PROTECTED_FILL_TLB(addr); BCM4710_PROTECTED_FILL_TLB(aend);)
330 +__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_, )
331 +__BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_, )
332 +__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, , BCM4710_FILL_TLB(addr); BCM4710_FILL_TLB(aend);)
333 +__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, , )
334 /* blast_inv_dcache_range */
335 -__BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D, )
336 -__BUILD_BLAST_CACHE_RANGE(inv_s, scache, Hit_Invalidate_SD, )
337 +__BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D, , )
338 +__BUILD_BLAST_CACHE_RANGE(inv_s, scache, Hit_Invalidate_SD, , )
340 #endif /* _ASM_R4KCACHE_H */
341 diff -Nur linux-2.6.17/include/asm-mips/stackframe.h linux-2.6.17-owrt/include/asm-mips/stackframe.h
342 --- linux-2.6.17/include/asm-mips/stackframe.h 2006-06-18 03:49:35.000000000 +0200
343 +++ linux-2.6.17-owrt/include/asm-mips/stackframe.h 2006-06-18 15:36:58.000000000 +0200
345 .macro RESTORE_SP_AND_RET
346 LONG_L sp, PT_R29(sp)
348 +#ifdef CONFIG_BCM4710