aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k
diff options
context:
space:
mode:
authorFinn Thain <fthain@telegraphics.com.au>2014-04-12 09:48:56 -0400
committerGeert Uytterhoeven <geert@linux-m68k.org>2014-05-28 04:10:04 -0400
commit7913ad1ad83409e7f9ed5758bb4324bf64c95a73 (patch)
tree562d7acf6b0ab016a1c7ca3cbfe9cd4ed9f8f9ab /arch/m68k
parent97f3f68c21fb5edaf4503b9aef6beefddf316d76 (diff)
m68k: Multi-platform EARLY_PRINTK
Make the boot console available to more m68k platforms by leveraging the head.S debug console. The boot console is enabled by the "earlyprintk" command line argument which is how most other architectures do this. This is a change of behaviour for the Mac but does not negatively impact the common use-case which is not debugging. This is also a change of behaviour for other platforms because it means the serial port stays quiet when CONFIG_EARLY_PRINTK is not enabled. This is also an improvement for the common use-case. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Tested-by: Stephen N Chivers <schivers@csc.com.au> [Geert: CONSOLE_DEBUG should depend on CONFIG_FONT_SUPPORT] Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'arch/m68k')
-rw-r--r--arch/m68k/Kconfig.debug9
-rw-r--r--arch/m68k/kernel/Makefile2
-rw-r--r--arch/m68k/kernel/early_printk.c62
-rw-r--r--arch/m68k/kernel/head.S36
-rw-r--r--arch/m68k/mac/config.c29
5 files changed, 83 insertions, 55 deletions
diff --git a/arch/m68k/Kconfig.debug b/arch/m68k/Kconfig.debug
index 229682721240..64776d7ac199 100644
--- a/arch/m68k/Kconfig.debug
+++ b/arch/m68k/Kconfig.debug
@@ -12,12 +12,17 @@ config BOOTPARAM_STRING
12 12
13config EARLY_PRINTK 13config EARLY_PRINTK
14 bool "Early printk" 14 bool "Early printk"
15 depends on MVME16x || MAC 15 depends on !(SUN3 || M68360 || M68000 || COLDFIRE)
16 help 16 help
17 Write kernel log output directly to a serial port. 17 Write kernel log output directly to a serial port.
18 Where implemented, output goes to the framebuffer as well.
19 PROM console functionality on Sun 3x is not affected by this option.
20
21 Pass "earlyprintk" on the kernel command line to get a
22 boot console.
18 23
19 This is useful for kernel debugging when your machine crashes very 24 This is useful for kernel debugging when your machine crashes very
20 early before the console code is initialized. 25 early, i.e. before the normal console driver is loaded.
21 You should normally say N here, unless you want to debug such a crash. 26 You should normally say N here, unless you want to debug such a crash.
22 27
23if !MMU 28if !MMU
diff --git a/arch/m68k/kernel/Makefile b/arch/m68k/kernel/Makefile
index 2d5d9be16273..e47778f8588d 100644
--- a/arch/m68k/kernel/Makefile
+++ b/arch/m68k/kernel/Makefile
@@ -25,3 +25,5 @@ obj-$(CONFIG_HAS_DMA) += dma.o
25obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o 25obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
26obj-$(CONFIG_BOOTINFO_PROC) += bootinfo_proc.o 26obj-$(CONFIG_BOOTINFO_PROC) += bootinfo_proc.o
27 27
28obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
29
diff --git a/arch/m68k/kernel/early_printk.c b/arch/m68k/kernel/early_printk.c
new file mode 100644
index 000000000000..919b83794545
--- /dev/null
+++ b/arch/m68k/kernel/early_printk.c
@@ -0,0 +1,62 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2014 Finn Thain
7 */
8
9#include <linux/kernel.h>
10#include <linux/console.h>
11#include <linux/init.h>
12#include <linux/string.h>
13#include <asm/setup.h>
14
15asmlinkage void __init debug_cons_nputs(const char *s, unsigned n);
16
17static void debug_cons_write(struct console *c,
18 const char *s, unsigned n)
19{
20 debug_cons_nputs(s, n);
21}
22
23static struct console early_console_instance = {
24 .name = "debug",
25 .write = debug_cons_write,
26 .flags = CON_PRINTBUFFER | CON_BOOT,
27 .index = -1
28};
29
30static int __init setup_early_printk(char *buf)
31{
32 /* MVME16x registers an early console after interrupt setup. */
33 if (MACH_IS_MVME16x)
34 return 0;
35
36 if (early_console || buf)
37 return 0;
38
39 early_console = &early_console_instance;
40 register_console(early_console);
41
42 return 0;
43}
44early_param("earlyprintk", setup_early_printk);
45
46/*
47 * debug_cons_nputs() defined in arch/m68k/kernel/head.S cannot be called
48 * after init sections are discarded (for platforms that use it).
49 */
50#if !(defined(CONFIG_SUN3) || defined(CONFIG_M68360) || \
51 defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE))
52
53static int __init unregister_early_console(void)
54{
55 if (!early_console)
56 return 0;
57
58 return unregister_console(early_console);
59}
60late_initcall(unregister_early_console);
61
62#endif
diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S
index 81e610bfa237..a3cfada88368 100644
--- a/arch/m68k/kernel/head.S
+++ b/arch/m68k/kernel/head.S
@@ -221,7 +221,7 @@
221 * MMU_PRINT: There is a routine built into head.S that can display the 221 * MMU_PRINT: There is a routine built into head.S that can display the
222 * MMU data structures. It outputs its result through the serial_putc 222 * MMU data structures. It outputs its result through the serial_putc
223 * interface. So where ever that winds up driving data, that's where the 223 * interface. So where ever that winds up driving data, that's where the
224 * mmu struct will appear. On the Macintosh that's typically the console. 224 * mmu struct will appear.
225 * 225 *
226 * SERIAL_DEBUG: There are a series of putc() macro statements 226 * SERIAL_DEBUG: There are a series of putc() macro statements
227 * scattered through out the code to give progress of status to the 227 * scattered through out the code to give progress of status to the
@@ -249,8 +249,8 @@
249 * USE_MFP: Use the ST-MFP port (Modem1) for serial debug. 249 * USE_MFP: Use the ST-MFP port (Modem1) for serial debug.
250 * 250 *
251 * Macintosh constants: 251 * Macintosh constants:
252 * MAC_USE_SCC_A: Use SCC port A (modem) for serial debug and early console. 252 * MAC_USE_SCC_A: Use SCC port A (modem) for serial debug.
253 * MAC_USE_SCC_B: Use SCC port B (printer) for serial debug and early console. 253 * MAC_USE_SCC_B: Use SCC port B (printer) for serial debug.
254 */ 254 */
255 255
256#include <linux/linkage.h> 256#include <linux/linkage.h>
@@ -267,27 +267,17 @@
267#include <asm/pgtable.h> 267#include <asm/pgtable.h>
268#include <asm/page.h> 268#include <asm/page.h>
269#include <asm/asm-offsets.h> 269#include <asm/asm-offsets.h>
270
271#ifdef CONFIG_MAC 270#ifdef CONFIG_MAC
272 271# include <asm/machw.h>
273#include <asm/machw.h>
274
275#ifdef CONFIG_FRAMEBUFFER_CONSOLE
276#define CONSOLE_DEBUG
277#endif 272#endif
278 273
279#ifdef CONFIG_EARLY_PRINTK 274#ifdef CONFIG_EARLY_PRINTK
280#define SERIAL_DEBUG 275# define SERIAL_DEBUG
281#else 276# if defined(CONFIG_MAC) && defined(CONFIG_FONT_SUPPORT)
282#undef SERIAL_DEBUG 277# define CONSOLE_DEBUG
278# endif
283#endif 279#endif
284 280
285#else /* !CONFIG_MAC */
286
287#define SERIAL_DEBUG
288
289#endif /* !CONFIG_MAC */
290
291#undef MMU_PRINT 281#undef MMU_PRINT
292#undef MMU_NOCACHE_KERNEL 282#undef MMU_NOCACHE_KERNEL
293#undef DEBUG 283#undef DEBUG
@@ -3213,21 +3203,19 @@ func_start putn,%d0-%d2
3213 3203
3214func_return putn 3204func_return putn
3215 3205
3216#ifdef CONFIG_MAC 3206#ifdef CONFIG_EARLY_PRINTK
3217/* 3207/*
3218 * mac_early_print
3219 *
3220 * This routine takes its parameters on the stack. It then 3208 * This routine takes its parameters on the stack. It then
3221 * turns around and calls the internal routines. This routine 3209 * turns around and calls the internal routines. This routine
3222 * is used by the boot console. 3210 * is used by the boot console.
3223 * 3211 *
3224 * The calling parameters are: 3212 * The calling parameters are:
3225 * void mac_early_print(const char *str, unsigned length); 3213 * void debug_cons_nputs(const char *str, unsigned length)
3226 * 3214 *
3227 * This routine does NOT understand variable arguments only 3215 * This routine does NOT understand variable arguments only
3228 * simple strings! 3216 * simple strings!
3229 */ 3217 */
3230ENTRY(mac_early_print) 3218ENTRY(debug_cons_nputs)
3231 moveml %d0/%d1/%a0,%sp@- 3219 moveml %d0/%d1/%a0,%sp@-
3232 movew %sr,%sp@- 3220 movew %sr,%sp@-
3233 ori #0x0700,%sr 3221 ori #0x0700,%sr
@@ -3249,7 +3237,7 @@ ENTRY(mac_early_print)
3249 movew %sp@+,%sr 3237 movew %sp@+,%sr
3250 moveml %sp@+,%d0/%d1/%a0 3238 moveml %sp@+,%d0/%d1/%a0
3251 rts 3239 rts
3252#endif /* CONFIG_MAC */ 3240#endif /* CONFIG_EARLY_PRINTK */
3253 3241
3254#if defined(CONFIG_HP300) || defined(CONFIG_APOLLO) 3242#if defined(CONFIG_HP300) || defined(CONFIG_APOLLO)
3255func_start set_leds,%d0/%a0 3243func_start set_leds,%d0/%a0
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 982c3fe73c4a..a471eab1a4dd 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -71,31 +71,6 @@ static void mac_get_model(char *str);
71static void mac_identify(void); 71static void mac_identify(void);
72static void mac_report_hardware(void); 72static void mac_report_hardware(void);
73 73
74#ifdef CONFIG_EARLY_PRINTK
75asmlinkage void __init mac_early_print(const char *s, unsigned n);
76
77static void __init mac_early_cons_write(struct console *con,
78 const char *s, unsigned n)
79{
80 mac_early_print(s, n);
81}
82
83static struct console __initdata mac_early_cons = {
84 .name = "early",
85 .write = mac_early_cons_write,
86 .flags = CON_PRINTBUFFER | CON_BOOT,
87 .index = -1
88};
89
90int __init mac_unregister_early_cons(void)
91{
92 /* mac_early_print can't be used after init sections are discarded */
93 return unregister_console(&mac_early_cons);
94}
95
96late_initcall(mac_unregister_early_cons);
97#endif
98
99static void __init mac_sched_init(irq_handler_t vector) 74static void __init mac_sched_init(irq_handler_t vector)
100{ 75{
101 via_init_clock(vector); 76 via_init_clock(vector);
@@ -190,10 +165,6 @@ void __init config_mac(void)
190 mach_beep = mac_mksound; 165 mach_beep = mac_mksound;
191#endif 166#endif
192 167
193#ifdef CONFIG_EARLY_PRINTK
194 register_console(&mac_early_cons);
195#endif
196
197 /* 168 /*
198 * Determine hardware present 169 * Determine hardware present
199 */ 170 */