import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / mips / mips-boards / malta / malta_setup.c
1 /*
2  * Carsten Langgaard, carstenl@mips.com
3  * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
4  *
5  *  This program is free software; you can distribute it and/or modify it
6  *  under the terms of the GNU General Public License (Version 2) as
7  *  published by the Free Software Foundation.
8  *
9  *  This program is distributed in the hope it will be useful, but WITHOUT
10  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  *  for more details.
13  *
14  *  You should have received a copy of the GNU General Public License along
15  *  with this program; if not, write to the Free Software Foundation, Inc.,
16  *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17  */
18 #include <linux/config.h>
19 #include <linux/init.h>
20 #include <linux/sched.h>
21 #include <linux/mc146818rtc.h>
22 #include <linux/ioport.h>
23 #include <linux/pci.h>
24 #ifdef CONFIG_BLK_DEV_IDE
25 #include <linux/ide.h>
26 #endif
27
28 #include <asm/cpu.h>
29 #include <asm/bootinfo.h>
30 #include <asm/irq.h>
31 #include <asm/mips-boards/generic.h>
32 #include <asm/mips-boards/prom.h>
33 #include <asm/mips-boards/malta.h>
34 #include <asm/mips-boards/maltaint.h>
35 #ifdef CONFIG_BLK_DEV_FD
36 #include <asm/floppy.h>
37 #endif
38 #include <asm/dma.h>
39 #include <asm/time.h>
40 #include <asm/traps.h>
41 #ifdef CONFIG_PC_KEYB
42 #include <asm/keyboard.h>
43 #endif
44 #ifdef CONFIG_VT
45 #include <linux/console.h>
46 #endif
47
48 #ifdef CONFIG_KGDB
49 extern void rs_kgdb_hook(int);
50 int remote_debug = 0;
51 #endif
52
53 extern struct ide_ops std_ide_ops;
54 extern struct fd_ops std_fd_ops;
55 extern struct rtc_ops malta_rtc_ops;
56 extern struct kbd_ops std_kbd_ops;
57
58 extern void mips_reboot_setup(void);
59
60 extern void mips_time_init(void);
61 extern void mips_timer_setup(struct irqaction *irq);
62 extern unsigned long mips_rtc_get_time(void);
63
64 struct resource standard_io_resources[] = {
65         { "dma1", 0x00, 0x1f, IORESOURCE_BUSY },
66         { "timer", 0x40, 0x5f, IORESOURCE_BUSY },
67         { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY },
68         { "dma2", 0xc0, 0xdf, IORESOURCE_BUSY },
69 };
70
71 #define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource))
72
73 const char *get_system_type(void)
74 {
75         return "MIPS Malta";
76 }
77
78 void __init malta_setup(void)
79 {
80 #ifdef CONFIG_KGDB
81         int rs_putDebugChar(char);
82         char rs_getDebugChar(void);
83         extern int (*generic_putDebugChar)(char);
84         extern char (*generic_getDebugChar)(void);
85 #endif
86         char *argptr;
87         int i;
88
89         /* Request I/O space for devices used on the Malta board. */
90         for (i = 0; i < STANDARD_IO_RESOURCES; i++)
91                 request_resource(&ioport_resource, standard_io_resources+i);
92
93         /*
94          * Enable DMA channel 4 (cascade channel) in the PIIX4 south bridge.
95          */
96         enable_dma(4);
97
98 #ifdef CONFIG_SERIAL_CONSOLE
99         argptr = prom_getcmdline();
100         if ((argptr = strstr(argptr, "console=")) == NULL) {
101                 argptr = prom_getcmdline();
102                 strcat(argptr, " console=ttyS0,38400");
103         }
104 #endif
105
106 #ifdef CONFIG_KGDB
107         argptr = prom_getcmdline();
108         if ((argptr = strstr(argptr, "kgdb=ttyS")) != NULL) {
109                 int line;
110                 argptr += strlen("kgdb=ttyS");
111                 if (*argptr != '0' && *argptr != '1')
112                         printk("KGDB: Uknown serial line /dev/ttyS%c, "
113                                "falling back to /dev/ttyS1\n", *argptr);
114                 line = *argptr == '0' ? 0 : 1;
115                 printk("KGDB: Using serial line /dev/ttyS%d for session\n",
116                        line ? 1 : 0);
117
118                 rs_kgdb_hook(line);
119                 generic_putDebugChar = rs_putDebugChar;
120                 generic_getDebugChar = rs_getDebugChar;
121
122                 prom_printf("KGDB: Using serial line /dev/ttyS%d for session, "
123                             "please connect your debugger\n", line ? 1 : 0);
124
125                 remote_debug = 1;
126                 /* Breakpoints are in init_IRQ() */
127         }
128 #endif
129
130         argptr = prom_getcmdline();
131         if ((argptr = strstr(argptr, "nofpu")) != NULL)
132                 cpu_data[0].options &= ~MIPS_CPU_FPU;
133
134         rtc_ops = &malta_rtc_ops;
135
136 #ifdef CONFIG_BLK_DEV_IDE
137         ide_ops = &std_ide_ops;
138 #endif
139 #ifdef CONFIG_BLK_DEV_FD
140         fd_ops = &std_fd_ops;
141 #endif
142 #ifdef CONFIG_PC_KEYB
143         kbd_ops = &std_kbd_ops;
144 #endif
145 #ifdef CONFIG_VT
146 #if defined(CONFIG_VGA_CONSOLE)
147         conswitchp = &vga_con;
148
149         screen_info = (struct screen_info) {
150                 0, 25,                  /* orig-x, orig-y */
151                 0,                      /* unused */
152                 0,                      /* orig-video-page */
153                 0,                      /* orig-video-mode */
154                 80,                     /* orig-video-cols */
155                 0,0,0,                  /* ega_ax, ega_bx, ega_cx */
156                 25,                     /* orig-video-lines */
157                 1,                      /* orig-video-isVGA */
158                 16                      /* orig-video-points */
159         };
160 #elif defined(CONFIG_DUMMY_CONSOLE)
161         conswitchp = &dummy_con;
162 #endif
163 #endif
164         mips_reboot_setup();
165
166         board_time_init = mips_time_init;
167         board_timer_setup = mips_timer_setup;
168         rtc_get_time = mips_rtc_get_time;
169 }