DaVinci DM365: Adding support for SPI EEPROM
[pandora-kernel.git] / arch / sh / kernel / early_printk.c
1 /*
2  * arch/sh/kernel/early_printk.c
3  *
4  *  Copyright (C) 1999, 2000  Niibe Yutaka
5  *  Copyright (C) 2002  M. R. Brown
6  *  Copyright (C) 2004 - 2007  Paul Mundt
7  *
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>
15 #include <linux/io.h>
16 #include <linux/delay.h>
17
18 #include <asm/sh_bios.h>
19
20 /*
21  *      Print a string through the BIOS
22  */
23 static 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  */
35 static 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
52 static struct console bios_console = {
53         .name           = "bios",
54         .write          = sh_console_write,
55         .setup          = sh_console_setup,
56         .flags          = CON_PRINTBUFFER,
57         .index          = -1,
58 };
59
60 static struct console *early_console;
61
62 static int __init setup_early_printk(char *buf)
63 {
64         int keep_early = 0;
65
66         if (!buf)
67                 return 0;
68
69         if (strstr(buf, "keep"))
70                 keep_early = 1;
71
72         if (!strncmp(buf, "bios", 4))
73                 early_console = &bios_console;
74
75         if (likely(early_console)) {
76                 if (keep_early)
77                         early_console->flags &= ~CON_BOOT;
78                 else
79                         early_console->flags |= CON_BOOT;
80                 register_console(early_console);
81         }
82
83         return 0;
84 }
85 early_param("earlyprintk", setup_early_printk);