blob: f8bb50c6e0504e0d6041ff3321629d5ba9c26aeb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/sh/kernel/early_printk.c
3 *
4 * Copyright (C) 1999, 2000 Niibe Yutaka
5 * Copyright (C) 2002 M. R. Brown
Paul Mundt008d50f2007-10-02 16:24:50 +09006 * Copyright (C) 2004 - 2007 Paul Mundt
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/console.h>
13#include <linux/tty.h>
14#include <linux/init.h>
Paul Mundt6fc21b82006-11-27 12:10:23 +090015#include <linux/io.h>
Markus Brunner3ea6bc32007-08-20 08:59:33 +090016#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/sh_bios.h>
19
20/*
21 * Print a string through the BIOS
22 */
23static void sh_console_write(struct console *co, const char *s,
24 unsigned count)
25{
26 sh_bios_console_write(s, count);
27}
28
29/*
30 * Setup initial baud/bits/parity. We do two things here:
31 * - construct a cflag setting for the first rs_open()
32 * - initialize the serial port
33 * Return non-zero if we didn't find a serial port.
34 */
35static int __init sh_console_setup(struct console *co, char *options)
36{
37 int cflag = CREAD | HUPCL | CLOCAL;
38
39 /*
40 * Now construct a cflag setting.
41 * TODO: this is a totally bogus cflag, as we have
42 * no idea what serial settings the BIOS is using, or
43 * even if its using the serial port at all.
44 */
45 cflag |= B115200 | CS8 | /*no parity*/0;
46
47 co->cflag = cflag;
48
49 return 0;
50}
51
Paul Mundta80fd212006-09-27 14:26:53 +090052static struct console bios_console = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 .name = "bios",
54 .write = sh_console_write,
55 .setup = sh_console_setup,
56 .flags = CON_PRINTBUFFER,
57 .index = -1,
58};
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
Magnus Damm7b6fd3b2009-12-14 10:24:42 +000060static struct console *early_console;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
Paul Mundt008d50f2007-10-02 16:24:50 +090062static int __init setup_early_printk(char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -070063{
Paul Mundt008d50f2007-10-02 16:24:50 +090064 int keep_early = 0;
65
Paul Mundtb641fe02006-12-12 09:00:47 +090066 if (!buf)
67 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Paul Mundta80fd212006-09-27 14:26:53 +090069 if (strstr(buf, "keep"))
70 keep_early = 1;
71
Paul Mundta80fd212006-09-27 14:26:53 +090072 if (!strncmp(buf, "bios", 4))
73 early_console = &bios_console;
Paul Mundta80fd212006-09-27 14:26:53 +090074
Gerd Hoffmann69331af2007-05-08 00:26:49 -070075 if (likely(early_console)) {
76 if (keep_early)
77 early_console->flags &= ~CON_BOOT;
78 else
79 early_console->flags |= CON_BOOT;
Paul Mundta80fd212006-09-27 14:26:53 +090080 register_console(early_console);
Gerd Hoffmann69331af2007-05-08 00:26:49 -070081 }
Paul Mundta80fd212006-09-27 14:26:53 +090082
Paul Mundtb641fe02006-12-12 09:00:47 +090083 return 0;
Paul Mundta80fd212006-09-27 14:26:53 +090084}
Paul Mundtb641fe02006-12-12 09:00:47 +090085early_param("earlyprintk", setup_early_printk);