Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 2001, 2002 Ralf Baechle |
| 7 | */ |
| 8 | #include <linux/init.h> |
| 9 | #include <linux/console.h> |
| 10 | #include <linux/kdev_t.h> |
| 11 | #include <linux/major.h> |
| 12 | #include <linux/termios.h> |
| 13 | #include <linux/sched.h> |
| 14 | #include <linux/tty.h> |
| 15 | |
| 16 | #include <asm/page.h> |
| 17 | #include <asm/semaphore.h> |
| 18 | #include <asm/sn/addrs.h> |
| 19 | #include <asm/sn/sn0/hub.h> |
| 20 | #include <asm/sn/klconfig.h> |
| 21 | #include <asm/sn/ioc3.h> |
| 22 | #include <asm/sn/sn_private.h> |
| 23 | |
| 24 | #include <linux/serial.h> |
| 25 | #include <linux/serial_core.h> |
| 26 | |
| 27 | #define IOC3_CLK (22000000 / 3) |
| 28 | #define IOC3_FLAGS (0) |
| 29 | |
| 30 | static inline struct ioc3_uartregs *console_uart(void) |
| 31 | { |
| 32 | struct ioc3 *ioc3; |
Ralf Baechle | 01d42ab | 2005-06-27 08:34:27 +0000 | [diff] [blame] | 33 | nasid_t nasid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Ralf Baechle | 01d42ab | 2005-06-27 08:34:27 +0000 | [diff] [blame] | 35 | nasid = (master_nasid == INVALID_NASID) ? get_nasid() : master_nasid; |
| 36 | ioc3 = (struct ioc3 *)KL_CONFIG_CH_CONS_INFO(nasid)->memory_base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | return &ioc3->sregs.uarta; |
| 39 | } |
| 40 | |
| 41 | void prom_putchar(char c) |
| 42 | { |
| 43 | struct ioc3_uartregs *uart = console_uart(); |
| 44 | |
| 45 | while ((uart->iu_lsr & 0x20) == 0); |
| 46 | uart->iu_thr = c; |
| 47 | } |
| 48 | |
Ralf Baechle | a3d4539 | 2006-06-22 20:09:04 +0100 | [diff] [blame^] | 49 | static void ioc3_console_write(struct console *con, const char *s, unsigned n) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | { |
Ralf Baechle | a3d4539 | 2006-06-22 20:09:04 +0100 | [diff] [blame^] | 51 | while (n-- && *s) { |
| 52 | if (*s == '\n') |
| 53 | prom_putchar('\r'); |
| 54 | prom_putchar(*s); |
| 55 | s++; |
| 56 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Ralf Baechle | a3d4539 | 2006-06-22 20:09:04 +0100 | [diff] [blame^] | 59 | static struct console ioc3_console = { |
| 60 | .name = "ioc3", |
| 61 | .write = ioc3_console_write, |
| 62 | .flags = CON_PRINTBUFFER | CON_BOOT, |
| 63 | .index = -1 |
| 64 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | |
| 66 | __init void ip27_setup_console(void) |
| 67 | { |
Ralf Baechle | a3d4539 | 2006-06-22 20:09:04 +0100 | [diff] [blame^] | 68 | register_console(&ioc3_console); |
| 69 | } |
| 70 | |
| 71 | void __init disable_early_printk(void) |
| 72 | { |
| 73 | unregister_console(&ioc3_console); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | } |