1 diff -urN linux.old/arch/mips/kernel/genex.S linux.dev/arch/mips/kernel/genex.S
2 --- linux.old/arch/mips/kernel/genex.S 2006-03-20 06:53:29.000000000 +0100
3 +++ linux.dev/arch/mips/kernel/genex.S 2006-03-21 12:19:26.000000000 +0100
15 diff -urN linux.old/arch/mips/mm/c-r4k.c linux.dev/arch/mips/mm/c-r4k.c
16 --- linux.old/arch/mips/mm/c-r4k.c 2006-03-20 06:53:29.000000000 +0100
17 +++ linux.dev/arch/mips/mm/c-r4k.c 2006-03-21 12:19:26.000000000 +0100
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>
33 #include <asm/cacheflush.h> /* for run_uncached() */
35 +/* For enabling BCM4710 cache workarounds */
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 @@ -1136,6 +1153,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 @@ -1165,6 +1192,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 -urN linux.old/arch/mips/mm/tlbex.c linux.dev/arch/mips/mm/tlbex.c
117 --- linux.old/arch/mips/mm/tlbex.c 2006-03-21 12:12:38.000000000 +0100
118 +++ linux.dev/arch/mips/mm/tlbex.c 2006-03-21 12:19:26.000000000 +0100
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 @@ -1152,6 +1156,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 -urN linux.old/include/asm-mips/r4kcache.h linux.dev/include/asm-mips/r4kcache.h
144 --- linux.old/include/asm-mips/r4kcache.h 2006-03-20 06:53:29.000000000 +0100
145 +++ linux.dev/include/asm-mips/r4kcache.h 2006-03-21 18:40:32.000000000 +0100
147 #include <asm/cacheops.h>
148 #include <asm/cpu-features.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:
167 static inline void flush_dcache_line_indexed(unsigned long addr)
169 + BCM4710_DUMMY_RREG();
170 cache_op(Index_Writeback_Inv_D, addr);
175 static inline void flush_dcache_line(unsigned long addr)
177 + BCM4710_DUMMY_RREG();
178 cache_op(Hit_Writeback_Inv_D, addr);
181 static inline void invalidate_dcache_line(unsigned long addr)
183 + BCM4710_DUMMY_RREG();
184 cache_op(Hit_Invalidate_D, addr);
189 static inline void protected_flush_icache_line(unsigned long addr)
191 + BCM4710_DUMMY_RREG();
192 protected_cache_op(Hit_Invalidate_I, addr);
197 static inline void protected_writeback_dcache_line(unsigned long addr)
199 + BCM4710_DUMMY_RREG();
200 protected_cache_op(Hit_Writeback_Inv_D, addr);
207 +static inline void blast_dcache(void)
209 + unsigned long start = KSEG0;
210 + unsigned long dcache_size = current_cpu_data.dcache.waysize * current_cpu_data.dcache.ways;
211 + unsigned long end = (start + dcache_size);
214 + BCM4710_DUMMY_RREG();
215 + cache_op(Index_Writeback_Inv_D, start);
216 + start += current_cpu_data.dcache.linesz;
217 + } while(start < end);
220 +static inline void blast_dcache_page(unsigned long page)
222 + unsigned long start = page;
223 + unsigned long end = start + PAGE_SIZE;
225 + BCM4710_FILL_TLB(start);
227 + BCM4710_DUMMY_RREG();
228 + cache_op(Hit_Writeback_Inv_D, start);
229 + start += current_cpu_data.dcache.linesz;
230 + } while(start < end);
233 +static inline void blast_dcache_page_indexed(unsigned long page)
235 + unsigned long start = page;
236 + unsigned long end = start + PAGE_SIZE;
237 + unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
238 + unsigned long ws_end = current_cpu_data.dcache.ways <<
239 + current_cpu_data.dcache.waybit;
240 + unsigned long ws, addr;
241 + for (ws = 0; ws < ws_end; ws += ws_inc) {
243 + for (addr = start; addr < end; addr += current_cpu_data.dcache.linesz) {
244 + BCM4710_DUMMY_RREG();
245 + cache_op(Index_Writeback_Inv_D, addr);
251 /* build blast_xxx, blast_xxx_page, blast_xxx_page_indexed */
252 -#define __BUILD_BLAST_CACHE(pfx, desc, indexop, hitop, lsize) \
253 +#define __BUILD_BLAST_CACHE(pfx, desc, indexop, hitop, lsize, war) \
254 static inline void blast_##pfx##cache##lsize(void) \
256 unsigned long start = INDEX_BASE; \
258 current_cpu_data.desc.waybit; \
259 unsigned long ws, addr; \
262 for (ws = 0; ws < ws_end; ws += ws_inc) \
263 for (addr = start; addr < end; addr += lsize * 32) \
264 cache##lsize##_unroll32(addr|ws,indexop); \
266 unsigned long start = page; \
267 unsigned long end = page + PAGE_SIZE; \
271 cache##lsize##_unroll32(start,hitop); \
272 start += lsize * 32; \
273 @@ -265,29 +328,31 @@
274 current_cpu_data.desc.waybit; \
275 unsigned long ws, addr; \
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 -__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16)
284 -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16)
285 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16)
286 -__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32)
287 -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32)
288 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32)
289 -__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64)
290 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64)
291 -__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128)
292 +__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16, )
293 +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16, BCM4710_FILL_TLB(start);)
294 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16, )
295 +__BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32, )
296 +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32, BCM4710_FILL_TLB(start);)
297 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32, )
298 +__BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64, BCM4710_FILL_TLB(start);)
299 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64, )
300 +__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128, )
302 /* build blast_xxx_range, protected_blast_xxx_range */
303 -#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot) \
304 +#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot, war) \
305 static inline void prot##blast_##pfx##cache##_range(unsigned long start, \
308 unsigned long lsize = cpu_##desc##_line_size(); \
309 unsigned long addr = start & ~(lsize - 1); \
310 unsigned long aend = (end - 1) & ~(lsize - 1); \
313 prot##cache_op(hitop, addr); \
315 @@ -296,12 +361,12 @@
319 -__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_)
320 -__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_)
321 -__BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_)
322 -__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, )
323 -__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, )
324 +__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_, BCM4710_PROTECTED_FILL_TLB(addr); BCM4710_PROTECTED_FILL_TLB(aend);)
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, , BCM4710_FILL_TLB(addr); BCM4710_FILL_TLB(aend);)
328 +__BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, , )
329 /* blast_inv_dcache_range */
330 -__BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D, )
331 +__BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D, , )
333 #endif /* _ASM_R4KCACHE_H */
334 diff -urN linux.old/include/asm-mips/stackframe.h linux.dev/include/asm-mips/stackframe.h
335 --- linux.old/include/asm-mips/stackframe.h 2006-03-20 06:53:29.000000000 +0100
336 +++ linux.dev/include/asm-mips/stackframe.h 2006-03-21 12:19:26.000000000 +0100
338 .macro RESTORE_SP_AND_RET
339 LONG_L sp, PT_R29(sp)
341 +#ifdef CONFIG_BCM4710