Cleanup glamo mmc driver.
[openwrt.git] / target / linux / coldfire / patches / 005-mcfv4e_kernel_mods.patch
1 From 823ad3e6e88353226ec28f48183a467181887a1b Mon Sep 17 00:00:00 2001
2 From: Kurt Mahan <kmahan@freescale.com>
3 Date: Wed, 31 Oct 2007 16:56:09 -0600
4 Subject: [PATCH] Core Coldfire/MCF54455 kernel changes.
5
6 LTIBName: mcfv4e-kernel-mods
7 Signed-off-by: Kurt Mahan <kmahan@freescale.com>
8 ---
9 arch/m68k/Kconfig | 65 ++++++++++++++++++++++++++++++++++++++-
10 arch/m68k/Kconfig.debug | 9 +++++
11 arch/m68k/Makefile | 14 ++++++++
12 arch/m68k/kernel/Makefile | 15 ++++++---
13 arch/m68k/kernel/asm-offsets.c | 7 ++++
14 arch/m68k/kernel/dma.c | 17 ++++++++++
15 arch/m68k/kernel/process.c | 57 +++++++++++++++++++++++++++++++++++
16 arch/m68k/kernel/setup.c | 49 ++++++++++++++++++++++++++----
17 arch/m68k/kernel/time.c | 5 +++
18 arch/m68k/kernel/vmlinux.lds.S | 2 +
19 10 files changed, 227 insertions(+), 13 deletions(-)
20
21 --- a/arch/m68k/Kconfig
22 +++ b/arch/m68k/Kconfig
23 @@ -119,6 +119,20 @@ config SUN3
24
25 If you don't want to compile a kernel exclusively for a Sun 3, say N.
26
27 +config COLDFIRE
28 + bool "ColdFire V4e support"
29 + default y
30 + select CFV4E
31 + help
32 + Say Y if you want to build a kernel to run on one of the ColdFire
33 + V4e boards.
34 +
35 +config CFV4E
36 + bool
37 + depends on COLDFIRE
38 + select MMU_CFV4E if MMU
39 + default y
40 +
41 config AMIGA
42 bool "Amiga support"
43 depends on !MMU_SUN3
44 @@ -294,14 +308,53 @@ config M68060
45 If you anticipate running this kernel on a computer with a MC68060
46 processor, say Y. Otherwise, say N.
47
48 +config M54455
49 + bool "MCF54455 support"
50 + depends on COLDFIRE
51 + default y
52 + help
53 + This option will add support for the MCF54455 processor with mmu.
54 +
55 +config MCFCLK
56 + int "M54455EVB System Clock"
57 + depends on M54455
58 + default 266666666
59 + help
60 + System clock for EVB. Usually 266MHz for u-boot and 200MHz for dBUG.
61 +
62 +config MCF_USER_HALT
63 + bool "Coldfire User Halt Enable"
64 + depends on M54455
65 + default n
66 + help
67 + Enables the HALT instruction in User Mode.
68 +
69 config MMU_MOTOROLA
70 bool
71 - depends on MMU && !MMU_SUN3
72 + depends on MMU && !MMU_SUN3 && !COLDFIRE
73 default y
74
75 config MMU_SUN3
76 bool
77
78 +config MMU_CFV4E
79 + bool
80 +
81 +config SDRAM_BASE
82 + hex
83 + depends on M54455
84 + default 0x40000000
85 +
86 +config SDRAM_SIZE
87 + hex
88 + depends on M54455
89 + default 0x0FFFFFFF
90 +
91 +config NOR_FLASH_BASE
92 + hex "NOR Flash Base Address"
93 + depends on M54455
94 + default 0x00000000
95 +
96 config M68KFPU_EMU
97 bool "Math emulation support (EXPERIMENTAL)"
98 depends on EXPERIMENTAL
99 @@ -468,6 +521,14 @@ config ZONE_DMA
100 source "drivers/pci/Kconfig"
101
102 source "drivers/zorro/Kconfig"
103 +endmenu
104 +
105 +menu "Power management options"
106 +
107 +config PM
108 + bool "Power Management support"
109 + help
110 + Support processor power management modes
111
112 endmenu
113
114 @@ -647,7 +708,7 @@ config DN_SERIAL
115
116 config SERIAL_CONSOLE
117 bool "Support for serial port console"
118 - depends on (AMIGA || ATARI || MAC || SUN3 || SUN3X || VME || APOLLO) && (ATARI_MFPSER=y || ATARI_SCC=y || ATARI_MIDI=y || MAC_SCC=y || AMIGA_BUILTIN_SERIAL=y || GVPIOEXT=y || MULTIFACE_III_TTY=y || SERIAL=y || MVME147_SCC || SERIAL167 || MVME162_SCC || BVME6000_SCC || DN_SERIAL)
119 + depends on (AMIGA || ATARI || MAC || SUN3 || SUN3X || VME || APOLLO || COLDFIRE) && (ATARI_MFPSER=y || ATARI_SCC=y || ATARI_MIDI=y || MAC_SCC=y || AMIGA_BUILTIN_SERIAL=y || GVPIOEXT=y || MULTIFACE_III_TTY=y || SERIAL=y || MVME147_SCC || SERIAL167 || MVME162_SCC || BVME6000_SCC || DN_SERIAL || SERIAL_COLDFIRE)
120 ---help---
121 If you say Y here, it will be possible to use a serial port as the
122 system console (the system console is the device which receives all
123 --- a/arch/m68k/Kconfig.debug
124 +++ b/arch/m68k/Kconfig.debug
125 @@ -2,4 +2,13 @@ menu "Kernel hacking"
126
127 source "lib/Kconfig.debug"
128
129 +config BOOTPARAM
130 + bool 'Compiled-in Kernel Boot Parameter'
131 + depends on COLDFIRE
132 +
133 +config BOOTPARAM_STRING
134 + string 'Kernel Boot Parameter'
135 + default 'console=ttyS0,115200'
136 + depends on BOOTPARAM
137 +
138 endmenu
139 --- a/arch/m68k/Makefile
140 +++ b/arch/m68k/Makefile
141 @@ -16,7 +16,9 @@
142 KBUILD_DEFCONFIG := amiga_defconfig
143
144 # override top level makefile
145 +ifndef CONFIG_COLDFIRE
146 AS += -m68020
147 +endif
148 LDFLAGS := -m m68kelf
149 LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds
150 ifneq ($(SUBARCH),$(ARCH))
151 @@ -36,6 +38,7 @@ CHECKFLAGS += -D__mc68000__
152 KBUILD_CFLAGS += -pipe -fno-strength-reduce -ffixed-a2
153
154 # enable processor switch if compiled only for a single cpu
155 +ifndef CONFIG_COLDFIRE
156 ifndef CONFIG_M68020
157 ifndef CONFIG_M68030
158
159 @@ -49,6 +52,12 @@ endif
160
161 endif
162 endif
163 +endif
164 +
165 +ifdef CONFIG_M54455
166 +CFLAGS := $(CFLAGS) -march=isac -mcpu=54455 -msoft-float -g
167 +AFLAGS := $(AFLAGS) -march=isac -mcpu=54455 -msoft-float
168 +endif
169
170 ifdef CONFIG_KGDB
171 # If configured for kgdb support, include debugging infos and keep the
172 @@ -57,8 +66,12 @@ KBUILD_CFLAGS := $(subst -fomit-frame-po
173 endif
174
175 ifndef CONFIG_SUN3
176 +ifndef CONFIG_COLDFIRE
177 head-y := arch/m68k/kernel/head.o
178 else
179 +head-y := arch/m68k/coldfire/head.o
180 +endif
181 +else
182 head-y := arch/m68k/kernel/sun3-head.o
183 endif
184
185 @@ -79,6 +92,7 @@ core-$(CONFIG_SUN3) += arch/m68k/sun3/
186 core-$(CONFIG_M68040) += arch/m68k/fpsp040/
187 core-$(CONFIG_M68060) += arch/m68k/ifpsp060/
188 core-$(CONFIG_M68KFPU_EMU) += arch/m68k/math-emu/
189 +core-$(CONFIG_COLDFIRE) += arch/m68k/coldfire/
190
191 all: zImage
192
193 --- a/arch/m68k/kernel/Makefile
194 +++ b/arch/m68k/kernel/Makefile
195 @@ -2,14 +2,19 @@
196 # Makefile for the linux kernel.
197 #
198
199 -ifndef CONFIG_SUN3
200 - extra-y := head.o
201 +ifdef CONFIG_SUN3
202 + extra-y := sun3-head.o vmlinux.lds
203 + obj-y := entry.o signal.o ints.o
204 else
205 - extra-y := sun3-head.o
206 +ifndef CONFIG_COLDFIRE
207 + extra-y := head.o vmlinux.lds
208 + obj-y := entry.o signal.o traps.o ints.o
209 +else # CONFIG_COLDFIRE
210 + extra-y := ../coldfire/head.o vmlinux.lds
211 +endif
212 endif
213 -extra-y += vmlinux.lds
214
215 -obj-y := entry.o process.o traps.o ints.o signal.o ptrace.o module.o \
216 +obj-y += process.o ptrace.o module.o \
217 sys_m68k.o time.o semaphore.o setup.o m68k_ksyms.o devres.o
218
219 devres-y = ../../../kernel/irq/devres.o
220 --- a/arch/m68k/kernel/asm-offsets.c
221 +++ b/arch/m68k/kernel/asm-offsets.c
222 @@ -58,8 +58,15 @@ int main(void)
223 DEFINE(PT_A2, offsetof(struct pt_regs, a2));
224 DEFINE(PT_PC, offsetof(struct pt_regs, pc));
225 DEFINE(PT_SR, offsetof(struct pt_regs, sr));
226 +#ifdef CONFIG_COLDFIRE
227 + /* Need to get the context out of struct mm for ASID setting */
228 + DEFINE(MM_CONTEXT, offsetof(struct mm_struct, context));
229 + /* Coldfire exception frame has vector *before* pc */
230 + DEFINE(PT_VECTOR, offsetof(struct pt_regs, pc) - 4);
231 +#else
232 /* bitfields are a bit difficult */
233 DEFINE(PT_VECTOR, offsetof(struct pt_regs, pc) + 4);
234 +#endif
235
236 /* offsets into the irq_handler struct */
237 DEFINE(IRQ_HANDLER, offsetof(struct irq_node, handler));
238 --- a/arch/m68k/kernel/dma.c
239 +++ b/arch/m68k/kernel/dma.c
240 @@ -17,6 +17,7 @@
241 void *dma_alloc_coherent(struct device *dev, size_t size,
242 dma_addr_t *handle, gfp_t flag)
243 {
244 +#ifndef CONFIG_M54455
245 struct page *page, **map;
246 pgprot_t pgprot;
247 void *addr;
248 @@ -55,6 +56,18 @@ void *dma_alloc_coherent(struct device *
249 kfree(map);
250
251 return addr;
252 +#else
253 + /*
254 + * On the M5445x platform the memory allocated with GFP_DMA
255 + * is guaranteed to be DMA'able.
256 + */
257 + void *addr;
258 +
259 + size = PAGE_ALIGN(size);
260 + addr = kmalloc(size, GFP_DMA);
261 + *handle = virt_to_phys(addr);
262 + return addr;
263 +#endif
264 }
265 EXPORT_SYMBOL(dma_alloc_coherent);
266
267 @@ -62,7 +75,11 @@ void dma_free_coherent(struct device *de
268 void *addr, dma_addr_t handle)
269 {
270 pr_debug("dma_free_coherent: %p, %x\n", addr, handle);
271 +#ifndef CONFIG_M54455
272 vfree(addr);
273 +#else
274 + kfree(addr);
275 +#endif
276 }
277 EXPORT_SYMBOL(dma_free_coherent);
278
279 --- a/arch/m68k/kernel/process.c
280 +++ b/arch/m68k/kernel/process.c
281 @@ -191,6 +191,7 @@ EXPORT_SYMBOL(kernel_thread);
282
283 void flush_thread(void)
284 {
285 +#if !defined(CONFIG_COLDFIRE)
286 unsigned long zero = 0;
287 set_fs(USER_DS);
288 current->thread.fs = __USER_DS;
289 @@ -198,6 +199,14 @@ void flush_thread(void)
290 asm volatile (".chip 68k/68881\n\t"
291 "frestore %0@\n\t"
292 ".chip 68k" : : "a" (&zero));
293 +#else
294 + set_fs(USER_DS);
295 + current->thread.fs = USER_DS;
296 +#if defined(CONFIG_FPU)
297 + if (!FPU_IS_EMU)
298 + asm volatile ("frestore %0@\n\t" : : "a" (&zero));
299 +#endif
300 +#endif
301 }
302
303 /*
304 @@ -261,6 +270,7 @@ int copy_thread(int nr, unsigned long cl
305 * Must save the current SFC/DFC value, NOT the value when
306 * the parent was last descheduled - RGH 10-08-96
307 */
308 +#if !defined(CONFIG_COLDFIRE)
309 p->thread.fs = get_fs().seg;
310
311 if (!FPU_IS_EMU) {
312 @@ -272,9 +282,34 @@ int copy_thread(int nr, unsigned long cl
313 "fmoveml %/fpiar/%/fpcr/%/fpsr,%1"
314 : : "m" (p->thread.fp[0]), "m" (p->thread.fpcntl[0])
315 : "memory");
316 +#else
317 + p->thread.fs = get_fs();
318 +
319 +#if defined(CONFIG_FPU)
320 + if (!FPU_IS_EMU) {
321 + /* Copy the current fpu state */
322 + asm volatile ("fsave %0" : : "m" (p->thread.fpstate[0])
323 + : "memory");
324 +
325 + if (p->thread.fpstate[0]) {
326 + asm volatile ("fmovemd %/fp0-%/fp7,%0"
327 + : : "m" (p->thread.fp[0])
328 + : "memory");
329 + asm volatile ("fmovel %/fpiar,%0"
330 + : : "m" (p->thread.fpcntl[0])
331 + : "memory");
332 + asm volatile ("fmovel %/fpcr,%0"
333 + : : "m" (p->thread.fpcntl[1])
334 + : "memory");
335 + asm volatile ("fmovel %/fpsr,%0"
336 + : : "m" (p->thread.fpcntl[2])
337 + : "memory");
338 + }
339 /* Restore the state in case the fpu was busy */
340 asm volatile ("frestore %0" : : "m" (p->thread.fpstate[0]));
341 }
342 +#endif
343 +#endif
344
345 return 0;
346 }
347 @@ -283,7 +318,9 @@ int copy_thread(int nr, unsigned long cl
348
349 int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)
350 {
351 +#if !defined(CONFIG_COLDFIRE) || defined(CONFIG_FPU)
352 char fpustate[216];
353 +#endif
354
355 if (FPU_IS_EMU) {
356 int i;
357 @@ -300,6 +337,7 @@ int dump_fpu (struct pt_regs *regs, stru
358 }
359
360 /* First dump the fpu context to avoid protocol violation. */
361 +#if !defined(CONFIG_COLDFIRE)
362 asm volatile ("fsave %0" :: "m" (fpustate[0]) : "memory");
363 if (!CPU_IS_060 ? !fpustate[0] : !fpustate[2])
364 return 0;
365 @@ -310,6 +348,25 @@ int dump_fpu (struct pt_regs *regs, stru
366 asm volatile ("fmovemx %/fp0-%/fp7,%0"
367 :: "m" (fpu->fpregs[0])
368 : "memory");
369 +#elif defined(CONFIG_FPU)
370 + asm volatile ("fsave %0" :: "m" (fpustate[0]) : "memory");
371 + if (!CPU_IS_060 ? !fpustate[0] : !fpustate[2])
372 + return 0;
373 +
374 + asm volatile ("fmovel %/fpiar,%0"
375 + : : "m" (fpu->fpcntl[0])
376 + : "memory");
377 + asm volatile ("fmovel %/fpcr,%0"
378 + : : "m" (fpu->fpcntl[1])
379 + : "memory");
380 + asm volatile ("fmovel %/fpsr,%0"
381 + : : "m" (fpu->fpcntl[2])
382 + : "memory");
383 + asm volatile ("fmovemd %/fp0-%/fp7,%0"
384 + : : "m" (fpu->fpregs[0])
385 + : "memory");
386 +#endif
387 +
388 return 1;
389 }
390 EXPORT_SYMBOL(dump_fpu);
391 --- a/arch/m68k/kernel/setup.c
392 +++ b/arch/m68k/kernel/setup.c
393 @@ -67,13 +67,22 @@ EXPORT_SYMBOL(m68k_memory);
394
395 struct mem_info m68k_ramdisk;
396
397 +#if !defined(CONFIG_COLDFIRE)
398 static char m68k_command_line[CL_SIZE];
399 +#else
400 +char m68k_command_line[CL_SIZE];
401 +unsigned long uboot_info_stk;
402 +EXPORT_SYMBOL(uboot_info_stk);
403 +#endif
404
405 void (*mach_sched_init) (irq_handler_t handler) __initdata = NULL;
406 /* machine dependent irq functions */
407 void (*mach_init_IRQ) (void) __initdata = NULL;
408 void (*mach_get_model) (char *model);
409 int (*mach_get_hardware_list) (char *buffer);
410 +#ifdef CONFIG_COLDFIRE
411 +void (*mach_tick)(void);
412 +#endif
413 /* machine dependent timer functions */
414 unsigned long (*mach_gettimeoffset) (void);
415 int (*mach_hwclk) (int, struct rtc_time*);
416 @@ -128,13 +137,17 @@ extern void config_hp300(void);
417 extern void config_q40(void);
418 extern void config_sun3x(void);
419
420 +#ifdef CONFIG_COLDFIRE
421 +void coldfire_sort_memrec(void);
422 +#endif
423 +
424 #define MASK_256K 0xfffc0000
425
426 extern void paging_init(void);
427
428 static void __init m68k_parse_bootinfo(const struct bi_record *record)
429 {
430 - while (record->tag != BI_LAST) {
431 + while ((record->tag != BI_LAST) && !(CONFIG_COLDFIRE)) {
432 int unknown = 0;
433 const unsigned long *data = record->data;
434
435 @@ -192,7 +205,11 @@ static void __init m68k_parse_bootinfo(c
436 record->size);
437 }
438
439 - m68k_realnum_memory = m68k_num_memory;
440 +#ifdef CONFIG_COLDFIRE
441 + coldfire_sort_memrec();
442 +#endif
443 +
444 + m68k_realnum_memory = m68k_num_memory;
445 #ifdef CONFIG_SINGLE_MEMORY_CHUNK
446 if (m68k_num_memory > 1) {
447 printk("Ignoring last %i chunks of physical memory\n",
448 @@ -205,7 +222,9 @@ static void __init m68k_parse_bootinfo(c
449 void __init setup_arch(char **cmdline_p)
450 {
451 extern int _etext, _edata, _end;
452 +#if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
453 int i;
454 +#endif
455
456 /* The bootinfo is located right after the kernel bss */
457 m68k_parse_bootinfo((const struct bi_record *)&_end);
458 @@ -220,9 +239,10 @@ void __init setup_arch(char **cmdline_p)
459 * We should really do our own FPU check at startup.
460 * [what do we do with buggy 68LC040s? if we have problems
461 * with them, we should add a test to check_bugs() below] */
462 -#ifndef CONFIG_M68KFPU_EMU_ONLY
463 +#if !defined(CONFIG_M68KFPU_EMU_ONLY) && defined(CONFIG_FPU)
464 /* clear the fpu if we have one */
465 - if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
466 + if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060|
467 + FPU_CFV4E)) {
468 volatile int zero = 0;
469 asm volatile ("frestore %0" : : "m" (zero));
470 }
471 @@ -310,13 +330,18 @@ void __init setup_arch(char **cmdline_p)
472 config_sun3x();
473 break;
474 #endif
475 +#ifdef CONFIG_COLDFIRE
476 + case MACH_CFMMU:
477 + config_coldfire();
478 + break;
479 +#endif
480 default:
481 panic("No configuration setup");
482 }
483
484 paging_init();
485
486 -#ifndef CONFIG_SUN3
487 +#if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
488 for (i = 1; i < m68k_num_memory; i++)
489 free_bootmem_node(NODE_DATA(i), m68k_memory[i].addr,
490 m68k_memory[i].size);
491 @@ -343,6 +368,10 @@ void __init setup_arch(char **cmdline_p)
492
493 #endif /* !CONFIG_SUN3 */
494
495 +#ifdef CONFIG_COLDFIRE
496 + mmu_context_init();
497 +#endif
498 +
499 /* set ISA defs early as possible */
500 #if defined(CONFIG_ISA) && defined(MULTI_ISA)
501 #if defined(CONFIG_Q40)
502 @@ -373,6 +402,7 @@ static int show_cpuinfo(struct seq_file
503 #define LOOP_CYCLES_68030 (8)
504 #define LOOP_CYCLES_68040 (3)
505 #define LOOP_CYCLES_68060 (1)
506 +#define LOOP_CYCLES_COLDFIRE (2)
507
508 if (CPU_IS_020) {
509 cpu = "68020";
510 @@ -386,6 +416,9 @@ static int show_cpuinfo(struct seq_file
511 } else if (CPU_IS_060) {
512 cpu = "68060";
513 clockfactor = LOOP_CYCLES_68060;
514 + } else if (CPU_IS_CFV4E) {
515 + cpu = "ColdFire V4e";
516 + clockfactor = LOOP_CYCLES_COLDFIRE;
517 } else {
518 cpu = "680x0";
519 clockfactor = 0;
520 @@ -404,6 +437,8 @@ static int show_cpuinfo(struct seq_file
521 fpu = "68060";
522 else if (m68k_fputype & FPU_SUNFPA)
523 fpu = "Sun FPA";
524 + else if (m68k_fputype & FPU_CFV4E)
525 + fpu = "ColdFire V4e";
526 else
527 fpu = "none";
528 #endif
529 @@ -420,6 +455,8 @@ static int show_cpuinfo(struct seq_file
530 mmu = "Sun-3";
531 else if (m68k_mmutype & MMU_APOLLO)
532 mmu = "Apollo";
533 + else if (m68k_mmutype & MMU_CFV4E)
534 + mmu = "ColdFire";
535 else
536 mmu = "unknown";
537
538 @@ -482,7 +519,7 @@ int get_hardware_list(char *buffer)
539
540 void check_bugs(void)
541 {
542 -#ifndef CONFIG_M68KFPU_EMU
543 +#if !defined(CONFIG_M68KFPU_EMU) && !defined(CONFIG_M54455)
544 if (m68k_fputype == 0) {
545 printk(KERN_EMERG "*** YOU DO NOT HAVE A FLOATING POINT UNIT, "
546 "WHICH IS REQUIRED BY LINUX/M68K ***\n");
547 --- a/arch/m68k/kernel/time.c
548 +++ b/arch/m68k/kernel/time.c
549 @@ -40,6 +40,11 @@ static inline int set_rtc_mmss(unsigned
550 */
551 static irqreturn_t timer_interrupt(int irq, void *dummy)
552 {
553 +#ifdef CONFIG_COLDFIRE
554 + /* kick hardware timer if necessary */
555 + if (mach_tick)
556 + mach_tick();
557 +#endif
558 do_timer(1);
559 #ifndef CONFIG_SMP
560 update_process_times(user_mode(get_irq_regs()));
561 --- a/arch/m68k/kernel/vmlinux.lds.S
562 +++ b/arch/m68k/kernel/vmlinux.lds.S
563 @@ -5,6 +5,8 @@ PHDRS
564 }
565 #ifdef CONFIG_SUN3
566 #include "vmlinux-sun3.lds"
567 +#elif CONFIG_COLDFIRE
568 +#include "../coldfire/vmlinux-cf.lds"
569 #else
570 #include "vmlinux-std.lds"
571 #endif
This page took 0.069936 seconds and 5 git commands to generate.