VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.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/ds1286.h>
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/kdev_t.h>
12 #include <linux/types.h>
13 #include <linux/module.h>
14 #include <linux/console.h>
15 #include <linux/sched.h>
16 #include <linux/tty.h>
17
18 #include <asm/addrspace.h>
19 #include <asm/bcache.h>
20 #include <asm/bootinfo.h>
21 #include <asm/irq.h>
22 #include <asm/reboot.h>
23 #include <asm/time.h>
24 #include <asm/gdb-stub.h>
25 #include <asm/io.h>
26 #include <asm/traps.h>
27 #include <asm/sgialib.h>
28 #include <asm/sgi/mc.h>
29 #include <asm/sgi/hpc3.h>
30 #include <asm/sgi/ip22.h>
31
32 #ifdef CONFIG_KGDB
33 extern void rs_kgdb_hook(int);
34 extern void breakpoint(void);
35 static int remote_debug = 0;
36 #endif
37
38 unsigned long sgi_gfxaddr;
39
40 /*
41  * Stop-A is originally a Sun thing that isn't standard on IP22 so to avoid
42  * accidents it's disabled by default on IP22.
43  *
44  * FIXME: provide a mechanism to change the value of stop_a_enabled.
45  */
46 int serial_console;
47 int stop_a_enabled;
48
49 void ip22_do_break(void)
50 {
51         if (!stop_a_enabled)
52                 return;
53
54         printk("\n");
55         ArcEnterInteractiveMode();
56 }
57
58 EXPORT_SYMBOL(ip22_do_break);
59
60 extern void ip22_be_init(void) __init;
61 extern void ip22_time_init(void) __init;
62
63 static int __init ip22_setup(void)
64 {
65         char *ctype;
66 #ifdef CONFIG_KGDB
67         char *kgdb_ttyd;
68 #endif
69
70         board_be_init = ip22_be_init;
71         ip22_time_init();
72
73         /* Init the INDY HPC I/O controller.  Need to call this before
74          * fucking with the memory controller because it needs to know the
75          * boardID and whether this is a Guiness or a FullHouse machine.
76          */
77         sgihpc_init();
78
79         /* Init INDY memory controller. */
80         sgimc_init();
81
82 #ifdef CONFIG_BOARD_SCACHE
83         /* Now enable boardcaches, if any. */
84         indy_sc_init();
85 #endif
86
87         /* Set EISA IO port base for Indigo2 */
88         set_io_port_base(KSEG1ADDR(0x00080000));
89
90         /* ARCS console environment variable is set to "g?" for
91          * graphics console, it is set to "d" for the first serial
92          * line and "d2" for the second serial line.
93          */
94         ctype = ArcGetEnvironmentVariable("console");
95         if (ctype && *ctype == 'd') {
96                 static char options[8];
97                 char *baud = ArcGetEnvironmentVariable("dbaud");
98                 if (baud)
99                         strcpy(options, baud);
100                 add_preferred_console("ttyS", *(ctype + 1) == '2' ? 1 : 0,
101                                       baud ? options : NULL);
102         } else if (!ctype || *ctype != 'g') {
103                 /* Use ARC if we don't want serial ('d') or Newport ('g'). */
104                 prom_flags |= PROM_FLAG_USE_AS_CONSOLE;
105                 add_preferred_console("arc", 0, NULL);
106         }
107
108 #ifdef CONFIG_KGDB
109         kgdb_ttyd = prom_getcmdline();
110         if ((kgdb_ttyd = strstr(kgdb_ttyd, "kgdb=ttyd")) != NULL) {
111                 int line;
112                 kgdb_ttyd += strlen("kgdb=ttyd");
113                 if (*kgdb_ttyd != '1' && *kgdb_ttyd != '2')
114                         printk(KERN_INFO "KGDB: Uknown serial line /dev/ttyd%c"
115                                ", falling back to /dev/ttyd1\n", *kgdb_ttyd);
116                 line = *kgdb_ttyd == '2' ? 0 : 1;
117                 printk(KERN_INFO "KGDB: Using serial line /dev/ttyd%d for "
118                        "session\n", line ? 1 : 2);
119                 rs_kgdb_hook(line);
120
121                 printk(KERN_INFO "KGDB: Using serial line /dev/ttyd%d for "
122                        "session, please connect your debugger\n", line ? 1:2);
123
124                 remote_debug = 1;
125                 /* Breakpoints and stuff are in sgi_irq_setup() */
126         }
127 #endif
128
129 #ifdef CONFIG_VT
130 #ifdef CONFIG_SGI_NEWPORT_CONSOLE
131         if (ctype && *ctype == 'g'){
132                 ULONG *gfxinfo;
133                 ULONG * (*__vec)(void) = (void *) (long)
134                         *((_PULONG *)(long)((PROMBLOCK)->pvector + 0x20));
135
136                 gfxinfo = __vec();
137                 sgi_gfxaddr = ((gfxinfo[1] >= 0xa0000000
138                                && gfxinfo[1] <= 0xc0000000)
139                                ? gfxinfo[1] - 0xa0000000 : 0);
140
141                 /* newport addresses? */
142                 if (sgi_gfxaddr == 0x1f0f0000 || sgi_gfxaddr == 0x1f4f0000) {
143                         conswitchp = &newport_con;
144                 }
145         }
146 #endif
147 #endif
148
149         return 0;
150 }
151
152 early_initcall(ip22_setup);