blob: 9e6440eaa455a4e68a0f9b2dce549a29b6b8188d [file] [log] [blame]
Ralf Baechle36a88532007-03-01 11:56:43 +00001/*
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) 2002, 2003, 06, 07 Ralf Baechle (ralf@linux-mips.org)
7 * Copyright (C) 2007 MIPS Technologies, Inc.
8 * written by Ralf Baechle (ralf@linux-mips.org)
9 */
10#include <linux/console.h>
11#include <linux/init.h>
12
Dmitri Vorobiev07cdb782008-05-29 17:57:08 +030013#include <asm/setup.h>
14
Ralf Baechle36a88532007-03-01 11:56:43 +000015extern void prom_putchar(char);
16
Aaro Koskinenf7be4e72013-02-11 20:51:49 +000017static void early_console_write(struct console *con, const char *s, unsigned n)
Ralf Baechle36a88532007-03-01 11:56:43 +000018{
19 while (n-- && *s) {
20 if (*s == '\n')
21 prom_putchar('\r');
22 prom_putchar(*s);
23 s++;
24 }
25}
26
Aaro Koskinenf7be4e72013-02-11 20:51:49 +000027static struct console early_console = {
Ralf Baechle36a88532007-03-01 11:56:43 +000028 .name = "early",
29 .write = early_console_write,
30 .flags = CON_PRINTBUFFER | CON_BOOT,
31 .index = -1
32};
33
Franck Bui-Huu36ea1d52007-05-03 13:01:32 +020034static int early_console_initialized __initdata;
35
Ralf Baechle36a88532007-03-01 11:56:43 +000036void __init setup_early_printk(void)
37{
Franck Bui-Huu36ea1d52007-05-03 13:01:32 +020038 if (early_console_initialized)
39 return;
40 early_console_initialized = 1;
41
Ralf Baechle36a88532007-03-01 11:56:43 +000042 register_console(&early_console);
43}