1 From 42789dfb077bb7b640ee19d0e3f7808dc5318adf Mon Sep 17 00:00:00 2001
2 From: Lars-Peter Clausen <lars@metafoo.de>
3 Date: Mon, 11 Jan 2010 04:29:35 +0100
4 Subject: [PATCH] /opt/Projects/openwrt/target/linux/xburst/patches-2.6.31/001-core.patch
7 arch/mips/Kconfig | 29 ++++
8 arch/mips/Makefile | 18 +++
9 arch/mips/boot/Makefile | 23 +++-
10 arch/mips/include/asm/bootinfo.h | 6 +
11 arch/mips/include/asm/cpu.h | 13 ++-
12 arch/mips/include/asm/mach-generic/irq.h | 2 +-
13 arch/mips/include/asm/r4kcache.h | 231 ++++++++++++++++++++++++++++++
14 arch/mips/include/asm/suspend.h | 3 +
15 arch/mips/kernel/cpu-probe.c | 21 +++
16 arch/mips/mm/c-r4k.c | 30 ++++
17 arch/mips/mm/cache.c | 2 +
18 arch/mips/mm/tlbex.c | 5 +
19 12 files changed, 379 insertions(+), 4 deletions(-)
21 --- a/arch/mips/Kconfig
22 +++ b/arch/mips/Kconfig
23 @@ -174,6 +174,9 @@ config MACH_JAZZ
24 Members include the Acer PICA, MIPS Magnum 4000, MIPS Millennium and
25 Olivetti M700-10 workstations.
28 + bool "Ingenic JZ4720/JZ4740 based machines"
31 bool "LASAT Networks platforms"
33 @@ -677,6 +680,7 @@ source "arch/mips/alchemy/Kconfig"
34 source "arch/mips/basler/excite/Kconfig"
35 source "arch/mips/bcm63xx/Kconfig"
36 source "arch/mips/jazz/Kconfig"
37 +source "arch/mips/jz4740/Kconfig"
38 source "arch/mips/lasat/Kconfig"
39 source "arch/mips/pmc-sierra/Kconfig"
40 source "arch/mips/sgi-ip27/Kconfig"
41 --- a/arch/mips/Makefile
42 +++ b/arch/mips/Makefile
43 @@ -186,6 +186,14 @@ cflags-$(CONFIG_AR7) += -I$(srctree)/ar
44 load-$(CONFIG_AR7) += 0xffffffff94100000
47 +# Commond Ingenic JZ4740 series
50 +core-$(CONFIG_SOC_JZ4740) += arch/mips/jz4740/
51 +cflags-$(CONFIG_SOC_JZ4740) += -I$(srctree)/arch/mips/include/asm/mach-jz4740
52 +load-$(CONFIG_SOC_JZ4740) += 0xffffffff80010000
55 # Acer PICA 61, Mips Magnum 4000 and Olivetti M700.
57 core-$(CONFIG_MACH_JAZZ) += arch/mips/jazz/
58 @@ -704,6 +712,12 @@ makeboot =$(Q)$(MAKE) $(build)=arch/mips
62 +uImage: $(vmlinux-32)
63 + +@$(call makeboot,$@)
65 +zImage: $(vmlinux-32)
66 + +@$(call makeboot,$@)
68 vmlinux.bin: $(vmlinux-32)
71 @@ -733,6 +747,7 @@ install:
74 @$(MAKE) $(clean)=arch/mips/boot
75 + @$(MAKE) $(clean)=arch/mips/boot/compressed
76 @$(MAKE) $(clean)=arch/mips/lasat
79 @@ -740,6 +755,9 @@ define archhelp
80 echo ' vmlinux.ecoff - ECOFF boot image'
81 echo ' vmlinux.bin - Raw binary boot image'
82 echo ' vmlinux.srec - SREC boot image'
83 + echo ' uImage - u-boot format image (arch/$(ARCH)/boot/uImage)'
84 + echo ' zImage - Compressed binary image (arch/$(ARCH)/boot/compressed/zImage)'
85 + echo ' vmlinux.bin - Uncompressed binary image (arch/$(ARCH)/boot/vmlinux.bin)'
87 echo ' These will be default as apropriate for a configured platform.'
89 --- a/arch/mips/boot/Makefile
90 +++ b/arch/mips/boot/Makefile
92 # Copyright (C) 2004 Maciej W. Rozycki
95 +# This one must match the LOADADDR in arch/mips/Makefile!
99 # Some DECstations need all possible sections of an ECOFF executable
101 @@ -25,7 +28,7 @@ strip-flags = $(addprefix --remove-secti
105 -all: vmlinux.ecoff vmlinux.srec addinitrd
106 +all: vmlinux.ecoff vmlinux.srec addinitrd uImage zImage
108 vmlinux.ecoff: $(obj)/elf2ecoff $(VMLINUX)
109 $(obj)/elf2ecoff $(VMLINUX) vmlinux.ecoff $(E2EFLAGS)
110 @@ -42,8 +45,24 @@ vmlinux.srec: $(VMLINUX)
111 $(obj)/addinitrd: $(obj)/addinitrd.c
114 +uImage: $(VMLINUX) vmlinux.bin
115 + rm -f $(obj)/vmlinux.bin.gz
116 + gzip -9 $(obj)/vmlinux.bin
117 + mkimage -A mips -O linux -T kernel -C gzip \
118 + -a $(LOADADDR) -e $(shell sh ./$(obj)/tools/entry $(NM) $(VMLINUX) ) \
119 + -n 'Linux-$(KERNELRELEASE)' \
120 + -d $(obj)/vmlinux.bin.gz $(obj)/uImage
121 + @echo ' Kernel: arch/mips/boot/$@ is ready'
124 + $(Q)$(MAKE) $(build)=$(obj)/compressed loadaddr=$(LOADADDR) $@
125 + @echo ' Kernel: arch/mips/boot/compressed/$@ is ready'
127 clean-files += addinitrd \
136 --- a/arch/mips/include/asm/bootinfo.h
137 +++ b/arch/mips/include/asm/bootinfo.h
139 #define MACH_DEXXON_GDIUM2F10 5
140 #define MACH_LOONGSON_END 6
143 + * Valid machtype for group INGENIC
145 +#define MACH_INGENIC_JZ4730 0 /* JZ4730 SOC */
146 +#define MACH_INGENIC_JZ4740 1 /* JZ4740 SOC */
148 #define CL_SIZE COMMAND_LINE_SIZE
150 extern char *system_type;
151 --- a/arch/mips/include/asm/cpu.h
152 +++ b/arch/mips/include/asm/cpu.h
154 #define PRID_COMP_LSI 0x080000
155 #define PRID_COMP_LEXRA 0x0b0000
156 #define PRID_COMP_CAVIUM 0x0d0000
158 +#define PRID_COMP_INGENIC 0xd00000
161 * Assigned values for the product ID register. In order to detect a
163 #define PRID_IMP_CAVIUM_CN52XX 0x0700
166 + * These are the PRID's for when 23:16 == PRID_COMP_INGENIC
169 +#define PRID_IMP_JZRISC 0x0200
172 * Definitions for 7:0 on legacy processors
175 @@ -224,6 +230,11 @@ enum cpu_type_enum {
176 CPU_5KC, CPU_20KC, CPU_25KF, CPU_SB1, CPU_SB1A, CPU_LOONGSON2,
180 + * Ingenic class processors
182 + CPU_JZRISC, CPU_XBURST,
187 --- a/arch/mips/include/asm/r4kcache.h
188 +++ b/arch/mips/include/asm/r4kcache.h
190 #include <asm/cpu-features.h>
191 #include <asm/mipsmtregs.h>
193 +#ifdef CONFIG_JZRISC
195 +#define K0_TO_K1() \
197 + unsigned long __k0_addr; \
199 + __asm__ __volatile__( \
201 + "or %0, %0, %1\n\t" \
205 + : "=&r"(__k0_addr) \
206 + : "r" (0x20000000) ); \
209 +#define K1_TO_K0() \
211 + unsigned long __k0_addr; \
212 + __asm__ __volatile__( \
213 + "nop;nop;nop;nop;nop;nop;nop\n\t" \
218 + : "=&r" (__k0_addr)); \
221 +#define INVALIDATE_BTB() \
223 + unsigned long tmp; \
224 + __asm__ __volatile__( \
225 + ".set mips32\n\t" \
226 + "mfc0 %0, $16, 7\n\t" \
229 + "mtc0 %0, $16, 7\n\t" \
234 +#define SYNC_WB() __asm__ __volatile__ ("sync")
236 +#else /* CONFIG_JZRISC */
238 +#define K0_TO_K1() do { } while (0)
239 +#define K1_TO_K0() do { } while (0)
240 +#define INVALIDATE_BTB() do { } while (0)
241 +#define SYNC_WB() do { } while (0)
243 +#endif /* CONFIG_JZRISC */
246 * This macro return a properly sign-extended address suitable as base address
247 * for indexed cache operations. Two issues here:
248 @@ -144,6 +196,7 @@ static inline void flush_icache_line_ind
251 cache_op(Index_Invalidate_I, addr);
256 @@ -151,6 +204,7 @@ static inline void flush_dcache_line_ind
259 cache_op(Index_Writeback_Inv_D, addr);
264 @@ -163,6 +217,7 @@ static inline void flush_icache_line(uns
267 cache_op(Hit_Invalidate_I, addr);
272 @@ -170,6 +225,7 @@ static inline void flush_dcache_line(uns
275 cache_op(Hit_Writeback_Inv_D, addr);
280 @@ -177,6 +233,7 @@ static inline void invalidate_dcache_lin
283 cache_op(Hit_Invalidate_D, addr);
288 @@ -209,6 +266,7 @@ static inline void flush_scache_line(uns
289 static inline void protected_flush_icache_line(unsigned long addr)
291 protected_cache_op(Hit_Invalidate_I, addr);
296 @@ -220,6 +278,7 @@ static inline void protected_flush_icach
297 static inline void protected_writeback_dcache_line(unsigned long addr)
299 protected_cache_op(Hit_Writeback_Inv_D, addr);
303 static inline void protected_writeback_scache_line(unsigned long addr)
304 @@ -396,8 +455,10 @@ static inline void blast_##pfx##cache##l
305 __BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16)
306 __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16)
307 __BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16)
308 +#ifndef CONFIG_JZRISC
309 __BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32)
310 __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32)
312 __BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32)
313 __BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 64)
314 __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64)
315 @@ -405,12 +466,122 @@ __BUILD_BLAST_CACHE(s, scache, Index_Wri
316 __BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128)
318 __BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 16)
319 +#ifndef CONFIG_JZRISC
320 __BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 32)
322 __BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 16)
323 __BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 32)
324 __BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 64)
325 __BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 128)
327 +#ifdef CONFIG_JZRISC
329 +static inline void blast_dcache32(void)
331 + unsigned long start = INDEX_BASE;
332 + unsigned long end = start + current_cpu_data.dcache.waysize;
333 + unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
334 + unsigned long ws_end = current_cpu_data.dcache.ways <<
335 + current_cpu_data.dcache.waybit;
336 + unsigned long ws, addr;
338 + for (ws = 0; ws < ws_end; ws += ws_inc)
339 + for (addr = start; addr < end; addr += 0x400)
340 + cache32_unroll32(addr|ws,Index_Writeback_Inv_D);
345 +static inline void blast_dcache32_page(unsigned long page)
347 + unsigned long start = page;
348 + unsigned long end = page + PAGE_SIZE;
351 + cache32_unroll32(start,Hit_Writeback_Inv_D);
353 + } while (start < end);
358 +static inline void blast_dcache32_page_indexed(unsigned long page)
360 + unsigned long indexmask = current_cpu_data.dcache.waysize - 1;
361 + unsigned long start = INDEX_BASE + (page & indexmask);
362 + unsigned long end = start + PAGE_SIZE;
363 + unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
364 + unsigned long ws_end = current_cpu_data.dcache.ways <<
365 + current_cpu_data.dcache.waybit;
366 + unsigned long ws, addr;
368 + for (ws = 0; ws < ws_end; ws += ws_inc)
369 + for (addr = start; addr < end; addr += 0x400)
370 + cache32_unroll32(addr|ws,Index_Writeback_Inv_D);
375 +static inline void blast_icache32(void)
377 + unsigned long start = INDEX_BASE;
378 + unsigned long end = start + current_cpu_data.icache.waysize;
379 + unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
380 + unsigned long ws_end = current_cpu_data.icache.ways <<
381 + current_cpu_data.icache.waybit;
382 + unsigned long ws, addr;
386 + for (ws = 0; ws < ws_end; ws += ws_inc)
387 + for (addr = start; addr < end; addr += 0x400)
388 + cache32_unroll32(addr|ws,Index_Invalidate_I);
395 +static inline void blast_icache32_page(unsigned long page)
397 + unsigned long start = page;
398 + unsigned long end = page + PAGE_SIZE;
403 + cache32_unroll32(start,Hit_Invalidate_I);
405 + } while (start < end);
412 +static inline void blast_icache32_page_indexed(unsigned long page)
414 + unsigned long indexmask = current_cpu_data.icache.waysize - 1;
415 + unsigned long start = INDEX_BASE + (page & indexmask);
416 + unsigned long end = start + PAGE_SIZE;
417 + unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
418 + unsigned long ws_end = current_cpu_data.icache.ways <<
419 + current_cpu_data.icache.waybit;
420 + unsigned long ws, addr;
424 + for (ws = 0; ws < ws_end; ws += ws_inc)
425 + for (addr = start; addr < end; addr += 0x400)
426 + cache32_unroll32(addr|ws,Index_Invalidate_I);
433 +#endif /* CONFIG_JZRISC */
435 /* build blast_xxx_range, protected_blast_xxx_range */
436 #define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot) \
437 static inline void prot##blast_##pfx##cache##_range(unsigned long start, \
438 @@ -432,13 +603,73 @@ static inline void prot##blast_##pfx##ca
439 __##pfx##flush_epilogue \
442 +#ifndef CONFIG_JZRISC
443 __BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_)
445 __BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_)
446 +#ifndef CONFIG_JZRISC
447 __BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_)
448 __BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, )
450 __BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, )
451 /* blast_inv_dcache_range */
452 __BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D, )
453 __BUILD_BLAST_CACHE_RANGE(inv_s, scache, Hit_Invalidate_SD, )
455 +#ifdef CONFIG_JZRISC
457 +static inline void protected_blast_dcache_range(unsigned long start,
460 + unsigned long lsize = cpu_dcache_line_size();
461 + unsigned long addr = start & ~(lsize - 1);
462 + unsigned long aend = (end - 1) & ~(lsize - 1);
465 + protected_cache_op(Hit_Writeback_Inv_D, addr);
473 +static inline void protected_blast_icache_range(unsigned long start,
476 + unsigned long lsize = cpu_icache_line_size();
477 + unsigned long addr = start & ~(lsize - 1);
478 + unsigned long aend = (end - 1) & ~(lsize - 1);
483 + protected_cache_op(Hit_Invalidate_I, addr);
493 +static inline void blast_dcache_range(unsigned long start,
496 + unsigned long lsize = cpu_dcache_line_size();
497 + unsigned long addr = start & ~(lsize - 1);
498 + unsigned long aend = (end - 1) & ~(lsize - 1);
501 + cache_op(Hit_Writeback_Inv_D, addr);
509 +#endif /* CONFIG_JZRISC */
511 #endif /* _ASM_R4KCACHE_H */
512 --- a/arch/mips/kernel/cpu-probe.c
513 +++ b/arch/mips/kernel/cpu-probe.c
514 @@ -160,6 +160,7 @@ void __init check_wait(void)
517 case CPU_CAVIUM_OCTEON:
522 @@ -902,6 +903,21 @@ static inline void cpu_probe_cavium(stru
526 +static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
529 + c->options &= ~MIPS_CPU_COUNTER; /* JZRISC does not implement the CP0 counter. */
530 + switch (c->processor_id & 0xff00) {
531 + case PRID_IMP_JZRISC:
532 + c->cputype = CPU_JZRISC;
533 + __cpu_name[cpu] = "Ingenic JZRISC";
536 + panic("Unknown Ingenic Processor ID!");
541 const char *__cpu_name[NR_CPUS];
543 __cpuinit void cpu_probe(void)
544 @@ -939,6 +955,9 @@ __cpuinit void cpu_probe(void)
545 case PRID_COMP_CAVIUM:
546 cpu_probe_cavium(c, cpu);
548 + case PRID_COMP_INGENIC:
549 + cpu_probe_ingenic(c, cpu);
553 BUG_ON(!__cpu_name[cpu]);
554 --- a/arch/mips/mm/tlbex.c
555 +++ b/arch/mips/mm/tlbex.c
556 @@ -389,6 +389,11 @@ static void __cpuinit build_tlb_write_en
566 panic("No TLB refill handler yet (CPU type: %d)",
567 current_cpu_data.cputype);