d5a7cdf99d941acaace149e890c45b24bbead33f
[linux-flexiantxendom0-3.2.10.git] / arch / mips / sgi-ip22 / ip22-setup.c
1 /*
2  * ip22-setup.c: SGI specific setup, including init of the feature struct.
3  *
4  * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
5  * Copyright (C) 1997, 1998 Ralf Baechle (ralf@gnu.org)
6  */
7 #include <linux/config.h>
8 #include <linux/init.h>
9 #include <linux/kernel.h>
10 #include <linux/kdev_t.h>
11 #include <linux/types.h>
12 #include <linux/console.h>
13 #include <linux/sched.h>
14 #include <linux/tty.h>
15
16 #include <asm/addrspace.h>
17 #include <asm/bcache.h>
18 #include <asm/bootinfo.h>
19 #include <asm/irq.h>
20 #include <asm/reboot.h>
21 #include <asm/ds1286.h>
22 #include <asm/time.h>
23 #include <asm/gdb-stub.h>
24 #include <asm/io.h>
25 #include <asm/traps.h>
26 #include <asm/sgialib.h>
27 #include <asm/sgi/mc.h>
28 #include <asm/sgi/hpc3.h>
29 #include <asm/sgi/ip22.h>
30
31 #ifdef CONFIG_KGDB
32 extern void rs_kgdb_hook(int);
33 extern void breakpoint(void);
34 static int remote_debug = 0;
35 #endif
36
37 #if defined(CONFIG_IP22_SERIAL_CONSOLE) || defined(CONFIG_ARC_CONSOLE)
38 extern void console_setup(char *);
39 #endif
40
41 extern struct rtc_ops ip22_rtc_ops;
42
43 #define KBD_STAT_IBF            0x02    /* Keyboard input buffer full */
44
45 unsigned long sgi_gfxaddr;
46
47 /*
48  * Stop-A is originally a Sun thing that isn't standard on IP22 so to avoid
49  * accidents it's disabled by default on IP22.
50  *
51  * FIXME: provide a mechanism to change the value of stop_a_enabled.
52  */
53 int serial_console;
54 int stop_a_enabled;
55
56 void ip22_do_break(void)
57 {
58         if (!stop_a_enabled)
59                 return;
60
61         printk("\n");
62         ArcEnterInteractiveMode();
63 }
64
65 extern void ip22_be_init(void) __init;
66 extern void ip22_time_init(void) __init;
67
68 void __init ip22_setup(void)
69 {
70         char *ctype;
71 #ifdef CONFIG_KGDB
72         char *kgdb_ttyd;
73 #endif
74
75         board_be_init = ip22_be_init;
76         ip22_time_init();
77
78         /* Init the INDY HPC I/O controller.  Need to call this before
79          * fucking with the memory controller because it needs to know the
80          * boardID and whether this is a Guiness or a FullHouse machine.
81          */
82         sgihpc_init();
83
84         /* Init INDY memory controller. */
85         sgimc_init();
86
87 #ifdef CONFIG_BOARD_SCACHE
88         /* Now enable boardcaches, if any. */
89         indy_sc_init();
90 #endif
91 #ifdef CONFIG_VT
92         conswitchp = NULL;
93 #endif
94         /* Set the IO space to some sane value */
95         set_io_port_base (KSEG1ADDR (0x00080000));
96
97         /* ARCS console environment variable is set to "g?" for
98          * graphics console, it is set to "d" for the first serial
99          * line and "d2" for the second serial line.
100          */
101         ctype = ArcGetEnvironmentVariable("console");
102         if (ctype && *ctype == 'd') {
103 #ifdef CONFIG_IP22_SERIAL_CONSOLE
104                 if (*(ctype + 1) == '2')
105                         console_setup("ttyS1");
106                 else
107                         console_setup("ttyS0");
108 #endif
109         }
110 #ifdef CONFIG_ARC_CONSOLE
111         else if (!ctype || *ctype != 'g') {
112                 /* Use ARC if we don't want serial ('d') or Newport ('g'). */
113                 prom_flags |= PROM_FLAG_USE_AS_CONSOLE;
114                 console_setup("arc");
115         }
116 #endif
117
118 #ifdef CONFIG_KGDB
119         kgdb_ttyd = prom_getcmdline();
120         if ((kgdb_ttyd = strstr(kgdb_ttyd, "kgdb=ttyd")) != NULL) {
121                 int line;
122                 kgdb_ttyd += strlen("kgdb=ttyd");
123                 if (*kgdb_ttyd != '1' && *kgdb_ttyd != '2')
124                         printk(KERN_INFO "KGDB: Uknown serial line /dev/ttyd%c"
125                                ", falling back to /dev/ttyd1\n", *kgdb_ttyd);
126                 line = *kgdb_ttyd == '2' ? 0 : 1;
127                 printk(KERN_INFO "KGDB: Using serial line /dev/ttyd%d for "
128                        "session\n", line ? 1 : 2);
129                 rs_kgdb_hook(line);
130
131                 printk(KERN_INFO "KGDB: Using serial line /dev/ttyd%d for "
132                        "session, please connect your debugger\n", line ? 1:2);
133
134                 remote_debug = 1;
135                 /* Breakpoints and stuff are in sgi_irq_setup() */
136         }
137 #endif
138
139 #ifdef CONFIG_VT
140 #ifdef CONFIG_SGI_NEWPORT_CONSOLE
141         if (ctype && *ctype == 'g'){
142                 unsigned long *gfxinfo;
143                 long (*__vec)(void) =
144                         (void *) *(long *)(long)((PROMBLOCK)->pvector + 0x20);
145
146                 gfxinfo = (unsigned long *)__vec();
147                 sgi_gfxaddr = ((gfxinfo[1] >= 0xa0000000
148                                && gfxinfo[1] <= 0xc0000000)
149                                ? gfxinfo[1] - 0xa0000000 : 0);
150
151                 /* newport addresses? */
152                 if (sgi_gfxaddr == 0x1f0f0000 || sgi_gfxaddr == 0x1f4f0000) {
153                         conswitchp = &newport_con;
154
155                         screen_info = (struct screen_info) {
156                                 0, 0,           /* orig-x, orig-y */
157                                 0,              /* unused */
158                                 0,              /* orig_video_page */
159                                 0,              /* orig_video_mode */
160                                 160,            /* orig_video_cols */
161                                 0, 0, 0,        /* unused, ega_bx, unused */
162                                 64,             /* orig_video_lines */
163                                 0,              /* orig_video_isVGA */
164                                 16              /* orig_video_points */
165                         };
166                 }
167         }
168 #endif
169 #ifdef CONFIG_DUMMY_CONSOLE
170         /* Either if newport console wasn't used or failed to initialize. */
171 #ifdef CONFIG_SGI_NEWPORT_CONSOLE
172         if(conswitchp != &newport_con)
173 #endif
174                 conswitchp = &dummy_con;
175 #endif
176 #endif
177         rtc_ops = &ip22_rtc_ops;
178 #ifdef CONFIG_PSMOUSE
179         aux_device_present = 0xaa;
180 #endif
181 }