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 --- a/arch/mips/Makefile
34 +++ b/arch/mips/Makefile
35 @@ -184,6 +184,14 @@ cflags-$(CONFIG_AR7) += -I$(srctree)/ar
36 load-$(CONFIG_AR7) += 0xffffffff94100000
39 +# Commond Ingenic JZ4740 series
42 +core-$(CONFIG_SOC_JZ4740) += arch/mips/jz4740/
43 +cflags-$(CONFIG_SOC_JZ4740) += -I$(srctree)/arch/mips/include/asm/mach-jz4740
44 +load-$(CONFIG_SOC_JZ4740) += 0xffffffff80010000
47 # Acer PICA 61, Mips Magnum 4000 and Olivetti M700.
49 core-$(CONFIG_MACH_JAZZ) += arch/mips/jazz/
50 @@ -705,6 +713,12 @@ makeboot =$(Q)$(MAKE) $(build)=arch/mips
54 +uImage: $(vmlinux-32)
55 + +@$(call makeboot,$@)
57 +zImage: $(vmlinux-32)
58 + +@$(call makeboot,$@)
60 vmlinux.bin: $(vmlinux-32)
63 @@ -734,6 +748,7 @@ install:
66 @$(MAKE) $(clean)=arch/mips/boot
67 + @$(MAKE) $(clean)=arch/mips/boot/compressed
68 @$(MAKE) $(clean)=arch/mips/lasat
71 @@ -741,6 +756,9 @@ define archhelp
72 echo ' vmlinux.ecoff - ECOFF boot image'
73 echo ' vmlinux.bin - Raw binary boot image'
74 echo ' vmlinux.srec - SREC boot image'
75 + echo ' uImage - u-boot format image (arch/$(ARCH)/boot/uImage)'
76 + echo ' zImage - Compressed binary image (arch/$(ARCH)/boot/compressed/zImage)'
77 + echo ' vmlinux.bin - Uncompressed binary image (arch/$(ARCH)/boot/vmlinux.bin)'
79 echo ' These will be default as apropriate for a configured platform.'
81 --- a/arch/mips/boot/Makefile
82 +++ b/arch/mips/boot/Makefile
84 # Copyright (C) 2004 Maciej W. Rozycki
87 +# This one must match the LOADADDR in arch/mips/Makefile!
91 # Some DECstations need all possible sections of an ECOFF executable
93 @@ -25,7 +28,7 @@ strip-flags = $(addprefix --remove-secti
97 -all: vmlinux.ecoff vmlinux.srec addinitrd
98 +all: vmlinux.ecoff vmlinux.srec addinitrd uImage zImage
100 vmlinux.ecoff: $(obj)/elf2ecoff $(VMLINUX)
101 $(obj)/elf2ecoff $(VMLINUX) vmlinux.ecoff $(E2EFLAGS)
102 @@ -42,8 +45,24 @@ vmlinux.srec: $(VMLINUX)
103 $(obj)/addinitrd: $(obj)/addinitrd.c
106 +uImage: $(VMLINUX) vmlinux.bin
107 + rm -f $(obj)/vmlinux.bin.gz
108 + gzip -9 $(obj)/vmlinux.bin
109 + mkimage -A mips -O linux -T kernel -C gzip \
110 + -a $(LOADADDR) -e $(shell sh ./$(obj)/tools/entry $(NM) $(VMLINUX) ) \
111 + -n 'Linux-$(KERNELRELEASE)' \
112 + -d $(obj)/vmlinux.bin.gz $(obj)/uImage
113 + @echo ' Kernel: arch/mips/boot/$@ is ready'
116 + $(Q)$(MAKE) $(build)=$(obj)/compressed loadaddr=$(LOADADDR) $@
117 + @echo ' Kernel: arch/mips/boot/compressed/$@ is ready'
119 clean-files += addinitrd \
128 --- a/arch/mips/include/asm/bootinfo.h
129 +++ b/arch/mips/include/asm/bootinfo.h
131 #define MACH_DEXXON_GDIUM2F10 5
132 #define MACH_LOONGSON_END 6
135 + * Valid machtype for group INGENIC
137 +#define MACH_INGENIC_JZ4730 0 /* JZ4730 SOC */
138 +#define MACH_INGENIC_JZ4740 1 /* JZ4740 SOC */
140 #define CL_SIZE COMMAND_LINE_SIZE
142 extern char *system_type;
143 --- a/arch/mips/include/asm/cpu.h
144 +++ b/arch/mips/include/asm/cpu.h
146 #define PRID_COMP_LSI 0x080000
147 #define PRID_COMP_LEXRA 0x0b0000
148 #define PRID_COMP_CAVIUM 0x0d0000
150 +#define PRID_COMP_INGENIC 0xd00000
153 * Assigned values for the product ID register. In order to detect a
155 #define PRID_IMP_CAVIUM_CN52XX 0x0700
158 + * These are the PRID's for when 23:16 == PRID_COMP_INGENIC
161 +#define PRID_IMP_JZRISC 0x0200
164 * Definitions for 7:0 on legacy processors
167 @@ -224,6 +230,11 @@ enum cpu_type_enum {
168 CPU_5KC, CPU_20KC, CPU_25KF, CPU_SB1, CPU_SB1A, CPU_LOONGSON2,
172 + * Ingenic class processors
174 + CPU_JZRISC, CPU_XBURST,
179 --- a/arch/mips/include/asm/r4kcache.h
180 +++ b/arch/mips/include/asm/r4kcache.h
182 #include <asm/cpu-features.h>
183 #include <asm/mipsmtregs.h>
185 +#ifdef CONFIG_JZRISC
187 +#define K0_TO_K1() \
189 + unsigned long __k0_addr; \
191 + __asm__ __volatile__( \
193 + "or %0, %0, %1\n\t" \
197 + : "=&r"(__k0_addr) \
198 + : "r" (0x20000000) ); \
201 +#define K1_TO_K0() \
203 + unsigned long __k0_addr; \
204 + __asm__ __volatile__( \
205 + "nop;nop;nop;nop;nop;nop;nop\n\t" \
210 + : "=&r" (__k0_addr)); \
213 +#define INVALIDATE_BTB() \
215 + unsigned long tmp; \
216 + __asm__ __volatile__( \
217 + ".set mips32\n\t" \
218 + "mfc0 %0, $16, 7\n\t" \
221 + "mtc0 %0, $16, 7\n\t" \
226 +#define SYNC_WB() __asm__ __volatile__ ("sync")
228 +#else /* CONFIG_JZRISC */
230 +#define K0_TO_K1() do { } while (0)
231 +#define K1_TO_K0() do { } while (0)
232 +#define INVALIDATE_BTB() do { } while (0)
233 +#define SYNC_WB() do { } while (0)
235 +#endif /* CONFIG_JZRISC */
238 * This macro return a properly sign-extended address suitable as base address
239 * for indexed cache operations. Two issues here:
240 @@ -144,6 +196,7 @@ static inline void flush_icache_line_ind
243 cache_op(Index_Invalidate_I, addr);
248 @@ -151,6 +204,7 @@ static inline void flush_dcache_line_ind
251 cache_op(Index_Writeback_Inv_D, addr);
256 @@ -163,6 +217,7 @@ static inline void flush_icache_line(uns
259 cache_op(Hit_Invalidate_I, addr);
264 @@ -170,6 +225,7 @@ static inline void flush_dcache_line(uns
267 cache_op(Hit_Writeback_Inv_D, addr);
272 @@ -177,6 +233,7 @@ static inline void invalidate_dcache_lin
275 cache_op(Hit_Invalidate_D, addr);
280 @@ -209,6 +266,7 @@ static inline void flush_scache_line(uns
281 static inline void protected_flush_icache_line(unsigned long addr)
283 protected_cache_op(Hit_Invalidate_I, addr);
288 @@ -220,6 +278,7 @@ static inline void protected_flush_icach
289 static inline void protected_writeback_dcache_line(unsigned long addr)
291 protected_cache_op(Hit_Writeback_Inv_D, addr);
295 static inline void protected_writeback_scache_line(unsigned long addr)
296 @@ -396,8 +455,10 @@ static inline void blast_##pfx##cache##l
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)
299 __BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16)
300 +#ifndef CONFIG_JZRISC
301 __BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 32)
302 __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32)
304 __BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 32)
305 __BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 64)
306 __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64)
307 @@ -405,12 +466,122 @@ __BUILD_BLAST_CACHE(s, scache, Index_Wri
308 __BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128)
310 __BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 16)
311 +#ifndef CONFIG_JZRISC
312 __BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 32)
314 __BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 16)
315 __BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 32)
316 __BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 64)
317 __BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 128)
319 +#ifdef CONFIG_JZRISC
321 +static inline void blast_dcache32(void)
323 + unsigned long start = INDEX_BASE;
324 + unsigned long end = start + current_cpu_data.dcache.waysize;
325 + unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
326 + unsigned long ws_end = current_cpu_data.dcache.ways <<
327 + current_cpu_data.dcache.waybit;
328 + unsigned long ws, addr;
330 + for (ws = 0; ws < ws_end; ws += ws_inc)
331 + for (addr = start; addr < end; addr += 0x400)
332 + cache32_unroll32(addr|ws,Index_Writeback_Inv_D);
337 +static inline void blast_dcache32_page(unsigned long page)
339 + unsigned long start = page;
340 + unsigned long end = page + PAGE_SIZE;
343 + cache32_unroll32(start,Hit_Writeback_Inv_D);
345 + } while (start < end);
350 +static inline void blast_dcache32_page_indexed(unsigned long page)
352 + unsigned long indexmask = current_cpu_data.dcache.waysize - 1;
353 + unsigned long start = INDEX_BASE + (page & indexmask);
354 + unsigned long end = start + PAGE_SIZE;
355 + unsigned long ws_inc = 1UL << current_cpu_data.dcache.waybit;
356 + unsigned long ws_end = current_cpu_data.dcache.ways <<
357 + current_cpu_data.dcache.waybit;
358 + unsigned long ws, addr;
360 + for (ws = 0; ws < ws_end; ws += ws_inc)
361 + for (addr = start; addr < end; addr += 0x400)
362 + cache32_unroll32(addr|ws,Index_Writeback_Inv_D);
367 +static inline void blast_icache32(void)
369 + unsigned long start = INDEX_BASE;
370 + unsigned long end = start + current_cpu_data.icache.waysize;
371 + unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
372 + unsigned long ws_end = current_cpu_data.icache.ways <<
373 + current_cpu_data.icache.waybit;
374 + unsigned long ws, addr;
378 + for (ws = 0; ws < ws_end; ws += ws_inc)
379 + for (addr = start; addr < end; addr += 0x400)
380 + cache32_unroll32(addr|ws,Index_Invalidate_I);
387 +static inline void blast_icache32_page(unsigned long page)
389 + unsigned long start = page;
390 + unsigned long end = page + PAGE_SIZE;
395 + cache32_unroll32(start,Hit_Invalidate_I);
397 + } while (start < end);
404 +static inline void blast_icache32_page_indexed(unsigned long page)
406 + unsigned long indexmask = current_cpu_data.icache.waysize - 1;
407 + unsigned long start = INDEX_BASE + (page & indexmask);
408 + unsigned long end = start + PAGE_SIZE;
409 + unsigned long ws_inc = 1UL << current_cpu_data.icache.waybit;
410 + unsigned long ws_end = current_cpu_data.icache.ways <<
411 + current_cpu_data.icache.waybit;
412 + unsigned long ws, addr;
416 + for (ws = 0; ws < ws_end; ws += ws_inc)
417 + for (addr = start; addr < end; addr += 0x400)
418 + cache32_unroll32(addr|ws,Index_Invalidate_I);
425 +#endif /* CONFIG_JZRISC */
427 /* build blast_xxx_range, protected_blast_xxx_range */
428 #define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot) \
429 static inline void prot##blast_##pfx##cache##_range(unsigned long start, \
430 @@ -432,13 +603,73 @@ static inline void prot##blast_##pfx##ca
431 __##pfx##flush_epilogue \
434 +#ifndef CONFIG_JZRISC
435 __BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, protected_)
437 __BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, protected_)
438 +#ifndef CONFIG_JZRISC
439 __BUILD_BLAST_CACHE_RANGE(i, icache, Hit_Invalidate_I, protected_)
440 __BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D, )
442 __BUILD_BLAST_CACHE_RANGE(s, scache, Hit_Writeback_Inv_SD, )
443 /* blast_inv_dcache_range */
444 __BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D, )
445 __BUILD_BLAST_CACHE_RANGE(inv_s, scache, Hit_Invalidate_SD, )
447 +#ifdef CONFIG_JZRISC
449 +static inline void protected_blast_dcache_range(unsigned long start,
452 + unsigned long lsize = cpu_dcache_line_size();
453 + unsigned long addr = start & ~(lsize - 1);
454 + unsigned long aend = (end - 1) & ~(lsize - 1);
457 + protected_cache_op(Hit_Writeback_Inv_D, addr);
465 +static inline void protected_blast_icache_range(unsigned long start,
468 + unsigned long lsize = cpu_icache_line_size();
469 + unsigned long addr = start & ~(lsize - 1);
470 + unsigned long aend = (end - 1) & ~(lsize - 1);
475 + protected_cache_op(Hit_Invalidate_I, addr);
485 +static inline void blast_dcache_range(unsigned long start,
488 + unsigned long lsize = cpu_dcache_line_size();
489 + unsigned long addr = start & ~(lsize - 1);
490 + unsigned long aend = (end - 1) & ~(lsize - 1);
493 + cache_op(Hit_Writeback_Inv_D, addr);
501 +#endif /* CONFIG_JZRISC */
503 #endif /* _ASM_R4KCACHE_H */
504 --- a/arch/mips/kernel/cpu-probe.c
505 +++ b/arch/mips/kernel/cpu-probe.c
506 @@ -160,6 +160,7 @@ void __init check_wait(void)
509 case CPU_CAVIUM_OCTEON:
514 @@ -902,6 +903,21 @@ static inline void cpu_probe_cavium(stru
518 +static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
521 + c->options &= ~MIPS_CPU_COUNTER; /* JZRISC does not implement the CP0 counter. */
522 + switch (c->processor_id & 0xff00) {
523 + case PRID_IMP_JZRISC:
524 + c->cputype = CPU_JZRISC;
525 + __cpu_name[cpu] = "Ingenic JZRISC";
528 + panic("Unknown Ingenic Processor ID!");
533 const char *__cpu_name[NR_CPUS];
535 __cpuinit void cpu_probe(void)
536 @@ -939,6 +957,9 @@ __cpuinit void cpu_probe(void)
537 case PRID_COMP_CAVIUM:
538 cpu_probe_cavium(c, cpu);
540 + case PRID_COMP_INGENIC:
541 + cpu_probe_ingenic(c, cpu);
545 BUG_ON(!__cpu_name[cpu]);
546 --- a/arch/mips/mm/tlbex.c
547 +++ b/arch/mips/mm/tlbex.c
548 @@ -389,6 +389,11 @@ static void __cpuinit build_tlb_write_en
558 panic("No TLB refill handler yet (CPU type: %d)",
559 current_cpu_data.cputype);