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, 2004 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 <linux/serial.h> |
| 17 | #include <linux/serial_core.h> |
| 18 | #include <asm/serial.h> |
| 19 | |
| 20 | /* SUPERIO uart register map */ |
| 21 | struct ja_uartregs { |
| 22 | union { |
| 23 | volatile u8 pad0[3]; |
| 24 | volatile u8 rbr; /* read only, DLAB == 0 */ |
| 25 | volatile u8 pad1[3]; |
| 26 | volatile u8 thr; /* write only, DLAB == 0 */ |
| 27 | volatile u8 pad2[3]; |
| 28 | volatile u8 dll; /* DLAB == 1 */ |
| 29 | } u1; |
| 30 | union { |
| 31 | volatile u8 pad0[3]; |
| 32 | volatile u8 ier; /* DLAB == 0 */ |
| 33 | volatile u8 pad1[3]; |
| 34 | volatile u8 dlm; /* DLAB == 1 */ |
| 35 | } u2; |
| 36 | union { |
| 37 | volatile u8 pad0[3]; |
| 38 | volatile u8 iir; /* read only */ |
| 39 | volatile u8 pad1[3]; |
| 40 | volatile u8 fcr; /* write only */ |
| 41 | } u3; |
| 42 | volatile u8 pad0[3]; |
| 43 | volatile u8 iu_lcr; |
| 44 | volatile u8 pad1[3]; |
| 45 | volatile u8 iu_mcr; |
| 46 | volatile u8 pad2[3]; |
| 47 | volatile u8 iu_lsr; |
| 48 | volatile u8 pad3[3]; |
| 49 | volatile u8 iu_msr; |
| 50 | volatile u8 pad4[3]; |
| 51 | volatile u8 iu_scr; |
| 52 | } ja_uregs_t; |
| 53 | |
| 54 | #define iu_rbr u1.rbr |
| 55 | #define iu_thr u1.thr |
| 56 | #define iu_dll u1.dll |
| 57 | #define iu_ier u2.ier |
| 58 | #define iu_dlm u2.dlm |
| 59 | #define iu_iir u3.iir |
| 60 | #define iu_fcr u3.fcr |
| 61 | |
| 62 | extern unsigned long uart_base; |
| 63 | |
| 64 | static inline struct ja_uartregs *console_uart(void) |
| 65 | { |
| 66 | return (struct ja_uartregs *) (uart_base + 0x23UL); |
| 67 | } |
| 68 | |
| 69 | void prom_putchar(char c) |
| 70 | { |
| 71 | struct ja_uartregs *uart = console_uart(); |
| 72 | |
| 73 | while ((uart->iu_lsr & 0x20) == 0); |
| 74 | uart->iu_thr = c; |
| 75 | } |
| 76 | |
| 77 | char __init prom_getchar(void) |
| 78 | { |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | static void inline ja_console_probe(void) |
| 83 | { |
| 84 | struct uart_port up; |
| 85 | |
| 86 | /* |
| 87 | * Register to interrupt zero because we share the interrupt with |
| 88 | * the serial driver which we don't properly support yet. |
| 89 | */ |
| 90 | memset(&up, 0, sizeof(up)); |
| 91 | up.membase = (unsigned char *) uart_base + 0x23UL; |
| 92 | up.irq = JAGUAR_ATX_SERIAL1_IRQ; |
| 93 | up.uartclk = JAGUAR_ATX_UART_CLK; |
| 94 | up.regshift = 2; |
| 95 | up.iotype = UPIO_MEM; |
| 96 | up.flags = ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST; |
| 97 | up.line = 0; |
| 98 | |
| 99 | if (early_serial_setup(&up)) |
| 100 | printk(KERN_ERR "Early serial init of port 0 failed\n"); |
| 101 | } |
| 102 | |
| 103 | __init void ja_setup_console(void) |
| 104 | { |
| 105 | ja_console_probe(); |
| 106 | } |