2 * Copyright (C) 1995, 1996, 1997 Paul M. Antoine and Harald Koerfgen
3 * Copyright (C) 2000, 2001, 2002, 2003, 2005 Maciej W. Rozycki
5 * Written by Ralf Baechle and Andreas Busse, modified for DECstation
6 * support by Paul Antoine and Harald Koerfgen.
8 * completely rewritten:
9 * Copyright (C) 1998 Harald Koerfgen
11 * Rewritten extensively for controller-driven IRQ support
12 * by Maciej W. Rozycki.
15 #include <asm/addrspace.h>
17 #include <asm/mipsregs.h>
18 #include <asm/regdef.h>
19 #include <asm/stackframe.h>
21 #include <asm/dec/interrupts.h>
22 #include <asm/dec/ioasic_addrs.h>
23 #include <asm/dec/ioasic_ints.h>
24 #include <asm/dec/kn01.h>
25 #include <asm/dec/kn02.h>
26 #include <asm/dec/kn02xa.h>
27 #include <asm/dec/kn03.h>
29 #define KN02_CSR_BASE CKSEG1ADDR(KN02_SLOT_BASE + KN02_CSR)
30 #define KN02XA_IOASIC_BASE CKSEG1ADDR(KN02XA_SLOT_BASE + IOASIC_IOCTL)
31 #define KN03_IOASIC_BASE CKSEG1ADDR(KN03_SLOT_BASE + IOASIC_IOCTL)
36 * plat_irq_dispatch: Interrupt handler for DECstations
38 * We follow the model in the Indy interrupt code by David Miller, where he
39 * says: a lot of complication here is taken away because:
41 * 1) We handle one interrupt and return, sitting in a loop
42 * and moving across all the pending IRQ bits in the cause
43 * register is _NOT_ the answer, the common case is one
44 * pending IRQ so optimize in that direction.
46 * 2) We need not check against bits in the status register
47 * IRQ mask, that would make this routine slow as hell.
49 * 3) Linux only thinks in terms of all IRQs on or all IRQs
50 * off, nothing in between like BSD spl() brain-damage.
52 * Furthermore, the IRQs on the DECstations look basically (barring
53 * software IRQs which we don't use at all) like...
55 * DS2100/3100's, aka kn01, aka Pmax:
59 * 0 Software (ignored)
60 * 1 Software (ignored)
65 * 6 Memory Controller & Video
68 * DS5000/200, aka kn02, aka 3max:
72 * 0 Software (ignored)
73 * 1 Software (ignored)
81 * DS5000/1xx's, aka kn02ba, aka 3min:
85 * 0 Software (ignored)
86 * 1 Software (ignored)
87 * 2 TurboChannel Slot 0
88 * 3 TurboChannel Slot 1
89 * 4 TurboChannel Slot 2
90 * 5 TurboChannel Slot 3 (ASIC)
94 * DS5000/2x's, aka kn02ca, aka maxine:
98 * 0 Software (ignored)
99 * 1 Software (ignored)
100 * 2 Periodic Interrupt (100usec)
102 * 4 I/O write timeout
103 * 5 TurboChannel (ASIC)
104 * 6 Halt Keycode from Access.Bus keyboard (CTRL-ALT-ENTER)
107 * DS5000/2xx's, aka kn03, aka 3maxplus:
111 * 0 Software (ignored)
112 * 1 Software (ignored)
113 * 2 System Board (ASIC)
120 * We handle the IRQ according to _our_ priority (see setup.c),
121 * then we just return. If multiple IRQs are pending then we will
122 * just take another exception, big deal.
125 NESTED(plat_irq_dispatch, PT_SIZE, ra)
129 * Get pending Interrupts
131 mfc0 t0,CP0_CAUSE # get pending interrupts
136 andi t0,ST0_IM # CAUSE.CE may be non-zero!
137 and t0,t1 # isolate allowed ones
143 bnez t2,fpu # handle FPU immediately
147 * Find irq with highest priority
149 # open coded PTR_LA t1, cpu_mask_nr_tbl
150 #if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
151 # open coded la t1, cpu_mask_nr_tbl
152 lui t1, %hi(cpu_mask_nr_tbl)
153 addiu t1, %lo(cpu_mask_nr_tbl)
155 #error GCC `-msym32' option required for 64-bit DECstation builds
161 addu t1,2*PTRSIZE # delay slot
164 * Do the low-level stuff
168 bgez a0,handle_it # irq_nr >= 0?
169 # irq_nr < 0: it is an address
172 # a trick to save a branch:
173 lui t2,(KN03_IOASIC_BASE>>16)&0xffff
174 # upper part of IOASIC Address
177 * Handle "IRQ Controller" Interrupts
178 * Masked Interrupts are still visible and have to be masked "by hand".
180 FEXPORT(kn02_io_int) # 3max
181 lui t0,(KN02_CSR_BASE>>16)&0xffff
182 # get interrupt status and mask
185 andi t1,t0,KN02_IRQ_ALL
187 srl t0,16 # shift interrupt mask
189 FEXPORT(kn02xa_io_int) # 3min/maxine
190 lui t2,(KN02XA_IOASIC_BASE>>16)&0xffff
191 # upper part of IOASIC Address
193 FEXPORT(kn03_io_int) # 3max+ (t2 loaded earlier)
194 lw t0,IO_REG_SIR(t2) # get status: IOASIC sir
195 lw t1,IO_REG_SIMR(t2) # get mask: IOASIC simr
198 1: and t0,t1 # mask out allowed ones
203 * Find irq with highest priority
205 # open coded PTR_LA t1,asic_mask_nr_tbl
206 #if defined(CONFIG_32BIT) || defined(KBUILD_64BIT_SYM32)
207 # open coded la t1, asic_mask_nr_tbl
208 lui t1, %hi(asic_mask_nr_tbl)
209 addiu t1, %lo(asic_mask_nr_tbl)
211 #error GCC `-msym32' option required for 64-bit DECstation builds
217 addu t1,2*PTRSIZE # delay slot
220 * Do the low-level stuff
222 lw a0,%lo(-PTRSIZE)(t1)
224 bgez a0,handle_it # irq_nr >= 0?
225 # irq_nr < 0: it is an address
231 * Dispatch low-priority interrupts. We reconsider all status
232 * bits again, which looks like a lose, but it makes the code
233 * simple and O(log n), so it gets compensated.
235 FEXPORT(cpu_all_int) # HALT, timers, software junk
236 li a0,DEC_CPU_IRQ_BASE
238 li t1,CAUSEF_IP>>CAUSEB_IP # mask
240 li t2,4 # nr of bits / 2
242 FEXPORT(kn02_all_int) # impossible ?
244 li t1,KN02_IRQ_ALL # mask
246 li t2,4 # nr of bits / 2
248 FEXPORT(asic_all_int) # various I/O ASIC junk
250 li t1,IO_IRQ_ALL # mask
252 li t2,8 # nr of bits / 2
255 * Dispatch DMA interrupts -- O(log n).
257 FEXPORT(asic_dma_int) # I/O ASIC DMA events
258 li a0,IO_IRQ_BASE+IO_INR_DMA
260 li t1,IO_IRQ_DMA>>IO_INR_DMA # mask
261 li t2,8 # nr of bits / 2
264 * Find irq with highest priority.
265 * Highest irq number takes precedence.
296 END(plat_irq_dispatch)
299 * Generic unimplemented interrupt routines -- cpu_mask_nr_tbl
300 * and asic_mask_nr_tbl are initialized to point all interrupts here.
301 * The tables are then filled in by machine-specific initialisation
304 FEXPORT(dec_intr_unimplemented)
305 move a1,t0 # cheats way of printing an arg!
306 PANIC("Unimplemented cpu interrupt! CP0_CAUSE: 0x%08x");
308 FEXPORT(asic_intr_unimplemented)
309 move a1,t0 # cheats way of printing an arg!
310 PANIC("Unimplemented asic interrupt! ASIC ISR: 0x%08x");