2 * linux/arch/alpha/kernel/irq.c
4 * Copyright (C) 1995 Linus Torvalds
6 * This file contains the code used by various IRQ handling routines:
7 * asking for different IRQ's should be done through these routines
8 * instead of just grabbing them. Thus setups with different IRQ numbers
9 * shouldn't result in any weird surprises, and installing new handlers
13 #include <linux/config.h>
14 #include <linux/ptrace.h>
15 #include <linux/errno.h>
16 #include <linux/kernel_stat.h>
17 #include <linux/signal.h>
18 #include <linux/sched.h>
19 #include <linux/interrupt.h>
20 #include <linux/malloc.h>
21 #include <linux/random.h>
23 #include <asm/system.h>
26 #include <asm/bitops.h>
29 #define vulp volatile unsigned long *
30 #define vuip volatile unsigned int *
34 #define TIMER_IRQ 0 /* timer is the pit */
36 #define TIMER_IRQ RTC_IRQ /* the timer is, in fact, the rtc */
40 # error Unable to handle more than 64 irq levels.
43 /* PROBE_MASK is the bitset of irqs that we consider for autoprobing: */
44 #if defined(CONFIG_ALPHA_P2K)
45 /* always mask out unused timer irq 0 and RTC irq 8 */
46 # define PROBE_MASK (((1UL << NR_IRQS) - 1) & ~0x101UL)
47 #elif defined(CONFIG_ALPHA_ALCOR)
48 /* always mask out unused timer irq 0, "irqs" 20-30, and the EISA cascade: */
49 # define PROBE_MASK (((1UL << NR_IRQS) - 1) & ~0xfff000000001UL)
51 /* always mask out unused timer irq 0: */
52 # define PROBE_MASK (((1UL << NR_IRQS) - 1) & ~1UL)
55 /* Reserved interrupts. These must NEVER be requested by any driver!
57 #define IS_RESERVED_IRQ(irq) ((irq)==2) /* IRQ 2 used by hw cascade */
60 * Shadow-copy of masked interrupts.
61 * The bits are used as follows:
62 * 0.. 7 first (E)ISA PIC (irq level 0..7)
63 * 8..15 second (E)ISA PIC (irq level 8..15)
64 * Systems with PCI interrupt lines managed by GRU (e.g., Alcor, XLT)
65 * or PYXIS (e.g. Miata, PC164-LX):
66 * 16..47 PCI interrupts 0..31 (int at xxx_INT_MASK)
68 * 16..31 PCI interrupts 0..15 (short at I/O port 536)
69 * Other systems (not Mikasa) with 16 PCI interrupt lines:
70 * 16..23 PCI interrupts 0.. 7 (char at I/O port 26)
71 * 24..31 PCI interrupts 8..15 (char at I/O port 27)
72 * Systems with 17 PCI interrupt lines (e.g., Cabriolet and eb164):
73 * 16..32 PCI interrupts 0..31 (int at I/O port 804)
74 * For SABLE, which is really baroque, we manage 40 IRQ's, but the
75 * hardware really only supports 24, not via normal ISA PIC,
76 * but cascaded custom 8259's, etc.
81 static unsigned long irq_mask
= ~0UL;
83 #ifdef CONFIG_ALPHA_SABLE
85 * Note that the vector reported by the SRM PALcode corresponds to the
86 * interrupt mask bits, but we have to manage via more normal IRQs.
88 * We have to be able to go back and forth between MASK bits and IRQ:
89 * these tables help us do so.
91 static char sable_irq_to_mask
[NR_IRQS
] = {
92 -1, 6, -1, 8, 15, 12, 7, 9, /* pseudo PIC 0-7 */
93 -1, 16, 17, 18, 3, -1, 21, 22, /* pseudo PIC 8-15 */
94 -1, -1, -1, -1, -1, -1, -1, -1, /* pseudo EISA 0-7 */
95 -1, -1, -1, -1, -1, -1, -1, -1, /* pseudo EISA 8-15 */
96 2, 1, 0, 4, 5, -1, -1, -1, /* pseudo PCI */
98 #define IRQ_TO_MASK(irq) (sable_irq_to_mask[(irq)])
99 static char sable_mask_to_irq
[NR_IRQS
] = {
100 34, 33, 32, 12, 35, 36, 1, 6, /* mask 0-7 */
101 3, 7, -1, -1, 5, -1, -1, 4, /* mask 8-15 */
102 9, 10, 11, -1, -1, 14, 15, -1, /* mask 16-23 */
104 #else /* CONFIG_ALPHA_SABLE */
105 #define IRQ_TO_MASK(irq) (irq)
106 #endif /* CONFIG_ALPHA_SABLE */
109 * Update the hardware with the irq mask passed in MASK. The function
110 * exploits the fact that it is known that only bit IRQ has changed.
114 sable_update_hw(unsigned long irq
, unsigned long mask
)
116 /* The "irq" argument is really the mask bit number */
118 default: /* 16 ... 23 */
119 outb(mask
>> 16, 0x53d);
122 outb(mask
>> 8, 0x53b);
131 noritake_update_hw(unsigned long irq
, unsigned long mask
)
134 default: /* 32 ... 47 */
135 outw(~(mask
>> 32), 0x54c);
138 outw(~(mask
>> 16), 0x54a);
140 case 8 ... 15: /* ISA PIC2 */
141 outb(mask
>> 8, 0xA1);
143 case 0 ... 7: /* ISA PIC1 */
149 #ifdef CONFIG_ALPHA_MIATA
151 miata_update_hw(unsigned long irq
, unsigned long mask
)
154 default: /* 16 ... 47 */
155 /* Make CERTAIN none of the bogus ints get enabled... */
156 *(vulp
)PYXIS_INT_MASK
=
157 ~((long)mask
>> 16) & ~0x4000000000000e3bUL
;
159 /* ... and read it back to make sure it got written. */
160 *(vulp
)PYXIS_INT_MASK
;
162 case 8 ... 15: /* ISA PIC2 */
163 outb(mask
>> 8, 0xA1);
165 case 0 ... 7: /* ISA PIC1 */
172 #if defined(CONFIG_ALPHA_ALCOR) || defined(CONFIG_ALPHA_XLT)
174 alcor_and_xlt_update_hw(unsigned long irq
, unsigned long mask
)
177 default: /* 16 ... 47 */
178 /* On Alcor, at least, lines 20..30 are not connected and can
179 generate spurrious interrupts if we turn them on while IRQ
180 probing. So explicitly mask them out. */
181 mask
|= 0x7ff000000000UL
;
183 /* Note inverted sense of mask bits: */
184 *(vuip
)GRU_INT_MASK
= ~(mask
>> 16);
187 case 8 ... 15: /* ISA PIC2 */
188 outb(mask
>> 8, 0xA1);
190 case 0 ... 7: /* ISA PIC1 */
198 mikasa_update_hw(unsigned long irq
, unsigned long mask
)
201 default: /* 16 ... 31 */
202 outw(~(mask
>> 16), 0x536); /* note invert */
204 case 8 ... 15: /* ISA PIC2 */
205 outb(mask
>> 8, 0xA1);
207 case 0 ... 7: /* ISA PIC1 */
213 /* Unlabeled mechanisms based on the number of irqs. Someone should
214 probably document and name these. */
217 update_hw_33(unsigned long irq
, unsigned long mask
)
220 default: /* 16 ... 32 */
221 outl(mask
>> 16, 0x804);
224 case 8 ... 15: /* ISA PIC2 */
225 outb(mask
>> 8, 0xA1);
227 case 0 ... 7: /* ISA PIC1 */
234 update_hw_32(unsigned long irq
, unsigned long mask
)
237 default: /* 24 ... 31 */
238 outb(mask
>> 24, 0x27);
241 outb(mask
>> 16, 0x26);
243 case 8 ... 15: /* ISA PIC2 */
244 outb(mask
>> 8, 0xA1);
246 case 0 ... 7: /* ISA PIC1 */
253 update_hw_16(unsigned long irq
, unsigned long mask
)
256 default: /* 8 ... 15, ISA PIC2 */
257 outb(mask
>> 8, 0xA1);
259 case 0 ... 7: /* ISA PIC1 */
265 #if defined(CONFIG_ALPHA_PC164) && defined(CONFIG_ALPHA_SRM)
267 * On the pc164, we cannot take over the IRQs from the SRM,
268 * so we call down to do our dirty work. Too bad the SRM
269 * isn't consistent across platforms otherwise we could do
273 extern void cserve_ena(unsigned long);
274 extern void cserve_dis(unsigned long);
276 static inline void mask_irq(unsigned long irq
)
278 irq_mask
|= (1UL << irq
);
279 cserve_dis(irq
- 16);
282 static inline void unmask_irq(unsigned long irq
)
284 irq_mask
&= ~(1UL << irq
);
285 cserve_ena(irq
- 16);
288 /* Since we are calling down to PALcode, no need to diddle IPL. */
289 void disable_irq(unsigned int irq_nr
)
291 mask_irq(IRQ_TO_MASK(irq_nr
));
294 void enable_irq(unsigned int irq_nr
)
296 unmask_irq(IRQ_TO_MASK(irq_nr
));
301 * We manipulate the hardware ourselves.
304 static void update_hw(unsigned long irq
, unsigned long mask
)
306 #if defined(CONFIG_ALPHA_SABLE)
307 sable_update_hw(irq
, mask
);
308 #elif defined(CONFIG_ALPHA_MIATA)
309 miata_update_hw(irq
, mask
);
310 #elif defined(CONFIG_ALPHA_NORITAKE)
311 noritake_update_hw(irq
, mask
);
312 #elif defined(CONFIG_ALPHA_ALCOR) || defined(CONFIG_ALPHA_XLT)
313 alcor_and_xlt_update_hw(irq
, mask
);
314 #elif defined(CONFIG_ALPHA_MIKASA)
315 mikasa_update_hw(irq
, mask
);
317 update_hw_33(irq
, mask
);
319 update_hw_32(irq
, mask
);
321 update_hw_16(irq
, mask
);
323 #error "How do I update the IRQ hardware?"
327 static inline void mask_irq(unsigned long irq
)
329 irq_mask
|= (1UL << irq
);
330 update_hw(irq
, irq_mask
);
333 static inline void unmask_irq(unsigned long irq
)
335 irq_mask
&= ~(1UL << irq
);
336 update_hw(irq
, irq_mask
);
339 void disable_irq(unsigned int irq_nr
)
345 mask_irq(IRQ_TO_MASK(irq_nr
));
346 restore_flags(flags
);
349 void enable_irq(unsigned int irq_nr
)
355 unmask_irq(IRQ_TO_MASK(irq_nr
));
356 restore_flags(flags
);
358 #endif /* PC164 && SRM */
361 * Initial irq handlers.
363 static struct irqaction timer_irq
= { NULL
, 0, 0, NULL
, NULL
, NULL
};
364 static struct irqaction
*irq_action
[NR_IRQS
];
366 int get_irq_list(char *buf
)
369 struct irqaction
* action
;
371 for (i
= 0; i
< NR_IRQS
; i
++) {
372 action
= irq_action
[i
];
375 len
+= sprintf(buf
+len
, "%2d: %10u %c %s",
376 i
, kstat
.interrupts
[0][i
],
377 (action
->flags
& SA_INTERRUPT
) ? '+' : ' ',
379 for (action
=action
->next
; action
; action
= action
->next
) {
380 len
+= sprintf(buf
+len
, ",%s %s",
381 (action
->flags
& SA_INTERRUPT
) ? " +" : "",
384 len
+= sprintf(buf
+len
, "\n");
389 static inline void ack_irq(int irq
)
391 #ifdef CONFIG_ALPHA_SABLE
392 /* Note that the "irq" here is really the mask bit number */
395 outb(0xE0 | (irq
- 0), 0x536);
396 outb(0xE0 | 1, 0x534); /* slave 0 */
399 outb(0xE0 | (irq
- 8), 0x53a);
400 outb(0xE0 | 3, 0x534); /* slave 1 */
403 outb(0xE0 | (irq
- 16), 0x53c);
404 outb(0xE0 | 4, 0x534); /* slave 2 */
407 #else /* CONFIG_ALPHA_SABLE */
409 /* ACK the interrupt making it the lowest priority */
410 /* First the slave .. */
412 outb(0xE0 | (irq
- 8), 0xa0);
415 /* .. then the master */
416 outb(0xE0 | irq
, 0x20);
417 #if defined(CONFIG_ALPHA_ALCOR) || defined(CONFIG_ALPHA_XLT)
418 /* on ALCOR/XLT, need to dismiss interrupt via GRU */
419 *(vuip
)GRU_INT_CLEAR
= 0x80000000; mb();
420 *(vuip
)GRU_INT_CLEAR
= 0x00000000; mb();
421 #endif /* ALCOR || XLT */
423 #endif /* CONFIG_ALPHA_SABLE */
426 int request_irq(unsigned int irq
,
427 void (*handler
)(int, void *, struct pt_regs
*),
428 unsigned long irqflags
,
429 const char * devname
,
433 struct irqaction
* action
, **p
;
438 if (IS_RESERVED_IRQ(irq
))
442 p
= irq_action
+ irq
;
445 /* Can't share interrupts unless both agree to */
446 if (!(action
->flags
& irqflags
& SA_SHIRQ
))
449 /* Can't share interrupts unless both are same type */
450 if ((action
->flags
^ irqflags
) & SA_INTERRUPT
)
453 /* Add new interrupt at end of irq queue */
461 if (irq
== TIMER_IRQ
)
464 action
= (struct irqaction
*)kmalloc(sizeof(struct irqaction
),
469 if (irqflags
& SA_SAMPLE_RANDOM
)
470 rand_initialize_irq(irq
);
472 action
->handler
= handler
;
473 action
->flags
= irqflags
;
475 action
->name
= devname
;
477 action
->dev_id
= dev_id
;
484 unmask_irq(IRQ_TO_MASK(irq
));
486 restore_flags(flags
);
490 void free_irq(unsigned int irq
, void *dev_id
)
492 struct irqaction
* action
, **p
;
495 if (irq
>= NR_IRQS
) {
496 printk("Trying to free IRQ%d\n",irq
);
499 if (IS_RESERVED_IRQ(irq
)) {
500 printk("Trying to free reserved IRQ %d\n", irq
);
503 for (p
= irq
+ irq_action
; (action
= *p
) != NULL
; p
= &action
->next
) {
504 if (action
->dev_id
!= dev_id
)
507 /* Found it - now free it */
511 if (!irq
[irq_action
])
512 mask_irq(IRQ_TO_MASK(irq
));
513 restore_flags(flags
);
517 printk("Trying to free free IRQ%d\n",irq
);
520 static inline void handle_nmi(struct pt_regs
* regs
)
522 printk("Whee.. NMI received. Probable hardware error\n");
523 printk("61=%02x, 461=%02x\n", inb(0x61), inb(0x461));
526 unsigned int local_irq_count
[NR_CPUS
];
527 atomic_t __alpha_bh_counter
;
530 #error "Me no hablo Alpha SMP"
532 #define irq_enter(cpu, irq) (++local_irq_count[cpu])
533 #define irq_exit(cpu, irq) (--local_irq_count[cpu])
536 static void unexpected_irq(int irq
, struct pt_regs
* regs
)
538 struct irqaction
*action
;
541 printk("IO device interrupt, irq = %d\n", irq
);
542 printk("PC = %016lx PS=%04lx\n", regs
->pc
, regs
->ps
);
543 printk("Expecting: ");
544 for (i
= 0; i
< 16; i
++)
545 if ((action
= irq_action
[i
]))
546 while (action
->handler
) {
547 printk("[%s:%d] ", action
->name
, i
);
548 action
= action
->next
;
552 #if defined(CONFIG_ALPHA_JENSEN)
553 /* ??? Is all this just debugging, or are the inb's and outb's
554 necessary to make things work? */
555 printk("64=%02x, 60=%02x, 3fa=%02x 2fa=%02x\n",
556 inb(0x64), inb(0x60), inb(0x3fa), inb(0x2fa));
564 static inline void handle_irq(int irq
, struct pt_regs
* regs
)
566 struct irqaction
* action
= irq_action
[irq
];
567 int cpu
= smp_processor_id();
570 kstat
.interrupts
[0][irq
] += 1;
572 unexpected_irq(irq
, regs
);
575 action
->handler(irq
, action
->dev_id
, regs
);
576 action
= action
->next
;
582 static inline void device_interrupt(int irq
, int ack
, struct pt_regs
* regs
)
584 struct irqaction
* action
;
585 int cpu
= smp_processor_id();
587 if ((unsigned) irq
> NR_IRQS
) {
588 printk("device_interrupt: illegal interrupt %d\n", irq
);
593 kstat
.interrupts
[0][irq
] += 1;
594 action
= irq_action
[irq
];
596 * For normal interrupts, we mask it out, and then ACK it.
597 * This way another (more timing-critical) interrupt can
598 * come through while we're doing this one.
600 * Note! An irq without a handler gets masked and acked, but
601 * never unmasked. The autoirq stuff depends on this (it looks
602 * at the masks before and after doing the probing).
607 if (action
->flags
& SA_SAMPLE_RANDOM
)
608 add_interrupt_randomness(irq
);
610 action
->handler(irq
, action
->dev_id
, regs
);
611 action
= action
->next
;
621 * Handle ISA interrupt via the PICs.
623 static inline void isa_device_interrupt(unsigned long vector
,
624 struct pt_regs
* regs
)
626 #if defined(CONFIG_ALPHA_APECS)
627 # define IACK_SC APECS_IACK_SC
628 #elif defined(CONFIG_ALPHA_LCA)
629 # define IACK_SC LCA_IACK_SC
630 #elif defined(CONFIG_ALPHA_CIA)
631 # define IACK_SC CIA_IACK_SC
632 #elif defined(CONFIG_ALPHA_PYXIS)
633 # define IACK_SC PYXIS_IACK_SC
636 * This is bogus but necessary to get it to compile
637 * on all platforms. If you try to use this on any
638 * other than the intended platforms, you'll notice
647 * Generate a PCI interrupt acknowledge cycle. The PIC will
648 * respond with the interrupt vector of the highest priority
649 * interrupt that is pending. The PALcode sets up the
650 * interrupts vectors such that irq level L generates vector L.
652 j
= *(volatile int *) IACK_SC
;
655 if (!(inb(0x20) & 0x80)) {
656 /* It's only a passive release... */
660 device_interrupt(j
, j
, regs
);
665 * It seems to me that the probability of two or more *device*
666 * interrupts occurring at almost exactly the same time is
667 * pretty low. So why pay the price of checking for
668 * additional interrupts here if the common case can be
669 * handled so much easier?
672 * The first read of gives you *all* interrupting lines.
673 * Therefore, read the mask register and and out those lines
674 * not enabled. Note that some documentation has 21 and a1
675 * write only. This is not true.
677 pic
= inb(0x20) | (inb(0xA0) << 8); /* read isr */
678 pic
&= ~irq_mask
; /* apply mask */
679 pic
&= 0xFFFB; /* mask out cascade & hibits */
684 device_interrupt(j
, j
, regs
);
689 #if defined(CONFIG_ALPHA_ALCOR) || defined(CONFIG_ALPHA_XLT)
690 /* We have to conditionally compile this because of GRU_xxx symbols */
692 alcor_and_xlt_device_interrupt(unsigned long vector
, struct pt_regs
*regs
)
701 /* read the interrupt summary register of the GRU */
702 pld
= (*(vuip
)GRU_INT_REQ
) & GRU_INT_REQ_BITS
;
705 printk("[0x%08lx/0x%04x]", pld
, inb(0x20) | (inb(0xA0) << 8));
709 * Now for every possible bit set, work through them and call
710 * the appropriate interrupt handler.
714 pld
&= pld
- 1; /* clear least bit set */
716 isa_device_interrupt(vector
, regs
);
718 device_interrupt(16 + i
, 16 + i
, regs
);
721 restore_flags(flags
);
723 #endif /* ALCOR || XLT */
726 cabriolet_and_eb66p_device_interrupt(unsigned long vector
,
727 struct pt_regs
*regs
)
736 /* read the interrupt summary registers */
737 pld
= inb(0x804) | (inb(0x805) << 8) | (inb(0x806) << 16);
740 printk("[0x%04X/0x%04X]", pld
, inb(0x20) | (inb(0xA0) << 8));
744 * Now for every possible bit set, work through them and call
745 * the appropriate interrupt handler.
749 pld
&= pld
- 1; /* clear least bit set */
751 isa_device_interrupt(vector
, regs
);
753 device_interrupt(16 + i
, 16 + i
, regs
);
756 restore_flags(flags
);
760 mikasa_device_interrupt(unsigned long vector
, struct pt_regs
*regs
)
769 /* read the interrupt summary registers */
770 pld
= (((unsigned long) (~inw(0x534)) & 0x0000ffffUL
) << 16) |
771 (((unsigned long) inb(0xa0)) << 8) |
772 ((unsigned long) inb(0x20));
775 printk("[0x%08lx]", pld
);
779 * Now for every possible bit set, work through them and call
780 * the appropriate interrupt handler.
784 pld
&= pld
- 1; /* clear least bit set */
786 isa_device_interrupt(vector
, regs
);
788 device_interrupt(i
, i
, regs
);
791 restore_flags(flags
);
795 eb66_and_eb64p_device_interrupt(unsigned long vector
, struct pt_regs
*regs
)
804 /* read the interrupt summary registers */
805 pld
= inb(0x26) | (inb(0x27) << 8);
807 * Now, for every possible bit set, work through
808 * them and call the appropriate interrupt handler.
812 pld
&= pld
- 1; /* clear least bit set */
815 isa_device_interrupt(vector
, regs
);
817 device_interrupt(16 + i
, 16 + i
, regs
);
820 restore_flags(flags
);
823 #if defined(CONFIG_ALPHA_MIATA)
824 /* We have to conditionally compile this because of PYXIS_xxx symbols */
826 miata_device_interrupt(unsigned long vector
, struct pt_regs
*regs
)
828 unsigned long pld
, tmp
;
835 /* read the interrupt summary register of PYXIS */
836 pld
= (*(vulp
)PYXIS_INT_REQ
);
839 printk("[0x%08lx/0x%08lx/0x%04x]", pld
,
840 *(vulp
)PYXIS_INT_MASK
, inb(0x20) | (inb(0xA0) << 8));
845 * For now, AND off any bits we are not interested in:
846 * HALT (2), timer (6), ISA Bridge (7), 21142/3 (8)
847 * then all the PCI slots/INTXs (12-31).
849 /* Maybe HALT should only be used for SRM console boots? */
850 pld
&= 0x00000000fffff1c4UL
;
854 * Now for every possible bit set, work through them and call
855 * the appropriate interrupt handler.
859 pld
&= pld
- 1; /* clear least bit set */
861 isa_device_interrupt(vector
, regs
);
864 else { /* if not timer int */
865 device_interrupt(16 + i
, 16 + i
, regs
);
867 *(vulp
)PYXIS_INT_REQ
= 1UL << i
; mb();
868 tmp
= *(vulp
)PYXIS_INT_REQ
;
870 restore_flags(flags
);
875 noritake_device_interrupt(unsigned long vector
, struct pt_regs
*regs
)
884 /* read the interrupt summary registers of NORITAKE */
885 pld
= ((unsigned long) inw(0x54c) << 32) |
886 ((unsigned long) inw(0x54a) << 16) |
887 ((unsigned long) inb(0xa0) << 8) |
888 ((unsigned long) inb(0x20));
891 printk("[0x%08lx]", pld
);
895 * Now for every possible bit set, work through them and call
896 * the appropriate interrupt handler.
900 pld
&= pld
- 1; /* clear least bit set */
902 isa_device_interrupt(vector
, regs
);
904 device_interrupt(i
, i
, regs
);
907 restore_flags(flags
);
910 #endif /* CONFIG_PCI */
913 * Jensen is special: the vector is 0x8X0 for EISA interrupt X, and
914 * 0x9X0 for the local motherboard interrupts..
918 * 0x800 - IRQ0 interval timer (not used, as we use the RTC timer)
919 * 0x810 - IRQ1 line printer (duh..)
920 * 0x860 - IRQ6 floppy disk
921 * 0x8E0 - IRQ14 SCSI controller
928 * PCI-based systems are more sane: they don't have the local
929 * interrupts at all, and have only normal PCI interrupts from
930 * devices. Happily it's easy enough to do a sane mapping from the
931 * Jensen.. Note that this means that we may have to do a hardware
932 * "ack" to a different interrupt than we report to the rest of the
936 srm_device_interrupt(unsigned long vector
, struct pt_regs
* regs
)
945 ack
= irq
= (vector
- 0x800) >> 4;
947 #ifdef CONFIG_ALPHA_JENSEN
949 case 0x660: handle_nmi(regs
); return;
950 /* local device interrupts: */
951 case 0x900: handle_irq(4, regs
); return; /* com1 -> irq 4 */
952 case 0x920: handle_irq(3, regs
); return; /* com2 -> irq 3 */
953 case 0x980: handle_irq(1, regs
); return; /* kbd -> irq 1 */
954 case 0x990: handle_irq(9, regs
); return; /* mouse -> irq 9 */
956 if (vector
> 0x900) {
957 printk("Unknown local interrupt %lx\n", vector
);
960 /* irq1 is supposed to be the keyboard, silly Jensen
961 (is this really needed??) */
964 #endif /* CONFIG_ALPHA_JENSEN */
966 #ifdef CONFIG_ALPHA_MIATA
968 * I really hate to do this, but the MIATA SRM console ignores the
969 * low 8 bits in the interrupt summary register, and reports the
970 * vector 0x80 *lower* than I expected from the bit numbering in
972 * This was done because the low 8 summary bits really aren't used
973 * for reporting any interrupts (the PCI-ISA bridge, bit 7, isn't
974 * used for this purpose, as PIC interrupts are delivered as the
975 * vectors 0x800-0x8f0).
976 * But I really don't want to change the fixup code for allocation
977 * of IRQs, nor the irq_mask maintenance stuff, both of which look
978 * nice and clean now.
979 * So, here's this grotty hack... :-(
983 #endif /* CONFIG_ALPHA_MIATA */
985 #ifdef CONFIG_ALPHA_NORITAKE
987 * I really hate to do this, but the NORITAKE SRM console reports
988 * PCI vectors *lower* than I expected from the bit numbering in
990 * But I really don't want to change the fixup code for allocation
991 * of IRQs, nor the irq_mask maintenance stuff, both of which look
992 * nice and clean now.
993 * So, here's this additional grotty hack... :-(
997 #endif /* CONFIG_ALPHA_NORITAKE */
999 #ifdef CONFIG_ALPHA_SABLE
1000 irq
= sable_mask_to_irq
[(ack
)];
1002 if (irq
== 5 || irq
== 9 || irq
== 10 || irq
== 11 ||
1003 irq
== 14 || irq
== 15)
1004 printk("srm_device_interrupt: vector=0x%lx ack=0x%x"
1005 " irq=0x%x\n", vector
, ack
, irq
);
1007 #endif /* CONFIG_ALPHA_SABLE */
1009 device_interrupt(irq
, ack
, regs
);
1011 restore_flags(flags
);
1015 * Start listening for interrupts..
1017 unsigned long probe_irq_on(void)
1019 struct irqaction
* action
;
1020 unsigned long irqs
= 0;
1021 unsigned long delay
;
1024 for (i
= NR_IRQS
- 1; i
> 0; i
--) {
1025 if (!(PROBE_MASK
& (1UL << i
))) {
1028 action
= irq_action
[i
];
1036 * Wait about 100ms for spurious interrupts to mask themselves
1039 for (delay
= jiffies
+ HZ
/10; delay
> jiffies
; )
1042 /* now filter out any obviously spurious interrupts */
1043 return irqs
& ~irq_mask
;
1047 * Get the result of the IRQ probe.. A negative result means that
1048 * we have several candidates (but we return the lowest-numbered
1051 int probe_irq_off(unsigned long irqs
)
1059 if (irqs
!= (1UL << i
))
1064 extern void lca_machine_check (unsigned long vector
, unsigned long la
,
1065 struct pt_regs
*regs
);
1066 extern void apecs_machine_check(unsigned long vector
, unsigned long la
,
1067 struct pt_regs
* regs
);
1068 extern void cia_machine_check(unsigned long vector
, unsigned long la
,
1069 struct pt_regs
* regs
);
1070 extern void pyxis_machine_check(unsigned long vector
, unsigned long la
,
1071 struct pt_regs
* regs
);
1072 extern void t2_machine_check(unsigned long vector
, unsigned long la
,
1073 struct pt_regs
* regs
);
1076 machine_check(unsigned long vector
, unsigned long la
, struct pt_regs
*regs
)
1078 #if defined(CONFIG_ALPHA_LCA)
1079 lca_machine_check(vector
, la
, regs
);
1080 #elif defined(CONFIG_ALPHA_APECS)
1081 apecs_machine_check(vector
, la
, regs
);
1082 #elif defined(CONFIG_ALPHA_CIA)
1083 cia_machine_check(vector
, la
, regs
);
1084 #elif defined(CONFIG_ALPHA_PYXIS)
1085 pyxis_machine_check(vector
, la
, regs
);
1086 #elif defined(CONFIG_ALPHA_T2)
1087 t2_machine_check(vector
, la
, regs
);
1089 printk("Machine check\n");
1094 do_entInt(unsigned long type
, unsigned long vector
, unsigned long la_ptr
,
1095 unsigned long a3
, unsigned long a4
, unsigned long a5
,
1096 struct pt_regs regs
)
1100 printk("Interprocessor interrupt? You must be kidding\n");
1103 handle_irq(RTC_IRQ
, ®s
);
1106 machine_check(vector
, la_ptr
, ®s
);
1109 #if defined(CONFIG_ALPHA_JENSEN) || defined(CONFIG_ALPHA_NONAME) || \
1110 defined(CONFIG_ALPHA_P2K) || defined(CONFIG_ALPHA_SRM)
1111 srm_device_interrupt(vector
, ®s
);
1112 #elif defined(CONFIG_ALPHA_MIATA)
1113 miata_device_interrupt(vector
, ®s
);
1114 #elif defined(CONFIG_ALPHA_NORITAKE)
1115 noritake_device_interrupt(vector
, ®s
);
1116 #elif defined(CONFIG_ALPHA_ALCOR) || defined(CONFIG_ALPHA_XLT)
1117 alcor_and_xlt_device_interrupt(vector
, ®s
);
1119 cabriolet_and_eb66p_device_interrupt(vector
, ®s
);
1120 #elif defined(CONFIG_ALPHA_MIKASA)
1121 mikasa_device_interrupt(vector
, ®s
);
1123 eb66_and_eb64p_device_interrupt(vector
, ®s
);
1125 isa_device_interrupt(vector
, ®s
);
1129 printk("Performance counter interrupt\n");
1132 printk("Hardware intr %ld %lx? Huh?\n", type
, vector
);
1134 printk("PC = %016lx PS=%04lx\n", regs
.pc
, regs
.ps
);
1137 extern asmlinkage
void entInt(void);
1139 static inline void sable_init_IRQ(void)
1141 outb(irq_mask
, 0x537); /* slave 0 */
1142 outb(irq_mask
>> 8, 0x53b); /* slave 1 */
1143 outb(irq_mask
>> 16, 0x53d); /* slave 2 */
1144 outb(0x44, 0x535); /* enable cascades in master */
1147 #ifdef CONFIG_ALPHA_MIATA
1148 static inline void miata_init_IRQ(void)
1150 /* note invert on MASK bits */
1151 *(vulp
)PYXIS_INT_MASK
= ~((long)irq_mask
>> 16); mb(); /* invert */
1152 *(vulp
)PYXIS_INT_HILO
= 0x000000B2UL
; mb(); /* ISA/NMI HI */
1153 *(vulp
)PYXIS_RT_COUNT
= 0UL; mb(); /* clear count */
1154 *(vulp
)PYXIS_INT_REQ
= 0x4000000000000000UL
; mb(); /* clear upper timer */
1156 *(vulp
)PYXIS_INT_ROUTE
= 0UL; mb(); /* all are level */
1157 *(vulp
)PYXIS_INT_CNFG
= 0UL; mb(); /* all clear */
1159 enable_irq(16 + 2); /* enable HALT switch - SRM only? */
1160 enable_irq(16 + 6); /* enable timer */
1161 enable_irq(16 + 7); /* enable ISA PIC cascade */
1162 enable_irq(2); /* enable cascade */
1166 static inline void noritake_init_IRQ(void)
1168 outw(~(irq_mask
>> 16), 0x54a); /* note invert */
1169 outw(~(irq_mask
>> 32), 0x54c); /* note invert */
1170 enable_irq(2); /* enable cascade */
1173 #if defined(CONFIG_ALPHA_ALCOR) || defined(CONFIG_ALPHA_XLT)
1174 static inline void alcor_and_xlt_init_IRQ(void)
1176 *(vuip
)GRU_INT_MASK
= ~(irq_mask
>> 16); mb(); /* note invert */
1177 *(vuip
)GRU_INT_EDGE
= 0U; mb(); /* all are level */
1178 *(vuip
)GRU_INT_HILO
= 0x80000000U
; mb(); /* ISA only HI */
1179 *(vuip
)GRU_INT_CLEAR
= 0UL; mb(); /* all clear */
1181 enable_irq(16 + 31); /* enable (E)ISA PIC cascade */
1182 enable_irq(2); /* enable cascade */
1186 static inline void mikasa_init_IRQ(void)
1188 outw(~(irq_mask
>> 16), 0x536); /* note invert */
1189 enable_irq(2); /* enable cascade */
1192 static inline void init_IRQ_33(void)
1194 outl(irq_mask
>> 16, 0x804);
1195 enable_irq(16 + 4); /* enable SIO cascade */
1196 enable_irq(2); /* enable cascade */
1199 static inline void init_IRQ_32(void)
1201 outb(irq_mask
>> 16, 0x26);
1202 outb(irq_mask
>> 24, 0x27);
1203 enable_irq(16 + 5); /* enable SIO cascade */
1204 enable_irq(2); /* enable cascade */
1207 static inline void init_IRQ_16(void)
1209 enable_irq(2); /* enable cascade */
1215 dma_outb(0, DMA1_RESET_REG
);
1216 dma_outb(0, DMA2_RESET_REG
);
1217 dma_outb(0, DMA1_CLR_MASK_REG
);
1218 dma_outb(0, DMA2_CLR_MASK_REG
);
1220 #if defined(CONFIG_ALPHA_SABLE)
1222 #elif defined(CONFIG_ALPHA_MIATA)
1224 #elif defined(CONFIG_ALPHA_NORITAKE)
1225 noritake_init_IRQ();
1226 #elif defined(CONFIG_ALPHA_ALCOR) || defined(CONFIG_ALPHA_XLT)
1227 alcor_and_xlt_init_IRQ();
1228 #elif defined(CONFIG_ALPHA_PC164) && defined(CONFIG_ALPHA_SRM)
1229 /* Disable all the PCI interrupts? Otherwise, everthing was
1230 done by SRM already. */
1231 #elif defined(CONFIG_ALPHA_MIKASA)
1240 #error "How do I initialize the interrupt hardware?"