Merge git://git.infradead.org/mtd-2.6
[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/io.h>
24 #include <asm/traps.h>
25 #include <asm/sgialib.h>
26 #include <asm/sgi/mc.h>
27 #include <asm/sgi/hpc3.h>
28 #include <asm/sgi/ip22.h>
29
30 unsigned long sgi_gfxaddr;
31 EXPORT_SYMBOL_GPL(sgi_gfxaddr);
32
33 extern void ip22_be_init(void) __init;
34
35 void __init plat_mem_setup(void)
36 {
37         char *ctype;
38         char *cserial;
39
40         board_be_init = ip22_be_init;
41
42         /* Init the INDY HPC I/O controller.  Need to call this before
43          * fucking with the memory controller because it needs to know the
44          * boardID and whether this is a Guiness or a FullHouse machine.
45          */
46         sgihpc_init();
47
48         /* Init INDY memory controller. */
49         sgimc_init();
50
51 #ifdef CONFIG_BOARD_SCACHE
52         /* Now enable boardcaches, if any. */
53         indy_sc_init();
54 #endif
55
56         /* Set EISA IO port base for Indigo2
57          * ioremap cannot fail */
58         set_io_port_base((unsigned long)ioremap(0x00080000,
59                                                 0x1fffffff - 0x00080000));
60         /* ARCS console environment variable is set to "g?" for
61          * graphics console, it is set to "d" for the first serial
62          * line and "d2" for the second serial line.
63          *
64          * Need to check if the case is 'g' but no keyboard:
65          * (ConsoleIn/Out = serial)
66          */
67         ctype = ArcGetEnvironmentVariable("console");
68         cserial = ArcGetEnvironmentVariable("ConsoleOut");
69
70         if ((ctype && *ctype == 'd') || (cserial && *cserial == 's')) {
71                 static char options[8];
72                 char *baud = ArcGetEnvironmentVariable("dbaud");
73                 if (baud)
74                         strcpy(options, baud);
75                 add_preferred_console("ttyS", *(ctype + 1) == '2' ? 1 : 0,
76                                       baud ? options : NULL);
77         } else if (!ctype || *ctype != 'g') {
78                 /* Use ARC if we don't want serial ('d') or graphics ('g'). */
79                 prom_flags |= PROM_FLAG_USE_AS_CONSOLE;
80                 add_preferred_console("arc", 0, NULL);
81         }
82
83 #if defined(CONFIG_VT) && defined(CONFIG_SGI_NEWPORT_CONSOLE)
84         {
85                 ULONG *gfxinfo;
86                 ULONG * (*__vec)(void) = (void *) (long)
87                         *((_PULONG *)(long)((PROMBLOCK)->pvector + 0x20));
88
89                 gfxinfo = __vec();
90                 sgi_gfxaddr = ((gfxinfo[1] >= 0xa0000000
91                                && gfxinfo[1] <= 0xc0000000)
92                                ? gfxinfo[1] - 0xa0000000 : 0);
93
94                 /* newport addresses? */
95                 if (sgi_gfxaddr == 0x1f0f0000 || sgi_gfxaddr == 0x1f4f0000) {
96                         conswitchp = &newport_con;
97                 }
98         }
99 #endif
100 }