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