1 diff -urN linux.old/arch/mips/mm/tlbex-mips32.S linux.dev/arch/mips/mm/tlbex-mips32.S
2 --- linux.old/arch/mips/mm/tlbex-mips32.S 2005-05-28 17:42:03.000000000 +0200
3 +++ linux.dev/arch/mips/mm/tlbex-mips32.S 2005-05-28 21:48:55.000000000 +0200
6 LEAF(except_vec0_r4000)
14 diff -urN linux.old/arch/mips/mm/pg-r4k.c linux.dev/arch/mips/mm/pg-r4k.c
15 --- linux.old/arch/mips/mm/pg-r4k.c 2005-01-19 15:09:29.000000000 +0100
16 +++ linux.dev/arch/mips/mm/pg-r4k.c 2005-05-28 21:57:52.000000000 +0200
19 static inline void build_cdex_s(void)
21 +#if !defined(CONFIG_BCM4704) && !defined(CONFIG_BCM4710)
22 union mips_instruction mi;
24 if ((store_offset & (cpu_scache_line_size() - 1)))
26 mi.c_format.simmediate = store_offset;
32 static inline void build_cdex_p(void)
34 +#if !defined(CONFIG_BCM4704) && !defined(CONFIG_BCM4710)
35 union mips_instruction mi;
37 if (store_offset & (cpu_dcache_line_size() - 1))
39 mi.c_format.simmediate = store_offset;
45 static void __build_store_reg(int reg)
46 diff -urN linux.old/include/asm-mips/stackframe.h linux.dev/include/asm-mips/stackframe.h
47 --- linux.old/include/asm-mips/stackframe.h 2002-11-29 00:53:15.000000000 +0100
48 +++ linux.dev/include/asm-mips/stackframe.h 2005-05-28 21:53:03.000000000 +0200
53 +#elif defined(CONFIG_BCM4710) || defined(CONFIG_BCM4704)
55 +#define RESTORE_SOME \
58 + mfc0 t0, CP0_STATUS; \
62 + mtc0 t0, CP0_STATUS; \
65 + lw v0, PT_STATUS(sp); \
69 + ori v1, v0, ST0_IE; \
70 + xori v1, v1, ST0_IE; \
71 + mtc0 v1, CP0_STATUS; \
72 + mtc0 v0, CP0_STATUS; \
73 + lw v1, PT_EPC(sp); \
75 + lw $31, PT_R31(sp); \
76 + lw $28, PT_R28(sp); \
77 + lw $25, PT_R25(sp); \
85 +#define RESTORE_SP_AND_RET \
86 + lw sp, PT_R29(sp); \
95 #define RESTORE_SOME \
96 diff -urN linux.old/arch/mips/mm/tlbex-r4k.S linux.dev/arch/mips/mm/tlbex-r4k.S
97 --- linux.old/arch/mips/mm/tlbex-r4k.S 2005-05-28 17:42:03.000000000 +0200
98 +++ linux.dev/arch/mips/mm/tlbex-r4k.S 2005-05-29 15:04:43.000000000 +0200
101 LEAF(except_vec0_r4000)
103 +#ifdef CONFIG_BCM4704
106 GET_PGD(k0, k1) # get pgd pointer
107 mfc0 k0, CP0_BADVADDR # Get faulting address
108 srl k0, k0, _PGDIR_SHIFT # get pgd only bits
109 diff -urN linux.old/arch/mips/kernel/entry.S linux.dev/arch/mips/kernel/entry.S
110 --- linux.old/arch/mips/kernel/entry.S 2003-08-25 13:44:40.000000000 +0200
111 +++ linux.dev/arch/mips/kernel/entry.S 2005-06-01 20:10:36.000000000 +0200
113 * and R4400 SC and MC versions.
115 NESTED(except_vec3_generic, 0, sp)
116 +#ifdef CONFIG_BCM4710
120 #if R5432_CP0_INTERRUPT_WAR
123 diff -urN linux.old/arch/mips/mm/c-r4k.c linux.dev/arch/mips/mm/c-r4k.c
124 --- linux.old/arch/mips/mm/c-r4k.c 2005-06-01 18:42:44.000000000 +0200
125 +++ linux.dev/arch/mips/mm/c-r4k.c 2005-06-01 18:49:07.000000000 +0200
127 #include <linux/mm.h>
128 #include <linux/bitops.h>
130 +#ifdef CONFIG_BCM4710
131 +#include "../bcm947xx/include/typedefs.h"
132 +#include "../bcm947xx/include/sbconfig.h"
133 +#include <asm/paccess.h>
136 #include <asm/bcache.h>
137 #include <asm/bootinfo.h>
138 #include <asm/cacheops.h>
140 addr = start & ~(dc_lsize - 1);
141 aend = (end - 1) & ~(dc_lsize - 1);
143 +#ifdef CONFIG_BCM4710
144 + BCM4710_FILL_TLB(addr);
145 + BCM4710_FILL_TLB(aend);
149 /* Hit_Writeback_Inv_D */
150 protected_writeback_dcache_line(addr);
153 addr = start & ~(ic_lsize - 1);
154 aend = (end - 1) & ~(ic_lsize - 1);
155 +#ifdef CONFIG_BCM4710
156 + BCM4710_FILL_TLB(addr);
157 + BCM4710_FILL_TLB(aend);
160 /* Hit_Invalidate_I */
161 protected_flush_icache_line(addr);
164 a = addr & ~(sc_lsize - 1);
165 end = (addr + size - 1) & ~(sc_lsize - 1);
166 +#ifdef CONFIG_BCM4710
167 + BCM4710_FILL_TLB(a);
168 + BCM4710_FILL_TLB(end);
171 flush_scache_line(a); /* Hit_Writeback_Inv_SD */
174 R4600_HIT_CACHEOP_WAR_IMPL;
175 a = addr & ~(dc_lsize - 1);
176 end = (addr + size - 1) & ~(dc_lsize - 1);
177 +#ifdef CONFIG_BCM4710
178 + BCM4710_FILL_TLB(a);
179 + BCM4710_FILL_TLB(end);
182 flush_dcache_line(a); /* Hit_Writeback_Inv_D */
186 a = addr & ~(sc_lsize - 1);
187 end = (addr + size - 1) & ~(sc_lsize - 1);
188 +#ifdef CONFIG_BCM4710
189 + BCM4710_FILL_TLB(a);
190 + BCM4710_FILL_TLB(end);
193 flush_scache_line(a); /* Hit_Writeback_Inv_SD */
196 unsigned long ic_lsize = current_cpu_data.icache.linesz;
197 unsigned long dc_lsize = current_cpu_data.dcache.linesz;
199 +#ifdef CONFIG_BCM4710
200 + BCM4710_PROTECTED_FILL_TLB(addr);
201 + BCM4710_PROTECTED_FILL_TLB(addr + 4);
203 R4600_HIT_CACHEOP_WAR_IMPL;
204 protected_writeback_dcache_line(addr & ~(dc_lsize - 1));
205 protected_flush_icache_line(addr & ~(ic_lsize - 1));
206 diff -urN linux.old/include/asm-mips/r4kcache.h linux.dev/include/asm-mips/r4kcache.h
207 --- linux.old/include/asm-mips/r4kcache.h 2005-06-01 18:42:43.000000000 +0200
208 +++ linux.dev/include/asm-mips/r4kcache.h 2005-06-01 19:07:11.000000000 +0200
211 #include <asm/cacheops.h>
213 +#ifdef CONFIG_BCM4710
214 +#define BCM4710_DUMMY_RREG() (((sbconfig_t *)(KSEG1ADDR(SB_ENUM_BASE + SBCONFIGOFF)))->sbimstate)
216 +#define BCM4710_FILL_TLB(addr) (*(volatile unsigned long *)(addr))
217 +#define BCM4710_PROTECTED_FILL_TLB(addr) ({ unsigned long x; get_dbe(x, (volatile unsigned long *)(addr)); })
219 +#define cache_op(op,addr) \
220 + BCM4710_DUMMY_RREG(); \
221 + __asm__ __volatile__( \
222 + " .set noreorder \n" \
223 + " .set mips3\n\t \n" \
224 + " cache %0, %1 \n" \
228 + : "i" (op), "m" (*(unsigned char *)(addr)))
232 #define cache_op(op,addr) \
233 __asm__ __volatile__( \
234 " .set noreorder \n" \
238 : "i" (op), "m" (*(unsigned char *)(addr)))
242 static inline void flush_icache_line_indexed(unsigned long addr)
246 static inline void flush_dcache_line_indexed(unsigned long addr)
248 +#ifdef CONFIG_BCM4710
249 + BCM4710_DUMMY_RREG();
251 cache_op(Index_Writeback_Inv_D, addr);
256 static inline void flush_dcache_line(unsigned long addr)
259 +#ifdef CONFIG_BCM4710
260 + BCM4710_DUMMY_RREG();
262 cache_op(Hit_Writeback_Inv_D, addr);
267 static inline void protected_writeback_dcache_line(unsigned long addr)
269 +#ifdef CONFIG_BCM4710
270 + BCM4710_DUMMY_RREG();
272 __asm__ __volatile__(
276 unsigned long ws, addr;
278 for (ws = 0; ws < ws_end; ws += ws_inc)
279 - for (addr = start; addr < end; addr += 0x200)
280 + for (addr = start; addr < end; addr += 0x200) {
281 +#ifdef CONFIG_BCM4710
282 + BCM4710_DUMMY_RREG();
284 cache16_unroll32(addr|ws,Index_Writeback_Inv_D);
288 static inline void blast_dcache16_page(unsigned long page)
290 unsigned long end = start + PAGE_SIZE;
293 +#ifdef CONFIG_BCM4710
294 + BCM4710_DUMMY_RREG();
296 cache16_unroll32(start,Hit_Writeback_Inv_D);
298 } while (start < end);
300 unsigned long ws, addr;
302 for (ws = 0; ws < ws_end; ws += ws_inc)
303 - for (addr = start; addr < end; addr += 0x200)
304 + for (addr = start; addr < end; addr += 0x200) {
305 +#ifdef CONFIG_BCM4710
306 + BCM4710_DUMMY_RREG();
308 cache16_unroll32(addr|ws,Index_Writeback_Inv_D);
312 static inline void blast_icache16(void)
314 unsigned long start = page;
315 unsigned long end = start + PAGE_SIZE;
317 +#ifdef CONFIG_BCM4710
318 + BCM4710_FILL_TLB(start);
321 +#ifdef CONFIG_BCM4710
322 + BCM4710_DUMMY_RREG();
324 cache16_unroll32(start,Hit_Invalidate_I);
326 } while (start < end);
328 unsigned long ws, addr;
330 for (ws = 0; ws < ws_end; ws += ws_inc)
331 - for (addr = start; addr < end; addr += 0x400)
332 + for (addr = start; addr < end; addr += 0x400) {
333 +#ifdef CONFIG_BCM4710
334 + BCM4710_DUMMY_RREG();
336 cache32_unroll32(addr|ws,Index_Writeback_Inv_D);
340 static inline void blast_dcache32_page(unsigned long page)
342 unsigned long start = page;
343 unsigned long end = start + PAGE_SIZE;
345 +#ifdef CONFIG_BCM4710
346 + __asm__ __volatile__("nop;nop;nop;nop");
349 +#ifdef CONFIG_BCM4710
350 + BCM4710_DUMMY_RREG();
352 cache32_unroll32(start,Hit_Writeback_Inv_D);
354 } while (start < end);
356 unsigned long start = page;
357 unsigned long end = start + PAGE_SIZE;
359 +#ifdef CONFIG_BCM4710
360 + BCM4710_FILL_TLB(start);
363 cache32_unroll32(start,Hit_Invalidate_I);
365 diff -urN linux.old/arch/mips/mm/c-r4k.c linux.dev/arch/mips/mm/c-r4k.c
366 --- linux.old/arch/mips/mm/c-r4k.c 2005-06-01 18:49:07.000000000 +0200
367 +++ linux.dev/arch/mips/mm/c-r4k.c 2005-06-03 12:11:13.000000000 +0200
369 #define cpu_is_r4600_v1_x() ((read_c0_prid() & 0xfffffff0) == 0x2010)
370 #define cpu_is_r4600_v2_x() ((read_c0_prid() & 0xfffffff0) == 0x2020)
372 +#ifndef CONFIG_BCM4710
373 #define R4600_HIT_CACHEOP_WAR_IMPL \
375 if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x()) \
377 if (R4600_V1_HIT_CACHEOP_WAR) \
378 __asm__ __volatile__("nop;nop;nop;nop"); \
381 +#define R4600_HIT_CACHEOP_WAR_IMPL
384 static void (* r4k_blast_dcache_page)(unsigned long addr);
386 static inline void r4k_blast_dcache_page_dc32(unsigned long addr)
388 +#ifdef CONFIG_BCM4710
389 + BCM4710_FILL_TLB(addr);
391 R4600_HIT_CACHEOP_WAR_IMPL;
392 blast_dcache32_page(addr);
395 R4600_HIT_CACHEOP_WAR_IMPL;
396 a = addr & ~(dc_lsize - 1);
397 end = (addr + size - 1) & ~(dc_lsize - 1);
398 +#ifdef CONFIG_BCM4710
399 + BCM4710_FILL_TLB(a);
400 + BCM4710_FILL_TLB(end);
403 flush_dcache_line(a); /* Hit_Writeback_Inv_D */
405 diff -urN linux.old/arch/mips/mm/c-r4k.c linux.dev/arch/mips/mm/c-r4k.c
406 --- linux.old/arch/mips/mm/c-r4k.c 2005-06-11 19:39:17.000000000 +0200
407 +++ linux.dev/arch/mips/mm/c-r4k.c 2005-06-11 19:54:48.000000000 +0200
408 @@ -1083,6 +1083,19 @@
409 static inline void coherency_setup(void)
411 change_c0_config(CONF_CM_CMASK, CONF_CM_DEFAULT);
413 +#if defined(CONFIG_BCM4310) || defined(CONFIG_BCM4704) || defined(CONFIG_BCM5365)
414 + if (BCM330X(current_cpu_data.processor_id)) {
417 + cm = read_c0_diag();
418 + /* Enable icache */
420 + /* Enable dcache */
427 * c0_status.cu=0 specifies that updates by the sc instruction use
428 @@ -1104,6 +1117,42 @@
432 +#ifdef CONFIG_BCM4704
433 +static void __init mips32_icache_fill(unsigned long addr, uint nbytes)
435 + unsigned long ic_lsize = current_cpu_data.icache.linesz;
437 + for (i = 0; i < nbytes; i += ic_lsize)
438 + fill_icache_line((addr + i));
442 + * This must be run from the cache on 4704A0
443 + * so there are no mips core BIU ops in progress
444 + * when the PFC is enabled.
446 +#define PFC_CR0 0xff400000 /* control reg 0 */
447 +#define PFC_CR1 0xff400004 /* control reg 1 */
448 +static void __init enable_pfc(u32 mode)
451 + *(volatile u32 *)PFC_CR1 = 0xffff0000;
454 + *(volatile u32 *)PFC_CR0 = mode;
457 +void check_enable_mips_pfc(int val)
459 + /* enable prefetch cache */
460 + if (BCM330X(current_cpu_data.processor_id)
461 + && (read_c0_diag() & (1 << 29))) {
462 + mips32_icache_fill((unsigned long) &enable_pfc, 64);
468 void __init ld_mmu_r4xx0(void)
470 extern void build_clear_page(void);
471 @@ -1159,47 +1208,9 @@
477 -#ifdef CONFIG_BCM4704
478 -static void __init mips32_icache_fill(unsigned long addr, uint nbytes)
480 - unsigned long ic_lsize = current_cpu_data.icache.linesz;
482 - for (i = 0; i < nbytes; i += ic_lsize)
483 - fill_icache_line((addr + i));
487 - * This must be run from the cache on 4704A0
488 - * so there are no mips core BIU ops in progress
489 - * when the PFC is enabled.
491 -#define PFC_CR0 0xff400000 /* control reg 0 */
492 -#define PFC_CR1 0xff400004 /* control reg 1 */
493 -static void __init enable_pfc(u32 mode)
496 - *(volatile u32 *)PFC_CR1 = 0xffff0000;
499 - *(volatile u32 *)PFC_CR0 = mode;
504 -void check_enable_mips_pfc(int val)
508 #ifdef CONFIG_BCM4704
509 - struct cpuinfo_mips *c = ¤t_cpu_data;
511 - /* enable prefetch cache */
512 - if (((c->processor_id & (PRID_COMP_MASK | PRID_IMP_MASK)) == PRID_IMP_BCM3302)
513 - && (read_c0_diag() & (1 << 29))) {
514 - mips32_icache_fill((unsigned long) &enable_pfc, 64);
517 + check_enable_mips_pfc(0x15);