17913ad1aSFinn Thain /*
27913ad1aSFinn Thain * This file is subject to the terms and conditions of the GNU General Public
37913ad1aSFinn Thain * License. See the file "COPYING" in the main directory of this archive
47913ad1aSFinn Thain * for more details.
57913ad1aSFinn Thain *
67913ad1aSFinn Thain * Copyright (c) 2014 Finn Thain
77913ad1aSFinn Thain */
87913ad1aSFinn Thain
97913ad1aSFinn Thain #include <linux/kernel.h>
107913ad1aSFinn Thain #include <linux/console.h>
117913ad1aSFinn Thain #include <linux/init.h>
127913ad1aSFinn Thain #include <linux/string.h>
137913ad1aSFinn Thain #include <asm/setup.h>
147913ad1aSFinn Thain
15*dcec33c1SGeert Uytterhoeven
16*dcec33c1SGeert Uytterhoeven #include "../mvme16x/mvme16x.h"
17c46f46d0SFinn Thain
187913ad1aSFinn Thain asmlinkage void __init debug_cons_nputs(const char *s, unsigned n);
197913ad1aSFinn Thain
debug_cons_write(struct console * c,const char * s,unsigned n)20c46f46d0SFinn Thain static void __ref debug_cons_write(struct console *c,
217913ad1aSFinn Thain const char *s, unsigned n)
227913ad1aSFinn Thain {
23a3595962SGreg Ungerer #if !(defined(CONFIG_SUN3) || defined(CONFIG_M68000) || \
24a3595962SGreg Ungerer defined(CONFIG_COLDFIRE))
25c46f46d0SFinn Thain if (MACH_IS_MVME16x)
26c46f46d0SFinn Thain mvme16x_cons_write(c, s, n);
27c46f46d0SFinn Thain else
287913ad1aSFinn Thain debug_cons_nputs(s, n);
29c46f46d0SFinn Thain #endif
307913ad1aSFinn Thain }
317913ad1aSFinn Thain
327913ad1aSFinn Thain static struct console early_console_instance = {
337913ad1aSFinn Thain .name = "debug",
347913ad1aSFinn Thain .write = debug_cons_write,
357913ad1aSFinn Thain .flags = CON_PRINTBUFFER | CON_BOOT,
367913ad1aSFinn Thain .index = -1
377913ad1aSFinn Thain };
387913ad1aSFinn Thain
setup_early_printk(char * buf)397913ad1aSFinn Thain static int __init setup_early_printk(char *buf)
407913ad1aSFinn Thain {
417913ad1aSFinn Thain if (early_console || buf)
427913ad1aSFinn Thain return 0;
437913ad1aSFinn Thain
447913ad1aSFinn Thain early_console = &early_console_instance;
457913ad1aSFinn Thain register_console(early_console);
467913ad1aSFinn Thain
477913ad1aSFinn Thain return 0;
487913ad1aSFinn Thain }
497913ad1aSFinn Thain early_param("earlyprintk", setup_early_printk);
507913ad1aSFinn Thain
517913ad1aSFinn Thain /*
527913ad1aSFinn Thain * debug_cons_nputs() defined in arch/m68k/kernel/head.S cannot be called
537913ad1aSFinn Thain * after init sections are discarded (for platforms that use it).
547913ad1aSFinn Thain */
55a3595962SGreg Ungerer #if !(defined(CONFIG_SUN3) || defined(CONFIG_M68000) || \
56a3595962SGreg Ungerer defined(CONFIG_COLDFIRE))
577913ad1aSFinn Thain
unregister_early_console(void)587913ad1aSFinn Thain static int __init unregister_early_console(void)
597913ad1aSFinn Thain {
60c46f46d0SFinn Thain if (!early_console || MACH_IS_MVME16x)
617913ad1aSFinn Thain return 0;
627913ad1aSFinn Thain
637913ad1aSFinn Thain return unregister_console(early_console);
647913ad1aSFinn Thain }
657913ad1aSFinn Thain late_initcall(unregister_early_console);
667913ad1aSFinn Thain
677913ad1aSFinn Thain #endif
68