1 /*
2  * Setup the interrupt stuff.
3  *
4  * This file is subject to the terms and conditions of the GNU General Public
5  * License.  See the file "COPYING" in the main directory of this archive
6  * for more details.
7  *
8  * Copyright (C) 1998 Harald Koerfgen
9  * Copyright (C) 2000, 2001, 2002, 2003  Maciej W. Rozycki
10  */
11 #include <linux/config.h>
12 #include <linux/sched.h>
13 #include <linux/interrupt.h>
14 #include <linux/mc146818rtc.h>
15 #include <linux/param.h>
16 #include <linux/console.h>
17 #include <linux/init.h>
18 #include <linux/module.h>
19 #include <linux/spinlock.h>
20 #include <linux/types.h>
21 
22 #include <asm/cpu.h>
23 #include <asm/bootinfo.h>
24 #include <asm/irq.h>
25 #include <asm/irq_cpu.h>
26 #include <asm/mipsregs.h>
27 #include <asm/reboot.h>
28 #include <asm/time.h>
29 #include <asm/traps.h>
30 #include <asm/wbflush.h>
31 
32 #include <asm/dec/interrupts.h>
33 #include <asm/dec/ioasic.h>
34 #include <asm/dec/ioasic_addrs.h>
35 #include <asm/dec/ioasic_ints.h>
36 #include <asm/dec/kn01.h>
37 #include <asm/dec/kn02.h>
38 #include <asm/dec/kn02ba.h>
39 #include <asm/dec/kn02ca.h>
40 #include <asm/dec/kn03.h>
41 #include <asm/dec/kn230.h>
42 
43 
44 extern void dec_machine_restart(char *command);
45 extern void dec_machine_halt(void);
46 extern void dec_machine_power_off(void);
47 extern void dec_intr_halt(int irq, void *dev_id, struct pt_regs *regs);
48 
49 extern asmlinkage void decstation_handle_int(void);
50 
51 #ifdef CONFIG_BLK_DEV_INITRD
52 extern unsigned long initrd_start, initrd_end;
53 extern void * __rd_start, * __rd_end;
54 #endif
55 
56 spinlock_t ioasic_ssr_lock;
57 
58 volatile u32 *ioasic_base;
59 unsigned long dec_kn_slot_size;
60 
61 /*
62  * IRQ routing and priority tables.  Priorites are set as follows:
63  *
64  * 		KN01	KN230	KN02	KN02-BA	KN02-CA	KN03
65  *
66  * MEMORY	CPU	CPU	CPU	ASIC	CPU	CPU
67  * RTC		CPU	CPU	CPU	ASIC	CPU	CPU
68  * DMA		-	-	-	ASIC	ASIC	ASIC
69  * SERIAL0	CPU	CPU	CSR	ASIC	ASIC	ASIC
70  * SERIAL1	-	-	-	ASIC	-	ASIC
71  * SCSI		CPU	CPU	CSR	ASIC	ASIC	ASIC
72  * ETHERNET	CPU	*	CSR	ASIC	ASIC	ASIC
73  * other	-	-	-	ASIC	-	-
74  * TC2		-	-	CSR	CPU	ASIC	ASIC
75  * TC1		-	-	CSR	CPU	ASIC	ASIC
76  * TC0		-	-	CSR	CPU	ASIC	ASIC
77  * other	-	CPU	-	CPU	ASIC	ASIC
78  * other	-	-	-	-	CPU	CPU
79  *
80  * * -- shared with SCSI
81  */
82 
83 int dec_interrupt[DEC_NR_INTS] = {
84 	[0 ... DEC_NR_INTS - 1] = -1
85 };
86 int_ptr cpu_mask_nr_tbl[DEC_MAX_CPU_INTS][2] = {
87 	{ { .i = ~0 }, { .p = dec_intr_unimplemented } },
88 };
89 int_ptr asic_mask_nr_tbl[DEC_MAX_ASIC_INTS][2] = {
90 	{ { .i = ~0 }, { .p = asic_intr_unimplemented } },
91 };
92 int cpu_fpu_mask = DEC_CPU_IRQ_MASK(DEC_CPU_INR_FPU);
93 
94 static struct irqaction ioirq = {
95 	.handler = no_action,
96 	.name = "cascade",
97 };
98 static struct irqaction fpuirq = {
99 	.handler = no_action,
100 	.name = "fpu",
101 };
102 
103 static struct irqaction busirq = {
104 	.flags = SA_INTERRUPT,
105 	.name = "bus error",
106 };
107 
108 static struct irqaction haltirq = {
109 	.handler = dec_intr_halt,
110 	.name = "halt",
111 };
112 
113 
114 /*
115  * Bus error (DBE/IBE exceptions and bus interrupts) handling setup.
116  */
dec_be_init(void)117 void __init dec_be_init(void)
118 {
119 	switch (mips_machtype) {
120 	case MACH_DS23100:	/* DS2100/DS3100 Pmin/Pmax */
121 		busirq.flags |= SA_SHIRQ;
122 		break;
123 	case MACH_DS5000_200:	/* DS5000/200 3max */
124 	case MACH_DS5000_2X0:	/* DS5000/240 3max+ */
125 	case MACH_DS5900:	/* DS5900 bigmax */
126 		board_be_handler = dec_ecc_be_handler;
127 		busirq.handler = dec_ecc_be_interrupt;
128 		dec_ecc_be_init();
129 		break;
130 	}
131 }
132 
133 
134 extern void dec_time_init(void);
135 extern void dec_timer_setup(struct irqaction *);
136 
decstation_setup(void)137 void __init decstation_setup(void)
138 {
139 #ifdef CONFIG_BLK_DEV_INITRD
140 	ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
141 	initrd_start = (unsigned long)&__rd_start;
142 	initrd_end = (unsigned long)&__rd_end;
143 #endif
144 	board_be_init = dec_be_init;
145 	board_time_init = dec_time_init;
146 	board_timer_setup = dec_timer_setup;
147 
148 	wbflush_setup();
149 
150 	_machine_restart = dec_machine_restart;
151 	_machine_halt = dec_machine_halt;
152 	_machine_power_off = dec_machine_power_off;
153 
154 #ifdef CONFIG_FB
155 	conswitchp = &dummy_con;
156 #endif
157 
158 	rtc_ops = &dec_rtc_ops;
159 }
160 
161 
162 /*
163  * Machine-specific initialisation for KN01, aka DS2100 (aka Pmin)
164  * or DS3100 (aka Pmax).
165  */
166 static int kn01_interrupt[DEC_NR_INTS] __initdata = {
167 	[DEC_IRQ_CASCADE]	= -1,
168 	[DEC_IRQ_AB_RECV]	= -1,
169 	[DEC_IRQ_AB_XMIT]	= -1,
170 	[DEC_IRQ_DZ11]		= DEC_CPU_IRQ_NR(KN01_CPU_INR_DZ11),
171 	[DEC_IRQ_ASC]		= -1,
172 	[DEC_IRQ_FLOPPY]	= -1,
173 	[DEC_IRQ_FPU]		= DEC_CPU_IRQ_NR(DEC_CPU_INR_FPU),
174 	[DEC_IRQ_HALT]		= -1,
175 	[DEC_IRQ_ISDN]		= -1,
176 	[DEC_IRQ_LANCE]		= DEC_CPU_IRQ_NR(KN01_CPU_INR_LANCE),
177 	[DEC_IRQ_BUS]		= DEC_CPU_IRQ_NR(KN01_CPU_INR_BUS),
178 	[DEC_IRQ_PSU]		= -1,
179 	[DEC_IRQ_RTC]		= DEC_CPU_IRQ_NR(KN01_CPU_INR_RTC),
180 	[DEC_IRQ_SCC0]		= -1,
181 	[DEC_IRQ_SCC1]		= -1,
182 	[DEC_IRQ_SII]		= DEC_CPU_IRQ_NR(KN01_CPU_INR_SII),
183 	[DEC_IRQ_TC0]		= -1,
184 	[DEC_IRQ_TC1]		= -1,
185 	[DEC_IRQ_TC2]		= -1,
186 	[DEC_IRQ_TIMER]		= -1,
187 	[DEC_IRQ_VIDEO]		= DEC_CPU_IRQ_NR(KN01_CPU_INR_VIDEO),
188 	[DEC_IRQ_ASC_MERR]	= -1,
189 	[DEC_IRQ_ASC_ERR]	= -1,
190 	[DEC_IRQ_ASC_DMA]	= -1,
191 	[DEC_IRQ_FLOPPY_ERR]	= -1,
192 	[DEC_IRQ_ISDN_ERR]	= -1,
193 	[DEC_IRQ_ISDN_RXDMA]	= -1,
194 	[DEC_IRQ_ISDN_TXDMA]	= -1,
195 	[DEC_IRQ_LANCE_MERR]	= -1,
196 	[DEC_IRQ_SCC0A_RXERR]	= -1,
197 	[DEC_IRQ_SCC0A_RXDMA]	= -1,
198 	[DEC_IRQ_SCC0A_TXERR]	= -1,
199 	[DEC_IRQ_SCC0A_TXDMA]	= -1,
200 	[DEC_IRQ_AB_RXERR]	= -1,
201 	[DEC_IRQ_AB_RXDMA]	= -1,
202 	[DEC_IRQ_AB_TXERR]	= -1,
203 	[DEC_IRQ_AB_TXDMA]	= -1,
204 	[DEC_IRQ_SCC1A_RXERR]	= -1,
205 	[DEC_IRQ_SCC1A_RXDMA]	= -1,
206 	[DEC_IRQ_SCC1A_TXERR]	= -1,
207 	[DEC_IRQ_SCC1A_TXDMA]	= -1,
208 };
209 
210 static int_ptr kn01_cpu_mask_nr_tbl[][2] __initdata = {
211 	{ { .i = DEC_CPU_IRQ_MASK(KN01_CPU_INR_BUS) },
212 		{ .i = DEC_CPU_IRQ_NR(KN01_CPU_INR_BUS) } },
213 	{ { .i = DEC_CPU_IRQ_MASK(KN01_CPU_INR_RTC) },
214 		{ .i = DEC_CPU_IRQ_NR(KN01_CPU_INR_RTC) } },
215 	{ { .i = DEC_CPU_IRQ_MASK(KN01_CPU_INR_DZ11) },
216 		{ .i = DEC_CPU_IRQ_NR(KN01_CPU_INR_DZ11) } },
217 	{ { .i = DEC_CPU_IRQ_MASK(KN01_CPU_INR_SII) },
218 		{ .i = DEC_CPU_IRQ_NR(KN01_CPU_INR_SII) } },
219 	{ { .i = DEC_CPU_IRQ_MASK(KN01_CPU_INR_LANCE) },
220 		{ .i = DEC_CPU_IRQ_NR(KN01_CPU_INR_LANCE) } },
221 	{ { .i = DEC_CPU_IRQ_ALL },
222 		{ .p = cpu_all_int } },
223 };
224 
dec_init_kn01(void)225 void __init dec_init_kn01(void)
226 {
227 	/* IRQ routing. */
228 	memcpy(&dec_interrupt, &kn01_interrupt,
229 		sizeof(kn01_interrupt));
230 
231 	/* CPU IRQ priorities. */
232 	memcpy(&cpu_mask_nr_tbl, &kn01_cpu_mask_nr_tbl,
233 		sizeof(kn01_cpu_mask_nr_tbl));
234 
235 	mips_cpu_irq_init(DEC_CPU_IRQ_BASE);
236 
237 }				/* dec_init_kn01 */
238 
239 
240 /*
241  * Machine-specific initialisation for KN230, aka DS5100, aka MIPSmate.
242  */
243 static int kn230_interrupt[DEC_NR_INTS] __initdata = {
244 	[DEC_IRQ_CASCADE]	= -1,
245 	[DEC_IRQ_AB_RECV]	= -1,
246 	[DEC_IRQ_AB_XMIT]	= -1,
247 	[DEC_IRQ_DZ11]		= DEC_CPU_IRQ_NR(KN230_CPU_INR_DZ11),
248 	[DEC_IRQ_ASC]		= -1,
249 	[DEC_IRQ_FLOPPY]	= -1,
250 	[DEC_IRQ_FPU]		= DEC_CPU_IRQ_NR(DEC_CPU_INR_FPU),
251 	[DEC_IRQ_HALT]		= DEC_CPU_IRQ_NR(KN230_CPU_INR_HALT),
252 	[DEC_IRQ_ISDN]		= -1,
253 	[DEC_IRQ_LANCE]		= DEC_CPU_IRQ_NR(KN230_CPU_INR_LANCE),
254 	[DEC_IRQ_BUS]		= DEC_CPU_IRQ_NR(KN230_CPU_INR_BUS),
255 	[DEC_IRQ_PSU]		= -1,
256 	[DEC_IRQ_RTC]		= DEC_CPU_IRQ_NR(KN230_CPU_INR_RTC),
257 	[DEC_IRQ_SCC0]		= -1,
258 	[DEC_IRQ_SCC1]		= -1,
259 	[DEC_IRQ_SII]		= DEC_CPU_IRQ_NR(KN230_CPU_INR_SII),
260 	[DEC_IRQ_TC0]		= -1,
261 	[DEC_IRQ_TC1]		= -1,
262 	[DEC_IRQ_TC2]		= -1,
263 	[DEC_IRQ_TIMER]		= -1,
264 	[DEC_IRQ_VIDEO]		= -1,
265 	[DEC_IRQ_ASC_MERR]	= -1,
266 	[DEC_IRQ_ASC_ERR]	= -1,
267 	[DEC_IRQ_ASC_DMA]	= -1,
268 	[DEC_IRQ_FLOPPY_ERR]	= -1,
269 	[DEC_IRQ_ISDN_ERR]	= -1,
270 	[DEC_IRQ_ISDN_RXDMA]	= -1,
271 	[DEC_IRQ_ISDN_TXDMA]	= -1,
272 	[DEC_IRQ_LANCE_MERR]	= -1,
273 	[DEC_IRQ_SCC0A_RXERR]	= -1,
274 	[DEC_IRQ_SCC0A_RXDMA]	= -1,
275 	[DEC_IRQ_SCC0A_TXERR]	= -1,
276 	[DEC_IRQ_SCC0A_TXDMA]	= -1,
277 	[DEC_IRQ_AB_RXERR]	= -1,
278 	[DEC_IRQ_AB_RXDMA]	= -1,
279 	[DEC_IRQ_AB_TXERR]	= -1,
280 	[DEC_IRQ_AB_TXDMA]	= -1,
281 	[DEC_IRQ_SCC1A_RXERR]	= -1,
282 	[DEC_IRQ_SCC1A_RXDMA]	= -1,
283 	[DEC_IRQ_SCC1A_TXERR]	= -1,
284 	[DEC_IRQ_SCC1A_TXDMA]	= -1,
285 };
286 
287 static int_ptr kn230_cpu_mask_nr_tbl[][2] __initdata = {
288 	{ { .i = DEC_CPU_IRQ_MASK(KN230_CPU_INR_BUS) },
289 		{ .i = DEC_CPU_IRQ_NR(KN230_CPU_INR_BUS) } },
290 	{ { .i = DEC_CPU_IRQ_MASK(KN230_CPU_INR_RTC) },
291 		{ .i = DEC_CPU_IRQ_NR(KN230_CPU_INR_RTC) } },
292 	{ { .i = DEC_CPU_IRQ_MASK(KN230_CPU_INR_DZ11) },
293 		{ .i = DEC_CPU_IRQ_NR(KN230_CPU_INR_DZ11) } },
294 	{ { .i = DEC_CPU_IRQ_MASK(KN230_CPU_INR_SII) },
295 		{ .i = DEC_CPU_IRQ_NR(KN230_CPU_INR_SII) } },
296 	{ { .i = DEC_CPU_IRQ_ALL },
297 		{ .p = cpu_all_int } },
298 };
299 
dec_init_kn230(void)300 void __init dec_init_kn230(void)
301 {
302 	/* IRQ routing. */
303 	memcpy(&dec_interrupt, &kn230_interrupt,
304 		sizeof(kn230_interrupt));
305 
306 	/* CPU IRQ priorities. */
307 	memcpy(&cpu_mask_nr_tbl, &kn230_cpu_mask_nr_tbl,
308 		sizeof(kn230_cpu_mask_nr_tbl));
309 
310 	mips_cpu_irq_init(DEC_CPU_IRQ_BASE);
311 
312 }				/* dec_init_kn230 */
313 
314 
315 /*
316  * Machine-specific initialisation for KN02, aka DS5000/200, aka 3max.
317  */
318 static int kn02_interrupt[DEC_NR_INTS] __initdata = {
319 	[DEC_IRQ_CASCADE]	= DEC_CPU_IRQ_NR(KN02_CPU_INR_CASCADE),
320 	[DEC_IRQ_AB_RECV]	= -1,
321 	[DEC_IRQ_AB_XMIT]	= -1,
322 	[DEC_IRQ_DZ11]		= KN02_IRQ_NR(KN02_CSR_INR_DZ11),
323 	[DEC_IRQ_ASC]		= KN02_IRQ_NR(KN02_CSR_INR_ASC),
324 	[DEC_IRQ_FLOPPY]	= -1,
325 	[DEC_IRQ_FPU]		= DEC_CPU_IRQ_NR(DEC_CPU_INR_FPU),
326 	[DEC_IRQ_HALT]		= -1,
327 	[DEC_IRQ_ISDN]		= -1,
328 	[DEC_IRQ_LANCE]		= KN02_IRQ_NR(KN02_CSR_INR_LANCE),
329 	[DEC_IRQ_BUS]		= DEC_CPU_IRQ_NR(KN02_CPU_INR_BUS),
330 	[DEC_IRQ_PSU]		= -1,
331 	[DEC_IRQ_RTC]		= DEC_CPU_IRQ_NR(KN02_CPU_INR_RTC),
332 	[DEC_IRQ_SCC0]		= -1,
333 	[DEC_IRQ_SCC1]		= -1,
334 	[DEC_IRQ_SII]		= -1,
335 	[DEC_IRQ_TC0]		= KN02_IRQ_NR(KN02_CSR_INR_TC0),
336 	[DEC_IRQ_TC1]		= KN02_IRQ_NR(KN02_CSR_INR_TC1),
337 	[DEC_IRQ_TC2]		= KN02_IRQ_NR(KN02_CSR_INR_TC2),
338 	[DEC_IRQ_TIMER]		= -1,
339 	[DEC_IRQ_VIDEO]		= -1,
340 	[DEC_IRQ_ASC_MERR]	= -1,
341 	[DEC_IRQ_ASC_ERR]	= -1,
342 	[DEC_IRQ_ASC_DMA]	= -1,
343 	[DEC_IRQ_FLOPPY_ERR]	= -1,
344 	[DEC_IRQ_ISDN_ERR]	= -1,
345 	[DEC_IRQ_ISDN_RXDMA]	= -1,
346 	[DEC_IRQ_ISDN_TXDMA]	= -1,
347 	[DEC_IRQ_LANCE_MERR]	= -1,
348 	[DEC_IRQ_SCC0A_RXERR]	= -1,
349 	[DEC_IRQ_SCC0A_RXDMA]	= -1,
350 	[DEC_IRQ_SCC0A_TXERR]	= -1,
351 	[DEC_IRQ_SCC0A_TXDMA]	= -1,
352 	[DEC_IRQ_AB_RXERR]	= -1,
353 	[DEC_IRQ_AB_RXDMA]	= -1,
354 	[DEC_IRQ_AB_TXERR]	= -1,
355 	[DEC_IRQ_AB_TXDMA]	= -1,
356 	[DEC_IRQ_SCC1A_RXERR]	= -1,
357 	[DEC_IRQ_SCC1A_RXDMA]	= -1,
358 	[DEC_IRQ_SCC1A_TXERR]	= -1,
359 	[DEC_IRQ_SCC1A_TXDMA]	= -1,
360 };
361 
362 static int_ptr kn02_cpu_mask_nr_tbl[][2] __initdata = {
363 	{ { .i = DEC_CPU_IRQ_MASK(KN02_CPU_INR_BUS) },
364 		{ .i = DEC_CPU_IRQ_NR(KN02_CPU_INR_BUS) } },
365 	{ { .i = DEC_CPU_IRQ_MASK(KN02_CPU_INR_RTC) },
366 		{ .i = DEC_CPU_IRQ_NR(KN02_CPU_INR_RTC) } },
367 	{ { .i = DEC_CPU_IRQ_MASK(KN02_CPU_INR_CASCADE) },
368 		{ .p = kn02_io_int } },
369 	{ { .i = DEC_CPU_IRQ_ALL },
370 		{ .p = cpu_all_int } },
371 };
372 
373 static int_ptr kn02_asic_mask_nr_tbl[][2] __initdata = {
374 	{ { .i = KN02_IRQ_MASK(KN02_CSR_INR_DZ11) },
375 		{ .i = KN02_IRQ_NR(KN02_CSR_INR_DZ11) } },
376 	{ { .i = KN02_IRQ_MASK(KN02_CSR_INR_ASC) },
377 		{ .i = KN02_IRQ_NR(KN02_CSR_INR_ASC) } },
378 	{ { .i = KN02_IRQ_MASK(KN02_CSR_INR_LANCE) },
379 		{ .i = KN02_IRQ_NR(KN02_CSR_INR_LANCE) } },
380 	{ { .i = KN02_IRQ_MASK(KN02_CSR_INR_TC2) },
381 		{ .i = KN02_IRQ_NR(KN02_CSR_INR_TC2) } },
382 	{ { .i = KN02_IRQ_MASK(KN02_CSR_INR_TC1) },
383 		{ .i = KN02_IRQ_NR(KN02_CSR_INR_TC1) } },
384 	{ { .i = KN02_IRQ_MASK(KN02_CSR_INR_TC0) },
385 		{ .i = KN02_IRQ_NR(KN02_CSR_INR_TC0) } },
386 	{ { .i = KN02_IRQ_ALL },
387 		{ .p = kn02_all_int } },
388 };
389 
dec_init_kn02(void)390 void __init dec_init_kn02(void)
391 {
392 	/* IRQ routing. */
393 	memcpy(&dec_interrupt, &kn02_interrupt,
394 		sizeof(kn02_interrupt));
395 
396 	/* CPU IRQ priorities. */
397 	memcpy(&cpu_mask_nr_tbl, &kn02_cpu_mask_nr_tbl,
398 		sizeof(kn02_cpu_mask_nr_tbl));
399 
400 	/* KN02 CSR IRQ priorities. */
401 	memcpy(&asic_mask_nr_tbl, &kn02_asic_mask_nr_tbl,
402 		sizeof(kn02_asic_mask_nr_tbl));
403 
404 	mips_cpu_irq_init(DEC_CPU_IRQ_BASE);
405 	init_kn02_irqs(KN02_IRQ_BASE);
406 
407 }				/* dec_init_kn02 */
408 
409 
410 /*
411  * Machine-specific initialisation for KN02-BA, aka DS5000/1xx
412  * (xx = 20, 25, 33), aka 3min.  Also applies to KN04(-BA), aka
413  * DS5000/150, aka 4min.
414  */
415 static int kn02ba_interrupt[DEC_NR_INTS] __initdata = {
416 	[DEC_IRQ_CASCADE]	= DEC_CPU_IRQ_NR(KN02BA_CPU_INR_CASCADE),
417 	[DEC_IRQ_AB_RECV]	= -1,
418 	[DEC_IRQ_AB_XMIT]	= -1,
419 	[DEC_IRQ_DZ11]		= -1,
420 	[DEC_IRQ_ASC]		= IO_IRQ_NR(KN02BA_IO_INR_ASC),
421 	[DEC_IRQ_FLOPPY]	= -1,
422 	[DEC_IRQ_FPU]		= DEC_CPU_IRQ_NR(DEC_CPU_INR_FPU),
423 	[DEC_IRQ_HALT]		= DEC_CPU_IRQ_NR(KN02BA_CPU_INR_HALT),
424 	[DEC_IRQ_ISDN]		= -1,
425 	[DEC_IRQ_LANCE]		= IO_IRQ_NR(KN02BA_IO_INR_LANCE),
426 	[DEC_IRQ_BUS]		= IO_IRQ_NR(KN02BA_IO_INR_BUS),
427 	[DEC_IRQ_PSU]		= IO_IRQ_NR(KN02BA_IO_INR_PSU),
428 	[DEC_IRQ_RTC]		= IO_IRQ_NR(KN02BA_IO_INR_RTC),
429 	[DEC_IRQ_SCC0]		= IO_IRQ_NR(KN02BA_IO_INR_SCC0),
430 	[DEC_IRQ_SCC1]		= IO_IRQ_NR(KN02BA_IO_INR_SCC1),
431 	[DEC_IRQ_SII]		= -1,
432 	[DEC_IRQ_TC0]		= DEC_CPU_IRQ_NR(KN02BA_CPU_INR_TC0),
433 	[DEC_IRQ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
459 static int_ptr kn02ba_cpu_mask_nr_tbl[][2] __initdata = {
460 	{ { .i = DEC_CPU_IRQ_MASK(KN02BA_CPU_INR_CASCADE) },
461 		{ .p = kn02xa_io_int } },
462 	{ { .i = DEC_CPU_IRQ_MASK(KN02BA_CPU_INR_TC2) },
463 		{ .i = DEC_CPU_IRQ_NR(KN02BA_CPU_INR_TC2) } },
464 	{ { .i = DEC_CPU_IRQ_MASK(KN02BA_CPU_INR_TC1) },
465 		{ .i = DEC_CPU_IRQ_NR(KN02BA_CPU_INR_TC1) } },
466 	{ { .i = DEC_CPU_IRQ_MASK(KN02BA_CPU_INR_TC0) },
467 		{ .i = DEC_CPU_IRQ_NR(KN02BA_CPU_INR_TC0) } },
468 	{ { .i = DEC_CPU_IRQ_ALL },
469 		{ .p = cpu_all_int } },
470 };
471 
472 static int_ptr kn02ba_asic_mask_nr_tbl[][2] __initdata = {
473 	{ { .i = IO_IRQ_MASK(KN02BA_IO_INR_BUS) },
474 		{ .i = IO_IRQ_NR(KN02BA_IO_INR_BUS) } },
475 	{ { .i = IO_IRQ_MASK(KN02BA_IO_INR_RTC) },
476 		{ .i = IO_IRQ_NR(KN02BA_IO_INR_RTC) } },
477 	{ { .i = IO_IRQ_DMA },
478 		{ .p = asic_dma_int } },
479 	{ { .i = IO_IRQ_MASK(KN02BA_IO_INR_SCC0) },
480 		{ .i = IO_IRQ_NR(KN02BA_IO_INR_SCC0) } },
481 	{ { .i = IO_IRQ_MASK(KN02BA_IO_INR_SCC1) },
482 		{ .i = IO_IRQ_NR(KN02BA_IO_INR_SCC1) } },
483 	{ { .i = IO_IRQ_MASK(KN02BA_IO_INR_ASC) },
484 		{ .i = IO_IRQ_NR(KN02BA_IO_INR_ASC) } },
485 	{ { .i = IO_IRQ_MASK(KN02BA_IO_INR_LANCE) },
486 		{ .i = IO_IRQ_NR(KN02BA_IO_INR_LANCE) } },
487 	{ { .i = IO_IRQ_ALL },
488 		{ .p = asic_all_int } },
489 };
490 
dec_init_kn02ba(void)491 void __init dec_init_kn02ba(void)
492 {
493 	/* IRQ routing. */
494 	memcpy(&dec_interrupt, &kn02ba_interrupt,
495 		sizeof(kn02ba_interrupt));
496 
497 	/* CPU IRQ priorities. */
498 	memcpy(&cpu_mask_nr_tbl, &kn02ba_cpu_mask_nr_tbl,
499 		sizeof(kn02ba_cpu_mask_nr_tbl));
500 
501 	/* I/O ASIC IRQ priorities. */
502 	memcpy(&asic_mask_nr_tbl, &kn02ba_asic_mask_nr_tbl,
503 		sizeof(kn02ba_asic_mask_nr_tbl));
504 
505 	mips_cpu_irq_init(DEC_CPU_IRQ_BASE);
506 	init_ioasic_irqs(IO_IRQ_BASE);
507 
508 }				/* dec_init_kn02ba */
509 
510 
511 /*
512  * Machine-specific initialisation for KN02-CA, aka DS5000/xx,
513  * (xx = 20, 25, 33), aka MAXine.  Also applies to KN04(-CA), aka
514  * DS5000/50, aka 4MAXine.
515  */
516 static int kn02ca_interrupt[DEC_NR_INTS] __initdata = {
517 	[DEC_IRQ_CASCADE]	= DEC_CPU_IRQ_NR(KN02CA_CPU_INR_CASCADE),
518 	[DEC_IRQ_AB_RECV]	= IO_IRQ_NR(KN02CA_IO_INR_AB_RECV),
519 	[DEC_IRQ_AB_XMIT]	= IO_IRQ_NR(KN02CA_IO_INR_AB_XMIT),
520 	[DEC_IRQ_DZ11]		= -1,
521 	[DEC_IRQ_ASC]		= IO_IRQ_NR(KN02CA_IO_INR_ASC),
522 	[DEC_IRQ_FLOPPY]	= IO_IRQ_NR(KN02CA_IO_INR_FLOPPY),
523 	[DEC_IRQ_FPU]		= DEC_CPU_IRQ_NR(DEC_CPU_INR_FPU),
524 	[DEC_IRQ_HALT]		= DEC_CPU_IRQ_NR(KN02CA_CPU_INR_HALT),
525 	[DEC_IRQ_ISDN]		= IO_IRQ_NR(KN02CA_IO_INR_ISDN),
526 	[DEC_IRQ_LANCE]		= IO_IRQ_NR(KN02CA_IO_INR_LANCE),
527 	[DEC_IRQ_BUS]		= DEC_CPU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MA]	= IO_IRQ_NR(IO_INR_SCC0A_TXDMA),
550 	[DEC_IRQ_AB_RXERR]	= IO_IRQ_NR(IO_INR_AB_RXERR),
551 	[DEC_IRQ_AB_RXDMA]	= IO_IRQ_NR(IO_INR_AB_RXDMA),
552 	[DEC_IRQ_AB_TXERR]	= IO_IRQ_NR(IO_INR_AB_TXERR),
553 	[DEC_IRQ_AB_TXDMA]	= IO_IRQ_NR(IO_INR_AB_TXDMA),
554 	[DEC_IRQ_SCC1A_RXERR]	= -1,
555 	[DEC_IRQ_SCC1A_RXDMA]	= -1,
556 	[DEC_IRQ_SCC1A_TXERR]	= -1,
557 	[DEC_IRQ_SCC1A_TXDMA]	= -1,
558 };
559 
560 static int_ptr kn02ca_cpu_mask_nr_tbl[][2] __initdata = {
561 	{ { .i = DEC_CPU_IRQ_MASK(KN02CA_CPU_INR_BUS) },
562 		{ .i = DEC_CPU_IRQ_NR(KN02CA_CPU_INR_BUS) } },
563 	{ { .i = DEC_CPU_IRQ_MASK(KN02CA_CPU_INR_RTC) },
564 		{ .i = DEC_CPU_IRQ_NR(KN02CA_CPU_INR_RTC) } },
565 	{ { .i = DEC_CPU_IRQ_MASK(KN02CA_CPU_INR_CASCADE) },
566 		{ .p = kn02xa_io_int } },
567 	{ { .i = DEC_CPU_IRQ_ALL },
568 		{ .p = cpu_all_int } },
569 };
570 
571 static int_ptr kn02ca_asic_mask_nr_tbl[][2] __initdata = {
572 	{ { .i = IO_IRQ_DMA },
573 		{ .p = asic_dma_int } },
574 	{ { .i = IO_IRQ_MASK(KN02CA_IO_INR_SCC0) },
575 		{ .i = IO_IRQ_NR(KN02CA_IO_INR_SCC0) } },
576 	{ { .i = IO_IRQ_MASK(KN02CA_IO_INR_ASC) },
577 		{ .i = IO_IRQ_NR(KN02CA_IO_INR_ASC) } },
578 	{ { .i = IO_IRQ_MASK(KN02CA_IO_INR_LANCE) },
579 		{ .i = IO_IRQ_NR(KN02CA_IO_INR_LANCE) } },
580 	{ { .i = IO_IRQ_MASK(KN02CA_IO_INR_TC1) },
581 		{ .i = IO_IRQ_NR(KN02CA_IO_INR_TC1) } },
582 	{ { .i = IO_IRQ_MASK(KN02CA_IO_INR_TC0) },
583 		{ .i = IO_IRQ_NR(KN02CA_IO_INR_TC0) } },
584 	{ { .i = IO_IRQ_ALL },
585 		{ .p = asic_all_int } },
586 };
587 
dec_init_kn02ca(void)588 void __init dec_init_kn02ca(void)
589 {
590 	/* IRQ routing. */
591 	memcpy(&dec_interrupt, &kn02ca_interrupt,
592 		sizeof(kn02ca_interrupt));
593 
594 	/* CPU IRQ priorities. */
595 	memcpy(&cpu_mask_nr_tbl, &kn02ca_cpu_mask_nr_tbl,
596 		sizeof(kn02ca_cpu_mask_nr_tbl));
597 
598 	/* I/O ASIC IRQ priorities. */
599 	memcpy(&asic_mask_nr_tbl, &kn02ca_asic_mask_nr_tbl,
600 		sizeof(kn02ca_asic_mask_nr_tbl));
601 
602 	mips_cpu_irq_init(DEC_CPU_IRQ_BASE);
603 	init_ioasic_irqs(IO_IRQ_BASE);
604 
605 }				/* dec_init_kn02ca */
606 
607 
608 /*
609  * Machine-specific initialisation for KN03, aka DS5000/240,
610  * aka 3max+ and DS5900, aka BIGmax.  Also applies to KN05, aka
611  * DS5000/260, aka 4max+ and DS5900/260.
612  */
613 static int kn03_interrupt[DEC_NR_INTS] __initdata = {
614 	[DEC_IRQ_CASCADE]	= DEC_CPU_IRQ_NR(KN03_CPU_INR_CASCADE),
615 	[DEC_IRQ_AB_RECV]	= -1,
616 	[DEC_IRQ_AB_XMIT]	= -1,
617 	[DEC_IRQ_DZ11]		= -1,
618 	[DEC_IRQ_ASC]		= IO_IRQ_NR(KN03_IO_INR_ASC),
619 	[DEC_IRQ_FLOPPY]	= -1,
620 	[DEC_IRQ_FPU]		= DEC_CPU_IRQ_NR(DEC_CPU_INR_FPU),
621 	[DEC_IRQ_HALT]		= DEC_CPU_IRQ_NR(KN03_CPU_INR_HALT),
622 	[DEC_IRQ_ISDN]		=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_SCC0A_TXDMA),
647 	[DEC_IRQ_AB_RXERR]	= -1,
648 	[DEC_IRQ_AB_RXDMA]	= -1,
649 	[DEC_IRQ_AB_TXERR]	= -1,
650 	[DEC_IRQ_AB_TXDMA]	= -1,
651 	[DEC_IRQ_SCC1A_RXERR]	= IO_IRQ_NR(IO_INR_SCC1A_RXERR),
652 	[DEC_IRQ_SCC1A_RXDMA]	= IO_IRQ_NR(IO_INR_SCC1A_RXDMA),
653 	[DEC_IRQ_SCC1A_TXERR]	= IO_IRQ_NR(IO_INR_SCC1A_TXERR),
654 	[DEC_IRQ_SCC1A_TXDMA]	= IO_IRQ_NR(IO_INR_SCC1A_TXDMA),
655 };
656 
657 static int_ptr kn03_cpu_mask_nr_tbl[][2] __initdata = {
658 	{ { .i = DEC_CPU_IRQ_MASK(KN03_CPU_INR_BUS) },
659 		{ .i = DEC_CPU_IRQ_NR(KN03_CPU_INR_BUS) } },
660 	{ { .i = DEC_CPU_IRQ_MASK(KN03_CPU_INR_RTC) },
661 		{ .i = DEC_CPU_IRQ_NR(KN03_CPU_INR_RTC) } },
662 	{ { .i = DEC_CPU_IRQ_MASK(KN03_CPU_INR_CASCADE) },
663 		{ .p = kn03_io_int } },
664 	{ { .i = DEC_CPU_IRQ_ALL },
665 		{ .p = cpu_all_int } },
666 };
667 
668 static int_ptr kn03_asic_mask_nr_tbl[][2] __initdata = {
669 	{ { .i = IO_IRQ_DMA },
670 		{ .p = asic_dma_int } },
671 	{ { .i = IO_IRQ_MASK(KN03_IO_INR_SCC0) },
672 		{ .i = IO_IRQ_NR(KN03_IO_INR_SCC0) } },
673 	{ { .i = IO_IRQ_MASK(KN03_IO_INR_SCC1) },
674 		{ .i = IO_IRQ_NR(KN03_IO_INR_SCC1) } },
675 	{ { .i = IO_IRQ_MASK(KN03_IO_INR_ASC) },
676 		{ .i = IO_IRQ_NR(KN03_IO_INR_ASC) } },
677 	{ { .i = IO_IRQ_MASK(KN03_IO_INR_LANCE) },
678 		{ .i = IO_IRQ_NR(KN03_IO_INR_LANCE) } },
679 	{ { .i = IO_IRQ_MASK(KN03_IO_INR_TC2) },
680 		{ .i = IO_IRQ_NR(KN03_IO_INR_TC2) } },
681 	{ { .i = IO_IRQ_MASK(KN03_IO_INR_TC1) },
682 		{ .i = IO_IRQ_NR(KN03_IO_INR_TC1) } },
683 	{ { .i = IO_IRQ_MASK(KN03_IO_INR_TC0) },
684 		{ .i = IO_IRQ_NR(KN03_IO_INR_TC0) } },
685 	{ { .i = IO_IRQ_ALL },
686 		{ .p = asic_all_int } },
687 };
688 
dec_init_kn03(void)689 void __init dec_init_kn03(void)
690 {
691 	/* IRQ routing. */
692 	memcpy(&dec_interrupt, &kn03_interrupt,
693 		sizeof(kn03_interrupt));
694 
695 	/* CPU IRQ priorities. */
696 	memcpy(&cpu_mask_nr_tbl, &kn03_cpu_mask_nr_tbl,
697 		sizeof(kn03_cpu_mask_nr_tbl));
698 
699 	/* I/O ASIC IRQ priorities. */
700 	memcpy(&asic_mask_nr_tbl, &kn03_asic_mask_nr_tbl,
701 		sizeof(kn03_asic_mask_nr_tbl));
702 
703 	mips_cpu_irq_init(DEC_CPU_IRQ_BASE);
704 	init_ioasic_irqs(IO_IRQ_BASE);
705 
706 }				/* dec_init_kn03 */
707 
708 
init_IRQ(void)709 void __init init_IRQ(void)
710 {
711 	switch (mips_machtype) {
712 	case MACH_DS23100:	/* DS2100/DS3100 Pmin/Pmax */
713 		dec_init_kn01();
714 		break;
715 	case MACH_DS5100:	/* DS5100 MIPSmate */
716 		dec_init_kn230();
717 		break;
718 	case MACH_DS5000_200:	/* DS5000/200 3max */
719 		dec_init_kn02();
720 		break;
721 	case MACH_DS5000_1XX:	/* DS5000/1xx 3min */
722 		dec_init_kn02ba();
723 		break;
724 	case MACH_DS5000_2X0:	/* DS5000/240 3max+ */
725 	case MACH_DS5900:	/* DS5900 bigmax */
726 		dec_init_kn03();
727 		break;
728 	case MACH_DS5000_XX:	/* Personal DS5000/xx */
729 		dec_init_kn02ca();
730 		break;
731 	case MACH_DS5800:	/* DS5800 Isis */
732 		panic("Don't know how to set this up!");
733 		break;
734 	case MACH_DS5400:	/* DS5400 MIPSfair */
735 		panic("Don't know how to set this up!");
736 		break;
737 	case MACH_DS5500:	/* DS5500 MIPSfair-2 */
738 		panic("Don't know how to set this up!");
739 		break;
740 	}
741 	set_except_vector(0, decstation_handle_int);
742 
743 	/* Free the FPU interrupt if the exception is present. */
744 	if (!cpu_has_nofpuex) {
745 		cpu_fpu_mask = 0;
746 		dec_interrupt[DEC_IRQ_FPU] = -1;
747 	}
748 
749 	/* Register board interrupts: FPU and cascade. */
750 	if (dec_interrupt[DEC_IRQ_FPU] >= 0)
751 		setup_irq(dec_interrupt[DEC_IRQ_FPU], &fpuirq);
752 	if (dec_interrupt[DEC_IRQ_CASCADE] >= 0)
753 		setup_irq(dec_interrupt[DEC_IRQ_CASCADE], &ioirq);
754 
755 	/* Register the bus error interrupt. */
756 	if (dec_interrupt[DEC_IRQ_BUS] >= 0 && busirq.handler)
757 		setup_irq(dec_interrupt[DEC_IRQ_BUS], &busirq);
758 
759 	/* Register the HALT interrupt. */
760 	if (dec_interrupt[DEC_IRQ_HALT] >= 0)
761 		setup_irq(dec_interrupt[DEC_IRQ_HALT], &haltirq);
762 }
763 
764 EXPORT_SYMBOL(ioasic_base);
765 EXPORT_SYMBOL(dec_kn_slot_size);
766 EXPORT_SYMBOL(dec_interrupt);
767