initial commit with v2.6.9
[linux-2.6.9-moxart.git] / arch / mips / cobalt / promcon.c
blobf03df761e9f10bf93d7beecdc99ea6bd42c91e44
1 /*
2 * PROM console for Cobalt Raq2
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
8 * Copyright (C) 1995, 1996, 1997 by Ralf Baechle
9 * Copyright (C) 2001 by Liam Davies (ldavies@agile.tv)
13 #include <linux/init.h>
14 #include <linux/console.h>
15 #include <linux/kdev_t.h>
16 #include <linux/serial_reg.h>
18 #include <asm/delay.h>
19 #include <asm/serial.h>
20 #include <asm/io.h>
22 static unsigned long port = 0xc800000;
24 static __inline__ void ns16550_cons_put_char(char ch, unsigned long ioaddr)
26 char lsr;
28 do {
29 lsr = inb(ioaddr + UART_LSR);
30 } while ((lsr & (UART_LSR_TEMT | UART_LSR_THRE)) != (UART_LSR_TEMT | UART_LSR_THRE));
31 outb(ch, ioaddr + UART_TX);
34 static __inline__ char ns16550_cons_get_char(unsigned long ioaddr)
36 while ((inb(ioaddr + UART_LSR) & UART_LSR_DR) == 0)
37 udelay(1);
38 return inb(ioaddr + UART_RX);
41 void ns16550_console_write(struct console *co, const char *s, unsigned count)
43 char lsr, ier;
44 unsigned i;
46 ier = inb(port + UART_IER);
47 outb(0x00, port + UART_IER);
48 for (i=0; i < count; i++, s++) {
50 if(*s == '\n')
51 ns16550_cons_put_char('\r', port);
52 ns16550_cons_put_char(*s, port);
55 do {
56 lsr = inb(port + UART_LSR);
57 } while ((lsr & (UART_LSR_TEMT | UART_LSR_THRE)) != (UART_LSR_TEMT | UART_LSR_THRE));
59 outb(ier, port + UART_IER);
62 char getDebugChar(void)
64 return ns16550_cons_get_char(port);
67 void putDebugChar(char kgdb_char)
69 ns16550_cons_put_char(kgdb_char, port);
72 static struct console ns16550_console = {
73 .name = "prom",
74 .setup = NULL,
75 .write = ns16550_console_write,
76 .flags = CON_PRINTBUFFER,
77 .index = -1,
80 static int __init ns16550_setup_console(void)
82 register_console(&ns16550_console);
84 return 0;
87 console_initcall(ns16550_setup_console);