2 * arch/sh/kernel/early_printk.c
4 * Copyright (C) 1999, 2000 Niibe Yutaka
5 * Copyright (C) 2002 M. R. Brown
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
11 #include <linux/console.h>
12 #include <linux/tty.h>
13 #include <linux/init.h>
16 #ifdef CONFIG_SH_STANDARD_BIOS
17 #include <asm/sh_bios.h>
20 * Print a string through the BIOS
22 static void sh_console_write(struct console *co, const char *s,
25 sh_bios_console_write(s, count);
29 * Setup initial baud/bits/parity. We do two things here:
30 * - construct a cflag setting for the first rs_open()
31 * - initialize the serial port
32 * Return non-zero if we didn't find a serial port.
34 static int __init sh_console_setup(struct console *co, char *options)
36 int cflag = CREAD | HUPCL | CLOCAL;
39 * Now construct a cflag setting.
40 * TODO: this is a totally bogus cflag, as we have
41 * no idea what serial settings the BIOS is using, or
42 * even if its using the serial port at all.
44 cflag |= B115200 | CS8 | /*no parity*/0;
51 static struct console early_console = {
53 .write = sh_console_write,
54 .setup = sh_console_setup,
55 .flags = CON_PRINTBUFFER,
60 #ifdef CONFIG_EARLY_SCIF_CONSOLE
61 #define SCIF_REG 0xffe80000
63 static void scif_sercon_putc(int c)
65 while (!(ctrl_inw(SCIF_REG + 0x10) & 0x20)) ;
67 ctrl_outb(c, SCIF_REG + 12);
68 ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0x9f), SCIF_REG + 0x10);
71 scif_sercon_putc('\r');
74 static void scif_sercon_flush(void)
76 ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0xbf), SCIF_REG + 0x10);
78 while (!(ctrl_inw(SCIF_REG + 0x10) & 0x40)) ;
80 ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0xbf), SCIF_REG + 0x10);
83 static void scif_sercon_write(struct console *con, const char *s, unsigned count)
86 scif_sercon_putc(*s++);
91 static int __init scif_sercon_setup(struct console *con, char *options)
93 con->cflag = CREAD | HUPCL | CLOCAL | B115200 | CS8;
98 static struct console early_console = {
100 .write = scif_sercon_write,
101 .setup = scif_sercon_setup,
102 .flags = CON_PRINTBUFFER,
106 void scif_sercon_init(int baud)
108 ctrl_outw(0, SCIF_REG + 8);
109 ctrl_outw(0, SCIF_REG);
112 ctrl_outb((50000000 / (32 * baud)) - 1, SCIF_REG + 4);
114 ctrl_outw(12, SCIF_REG + 24);
115 ctrl_outw(8, SCIF_REG + 24);
116 ctrl_outw(0, SCIF_REG + 32);
117 ctrl_outw(0x60, SCIF_REG + 16);
118 ctrl_outw(0, SCIF_REG + 36);
119 ctrl_outw(0x30, SCIF_REG + 8);
123 void __init enable_early_printk(void)
125 #ifdef CONFIG_EARLY_SCIF_CONSOLE
126 scif_sercon_init(115200);
128 register_console(&early_console);
131 void disable_early_printk(void)
133 unregister_console(&early_console);