1
2
3
4
5
6
7
8
9
10
11
12
13#include <asm/irq.h>
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>
19
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));
22
23extern void kgdb_init(void);
24extern void breakpoint(void);
25
26
27
28
29
30void
31set_int_vector(int n, irqvectptr addr)
32{
33 etrax_irv->v[n + 0x20] = (irqvectptr)addr;
34}
35
36
37
38
39
40
41
42void
43set_break_vector(int n, irqvectptr addr)
44{
45 unsigned short *jinstr = (unsigned short *)&etrax_irv->v[n*2];
46 unsigned long *jaddr = (unsigned long *)(jinstr + 1);
47
48
49
50 *jinstr = 0x0d3f;
51 *jaddr = (unsigned long)addr;
52
53
54}
55
56
57
58
59
60
61
62
63
64
65
66void hwbreakpoint(void);
67void IRQ1_interrupt(void);
68BUILD_TIMER_IRQ(2, 0x04)
69BUILD_IRQ(3, 0x08)
70BUILD_IRQ(4, 0x10)
71BUILD_IRQ(5, 0x20)
72BUILD_IRQ(6, 0x40)
73BUILD_IRQ(7, 0x80)
74BUILD_IRQ(8, 0x100)
75BUILD_IRQ(9, 0x200)
76BUILD_IRQ(10, 0x400)
77BUILD_IRQ(11, 0x800)
78BUILD_IRQ(12, 0x1000)
79BUILD_IRQ(13, 0x2000)
80void mmu_bus_fault(void);
81void multiple_interrupt(void);
82BUILD_IRQ(16, 0x10000 | 0x20000)
83BUILD_IRQ(17, 0x20000 | 0x10000)
84BUILD_IRQ(18, 0x40000)
85BUILD_IRQ(19, 0x80000)
86BUILD_IRQ(20, 0x100000)
87BUILD_IRQ(21, 0x200000)
88BUILD_IRQ(22, 0x400000)
89BUILD_IRQ(23, 0x800000)
90BUILD_IRQ(24, 0x1000000)
91BUILD_IRQ(25, 0x2000000)
92
93BUILD_IRQ(31, 0x80000000)
94
95
96
97
98
99static 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,
107 IRQ31_interrupt
108};
109
110static void enable_crisv10_irq(struct irq_data *data)
111{
112 crisv10_unmask_irq(data->irq);
113}
114
115static void disable_crisv10_irq(struct irq_data *data)
116{
117 crisv10_mask_irq(data->irq);
118}
119
120static struct irq_chip crisv10_irq_type = {
121 .name = "CRISv10",
122 .irq_shutdown = disable_crisv10_irq,
123 .irq_enable = enable_crisv10_irq,
124 .irq_disable = disable_crisv10_irq,
125};
126
127void weird_irq(void);
128void system_call(void);
129void do_sigtrap(void);
130void gdb_handle_breakpoint(void);
131
132extern void do_IRQ(int irq, struct pt_regs * regs);
133
134
135void do_multiple_IRQ(struct pt_regs* regs)
136{
137 int bit;
138 unsigned masked;
139 unsigned mask;
140 unsigned ethmask = 0;
141
142
143 mask = masked = *R_VECT_MASK_RD;
144
145
146 mask &= ~(IO_MASK(R_VECT_MASK_RD, timer0));
147
148
149
150
151
152 if (mask &
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));
157 }
158
159
160 *R_VECT_MASK_CLR = (mask | ethmask);
161
162
163
164
165 irq_enter();
166
167
168 for (bit = 2; bit < 32; bit++) {
169 if (masked & (1 << bit)) {
170 do_IRQ(bit, regs);
171 }
172 }
173
174
175 irq_exit();
176
177
178 *R_VECT_MASK_SET = (masked | ethmask);
179}
180
181
182
183
184
185void __init
186init_IRQ(void)
187{
188 int i;
189
190
191
192#ifndef CONFIG_SVINTO_SIM
193 *R_IRQ_MASK0_CLR = 0xffffffff;
194 *R_IRQ_MASK1_CLR = 0xffffffff;
195 *R_IRQ_MASK2_CLR = 0xffffffff;
196#endif
197
198 *R_VECT_MASK_CLR = 0xffffffff;
199
200 for (i = 0; i < 256; i++)
201 etrax_irv->v[i] = weird_irq;
202
203
204 for(i = 2; i < NR_IRQS; i++) {
205 irq_set_chip_and_handler(i, &crisv10_irq_type,
206 handle_simple_irq);
207 set_int_vector(i, interrupt[i]);
208 }
209
210
211
212
213
214
215 for (i = 0; i < 16; i++)
216 set_break_vector(i, do_sigtrap);
217
218
219
220 set_int_vector(15, multiple_interrupt);
221
222
223
224 set_int_vector(0, hwbreakpoint);
225 set_int_vector(1, IRQ1_interrupt);
226
227
228
229 set_int_vector(14, mmu_bus_fault);
230
231
232
233 set_break_vector(13, system_call);
234
235
236
237
238 set_break_vector(8, gdb_handle_breakpoint);
239
240#ifdef CONFIG_ETRAX_KGDB
241
242 kgdb_init();
243 breakpoint();
244#endif
245}
246