2 * arch/sh/kernel/early_printk.c
4 * Copyright (C) 1999, 2000 Niibe Yutaka
5 * Copyright (C) 2002 M. R. Brown
6 * Copyright (C) 2004 Paul Mundt
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
12 #include <linux/console.h>
13 #include <linux/tty.h>
14 #include <linux/init.h>
17 #ifdef CONFIG_SH_STANDARD_BIOS
18 #include <asm/sh_bios.h>
21 * Print a string through the BIOS
23 static void sh_console_write(struct console *co, const char *s,
26 sh_bios_console_write(s, count);
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.
35 static int __init sh_console_setup(struct console *co, char *options)
37 int cflag = CREAD | HUPCL | CLOCAL;
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.
45 cflag |= B115200 | CS8 | /*no parity*/0;
52 static struct console early_console = {
54 .write = sh_console_write,
55 .setup = sh_console_setup,
56 .flags = CON_PRINTBUFFER,
61 #ifdef CONFIG_EARLY_SCIF_CONSOLE
62 #define SCIF_REG 0xffe80000
64 static void scif_sercon_putc(int c)
66 while (!(ctrl_inw(SCIF_REG + 0x10) & 0x20)) ;
68 ctrl_outb(c, SCIF_REG + 12);
69 ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0x9f), SCIF_REG + 0x10);
72 scif_sercon_putc('\r');
75 static void scif_sercon_flush(void)
77 ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0xbf), SCIF_REG + 0x10);
79 while (!(ctrl_inw(SCIF_REG + 0x10) & 0x40)) ;
81 ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0xbf), SCIF_REG + 0x10);
84 static void scif_sercon_write(struct console *con, const char *s, unsigned count)
87 scif_sercon_putc(*s++);
92 static int __init scif_sercon_setup(struct console *con, char *options)
94 con->cflag = CREAD | HUPCL | CLOCAL | B115200 | CS8;
99 static struct console early_console = {
101 .write = scif_sercon_write,
102 .setup = scif_sercon_setup,
103 .flags = CON_PRINTBUFFER,
107 void scif_sercon_init(int baud)
109 ctrl_outw(0, SCIF_REG + 8);
110 ctrl_outw(0, SCIF_REG);
113 ctrl_outb((CONFIG_SH_PCLK_FREQ + 16 * baud) /
114 (32 * baud) - 1, SCIF_REG + 4);
116 ctrl_outw(12, SCIF_REG + 24);
117 ctrl_outw(8, SCIF_REG + 24);
118 ctrl_outw(0, SCIF_REG + 32);
119 ctrl_outw(0x60, SCIF_REG + 16);
120 ctrl_outw(0, SCIF_REG + 36);
121 ctrl_outw(0x30, SCIF_REG + 8);
125 void __init enable_early_printk(void)
127 #ifdef CONFIG_EARLY_SCIF_CONSOLE
128 scif_sercon_init(115200);
130 register_console(&early_console);
133 void disable_early_printk(void)
135 unregister_console(&early_console);