aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/kernel/early_printk.c
diff options
context:
space:
mode:
authorFinn Thain <fthain@telegraphics.com.au>2014-04-12 23:48:56 +1000
committerGeert Uytterhoeven <geert@linux-m68k.org>2014-05-28 10:10:04 +0200
commit7913ad1ad83409e7f9ed5758bb4324bf64c95a73 (patch)
tree562d7acf6b0ab016a1c7ca3cbfe9cd4ed9f8f9ab /arch/m68k/kernel/early_printk.c
parentm68k: Toward platform agnostic framebuffer debug logging (diff)
downloadlinux-dev-7913ad1ad83409e7f9ed5758bb4324bf64c95a73.tar.xz
linux-dev-7913ad1ad83409e7f9ed5758bb4324bf64c95a73.zip
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/kernel/early_printk.c')
-rw-r--r--arch/m68k/kernel/early_printk.c62
1 files changed, 62 insertions, 0 deletions
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 <linux/kernel.h>
+#include <linux/console.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <asm/setup.h>
+
+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