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