2 * arch/sh64/kernel/early_printk.c
4 * SH-5 Early SCIF console (cloned and hacked from sh implementation)
6 * Copyright (C) 2003, 2004 Paul Mundt <lethal@linux-sh.org>
7 * Copyright (C) 2002 M. R. Brown <mrbrown@0xd6.org>
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
13 #include <linux/console.h>
14 #include <linux/tty.h>
15 #include <linux/init.h>
17 #include <asm/hardware.h>
19 extern void cpu_relax(void);
21 #define SCIF_BASE_ADDR 0x01030000
22 #define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR
25 * Fixed virtual address where SCIF is mapped (should already be done
26 * in arch/sh64/kernel/head.S!).
28 #define SCIF_REG 0xfa030000
31 SCIF_SCSMR2 = SCIF_REG + 0x00,
32 SCIF_SCBRR2 = SCIF_REG + 0x04,
33 SCIF_SCSCR2 = SCIF_REG + 0x08,
34 SCIF_SCFTDR2 = SCIF_REG + 0x0c,
35 SCIF_SCFSR2 = SCIF_REG + 0x10,
36 SCIF_SCFRDR2 = SCIF_REG + 0x14,
37 SCIF_SCFCR2 = SCIF_REG + 0x18,
38 SCIF_SCFDR2 = SCIF_REG + 0x1c,
39 SCIF_SCSPTR2 = SCIF_REG + 0x20,
40 SCIF_SCLSR2 = SCIF_REG + 0x24,
43 static void sh_console_putc(int c)
45 while (!(ctrl_inw(SCIF_SCFSR2) & 0x20))
48 ctrl_outb(c, SCIF_SCFTDR2);
49 ctrl_outw((ctrl_inw(SCIF_SCFSR2) & 0x9f), SCIF_SCFSR2);
52 sh_console_putc('\r');
55 static void sh_console_flush(void)
57 ctrl_outw((ctrl_inw(SCIF_SCFSR2) & 0xbf), SCIF_SCFSR2);
59 while (!(ctrl_inw(SCIF_SCFSR2) & 0x40))
62 ctrl_outw((ctrl_inw(SCIF_SCFSR2) & 0xbf), SCIF_SCFSR2);
65 static void sh_console_write(struct console *con, const char *s, unsigned count)
68 sh_console_putc(*s++);
73 static int __init sh_console_setup(struct console *con, char *options)
75 con->cflag = CREAD | HUPCL | CLOCAL | B19200 | CS8;
80 static struct console sh_console = {
82 .write = sh_console_write,
83 .setup = sh_console_setup,
84 .flags = CON_PRINTBUFFER,
88 void __init enable_early_printk(void)
90 ctrl_outb(0x2a, SCIF_SCBRR2); /* 19200bps */
92 ctrl_outw(0x04, SCIF_SCFCR2); /* Reset TFRST */
93 ctrl_outw(0x10, SCIF_SCFCR2); /* TTRG0=1 */
95 ctrl_outw(0, SCIF_SCSPTR2);
96 ctrl_outw(0x60, SCIF_SCFSR2);
97 ctrl_outw(0, SCIF_SCLSR2);
98 ctrl_outw(0x30, SCIF_SCSCR2);
100 register_console(&sh_console);
103 void disable_early_printk(void)
105 unregister_console(&sh_console);