2 * linux/arch/mips/dec/ioasic-irq.c
4 * DEC I/O ASIC interrupts.
6 * Copyright (c) 2002, 2003 Maciej W. Rozycki
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
14 #include <linux/init.h>
15 #include <linux/irq.h>
16 #include <linux/spinlock.h>
17 #include <linux/types.h>
19 #include <asm/dec/ioasic.h>
20 #include <asm/dec/ioasic_addrs.h>
21 #include <asm/dec/ioasic_ints.h>
24 static DEFINE_SPINLOCK(ioasic_lock);
26 static int ioasic_irq_base;
29 static inline void unmask_ioasic_irq(unsigned int irq)
33 simr = ioasic_read(IO_REG_SIMR);
34 simr |= (1 << (irq - ioasic_irq_base));
35 ioasic_write(IO_REG_SIMR, simr);
38 static inline void mask_ioasic_irq(unsigned int irq)
42 simr = ioasic_read(IO_REG_SIMR);
43 simr &= ~(1 << (irq - ioasic_irq_base));
44 ioasic_write(IO_REG_SIMR, simr);
47 static inline void clear_ioasic_irq(unsigned int irq)
51 sir = ~(1 << (irq - ioasic_irq_base));
52 ioasic_write(IO_REG_SIR, sir);
55 static inline void enable_ioasic_irq(unsigned int irq)
59 spin_lock_irqsave(&ioasic_lock, flags);
60 unmask_ioasic_irq(irq);
61 spin_unlock_irqrestore(&ioasic_lock, flags);
64 static inline void disable_ioasic_irq(unsigned int irq)
68 spin_lock_irqsave(&ioasic_lock, flags);
70 spin_unlock_irqrestore(&ioasic_lock, flags);
74 static inline unsigned int startup_ioasic_irq(unsigned int irq)
76 enable_ioasic_irq(irq);
80 #define shutdown_ioasic_irq disable_ioasic_irq
82 static inline void ack_ioasic_irq(unsigned int irq)
84 spin_lock(&ioasic_lock);
86 spin_unlock(&ioasic_lock);
90 static inline void end_ioasic_irq(unsigned int irq)
92 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
93 enable_ioasic_irq(irq);
96 static struct irq_chip ioasic_irq_type = {
97 .typename = "IO-ASIC",
98 .startup = startup_ioasic_irq,
99 .shutdown = shutdown_ioasic_irq,
100 .enable = enable_ioasic_irq,
101 .disable = disable_ioasic_irq,
102 .ack = ack_ioasic_irq,
103 .end = end_ioasic_irq,
107 #define startup_ioasic_dma_irq startup_ioasic_irq
109 #define shutdown_ioasic_dma_irq shutdown_ioasic_irq
111 #define enable_ioasic_dma_irq enable_ioasic_irq
113 #define disable_ioasic_dma_irq disable_ioasic_irq
115 #define ack_ioasic_dma_irq ack_ioasic_irq
117 static inline void end_ioasic_dma_irq(unsigned int irq)
119 clear_ioasic_irq(irq);
124 static struct irq_chip ioasic_dma_irq_type = {
125 .typename = "IO-ASIC-DMA",
126 .startup = startup_ioasic_dma_irq,
127 .shutdown = shutdown_ioasic_dma_irq,
128 .enable = enable_ioasic_dma_irq,
129 .disable = disable_ioasic_dma_irq,
130 .ack = ack_ioasic_dma_irq,
131 .end = end_ioasic_dma_irq,
135 void __init init_ioasic_irqs(int base)
139 /* Mask interrupts. */
140 ioasic_write(IO_REG_SIMR, 0);
143 for (i = base; i < base + IO_INR_DMA; i++) {
144 irq_desc[i].status = IRQ_DISABLED;
145 irq_desc[i].action = 0;
146 irq_desc[i].depth = 1;
147 irq_desc[i].chip = &ioasic_irq_type;
149 for (; i < base + IO_IRQ_LINES; i++) {
150 irq_desc[i].status = IRQ_DISABLED;
151 irq_desc[i].action = 0;
152 irq_desc[i].depth = 1;
153 irq_desc[i].chip = &ioasic_dma_irq_type;
156 ioasic_irq_base = base;