blob: 505cb77d12805c7d80610abea5c0919320d5ed61 [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
Ralf Baechle36a88532007-03-01 11:56:43 +000017extern void prom_putchar(char);
18
Aaro Koskinenf7be4e72013-02-11 20:51:49 +000019static void early_console_write(struct console *con, const char *s, unsigned n)
Ralf Baechle36a88532007-03-01 11:56:43 +000020{
21 while (n-- && *s) {
22 if (*s == '\n')
23 prom_putchar('\r');
24 prom_putchar(*s);
25 s++;
26 }
27}
28
Thomas Gleixnerd0380e62013-04-29 16:17:18 -070029static struct console early_console_prom = {
Ralf Baechle36a88532007-03-01 11:56:43 +000030 .name = "early",
31 .write = early_console_write,
32 .flags = CON_PRINTBUFFER | CON_BOOT,
33 .index = -1
34};
35
36void __init setup_early_printk(void)
37{
Thomas Gleixnerd0380e62013-04-29 16:17:18 -070038 if (early_console)
Franck Bui-Huu36ea1d52007-05-03 13:01:32 +020039 return;
Thomas Gleixnerd0380e62013-04-29 16:17:18 -070040 early_console = &early_console_prom;
Franck Bui-Huu36ea1d52007-05-03 13:01:32 +020041
Thomas Gleixnerd0380e62013-04-29 16:17:18 -070042 register_console(&early_console_prom);
Ralf Baechle36a88532007-03-01 11:56:43 +000043}