http://www.hht-eu.com/pls/hht/docs/F3140/bcm963xx_Speedport500V.0.09.04L.300L01.V27_c...
[bcm963xx.git] / kernel / linux / arch / mips / pmc-sierra / yosemite / py-console.c
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 #include <asm/io.h>
20
21 /* SUPERIO uart register map */
22 struct yo_uartregs {
23         union {
24                 volatile u8     rbr;    /* read only, DLAB == 0 */
25                 volatile u8     thr;    /* write only, DLAB == 0 */
26                 volatile u8     dll;    /* DLAB == 1 */
27         } u1;
28         union {
29                 volatile u8     ier;    /* DLAB == 0 */
30                 volatile u8     dlm;    /* DLAB == 1 */
31         } u2;
32         union {
33                 volatile u8     iir;    /* read only */
34                 volatile u8     fcr;    /* write only */
35         } u3;
36         volatile u8     iu_lcr;
37         volatile u8     iu_mcr;
38         volatile u8     iu_lsr;
39         volatile u8     iu_msr;
40         volatile u8     iu_scr;
41 } yo_uregs_t;
42
43 #define iu_rbr u1.rbr
44 #define iu_thr u1.thr
45 #define iu_dll u1.dll
46 #define iu_ier u2.ier
47 #define iu_dlm u2.dlm
48 #define iu_iir u3.iir
49 #define iu_fcr u3.fcr
50
51 #define IO_BASE_64      0x9000000000000000ULL
52
53 static unsigned char readb_outer_space(unsigned long phys)
54 {
55         unsigned long long vaddr = IO_BASE_64 | phys;
56         unsigned char res;
57         unsigned int sr;
58
59         sr = read_c0_status();
60         write_c0_status((sr | ST0_KX) & ~ ST0_IE);
61         __asm__("sll    $0, $0, 2\n");
62         __asm__("sll    $0, $0, 2\n");
63         __asm__("sll    $0, $0, 2\n");
64         __asm__("sll    $0, $0, 2\n");
65
66         __asm__ __volatile__ (
67         "       .set    mips3           \n"
68         "       ld      %0, (%0)        \n"
69         "       lbu     %0, (%0)        \n"
70         "       .set    mips0           \n"
71         : "=r" (res)
72         : "0" (&vaddr));
73
74         write_c0_status(sr);
75         __asm__("sll    $0, $0, 2\n");
76         __asm__("sll    $0, $0, 2\n");
77         __asm__("sll    $0, $0, 2\n");
78         __asm__("sll    $0, $0, 2\n");
79
80         return res;
81 }
82
83 static void writeb_outer_space(unsigned long phys, unsigned char c)
84 {
85         unsigned long long vaddr = IO_BASE_64 | phys;
86         unsigned long tmp;
87         unsigned int sr;
88
89         sr = read_c0_status();
90         write_c0_status((sr | ST0_KX) & ~ ST0_IE);
91         __asm__("sll    $0, $0, 2\n");
92         __asm__("sll    $0, $0, 2\n");
93         __asm__("sll    $0, $0, 2\n");
94         __asm__("sll    $0, $0, 2\n");
95
96         __asm__ __volatile__ (
97         "       .set    mips3           \n"
98         "       ld      %0, (%1)        \n"
99         "       sb      %2, (%0)        \n"
100         "       .set    mips0           \n"
101         : "=r" (tmp)
102         : "r" (&vaddr), "r" (c));
103
104         write_c0_status(sr);
105         __asm__("sll    $0, $0, 2\n");
106         __asm__("sll    $0, $0, 2\n");
107         __asm__("sll    $0, $0, 2\n");
108         __asm__("sll    $0, $0, 2\n");
109 }
110
111 void prom_putchar(char c)
112 {
113         unsigned long lsr = 0xfd000008UL + offsetof(struct yo_uartregs, iu_lsr);
114         unsigned long thr = 0xfd000008UL + offsetof(struct yo_uartregs, iu_thr);
115
116         while ((readb_outer_space(lsr) & 0x20) == 0);
117         writeb_outer_space(thr, c);
118 }
119
120 char __init prom_getchar(void)
121 {
122         return 0;
123 }