2 * linux/arch/cris/kernel/irq.c
4 * Copyright (c) 2000-2002 Axis Communications AB
6 * Authors: Bjorn Wesen (bjornw@axis.com)
8 * This file contains the interrupt vectors and some
14 #include <asm/current.h>
15 #include <linux/irq.h>
16 #include <linux/interrupt.h>
17 #include <linux/kernel.h>
18 #include <linux/init.h>
20 #define crisv10_mask_irq(irq_nr) (*R_VECT_MASK_CLR = 1 << (irq_nr));
21 #define crisv10_unmask_irq(irq_nr) (*R_VECT_MASK_SET = 1 << (irq_nr));
23 extern void kgdb_init(void);
24 extern void breakpoint(void);
26 /* don't use set_int_vector, it bypasses the linux interrupt handlers. it is
27 * global just so that the kernel gdb can use it.
31 set_int_vector(int n
, irqvectptr addr
)
33 etrax_irv
->v
[n
+ 0x20] = (irqvectptr
)addr
;
36 /* the breakpoint vector is obviously not made just like the normal irq handlers
37 * but needs to contain _code_ to jump to addr.
39 * the BREAK n instruction jumps to IBR + n * 8
43 set_break_vector(int n
, irqvectptr addr
)
45 unsigned short *jinstr
= (unsigned short *)&etrax_irv
->v
[n
*2];
46 unsigned long *jaddr
= (unsigned long *)(jinstr
+ 1);
48 /* if you don't know what this does, do not touch it! */
51 *jaddr
= (unsigned long)addr
;
53 /* 00000026 <clrlop+1a> 3f0d82000000 jump 0x82 */
57 * This builds up the IRQ handler stubs using some ugly macros in irq.h
59 * These macros create the low-level assembly IRQ routines that do all
60 * the operations that are needed. They are also written to be fast - and to
61 * disable interrupts as little as humanly possible.
65 /* IRQ0 and 1 are special traps */
66 void hwbreakpoint(void);
67 void IRQ1_interrupt(void);
68 BUILD_TIMER_IRQ(2, 0x04) /* the timer interrupt is somewhat special */
80 void mmu_bus_fault(void); /* IRQ 14 is the bus fault interrupt */
81 void multiple_interrupt(void); /* IRQ 15 is the multiple IRQ interrupt */
82 BUILD_IRQ(16, 0x10000 | 0x20000) /* ethernet tx interrupt needs to block rx */
83 BUILD_IRQ(17, 0x20000 | 0x10000) /* ...and vice versa */
84 BUILD_IRQ(18, 0x40000)
85 BUILD_IRQ(19, 0x80000)
86 BUILD_IRQ(20, 0x100000)
87 BUILD_IRQ(21, 0x200000)
88 BUILD_IRQ(22, 0x400000)
89 BUILD_IRQ(23, 0x800000)
90 BUILD_IRQ(24, 0x1000000)
91 BUILD_IRQ(25, 0x2000000)
92 /* IRQ 26-30 are reserved */
93 BUILD_IRQ(31, 0x80000000)
96 * Pointers to the low-level handlers
99 static void (*interrupt
[NR_IRQS
])(void) = {
100 NULL
, NULL
, IRQ2_interrupt
, IRQ3_interrupt
,
101 IRQ4_interrupt
, IRQ5_interrupt
, IRQ6_interrupt
, IRQ7_interrupt
,
102 IRQ8_interrupt
, IRQ9_interrupt
, IRQ10_interrupt
, IRQ11_interrupt
,
103 IRQ12_interrupt
, IRQ13_interrupt
, NULL
, NULL
,
104 IRQ16_interrupt
, IRQ17_interrupt
, IRQ18_interrupt
, IRQ19_interrupt
,
105 IRQ20_interrupt
, IRQ21_interrupt
, IRQ22_interrupt
, IRQ23_interrupt
,
106 IRQ24_interrupt
, IRQ25_interrupt
, NULL
, NULL
, NULL
, NULL
, NULL
,
110 static void enable_crisv10_irq(struct irq_data
*data
)
112 crisv10_unmask_irq(data
->irq
);
115 static void disable_crisv10_irq(struct irq_data
*data
)
117 crisv10_mask_irq(data
->irq
);
120 static struct irq_chip crisv10_irq_type
= {
122 .irq_shutdown
= disable_crisv10_irq
,
123 .irq_enable
= enable_crisv10_irq
,
124 .irq_disable
= disable_crisv10_irq
,
127 void weird_irq(void);
128 void system_call(void); /* from entry.S */
129 void do_sigtrap(void); /* from entry.S */
130 void gdb_handle_breakpoint(void); /* from entry.S */
132 extern void do_IRQ(int irq
, struct pt_regs
* regs
);
134 /* Handle multiple IRQs */
135 void do_multiple_IRQ(struct pt_regs
* regs
)
140 unsigned ethmask
= 0;
142 /* Get interrupts to mask and handle */
143 mask
= masked
= *R_VECT_MASK_RD
;
145 /* Never mask timer IRQ */
146 mask
&= ~(IO_MASK(R_VECT_MASK_RD
, timer0
));
149 * If either ethernet interrupt (rx or tx) is active then block
150 * the other one too. Unblock afterwards also.
153 (IO_STATE(R_VECT_MASK_RD
, dma0
, active
) |
154 IO_STATE(R_VECT_MASK_RD
, dma1
, active
))) {
155 ethmask
= (IO_MASK(R_VECT_MASK_RD
, dma0
) |
156 IO_MASK(R_VECT_MASK_RD
, dma1
));
160 *R_VECT_MASK_CLR
= (mask
| ethmask
);
162 /* An extra irq_enter here to prevent softIRQs to run after
163 * each do_IRQ. This will decrease the interrupt latency.
167 /* Handle all IRQs */
168 for (bit
= 2; bit
< 32; bit
++) {
169 if (masked
& (1 << bit
)) {
174 /* This irq_exit() will trigger the soft IRQs. */
177 /* Unblock the IRQs again */
178 *R_VECT_MASK_SET
= (masked
| ethmask
);
181 /* init_IRQ() is called by start_kernel and is responsible for fixing IRQ masks and
182 setting the irq vector table.
185 void __init
init_IRQ(void)
189 /* clear all interrupt masks */
190 *R_IRQ_MASK0_CLR
= 0xffffffff;
191 *R_IRQ_MASK1_CLR
= 0xffffffff;
192 *R_IRQ_MASK2_CLR
= 0xffffffff;
193 *R_VECT_MASK_CLR
= 0xffffffff;
195 for (i
= 0; i
< 256; i
++)
196 etrax_irv
->v
[i
] = weird_irq
;
198 /* Initialize IRQ handler descriptors. */
199 for(i
= 2; i
< NR_IRQS
; i
++) {
200 irq_set_chip_and_handler(i
, &crisv10_irq_type
,
202 set_int_vector(i
, interrupt
[i
]);
205 /* the entries in the break vector contain actual code to be
206 executed by the associated break handler, rather than just a jump
207 address. therefore we need to setup a default breakpoint handler
208 for all breakpoints */
209 for (i
= 0; i
< 16; i
++)
210 set_break_vector(i
, do_sigtrap
);
212 /* except IRQ 15 which is the multiple-IRQ handler on Etrax100 */
213 set_int_vector(15, multiple_interrupt
);
215 /* 0 and 1 which are special breakpoint/NMI traps */
216 set_int_vector(0, hwbreakpoint
);
217 set_int_vector(1, IRQ1_interrupt
);
219 /* and irq 14 which is the mmu bus fault handler */
220 set_int_vector(14, mmu_bus_fault
);
222 /* setup the system-call trap, which is reached by BREAK 13 */
223 set_break_vector(13, system_call
);
225 /* setup a breakpoint handler for debugging used for both user and
226 kernel mode debugging (which is why it is not inside an ifdef
227 CONFIG_ETRAX_KGDB) */
228 set_break_vector(8, gdb_handle_breakpoint
);
230 #ifdef CONFIG_ETRAX_KGDB
231 /* setup kgdb if its enabled, and break into the debugger */