[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / sh64 / kernel / early_printk.c
blob8c8a76e180aabca423167cf247056590ded9fdce
1 /*
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
11 * for more details.
13 #include <linux/console.h>
14 #include <linux/tty.h>
15 #include <linux/init.h>
16 #include <asm/io.h>
17 #include <asm/hardware.h>
19 #define SCIF_BASE_ADDR 0x01030000
20 #define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR
23 * Fixed virtual address where SCIF is mapped (should already be done
24 * in arch/sh64/kernel/head.S!).
26 #define SCIF_REG 0xfa030000
28 enum {
29 SCIF_SCSMR2 = SCIF_REG + 0x00,
30 SCIF_SCBRR2 = SCIF_REG + 0x04,
31 SCIF_SCSCR2 = SCIF_REG + 0x08,
32 SCIF_SCFTDR2 = SCIF_REG + 0x0c,
33 SCIF_SCFSR2 = SCIF_REG + 0x10,
34 SCIF_SCFRDR2 = SCIF_REG + 0x14,
35 SCIF_SCFCR2 = SCIF_REG + 0x18,
36 SCIF_SCFDR2 = SCIF_REG + 0x1c,
37 SCIF_SCSPTR2 = SCIF_REG + 0x20,
38 SCIF_SCLSR2 = SCIF_REG + 0x24,
41 static void sh_console_putc(int c)
43 while (!(ctrl_inw(SCIF_SCFSR2) & 0x20))
44 cpu_relax();
46 ctrl_outb(c, SCIF_SCFTDR2);
47 ctrl_outw((ctrl_inw(SCIF_SCFSR2) & 0x9f), SCIF_SCFSR2);
49 if (c == '\n')
50 sh_console_putc('\r');
53 static void sh_console_flush(void)
55 ctrl_outw((ctrl_inw(SCIF_SCFSR2) & 0xbf), SCIF_SCFSR2);
57 while (!(ctrl_inw(SCIF_SCFSR2) & 0x40))
58 cpu_relax();
60 ctrl_outw((ctrl_inw(SCIF_SCFSR2) & 0xbf), SCIF_SCFSR2);
63 static void sh_console_write(struct console *con, const char *s, unsigned count)
65 while (count-- > 0)
66 sh_console_putc(*s++);
68 sh_console_flush();
71 static int __init sh_console_setup(struct console *con, char *options)
73 con->cflag = CREAD | HUPCL | CLOCAL | B19200 | CS8;
75 return 0;
78 static struct console sh_console = {
79 .name = "scifcon",
80 .write = sh_console_write,
81 .setup = sh_console_setup,
82 .flags = CON_PRINTBUFFER,
83 .index = -1,
86 void __init enable_early_printk(void)
88 ctrl_outb(0x2a, SCIF_SCBRR2); /* 19200bps */
90 ctrl_outw(0x04, SCIF_SCFCR2); /* Reset TFRST */
91 ctrl_outw(0x10, SCIF_SCFCR2); /* TTRG0=1 */
93 ctrl_outw(0, SCIF_SCSPTR2);
94 ctrl_outw(0x60, SCIF_SCFSR2);
95 ctrl_outw(0, SCIF_SCLSR2);
96 ctrl_outw(0x30, SCIF_SCSCR2);
98 register_console(&sh_console);
101 void disable_early_printk(void)
103 unregister_console(&sh_console);