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 2005-12-04 06:10:42.000000000 +0100
3 +++ linux.dev/arch/mips/kernel/genex.S 2005-12-18 05:30:48.564937750 +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 2005-12-04 06:10:42.000000000 +0100
17 +++ linux.dev/arch/mips/mm/c-r4k.c 2005-12-18 06:08:19.112437750 +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 addr = start & ~(dc_lsize - 1);
76 aend = (end - 1) & ~(dc_lsize - 1);
78 + BCM4710_PROTECTED_FILL_TLB(addr);
79 + BCM4710_PROTECTED_FILL_TLB(aend);
82 /* Hit_Writeback_Inv_D */
83 protected_writeback_dcache_line(addr);
85 R4600_HIT_CACHEOP_WAR_IMPL;
86 a = addr & ~(dc_lsize - 1);
87 end = (addr + size - 1) & ~(dc_lsize - 1);
89 + BCM4710_FILL_TLB(a);
90 + BCM4710_FILL_TLB(end);
93 flush_dcache_line(a); /* Hit_Writeback_Inv_D */
96 R4600_HIT_CACHEOP_WAR_IMPL;
97 a = addr & ~(dc_lsize - 1);
98 end = (addr + size - 1) & ~(dc_lsize - 1);
100 + BCM4710_FILL_TLB(a);
101 + BCM4710_FILL_TLB(end);
104 flush_dcache_line(a); /* Hit_Writeback_Inv_D */
107 unsigned long addr = (unsigned long) arg;
109 R4600_HIT_CACHEOP_WAR_IMPL;
110 + BCM4710_PROTECTED_FILL_TLB(addr);
111 + BCM4710_PROTECTED_FILL_TLB(addr + 4);
112 protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
113 if (!cpu_icache_snoops_remote_store)
114 protected_writeback_scache_line(addr & ~(sc_lsize - 1));
115 @@ -1202,6 +1230,16 @@
116 static inline void coherency_setup(void)
118 change_c0_config(CONF_CM_CMASK, CONF_CM_DEFAULT);
119 +#if defined(CONFIG_BCM4310) || defined(CONFIG_BCM4704) || defined(CONFIG_BCM5365)
120 + if (BCM330X(current_cpu_data.processor_id)) {
121 + __u32 cm = read_c0_diag();
122 + /* Enable icache */
124 + /* Enable dcache */
131 * c0_status.cu=0 specifies that updates by the sc instruction use
132 @@ -1231,6 +1269,15 @@
134 /* Default cache error handler for R4000 and R5000 family */
135 set_uncached_handler (0x100, &except_vec2_generic, 0x80);
137 + /* Check if special workarounds are required */
138 +#ifdef CONFIG_BCM4710
139 + if (current_cpu_data.cputype == CPU_BCM4710 && (current_cpu_data.processor_id & 0xff) == 0) {
140 + printk("Enabling BCM4710A0 cache workarounds.\n");
148 diff -urN linux.old/arch/mips/mm/tlbex.c linux.dev/arch/mips/mm/tlbex.c
149 --- linux.old/arch/mips/mm/tlbex.c 2005-12-15 12:57:27.945158000 +0100
150 +++ linux.dev/arch/mips/mm/tlbex.c 2005-12-18 06:06:17.916863500 +0100
153 /* #define DEBUG_TLB */
155 +#ifdef CONFIG_BCM4710
159 static __init int __attribute__((unused)) r45k_bvahwbug(void)
161 /* XXX: We should probe for the presence of this bug, but we don't. */
162 @@ -1152,6 +1156,12 @@
163 memset(relocs, 0, sizeof(relocs));
164 memset(final_handler, 0, sizeof(final_handler));
166 +#ifdef CONFIG_BCM4710
173 * create the plain linear handler
175 diff -urN linux.old/include/asm-mips/r4kcache.h linux.dev/include/asm-mips/r4kcache.h
176 --- linux.old/include/asm-mips/r4kcache.h 2005-12-17 22:39:19.281320000 +0100
177 +++ linux.dev/include/asm-mips/r4kcache.h 2005-12-18 05:22:06.020280750 +0100
180 #include <asm/cacheops.h>
182 +#ifdef CONFIG_BCM4710
183 +#define BCM4710_DUMMY_RREG() (((sbconfig_t *)(KSEG1ADDR(SB_ENUM_BASE + SBCONFIGOFF)))->sbimstate)
185 +#define BCM4710_FILL_TLB(addr) (*(volatile unsigned long *)(addr))
186 +#define BCM4710_PROTECTED_FILL_TLB(addr) ({ unsigned long x; get_dbe(x, (volatile unsigned long *)(addr)); })
188 +#define BCM4710_DUMMY_RREG()
190 +#define BCM4710_FILL_TLB(addr)
191 +#define BCM4710_PROTECTED_FILL_TLB(addr)
195 * This macro return a properly sign-extended address suitable as base address
196 * for indexed cache operations. Two issues here:
199 static inline void flush_dcache_line_indexed(unsigned long addr)
201 + BCM4710_DUMMY_RREG();
202 cache_op(Index_Writeback_Inv_D, addr);
207 static inline void flush_dcache_line(unsigned long addr)
209 + BCM4710_DUMMY_RREG();
210 cache_op(Hit_Writeback_Inv_D, addr);
213 static inline void invalidate_dcache_line(unsigned long addr)
215 + BCM4710_DUMMY_RREG();
216 cache_op(Hit_Invalidate_D, addr);
221 static inline void protected_writeback_dcache_line(unsigned long addr)
223 + BCM4710_DUMMY_RREG();
224 __asm__ __volatile__(
231 +static inline void blast_dcache(void)
233 + unsigned long start = KSEG0;
234 + unsigned long dcache_size = current_cpu_data.dcache.waysize * current_cpu_data.dcache.ways;
235 + unsigned long end = (start + dcache_size);
238 + BCM4710_DUMMY_RREG();
239 + cache_op(Index_Writeback_Inv_D, start);
240 + start += current_cpu_data.dcache.linesz;
241 + } while(start < end);
244 +static inline void blast_dcache_page(unsigned long page)
246 + unsigned long start = page;
247 + unsigned long end = start + PAGE_SIZE;
249 + BCM4710_FILL_TLB(start);
251 + BCM4710_DUMMY_RREG();
252 + cache_op(Hit_Writeback_Inv_D, start);
253 + start += current_cpu_data.dcache.linesz;
254 + } while(start < end);
257 +static inline void blast_dcache_page_indexed(unsigned long page)
259 + unsigned long start = page;
260 + unsigned long end = start + PAGE_SIZE;
261 + unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
262 + unsigned long ws_end = current_cpu_data.dcache.ways <<
263 + current_cpu_data.dcache.waybit;
264 + unsigned long ws, addr;
265 + for (ws = 0; ws < ws_end; ws += ws_inc) {
267 + for (addr = start; addr < end; addr += current_cpu_data.dcache.linesz) {
268 + BCM4710_DUMMY_RREG();
269 + cache_op(Index_Writeback_Inv_D, addr);
274 static inline void blast_dcache16(void)
276 unsigned long start = INDEX_BASE;
278 unsigned long ws_end = current_cpu_data.icache.ways <<
279 current_cpu_data.icache.waybit;
280 unsigned long ws, addr;
283 + BCM4710_FILL_TLB(start);
284 for (ws = 0; ws < ws_end; ws += ws_inc)
285 for (addr = start; addr < end; addr += 0x200)
286 cache16_unroll32(addr|ws,Index_Invalidate_I);
288 current_cpu_data.icache.waybit;
289 unsigned long ws, addr;
291 + BCM4710_FILL_TLB(start);
292 for (ws = 0; ws < ws_end; ws += ws_inc)
293 for (addr = start; addr < end; addr += 0x400)
294 cache32_unroll32(addr|ws,Index_Invalidate_I);
296 unsigned long start = page;
297 unsigned long end = start + PAGE_SIZE;
299 + BCM4710_FILL_TLB(start);
301 cache64_unroll32(start,Hit_Invalidate_I);
303 diff -urN linux.old/include/asm-mips/stackframe.h linux.dev/include/asm-mips/stackframe.h
304 --- linux.old/include/asm-mips/stackframe.h 2005-12-04 06:10:42.000000000 +0100
305 +++ linux.dev/include/asm-mips/stackframe.h 2005-12-18 05:33:02.405302250 +0100
307 .macro RESTORE_SP_AND_RET
308 LONG_L sp, PT_R29(sp)
310 +#ifdef CONFIG_BCM4710