From 7913ad1ad83409e7f9ed5758bb4324bf64c95a73 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Sat, 12 Apr 2014 23:48:56 +1000 Subject: 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 Tested-by: Stephen N Chivers [Geert: CONSOLE_DEBUG should depend on CONFIG_FONT_SUPPORT] Reported-by: kbuild test robot Signed-off-by: Geert Uytterhoeven --- arch/m68k/kernel/early_printk.c | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 arch/m68k/kernel/early_printk.c (limited to 'arch/m68k/kernel/early_printk.c') 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 @@ +/* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * Copyright (c) 2014 Finn Thain + */ + +#include +#include +#include +#include +#include + +asmlinkage void __init debug_cons_nputs(const char *s, unsigned n); + +static void debug_cons_write(struct console *c, + const char *s, unsigned n) +{ + debug_cons_nputs(s, n); +} + +static struct console early_console_instance = { + .name = "debug", + .write = debug_cons_write, + .flags = CON_PRINTBUFFER | CON_BOOT, + .index = -1 +}; + +static int __init setup_early_printk(char *buf) +{ + /* MVME16x registers an early console after interrupt setup. */ + if (MACH_IS_MVME16x) + return 0; + + if (early_console || buf) + return 0; + + early_console = &early_console_instance; + register_console(early_console); + + return 0; +} +early_param("earlyprintk", setup_early_printk); + +/* + * debug_cons_nputs() defined in arch/m68k/kernel/head.S cannot be called + * after init sections are discarded (for platforms that use it). + */ +#if !(defined(CONFIG_SUN3) || defined(CONFIG_M68360) || \ + defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)) + +static int __init unregister_early_console(void) +{ + if (!early_console) + return 0; + + return unregister_console(early_console); +} +late_initcall(unregister_early_console); + +#endif -- cgit v1.2.3-59-g8ed1b From c46f46d02c90959b82b99badfadc575081666aae Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Sat, 12 Apr 2014 23:49:30 +1000 Subject: m68k/mvme16x: Adopt common boot console In a multi-platform kernel binary we only need one early console instance. The difficulty here is that the common early console is started by early_param(), whereas the MVME16x instance is started later by config_mvme16x(). That means some interrupt setup must be done earlier. Signed-off-by: Finn Thain Tested-by: Stephen N Chivers [Geert] Tag debug_cons_write() with __ref to kill section mismatch warning Signed-off-by: Geert Uytterhoeven --- arch/m68k/kernel/early_printk.c | 21 +++++++++++++-------- arch/m68k/kernel/head.S | 11 +++++++++++ arch/m68k/mvme16x/config.c | 26 +------------------------- 3 files changed, 25 insertions(+), 33 deletions(-) (limited to 'arch/m68k/kernel/early_printk.c') diff --git a/arch/m68k/kernel/early_printk.c b/arch/m68k/kernel/early_printk.c index 919b83794545..ff9708d71921 100644 --- a/arch/m68k/kernel/early_printk.c +++ b/arch/m68k/kernel/early_printk.c @@ -12,12 +12,21 @@ #include #include +extern void mvme16x_cons_write(struct console *co, + const char *str, unsigned count); + asmlinkage void __init debug_cons_nputs(const char *s, unsigned n); -static void debug_cons_write(struct console *c, - const char *s, unsigned n) +static void __ref debug_cons_write(struct console *c, + const char *s, unsigned n) { - debug_cons_nputs(s, n); +#if !(defined(CONFIG_SUN3) || defined(CONFIG_M68360) || \ + defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE)) + if (MACH_IS_MVME16x) + mvme16x_cons_write(c, s, n); + else + debug_cons_nputs(s, n); +#endif } static struct console early_console_instance = { @@ -29,10 +38,6 @@ static struct console early_console_instance = { static int __init setup_early_printk(char *buf) { - /* MVME16x registers an early console after interrupt setup. */ - if (MACH_IS_MVME16x) - return 0; - if (early_console || buf) return 0; @@ -52,7 +57,7 @@ early_param("earlyprintk", setup_early_printk); static int __init unregister_early_console(void) { - if (!early_console) + if (!early_console || MACH_IS_MVME16x) return 0; return unregister_console(early_console); diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S index a3cfada88368..b671f07aeb81 100644 --- a/arch/m68k/kernel/head.S +++ b/arch/m68k/kernel/head.S @@ -2936,6 +2936,15 @@ L(serial_init_not_mac): 2: #endif +#ifdef CONFIG_MVME16x + is_not_mvme16x(L(serial_init_not_mvme16x)) + moveb #0x10,M167_PCSCCMICR + moveb #0x10,M167_PCSCCTICR + moveb #0x10,M167_PCSCCRICR + jra L(serial_init_done) +L(serial_init_not_mvme16x): +#endif + #ifdef CONFIG_APOLLO /* We count on the PROM initializing SIO1 */ #endif @@ -3768,7 +3777,9 @@ M167_CYIER = 0xfff45011 M167_CYLICR = 0xfff45026 M167_CYTEOIR = 0xfff45085 M167_CYTDR = 0xfff450f8 +M167_PCSCCMICR = 0xfff4201d M167_PCSCCTICR = 0xfff4201e +M167_PCSCCRICR = 0xfff4201f M167_PCTPIACKR = 0xfff42025 #endif diff --git a/arch/m68k/mvme16x/config.c b/arch/m68k/mvme16x/config.c index eab7d342757e..a53803cc66cd 100644 --- a/arch/m68k/mvme16x/config.c +++ b/arch/m68k/mvme16x/config.c @@ -213,7 +213,7 @@ static void __init mvme16x_init_IRQ (void) #define CySCRH (0x22) #define CyTFTC (0x80) -static void cons_write(struct console *co, const char *str, unsigned count) +void mvme16x_cons_write(struct console *co, const char *str, unsigned count) { volatile unsigned char *base_addr = (u_char *)CD2401_ADDR; volatile u_char sink; @@ -268,20 +268,6 @@ static void cons_write(struct console *co, const char *str, unsigned count) base_addr[CyIER] = ier; } -static struct console cons_info = -{ - .name = "sercon", - .write = cons_write, - .flags = CON_PRINTBUFFER | CON_BOOT, - .index = -1, -}; - -static void __init mvme16x_early_console(void) -{ - register_console(&cons_info); - - printk(KERN_INFO "MVME16x: early console registered\n"); -} #endif void __init config_mvme16x(void) @@ -336,16 +322,6 @@ void __init config_mvme16x(void) else { mvme16x_config = MVME16x_CONFIG_GOT_LP | MVME16x_CONFIG_GOT_CD2401; - - /* Dont allow any interrupts from the CD2401 until the interrupt */ - /* handlers are installed */ - - pcc2chip[PccSCCMICR] = 0x10; - pcc2chip[PccSCCTICR] = 0x10; - pcc2chip[PccSCCRICR] = 0x10; -#ifdef CONFIG_EARLY_PRINTK - mvme16x_early_console(); -#endif } } -- cgit v1.2.3-59-g8ed1b