2 * linux/arch/alpha/kernel/sys_dp264.c
4 * Copyright (C) 1995 David A Rusling
5 * Copyright (C) 1996, 1999 Jay A Estabrook
6 * Copyright (C) 1998, 1999 Richard Henderson
8 * Code supporting the DP264 (EV6+TSUNAMI).
11 #include <linux/kernel.h>
12 #include <linux/types.h>
14 #include <linux/sched.h>
15 #include <linux/pci.h>
16 #include <linux/init.h>
18 #include <asm/ptrace.h>
19 #include <asm/system.h>
22 #include <asm/bitops.h>
23 #include <asm/mmu_context.h>
25 #include <asm/pgtable.h>
26 #include <asm/core_tsunami.h>
27 #include <asm/hwrpb.h>
32 #include "machvec_impl.h"
36 * HACK ALERT! only the boot cpu is used for interrupts.
40 dp264_update_irq_hw(unsigned long irq
, unsigned long mask
, int unmask_p
)
43 volatile unsigned long *csr
;
45 if (TSUNAMI_bootcpu
< 2)
47 csr
= &TSUNAMI_cchip
->dim0
.csr
;
49 csr
= &TSUNAMI_cchip
->dim1
.csr
;
51 if (TSUNAMI_bootcpu
== 2)
52 csr
= &TSUNAMI_cchip
->dim2
.csr
;
54 csr
= &TSUNAMI_cchip
->dim3
.csr
;
61 outb(mask
>> 8, 0xA1); /* ISA PIC2 */
63 outb(mask
, 0x21); /* ISA PIC1 */
67 clipper_update_irq_hw(unsigned long irq
, unsigned long mask
, int unmask_p
)
70 volatile unsigned long *csr
;
72 if (TSUNAMI_bootcpu
< 2)
74 csr
= &TSUNAMI_cchip
->dim0
.csr
;
76 csr
= &TSUNAMI_cchip
->dim1
.csr
;
78 if (TSUNAMI_bootcpu
== 2)
79 csr
= &TSUNAMI_cchip
->dim2
.csr
;
81 csr
= &TSUNAMI_cchip
->dim3
.csr
;
83 *csr
= (~mask
>> 16) | (1UL << 55); /* master ISA enable */
88 outb(mask
>> 8, 0xA1); /* ISA PIC2 */
90 outb(mask
, 0x21); /* ISA PIC1 */
94 dp264_device_interrupt(unsigned long vector
, struct pt_regs
* regs
)
97 printk("dp264_device_interrupt: NOT IMPLEMENTED YET!! \n");
102 /* Read the interrupt summary register of TSUNAMI */
103 pld
= TSUNAMI_cchip
->dir0
.csr
;
106 * Now for every possible bit set, work through them and call
107 * the appropriate interrupt handler.
111 pld
&= pld
- 1; /* clear least bit set */
113 isa_device_interrupt(vector
, regs
);
115 handle_irq(16 + i
, 16 + i
, regs
);
117 TSUNAMI_cchip
->dir0
.csr
= 1UL << i
; mb();
118 tmp
= TSUNAMI_cchip
->dir0
.csr
;
125 dp264_srm_device_interrupt(unsigned long vector
, struct pt_regs
* regs
)
129 ack
= irq
= (vector
- 0x800) >> 4;
132 * The SRM console reports PCI interrupts with a vector calculated by:
134 * 0x900 + (0x10 * DRIR-bit)
136 * So bit 16 shows up as IRQ 32, etc.
138 * On DP264/BRICK/MONET, we adjust it down by 16 because at least
139 * that many of the low order bits of the DRIR are not used, and
140 * so we don't count them.
143 ack
= irq
= irq
- 16;
145 handle_irq(irq
, ack
, regs
);
149 clipper_srm_device_interrupt(unsigned long vector
, struct pt_regs
* regs
)
153 ack
= irq
= (vector
- 0x800) >> 4;
156 * The SRM console reports PCI interrupts with a vector calculated by:
158 * 0x900 + (0x10 * DRIR-bit)
160 * So bit 16 shows up as IRQ 32, etc.
162 * CLIPPER uses bits 8-47 for PCI interrupts, so we do not need
163 * to scale down the vector reported, we just use it.
165 * Eg IRQ 24 is DRIR bit 8, etc, etc
167 handle_irq(irq
, ack
, regs
);
173 outb(0, DMA1_RESET_REG
);
174 outb(0, DMA2_RESET_REG
);
175 outb(DMA_MODE_CASCADE
, DMA2_MODE_REG
);
176 outb(0, DMA2_MASK_REG
);
179 alpha_mv
.device_interrupt
= dp264_srm_device_interrupt
;
181 dp264_update_irq_hw(16, alpha_irq_mask
, 0);
183 enable_irq(55); /* Enable ISA interrupt controller. */
188 clipper_init_irq(void)
190 outb(0, DMA1_RESET_REG
);
191 outb(0, DMA2_RESET_REG
);
192 outb(DMA_MODE_CASCADE
, DMA2_MODE_REG
);
193 outb(0, DMA2_MASK_REG
);
196 alpha_mv
.device_interrupt
= clipper_srm_device_interrupt
;
198 clipper_update_irq_hw(16, alpha_irq_mask
, 0);
200 enable_irq(55); /* Enable ISA interrupt controller. */
206 * PCI Fixup configuration.
208 * Summary @ TSUNAMI_CSR_DIM0:
211 *18 Interrupt SCSI B (Adaptec 7895 builtin)
212 *19 Interrupt SCSI A (Adaptec 7895 builtin)
213 *20 Interrupt Line D from slot 2 PCI0
214 *21 Interrupt Line C from slot 2 PCI0
215 *22 Interrupt Line B from slot 2 PCI0
216 *23 Interrupt Line A from slot 2 PCI0
217 *24 Interrupt Line D from slot 1 PCI0
218 *25 Interrupt Line C from slot 1 PCI0
219 *26 Interrupt Line B from slot 1 PCI0
220 *27 Interrupt Line A from slot 1 PCI0
221 *28 Interrupt Line D from slot 0 PCI0
222 *29 Interrupt Line C from slot 0 PCI0
223 *30 Interrupt Line B from slot 0 PCI0
224 *31 Interrupt Line A from slot 0 PCI0
226 *32 Interrupt Line D from slot 3 PCI1
227 *33 Interrupt Line C from slot 3 PCI1
228 *34 Interrupt Line B from slot 3 PCI1
229 *35 Interrupt Line A from slot 3 PCI1
230 *36 Interrupt Line D from slot 2 PCI1
231 *37 Interrupt Line C from slot 2 PCI1
232 *38 Interrupt Line B from slot 2 PCI1
233 *39 Interrupt Line A from slot 2 PCI1
234 *40 Interrupt Line D from slot 1 PCI1
235 *41 Interrupt Line C from slot 1 PCI1
236 *42 Interrupt Line B from slot 1 PCI1
237 *43 Interrupt Line A from slot 1 PCI1
238 *44 Interrupt Line D from slot 0 PCI1
239 *45 Interrupt Line C from slot 0 PCI1
240 *46 Interrupt Line B from slot 0 PCI1
241 *47 Interrupt Line A from slot 0 PCI1
243 *53 PCI0 NMI (from Cypress)
244 *54 PCI0 SMI INT (from Cypress)
245 *55 PCI0 ISA Interrupt (from Cypress)
252 * 5 Cypress Bridge I/O
253 * 6 SCSI Adaptec builtin
254 * 7 64 bit PCI option slot 0 (all busses)
255 * 8 64 bit PCI option slot 1 (all busses)
256 * 9 64 bit PCI option slot 2 (all busses)
257 * 10 64 bit PCI option slot 3 (not bus 0)
261 dp264_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
263 static char irq_tab
[6][5] __initlocaldata
= {
264 /*INT INTA INTB INTC INTD */
265 { -1, -1, -1, -1, -1}, /* IdSel 5 ISA Bridge */
266 { 16+ 3, 16+ 3, 16+ 2, 16+ 2, 16+ 2}, /* IdSel 6 SCSI builtin*/
267 { 16+15, 16+15, 16+14, 16+13, 16+12}, /* IdSel 7 slot 0 */
268 { 16+11, 16+11, 16+10, 16+ 9, 16+ 8}, /* IdSel 8 slot 1 */
269 { 16+ 7, 16+ 7, 16+ 6, 16+ 5, 16+ 4}, /* IdSel 9 slot 2 */
270 { 16+ 3, 16+ 3, 16+ 2, 16+ 1, 16+ 0} /* IdSel 10 slot 3 */
272 const long min_idsel
= 5, max_idsel
= 10, irqs_per_slot
= 5;
274 struct pci_controler
*hose
= dev
->sysdata
;
275 int irq
= COMMON_TABLE_LOOKUP
;
278 irq
+= 16 * hose
->index
;
284 monet_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
286 static char irq_tab
[13][5] __initlocaldata
= {
287 /*INT INTA INTB INTC INTD */
288 { 45, 45, 45, 45, 45}, /* IdSel 3 21143 PCI1 */
289 { -1, -1, -1, -1, -1}, /* IdSel 4 unused */
290 { -1, -1, -1, -1, -1}, /* IdSel 5 unused */
291 { 47, 47, 47, 47, 47}, /* IdSel 6 SCSI PCI1 */
292 { -1, -1, -1, -1, -1}, /* IdSel 7 ISA Bridge */
293 { -1, -1, -1, -1, -1}, /* IdSel 8 P2P PCI1 */
295 { 28, 28, 29, 30, 31}, /* IdSel 14 slot 4 PCI2*/
296 { 24, 24, 25, 26, 27}, /* IdSel 15 slot 5 PCI2*/
298 { -1, -1, -1, -1, -1}, /* IdSel 9 unused */
299 { -1, -1, -1, -1, -1}, /* IdSel 10 unused */
301 { 40, 40, 41, 42, 43}, /* IdSel 11 slot 1 PCI0*/
302 { 36, 36, 37, 38, 39}, /* IdSel 12 slot 2 PCI0*/
303 { 32, 32, 33, 34, 35}, /* IdSel 13 slot 3 PCI0*/
304 { 28, 28, 29, 30, 31}, /* IdSel 14 slot 4 PCI2*/
305 { 24, 24, 25, 26, 27} /* IdSel 15 slot 5 PCI2*/
307 const long min_idsel
= 3, max_idsel
= 15, irqs_per_slot
= 5;
308 return COMMON_TABLE_LOOKUP
;
312 monet_swizzle(struct pci_dev
*dev
, u8
*pinp
)
314 struct pci_controler
*hose
= dev
->sysdata
;
315 int slot
, pin
= *pinp
;
317 if (hose
->first_busno
== dev
->bus
->number
) {
318 slot
= PCI_SLOT(dev
->devfn
);
320 /* Check for the built-in bridge on hose 1. */
321 else if (hose
->index
== 1 && PCI_SLOT(dev
->bus
->self
->devfn
) == 8) {
322 slot
= PCI_SLOT(dev
->devfn
);
324 /* Must be a card-based bridge. */
326 /* Check for built-in bridge on hose 1. */
327 if (hose
->index
== 1 &&
328 PCI_SLOT(dev
->bus
->self
->devfn
) == 8) {
329 slot
= PCI_SLOT(dev
->devfn
);
332 pin
= bridge_swizzle(pin
, PCI_SLOT(dev
->devfn
)) ;
334 /* Move up the chain of bridges. */
335 dev
= dev
->bus
->self
;
336 /* Slot of the next bridge. */
337 slot
= PCI_SLOT(dev
->devfn
);
338 } while (dev
->bus
->self
);
345 webbrick_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
347 static char irq_tab
[13][5] __initlocaldata
= {
348 /*INT INTA INTB INTC INTD */
349 { -1, -1, -1, -1, -1}, /* IdSel 7 ISA Bridge */
350 { -1, -1, -1, -1, -1}, /* IdSel 8 unused */
351 { 29, 29, 29, 29, 29}, /* IdSel 9 21143 #1 */
352 { -1, -1, -1, -1, -1}, /* IdSel 10 unused */
353 { 30, 30, 30, 30, 30}, /* IdSel 11 21143 #2 */
354 { -1, -1, -1, -1, -1}, /* IdSel 12 unused */
355 { -1, -1, -1, -1, -1}, /* IdSel 13 unused */
356 { 35, 35, 34, 33, 32}, /* IdSel 14 slot 0 */
357 { 39, 39, 38, 37, 36}, /* IdSel 15 slot 1 */
358 { 43, 43, 42, 41, 40}, /* IdSel 16 slot 2 */
359 { 47, 47, 46, 45, 44}, /* IdSel 17 slot 3 */
361 const long min_idsel
= 7, max_idsel
= 17, irqs_per_slot
= 5;
362 return COMMON_TABLE_LOOKUP
;
366 clipper_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
368 static char irq_tab
[7][5] __initlocaldata
= {
369 /*INT INTA INTB INTC INTD */
370 { 16+ 8, 16+ 8, 16+ 9, 16+10, 16+11}, /* IdSel 1 slot 1 */
371 { 16+12, 16+12, 16+13, 16+14, 16+15}, /* IdSel 2 slot 2 */
372 { 16+16, 16+16, 16+17, 16+18, 16+19}, /* IdSel 3 slot 3 */
373 { 16+20, 16+20, 16+21, 16+22, 16+23}, /* IdSel 4 slot 4 */
374 { 16+24, 16+24, 16+25, 16+26, 16+27}, /* IdSel 5 slot 5 */
375 { 16+28, 16+28, 16+29, 16+30, 16+31}, /* IdSel 6 slot 6 */
376 { -1, -1, -1, -1, -1} /* IdSel 7 ISA Bridge */
378 const long min_idsel
= 1, max_idsel
= 7, irqs_per_slot
= 5;
380 struct pci_controler
*hose
= dev
->sysdata
;
381 int irq
= COMMON_TABLE_LOOKUP
;
384 irq
+= 16 * hose
->index
;
409 struct alpha_machine_vector dp264_mv __initmv
= {
410 vector_name
: "DP264",
415 machine_check
: tsunami_machine_check
,
416 max_dma_address
: ALPHA_MAX_DMA_ADDRESS
,
417 min_io_address
: DEFAULT_IO_BASE
,
418 min_mem_address
: DEFAULT_MEM_BASE
,
421 irq_probe_mask
: _PROBE_MASK(64),
422 update_irq_hw
: dp264_update_irq_hw
,
423 ack_irq
: common_ack_irq
,
424 device_interrupt
: dp264_device_interrupt
,
426 init_arch
: tsunami_init_arch
,
427 init_irq
: dp264_init_irq
,
428 init_pit
: common_init_pit
,
429 init_pci
: dp264_init_pci
,
430 kill_arch
: common_kill_arch
,
431 pci_map_irq
: dp264_map_irq
,
432 pci_swizzle
: common_swizzle
,
436 struct alpha_machine_vector monet_mv __initmv
= {
437 vector_name
: "Monet",
442 machine_check
: tsunami_machine_check
,
443 max_dma_address
: ALPHA_MAX_DMA_ADDRESS
,
444 min_io_address
: DEFAULT_IO_BASE
,
445 min_mem_address
: DEFAULT_MEM_BASE
,
448 irq_probe_mask
: _PROBE_MASK(64),
449 update_irq_hw
: dp264_update_irq_hw
,
450 ack_irq
: common_ack_irq
,
451 device_interrupt
: dp264_device_interrupt
,
453 init_arch
: tsunami_init_arch
,
454 init_irq
: dp264_init_irq
,
455 init_pit
: common_init_pit
,
456 init_pci
: monet_init_pci
,
457 kill_arch
: common_kill_arch
,
458 pci_map_irq
: monet_map_irq
,
459 pci_swizzle
: monet_swizzle
,
462 struct alpha_machine_vector webbrick_mv __initmv
= {
463 vector_name
: "Webbrick",
468 machine_check
: tsunami_machine_check
,
469 max_dma_address
: ALPHA_MAX_DMA_ADDRESS
,
470 min_io_address
: DEFAULT_IO_BASE
,
471 min_mem_address
: DEFAULT_MEM_BASE
,
474 irq_probe_mask
: _PROBE_MASK(64),
475 update_irq_hw
: dp264_update_irq_hw
,
476 ack_irq
: common_ack_irq
,
477 device_interrupt
: dp264_device_interrupt
,
479 init_arch
: tsunami_init_arch
,
480 init_irq
: dp264_init_irq
,
481 init_pit
: common_init_pit
,
482 init_pci
: dp264_init_pci
,
483 kill_arch
: common_kill_arch
,
484 pci_map_irq
: webbrick_map_irq
,
485 pci_swizzle
: common_swizzle
,
488 struct alpha_machine_vector clipper_mv __initmv
= {
489 vector_name
: "Clipper",
494 machine_check
: tsunami_machine_check
,
495 max_dma_address
: ALPHA_MAX_DMA_ADDRESS
,
496 min_io_address
: DEFAULT_IO_BASE
,
497 min_mem_address
: DEFAULT_MEM_BASE
,
500 irq_probe_mask
: _PROBE_MASK(64),
501 update_irq_hw
: clipper_update_irq_hw
,
502 ack_irq
: common_ack_irq
,
503 device_interrupt
: dp264_device_interrupt
,
505 init_arch
: tsunami_init_arch
,
506 init_irq
: clipper_init_irq
,
507 init_pit
: common_init_pit
,
508 init_pci
: common_init_pci
,
509 kill_arch
: common_kill_arch
,
510 pci_map_irq
: clipper_map_irq
,
511 pci_swizzle
: common_swizzle
,
514 /* No alpha_mv alias for webbrick/monet/clipper, since we compile them
515 in unconditionally with DP264; setup_arch knows how to cope. */