blob: 4a1647ddfbd94cc40974a1643f655d6f1da9af2b [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 */
Thomas Gleixnerd0380e62013-04-29 16:17:18 -070010#include <linux/kernel.h>
Ralf Baechle36a88532007-03-01 11:56:43 +000011#include <linux/console.h>
Thomas Gleixnerd0380e62013-04-29 16:17:18 -070012#include <linux/printk.h>
Ralf Baechle36a88532007-03-01 11:56:43 +000013#include <linux/init.h>
14
Dmitri Vorobiev07cdb782008-05-29 17:57:08 +030015#include <asm/setup.h>
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
Thomas Gleixnerd0380e62013-04-29 16:17:18 -070027static struct console early_console_prom = {
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
34void __init setup_early_printk(void)
35{
Thomas Gleixnerd0380e62013-04-29 16:17:18 -070036 if (early_console)
Franck Bui-Huu36ea1d52007-05-03 13:01:32 +020037 return;
Thomas Gleixnerd0380e62013-04-29 16:17:18 -070038 early_console = &early_console_prom;
Franck Bui-Huu36ea1d52007-05-03 13:01:32 +020039
Thomas Gleixnerd0380e62013-04-29 16:17:18 -070040 register_console(&early_console_prom);
Ralf Baechle36a88532007-03-01 11:56:43 +000041}