[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / arch / m68k / sun3 / sun3ints.c
blobe62a033cd49301e7fa39eba9397d3dc9c3033b7f
1 /*
2 * linux/arch/m68k/sun3/sun3ints.c -- Sun-3(x) Linux interrupt handling code
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 */
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>
21 extern void sun3_leds (unsigned char);
22 static irqreturn_t sun3_inthandle(int irq, void *dev_id, struct pt_regs *fp);
24 void sun3_disable_interrupts(void)
26 sun3_disable_irq(0);
29 void sun3_enable_interrupts(void)
31 sun3_enable_irq(0);
34 int led_pattern[8] = {
35 ~(0x80), ~(0x01),
36 ~(0x40), ~(0x02),
37 ~(0x20), ~(0x04),
38 ~(0x10), ~(0x08)
41 volatile unsigned char* sun3_intreg;
43 void sun3_insert_irq(irq_node_t **list, irq_node_t *node)
47 void sun3_delete_irq(irq_node_t **list, void *dev_id)
51 void sun3_enable_irq(unsigned int irq)
53 *sun3_intreg |= (1<<irq);
56 void sun3_disable_irq(unsigned int irq)
58 *sun3_intreg &= ~(1<<irq);
61 inline void sun3_do_irq(int irq, struct pt_regs *fp)
63 kstat_cpu(0).irqs[SYS_IRQS + irq]++;
64 *sun3_intreg &= ~(1<<irq);
65 *sun3_intreg |= (1<<irq);
68 static irqreturn_t sun3_int7(int irq, void *dev_id, struct pt_regs *fp)
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;
77 static irqreturn_t sun3_int5(int irq, void *dev_id, struct pt_regs *fp)
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;
98 /* handle requested ints, excepting 5 and 7, which always do the same
99 thing */
100 irqreturn_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
111 static const char *dev_names[SYS_IRQS] = {
112 [5] = "timer",
113 [7] = "int7 handler"
115 static void *dev_ids[SYS_IRQS];
116 static irqreturn_t (*sun3_inthandler[SYS_IRQS])(int, void *, struct pt_regs *) = {
117 [5] = sun3_int5,
118 [7] = sun3_int7
120 static irqreturn_t (*sun3_vechandler[SUN3_INT_VECS])(int, void *, struct pt_regs *);
121 static void *vec_ids[SUN3_INT_VECS];
122 static const char *vec_names[SUN3_INT_VECS];
123 static int vec_ints[SUN3_INT_VECS];
126 int show_sun3_interrupts(struct seq_file *p, void *v)
128 int i;
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");
139 return 0;
142 static irqreturn_t sun3_inthandle(int irq, void *dev_id, struct pt_regs *fp)
144 if(sun3_inthandler[irq] == NULL)
145 panic ("bad interrupt %d received (id %p)\n",irq, dev_id);
147 kstat_cpu(0).irqs[SYS_IRQS + irq]++;
148 *sun3_intreg &= ~(1<<irq);
150 sun3_inthandler[irq](irq, dev_ids[irq], fp);
151 return IRQ_HANDLED;
154 static irqreturn_t sun3_vec255(int irq, void *dev_id, struct pt_regs *fp)
156 // intersil_clear();
157 return IRQ_HANDLED;
160 void sun3_init_IRQ(void)
162 int i;
164 *sun3_intreg = 1;
166 for(i = 0; i < SYS_IRQS; i++)
168 if(dev_names[i])
169 cpu_request_irq(i, sun3_default_handler[i], 0,
170 dev_names[i], NULL);
173 for(i = 0; i < 192; i++)
174 sun3_vechandler[i] = NULL;
176 sun3_vechandler[191] = sun3_vec255;
179 int sun3_request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *),
180 unsigned long flags, const char *devname, void *dev_id)
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;
189 sun3_inthandler[irq] = handler;
190 dev_ids[irq] = dev_id;
191 dev_names[irq] = devname;
193 /* setting devname would be nice */
194 cpu_request_irq(irq, sun3_default_handler[irq], 0, devname,
195 NULL);
197 return 0;
198 } else {
199 if((irq >= 64) && (irq <= 255)) {
200 int vec;
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;
208 sun3_vechandler[vec] = handler;
209 vec_ids[vec] = dev_id;
210 vec_names[vec] = devname;
211 vec_ints[vec] = 0;
213 return 0;
217 printk("sun3_request_irq: invalid irq %d\n", irq);
218 return 1;
222 void sun3_free_irq(unsigned int irq, void *dev_id)
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);
231 sun3_inthandler[irq] = NULL;
232 return;
233 } else if((irq >= 64) && (irq <= 255)) {
234 int vec;
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);
242 sun3_vechandler[vec] = NULL;
243 return;
244 } else {
245 panic("sun3_free_irq: invalid irq %d\n", irq);
249 irqreturn_t sun3_process_int(int irq, struct pt_regs *regs)
252 if((irq >= 64) && (irq <= 255)) {
253 int vec;
255 vec = irq - 64;
256 if(sun3_vechandler[vec] == NULL)
257 panic ("bad interrupt vector %d received\n",irq);
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);