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
6 * Copyright (C) 2001, 2002, 2004 Ralf Baechle
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>
16 #include <linux/serial.h>
17 #include <linux/serial_core.h>
18 #include <asm/serial.h>
21 /* SUPERIO uart register map */
24 volatile u8 rbr; /* read only, DLAB == 0 */
25 volatile u8 thr; /* write only, DLAB == 0 */
26 volatile u8 dll; /* DLAB == 1 */
29 volatile u8 ier; /* DLAB == 0 */
30 volatile u8 dlm; /* DLAB == 1 */
33 volatile u8 iir; /* read only */
34 volatile u8 fcr; /* write only */
51 extern unsigned long uart_base;
53 #define IO_BASE_64 0x9000000000000000ULL
55 static unsigned char readb_outer_space(unsigned long phys)
57 unsigned long long vaddr = IO_BASE_64 | phys;
61 sr = read_c0_status();
62 write_c0_status((sr | ST0_KX) & ~ ST0_IE);
63 __asm__("sll $0, $0, 2\n");
64 __asm__("sll $0, $0, 2\n");
65 __asm__("sll $0, $0, 2\n");
66 __asm__("sll $0, $0, 2\n");
68 __asm__ __volatile__ (
77 __asm__("sll $0, $0, 2\n");
78 __asm__("sll $0, $0, 2\n");
79 __asm__("sll $0, $0, 2\n");
80 __asm__("sll $0, $0, 2\n");
85 static void writeb_outer_space(unsigned long phys, unsigned char c)
87 unsigned long long vaddr = IO_BASE_64 | phys;
91 sr = read_c0_status();
92 write_c0_status((sr | ST0_KX) & ~ ST0_IE);
93 __asm__("sll $0, $0, 2\n");
94 __asm__("sll $0, $0, 2\n");
95 __asm__("sll $0, $0, 2\n");
96 __asm__("sll $0, $0, 2\n");
98 __asm__ __volatile__ (
104 : "r" (&vaddr), "r" (c));
107 __asm__("sll $0, $0, 2\n");
108 __asm__("sll $0, $0, 2\n");
109 __asm__("sll $0, $0, 2\n");
110 __asm__("sll $0, $0, 2\n");
113 static inline struct yo_uartregs *console_uart(void)
115 return (struct yo_uartregs *) (uart_base + 8);
118 void prom_putchar(char c)
120 unsigned long lsr = 0xfd000008UL + offsetof(struct yo_uartregs, iu_lsr);
121 unsigned long thr = 0xfd000008UL + offsetof(struct yo_uartregs, iu_thr);
123 while ((readb_outer_space(lsr) & 0x20) == 0);
124 writeb_outer_space(thr, c);
127 char __init prom_getchar(void)