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.
6 LTIBName: mcfv4e-kernel-mods
7 Signed-off-by: Kurt Mahan <kmahan@freescale.com>
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(-)
21 --- a/arch/m68k/Kconfig
22 +++ b/arch/m68k/Kconfig
23 @@ -119,6 +119,20 @@ config SUN3
25 If you don't want to compile a kernel exclusively for a Sun 3, say N.
28 + bool "ColdFire V4e support"
32 + Say Y if you want to build a kernel to run on one of the ColdFire
38 + select MMU_CFV4E if MMU
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.
49 + bool "MCF54455 support"
53 + This option will add support for the MCF54455 processor with mmu.
56 + int "M54455EVB System Clock"
60 + System clock for EVB. Usually 266MHz for u-boot and 200MHz for dBUG.
63 + bool "Coldfire User Halt Enable"
67 + Enables the HALT instruction in User Mode.
71 - depends on MMU && !MMU_SUN3
72 + depends on MMU && !MMU_SUN3 && !COLDFIRE
91 +config NOR_FLASH_BASE
92 + hex "NOR Flash Base Address"
97 bool "Math emulation support (EXPERIMENTAL)"
98 depends on EXPERIMENTAL
99 @@ -468,6 +521,14 @@ config ZONE_DMA
100 source "drivers/pci/Kconfig"
102 source "drivers/zorro/Kconfig"
105 +menu "Power management options"
108 + bool "Power Management support"
110 + Support processor power management modes
114 @@ -647,7 +708,7 @@ config DN_SERIAL
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)
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"
127 source "lib/Kconfig.debug"
130 + bool 'Compiled-in Kernel Boot Parameter'
131 + depends on COLDFIRE
133 +config BOOTPARAM_STRING
134 + string 'Kernel Boot Parameter'
135 + default 'console=ttyS0,115200'
136 + depends on BOOTPARAM
139 --- a/arch/m68k/Makefile
140 +++ b/arch/m68k/Makefile
142 KBUILD_DEFCONFIG := amiga_defconfig
144 # override top level makefile
145 +ifndef CONFIG_COLDFIRE
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
154 # enable processor switch if compiled only for a single cpu
155 +ifndef CONFIG_COLDFIRE
159 @@ -49,6 +52,12 @@ endif
166 +CFLAGS := $(CFLAGS) -march=isac -mcpu=54455 -msoft-float -g
167 +AFLAGS := $(AFLAGS) -march=isac -mcpu=54455 -msoft-float
171 # If configured for kgdb support, include debugging infos and keep the
172 @@ -57,8 +66,12 @@ KBUILD_CFLAGS := $(subst -fomit-frame-po
176 +ifndef CONFIG_COLDFIRE
177 head-y := arch/m68k/kernel/head.o
179 +head-y := arch/m68k/coldfire/head.o
182 head-y := arch/m68k/kernel/sun3-head.o
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/
193 --- a/arch/m68k/kernel/Makefile
194 +++ b/arch/m68k/kernel/Makefile
196 # Makefile for the linux kernel.
202 + extra-y := sun3-head.o vmlinux.lds
203 + obj-y := entry.o signal.o ints.o
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
213 -extra-y += vmlinux.lds
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
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);
232 /* bitfields are a bit difficult */
233 DEFINE(PT_VECTOR, offsetof(struct pt_regs, pc) + 4);
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
241 void *dma_alloc_coherent(struct device *dev, size_t size,
242 dma_addr_t *handle, gfp_t flag)
244 +#ifndef CONFIG_M54455
245 struct page *page, **map;
248 @@ -55,6 +56,18 @@ void *dma_alloc_coherent(struct device *
254 + * On the M5445x platform the memory allocated with GFP_DMA
255 + * is guaranteed to be DMA'able.
259 + size = PAGE_ALIGN(size);
260 + addr = kmalloc(size, GFP_DMA);
261 + *handle = virt_to_phys(addr);
265 EXPORT_SYMBOL(dma_alloc_coherent);
267 @@ -62,7 +75,11 @@ void dma_free_coherent(struct device *de
268 void *addr, dma_addr_t handle)
270 pr_debug("dma_free_coherent: %p, %x\n", addr, handle);
271 +#ifndef CONFIG_M54455
277 EXPORT_SYMBOL(dma_free_coherent);
279 --- a/arch/m68k/kernel/process.c
280 +++ b/arch/m68k/kernel/process.c
281 @@ -191,6 +191,7 @@ EXPORT_SYMBOL(kernel_thread);
283 void flush_thread(void)
285 +#if !defined(CONFIG_COLDFIRE)
286 unsigned long zero = 0;
288 current->thread.fs = __USER_DS;
289 @@ -198,6 +199,14 @@ void flush_thread(void)
290 asm volatile (".chip 68k/68881\n\t"
292 ".chip 68k" : : "a" (&zero));
295 + current->thread.fs = USER_DS;
296 +#if defined(CONFIG_FPU)
298 + asm volatile ("frestore %0@\n\t" : : "a" (&zero));
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
308 +#if !defined(CONFIG_COLDFIRE)
309 p->thread.fs = get_fs().seg;
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])
317 + p->thread.fs = get_fs();
319 +#if defined(CONFIG_FPU)
321 + /* Copy the current fpu state */
322 + asm volatile ("fsave %0" : : "m" (p->thread.fpstate[0])
325 + if (p->thread.fpstate[0]) {
326 + asm volatile ("fmovemd %/fp0-%/fp7,%0"
327 + : : "m" (p->thread.fp[0])
329 + asm volatile ("fmovel %/fpiar,%0"
330 + : : "m" (p->thread.fpcntl[0])
332 + asm volatile ("fmovel %/fpcr,%0"
333 + : : "m" (p->thread.fpcntl[1])
335 + asm volatile ("fmovel %/fpsr,%0"
336 + : : "m" (p->thread.fpcntl[2])
339 /* Restore the state in case the fpu was busy */
340 asm volatile ("frestore %0" : : "m" (p->thread.fpstate[0]));
347 @@ -283,7 +318,9 @@ int copy_thread(int nr, unsigned long cl
349 int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)
351 +#if !defined(CONFIG_COLDFIRE) || defined(CONFIG_FPU)
357 @@ -300,6 +337,7 @@ int dump_fpu (struct pt_regs *regs, stru
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])
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])
369 +#elif defined(CONFIG_FPU)
370 + asm volatile ("fsave %0" :: "m" (fpustate[0]) : "memory");
371 + if (!CPU_IS_060 ? !fpustate[0] : !fpustate[2])
374 + asm volatile ("fmovel %/fpiar,%0"
375 + : : "m" (fpu->fpcntl[0])
377 + asm volatile ("fmovel %/fpcr,%0"
378 + : : "m" (fpu->fpcntl[1])
380 + asm volatile ("fmovel %/fpsr,%0"
381 + : : "m" (fpu->fpcntl[2])
383 + asm volatile ("fmovemd %/fp0-%/fp7,%0"
384 + : : "m" (fpu->fpregs[0])
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);
395 struct mem_info m68k_ramdisk;
397 +#if !defined(CONFIG_COLDFIRE)
398 static char m68k_command_line[CL_SIZE];
400 +char m68k_command_line[CL_SIZE];
401 +unsigned long uboot_info_stk;
402 +EXPORT_SYMBOL(uboot_info_stk);
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);
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);
420 +#ifdef CONFIG_COLDFIRE
421 +void coldfire_sort_memrec(void);
424 #define MASK_256K 0xfffc0000
426 extern void paging_init(void);
428 static void __init m68k_parse_bootinfo(const struct bi_record *record)
430 - while (record->tag != BI_LAST) {
431 + while ((record->tag != BI_LAST) && !(CONFIG_COLDFIRE)) {
433 const unsigned long *data = record->data;
435 @@ -192,7 +205,11 @@ static void __init m68k_parse_bootinfo(c
439 - m68k_realnum_memory = m68k_num_memory;
440 +#ifdef CONFIG_COLDFIRE
441 + coldfire_sort_memrec();
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)
451 extern int _etext, _edata, _end;
452 +#if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
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|
468 volatile int zero = 0;
469 asm volatile ("frestore %0" : : "m" (zero));
471 @@ -310,13 +330,18 @@ void __init setup_arch(char **cmdline_p)
475 +#ifdef CONFIG_COLDFIRE
481 panic("No configuration setup");
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)
493 #endif /* !CONFIG_SUN3 */
495 +#ifdef CONFIG_COLDFIRE
496 + mmu_context_init();
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)
510 @@ -386,6 +416,9 @@ static int show_cpuinfo(struct seq_file
511 } else if (CPU_IS_060) {
513 clockfactor = LOOP_CYCLES_68060;
514 + } else if (CPU_IS_CFV4E) {
515 + cpu = "ColdFire V4e";
516 + clockfactor = LOOP_CYCLES_COLDFIRE;
520 @@ -404,6 +437,8 @@ static int show_cpuinfo(struct seq_file
522 else if (m68k_fputype & FPU_SUNFPA)
524 + else if (m68k_fputype & FPU_CFV4E)
525 + fpu = "ColdFire V4e";
529 @@ -420,6 +455,8 @@ static int show_cpuinfo(struct seq_file
531 else if (m68k_mmutype & MMU_APOLLO)
533 + else if (m68k_mmutype & MMU_CFV4E)
538 @@ -482,7 +519,7 @@ int get_hardware_list(char *buffer)
540 void check_bugs(void)
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
551 static irqreturn_t timer_interrupt(int irq, void *dummy)
553 +#ifdef CONFIG_COLDFIRE
554 + /* kick hardware timer if necessary */
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
566 #include "vmlinux-sun3.lds"
567 +#elif CONFIG_COLDFIRE
568 +#include "../coldfire/vmlinux-cf.lds"
570 #include "vmlinux-std.lds"