Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/sh/kernel/early_printk.c |
| 3 | * |
| 4 | * Copyright (C) 1999, 2000 Niibe Yutaka |
| 5 | * Copyright (C) 2002 M. R. Brown |
Paul Mundt | 008d50f | 2007-10-02 16:24:50 +0900 | [diff] [blame] | 6 | * Copyright (C) 2004 - 2007 Paul Mundt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Paul Mundt | 6fc21b8 | 2006-11-27 12:10:23 +0900 | [diff] [blame] | 15 | #include <linux/io.h> |
Markus Brunner | 3ea6bc3 | 2007-08-20 08:59:33 +0900 | [diff] [blame] | 16 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Paul Mundt | a80fd21 | 2006-09-27 14:26:53 +0900 | [diff] [blame] | 52 | static struct console bios_console = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | .name = "bios", |
| 54 | .write = sh_console_write, |
| 55 | .setup = sh_console_setup, |
| 56 | .flags = CON_PRINTBUFFER, |
| 57 | .index = -1, |
| 58 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
Magnus Damm | 7b6fd3b | 2009-12-14 10:24:42 +0000 | [diff] [blame] | 60 | static struct console *early_console; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
Paul Mundt | 008d50f | 2007-10-02 16:24:50 +0900 | [diff] [blame] | 62 | static int __init setup_early_printk(char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | { |
Paul Mundt | 008d50f | 2007-10-02 16:24:50 +0900 | [diff] [blame] | 64 | int keep_early = 0; |
| 65 | |
Paul Mundt | b641fe0 | 2006-12-12 09:00:47 +0900 | [diff] [blame] | 66 | if (!buf) |
| 67 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Paul Mundt | a80fd21 | 2006-09-27 14:26:53 +0900 | [diff] [blame] | 69 | if (strstr(buf, "keep")) |
| 70 | keep_early = 1; |
| 71 | |
Paul Mundt | a80fd21 | 2006-09-27 14:26:53 +0900 | [diff] [blame] | 72 | if (!strncmp(buf, "bios", 4)) |
| 73 | early_console = &bios_console; |
Paul Mundt | a80fd21 | 2006-09-27 14:26:53 +0900 | [diff] [blame] | 74 | |
Gerd Hoffmann | 69331af | 2007-05-08 00:26:49 -0700 | [diff] [blame] | 75 | if (likely(early_console)) { |
| 76 | if (keep_early) |
| 77 | early_console->flags &= ~CON_BOOT; |
| 78 | else |
| 79 | early_console->flags |= CON_BOOT; |
Paul Mundt | a80fd21 | 2006-09-27 14:26:53 +0900 | [diff] [blame] | 80 | register_console(early_console); |
Gerd Hoffmann | 69331af | 2007-05-08 00:26:49 -0700 | [diff] [blame] | 81 | } |
Paul Mundt | a80fd21 | 2006-09-27 14:26:53 +0900 | [diff] [blame] | 82 | |
Paul Mundt | b641fe0 | 2006-12-12 09:00:47 +0900 | [diff] [blame] | 83 | return 0; |
Paul Mundt | a80fd21 | 2006-09-27 14:26:53 +0900 | [diff] [blame] | 84 | } |
Paul Mundt | b641fe0 | 2006-12-12 09:00:47 +0900 | [diff] [blame] | 85 | early_param("earlyprintk", setup_early_printk); |