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