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
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)
29 void sun3_enable_interrupts(void)
34 int led_pattern
[8] = {
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
)
71 if(!(kstat_cpu(0).irqs
[SYS_IRQS
+ irq
] % 2000))
72 sun3_leds(led_pattern
[(kstat_cpu(0).irqs
[SYS_IRQS
+irq
]%16000)
77 static irqreturn_t
sun3_int5(int irq
, void *dev_id
, struct pt_regs
*fp
)
79 kstat_cpu(0).irqs
[SYS_IRQS
+ irq
]++;
83 *sun3_intreg
&= ~(1<<irq
);
84 *sun3_intreg
|= (1<<irq
);
90 update_process_times(user_mode(fp
));
92 if(!(kstat_cpu(0).irqs
[SYS_IRQS
+ irq
] % 20))
93 sun3_leds(led_pattern
[(kstat_cpu(0).irqs
[SYS_IRQS
+irq
]%160)
98 /* handle requested ints, excepting 5 and 7, which always do the same
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
,
107 [6] = sun3_inthandle
,
111 static const char *dev_names
[SYS_IRQS
] = {
115 static void *dev_ids
[SYS_IRQS
];
116 static irqreturn_t (*sun3_inthandler
[SYS_IRQS
])(int, void *, struct pt_regs
*) = {
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
)
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,
134 (vec_names
[i
]) ? vec_names
[i
] :
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
);
154 static irqreturn_t
sun3_vec255(int irq
, void *dev_id
, struct pt_regs
*fp
)
160 void sun3_init_IRQ(void)
166 for(i
= 0; i
< SYS_IRQS
; i
++)
169 cpu_request_irq(i
, sun3_default_handler
[i
], 0,
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
)
184 if(sun3_inthandler
[irq
] != NULL
) {
185 printk("sun3_request_irq: request for irq %d -- already taken!\n", irq
);
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
,
199 if((irq
>= 64) && (irq
<= 255)) {
203 if(sun3_vechandler
[vec
] != NULL
) {
204 printk("sun3_request_irq: request for vec %d -- already taken!\n", irq
);
208 sun3_vechandler
[vec
] = handler
;
209 vec_ids
[vec
] = dev_id
;
210 vec_names
[vec
] = devname
;
217 printk("sun3_request_irq: invalid irq %d\n", irq
);
222 void sun3_free_irq(unsigned int irq
, void *dev_id
)
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
;
233 } else if((irq
>= 64) && (irq
<= 255)) {
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
;
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)) {
256 if(sun3_vechandler
[vec
] == NULL
)
257 panic ("bad interrupt vector %d received\n",irq
);
260 return sun3_vechandler
[vec
](irq
, vec_ids
[vec
], regs
);
262 panic("sun3_process_int: unable to handle interrupt vector %d\n",