aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/sun3/sun3ints.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/m68k/sun3/sun3ints.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/m68k/sun3/sun3ints.c')
-rw-r--r--arch/m68k/sun3/sun3ints.c265
1 files changed, 265 insertions, 0 deletions
diff --git a/arch/m68k/sun3/sun3ints.c b/arch/m68k/sun3/sun3ints.c
new file mode 100644
index 000000000000..e62a033cd493
--- /dev/null
+++ b/arch/m68k/sun3/sun3ints.c
@@ -0,0 +1,265 @@
1 /*
2 * linux/arch/m68k/sun3/sun3ints.c -- Sun-3(x) Linux interrupt handling code
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive
6 * for more details.
7 */
8
9#include <linux/config.h>
10#include <linux/types.h>
11#include <linux/kernel.h>
12#include <linux/sched.h>
13#include <linux/kernel_stat.h>
14#include <linux/interrupt.h>
15#include <asm/segment.h>
16#include <asm/intersil.h>
17#include <asm/oplib.h>
18#include <asm/sun3ints.h>
19#include <linux/seq_file.h>
20
21extern void sun3_leds (unsigned char);
22static irqreturn_t sun3_inthandle(int irq, void *dev_id, struct pt_regs *fp);
23
24void sun3_disable_interrupts(void)
25{
26 sun3_disable_irq(0);
27}
28
29void sun3_enable_interrupts(void)
30{
31 sun3_enable_irq(0);
32}
33
34int led_pattern[8] = {
35 ~(0x80), ~(0x01),
36 ~(0x40), ~(0x02),
37 ~(0x20), ~(0x04),
38 ~(0x10), ~(0x08)
39};
40
41volatile unsigned char* sun3_intreg;
42
43void sun3_insert_irq(irq_node_t **list, irq_node_t *node)
44{
45}
46
47void sun3_delete_irq(irq_node_t **list, void *dev_id)
48{
49}
50
51void sun3_enable_irq(unsigned int irq)
52{
53 *sun3_intreg |= (1<<irq);
54}
55
56void sun3_disable_irq(unsigned int irq)
57{
58 *sun3_intreg &= ~(1<<irq);
59}
60
61inline void sun3_do_irq(int irq, struct pt_regs *fp)
62{
63 kstat_cpu(0).irqs[SYS_IRQS + irq]++;
64 *sun3_intreg &= ~(1<<irq);
65 *sun3_intreg |= (1<<irq);
66}
67
68static irqreturn_t sun3_int7(int irq, void *dev_id, struct pt_regs *fp)
69{
70 sun3_do_irq(irq,fp);
71 if(!(kstat_cpu(0).irqs[SYS_IRQS + irq] % 2000))
72 sun3_leds(led_pattern[(kstat_cpu(0).irqs[SYS_IRQS+irq]%16000)
73 /2000]);
74 return IRQ_HANDLED;
75}
76
77static irqreturn_t sun3_int5(int irq, void *dev_id, struct pt_regs *fp)
78{
79 kstat_cpu(0).irqs[SYS_IRQS + irq]++;
80#ifdef CONFIG_SUN3
81 intersil_clear();
82#endif
83 *sun3_intreg &= ~(1<<irq);
84 *sun3_intreg |= (1<<irq);
85#ifdef CONFIG_SUN3
86 intersil_clear();
87#endif
88 do_timer(fp);
89#ifndef CONFIG_SMP
90 update_process_times(user_mode(fp));
91#endif
92 if(!(kstat_cpu(0).irqs[SYS_IRQS + irq] % 20))
93 sun3_leds(led_pattern[(kstat_cpu(0).irqs[SYS_IRQS+irq]%160)
94 /20]);
95 return IRQ_HANDLED;
96}
97
98/* handle requested ints, excepting 5 and 7, which always do the same
99 thing */
100irqreturn_t (*sun3_default_handler[SYS_IRQS])(int, void *, struct pt_regs *) = {
101 [0] = sun3_inthandle,
102 [1] = sun3_inthandle,
103 [2] = sun3_inthandle,
104 [3] = sun3_inthandle,
105 [4] = sun3_inthandle,
106 [5] = sun3_int5,
107 [6] = sun3_inthandle,
108 [7] = sun3_int7
109};
110
111static const char *dev_names[SYS_IRQS] = {
112 [5] = "timer",
113 [7] = "int7 handler"
114};
115static void *dev_ids[SYS_IRQS];
116static irqreturn_t (*sun3_inthandler[SYS_IRQS])(int, void *, struct pt_regs *) = {
117 [5] = sun3_int5,
118 [7] = sun3_int7
119};
120static irqreturn_t (*sun3_vechandler[SUN3_INT_VECS])(int, void *, struct pt_regs *);
121static void *vec_ids[SUN3_INT_VECS];
122static const char *vec_names[SUN3_INT_VECS];
123static int vec_ints[SUN3_INT_VECS];
124
125
126int show_sun3_interrupts(struct seq_file *p, void *v)
127{
128 int i;
129
130 for(i = 0; i < (SUN3_INT_VECS-1); i++) {
131 if(sun3_vechandler[i] != NULL) {
132 seq_printf(p, "vec %3d: %10u %s\n", i+64,
133 vec_ints[i],
134 (vec_names[i]) ? vec_names[i] :
135 "sun3_vechandler");
136 }
137 }
138
139 return 0;
140}
141
142static irqreturn_t sun3_inthandle(int irq, void *dev_id, struct pt_regs *fp)
143{
144 if(sun3_inthandler[irq] == NULL)
145 panic ("bad interrupt %d received (id %p)\n",irq, dev_id);
146
147 kstat_cpu(0).irqs[SYS_IRQS + irq]++;
148 *sun3_intreg &= ~(1<<irq);
149
150 sun3_inthandler[irq](irq, dev_ids[irq], fp);
151 return IRQ_HANDLED;
152}
153
154static irqreturn_t sun3_vec255(int irq, void *dev_id, struct pt_regs *fp)
155{
156// intersil_clear();
157 return IRQ_HANDLED;
158}
159
160void sun3_init_IRQ(void)
161{
162 int i;
163
164 *sun3_intreg = 1;
165
166 for(i = 0; i < SYS_IRQS; i++)
167 {
168 if(dev_names[i])
169 cpu_request_irq(i, sun3_default_handler[i], 0,
170 dev_names[i], NULL);
171 }
172
173 for(i = 0; i < 192; i++)
174 sun3_vechandler[i] = NULL;
175
176 sun3_vechandler[191] = sun3_vec255;
177}
178
179int sun3_request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *),
180 unsigned long flags, const char *devname, void *dev_id)
181{
182
183 if(irq < SYS_IRQS) {
184 if(sun3_inthandler[irq] != NULL) {
185 printk("sun3_request_irq: request for irq %d -- already taken!\n", irq);
186 return 1;
187 }
188
189 sun3_inthandler[irq] = handler;
190 dev_ids[irq] = dev_id;
191 dev_names[irq] = devname;
192
193 /* setting devname would be nice */
194 cpu_request_irq(irq, sun3_default_handler[irq], 0, devname,
195 NULL);
196
197 return 0;
198 } else {
199 if((irq >= 64) && (irq <= 255)) {
200 int vec;
201
202 vec = irq - 64;
203 if(sun3_vechandler[vec] != NULL) {
204 printk("sun3_request_irq: request for vec %d -- already taken!\n", irq);
205 return 1;
206 }
207
208 sun3_vechandler[vec] = handler;
209 vec_ids[vec] = dev_id;
210 vec_names[vec] = devname;
211 vec_ints[vec] = 0;
212
213 return 0;
214 }
215 }
216
217 printk("sun3_request_irq: invalid irq %d\n", irq);
218 return 1;
219
220}
221
222void sun3_free_irq(unsigned int irq, void *dev_id)
223{
224
225 if(irq < SYS_IRQS) {
226 if(sun3_inthandler[irq] == NULL)
227 panic("sun3_free_int: attempt to free unused irq %d\n", irq);
228 if(dev_ids[irq] != dev_id)
229 panic("sun3_free_int: incorrect dev_id for irq %d\n", irq);
230
231 sun3_inthandler[irq] = NULL;
232 return;
233 } else if((irq >= 64) && (irq <= 255)) {
234 int vec;
235
236 vec = irq - 64;
237 if(sun3_vechandler[vec] == NULL)
238 panic("sun3_free_int: attempt to free unused vector %d\n", irq);
239 if(vec_ids[irq] != dev_id)
240 panic("sun3_free_int: incorrect dev_id for vec %d\n", irq);
241
242 sun3_vechandler[vec] = NULL;
243 return;
244 } else {
245 panic("sun3_free_irq: invalid irq %d\n", irq);
246 }
247}
248
249irqreturn_t sun3_process_int(int irq, struct pt_regs *regs)
250{
251
252 if((irq >= 64) && (irq <= 255)) {
253 int vec;
254
255 vec = irq - 64;
256 if(sun3_vechandler[vec] == NULL)
257 panic ("bad interrupt vector %d received\n",irq);
258
259 vec_ints[vec]++;
260 return sun3_vechandler[vec](irq, vec_ids[vec], regs);
261 } else {
262 panic("sun3_process_int: unable to handle interrupt vector %d\n",
263 irq);
264 }
265}