blob: 0912435e9e9090cee3bdf6b25a80faf06dff6df3 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001 /*
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);
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23void sun3_disable_interrupts(void)
24{
25 sun3_disable_irq(0);
26}
27
28void sun3_enable_interrupts(void)
29{
30 sun3_enable_irq(0);
31}
32
33int led_pattern[8] = {
34 ~(0x80), ~(0x01),
35 ~(0x40), ~(0x02),
36 ~(0x20), ~(0x04),
37 ~(0x10), ~(0x08)
38};
39
40volatile unsigned char* sun3_intreg;
41
Linus Torvalds1da177e2005-04-16 15:20:36 -070042void sun3_enable_irq(unsigned int irq)
43{
Roman Zippelebba61d2006-06-25 05:47:05 -070044 *sun3_intreg |= (1 << irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045}
46
47void sun3_disable_irq(unsigned int irq)
48{
Roman Zippelebba61d2006-06-25 05:47:05 -070049 *sun3_intreg &= ~(1 << irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
52static irqreturn_t sun3_int7(int irq, void *dev_id, struct pt_regs *fp)
53{
Roman Zippelebba61d2006-06-25 05:47:05 -070054 *sun3_intreg |= (1 << irq);
55 if (!(kstat_cpu(0).irqs[irq] % 2000))
56 sun3_leds(led_pattern[(kstat_cpu(0).irqs[irq] % 16000) / 2000]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 return IRQ_HANDLED;
58}
59
60static irqreturn_t sun3_int5(int irq, void *dev_id, struct pt_regs *fp)
61{
Linus Torvalds1da177e2005-04-16 15:20:36 -070062#ifdef CONFIG_SUN3
63 intersil_clear();
64#endif
Roman Zippelebba61d2006-06-25 05:47:05 -070065 *sun3_intreg |= (1 << irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#ifdef CONFIG_SUN3
67 intersil_clear();
68#endif
69 do_timer(fp);
70#ifndef CONFIG_SMP
71 update_process_times(user_mode(fp));
72#endif
Roman Zippelebba61d2006-06-25 05:47:05 -070073 if (!(kstat_cpu(0).irqs[irq] % 20))
74 sun3_leds(led_pattern[(kstat_cpu(0).irqs[irq] % 160) / 20]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 return IRQ_HANDLED;
76}
77
78static irqreturn_t sun3_vec255(int irq, void *dev_id, struct pt_regs *fp)
79{
80// intersil_clear();
81 return IRQ_HANDLED;
82}
83
Roman Zippelebba61d2006-06-25 05:47:05 -070084static void sun3_inthandle(unsigned int irq, struct pt_regs *fp)
85{
86 *sun3_intreg &= ~(1 << irq);
87
88 m68k_handle_int(irq, fp);
89}
90
91static struct irq_controller sun3_irq_controller = {
92 .name = "sun3",
93 .lock = SPIN_LOCK_UNLOCKED,
94 .startup = m68k_irq_startup,
95 .shutdown = m68k_irq_shutdown,
96 .enable = sun3_enable_irq,
97 .disable = sun3_disable_irq,
98};
99
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100void sun3_init_IRQ(void)
101{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 *sun3_intreg = 1;
103
Roman Zippelebba61d2006-06-25 05:47:05 -0700104 m68k_setup_auto_interrupt(sun3_inthandle);
105 m68k_setup_irq_controller(&sun3_irq_controller, IRQ_AUTO_1, 7);
106 m68k_setup_user_interrupt(VEC_USER, 192, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
Roman Zippelebba61d2006-06-25 05:47:05 -0700108 request_irq(IRQ_AUTO_5, sun3_int5, 0, "int5", NULL);
109 request_irq(IRQ_AUTO_7, sun3_int7, 0, "int7", NULL);
110 request_irq(IRQ_USER+127, sun3_vec255, 0, "vec255", NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111}