1 /*
2 * arch/m68k/bvme6000/bvmeints.c
3 *
4 * Copyright (C) 1997 Richard Hirst [richard@sleepie.demon.co.uk]
5 *
6 * based on amiints.c -- Amiga Linux interrupt handling code
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file README.legal in the main directory of this archive
10 * for more details.
11 *
12 */
13
14 #include <linux/types.h>
15 #include <linux/kernel.h>
16 #include <linux/errno.h>
17
18 #include <asm/ptrace.h>
19 #include <asm/system.h>
20 #include <asm/irq.h>
21 #include <asm/traps.h>
22
23 static void bvme6000_defhand (int irq, void *dev_id, struct pt_regs *fp);
24
25 /*
26 * This should ideally be 4 elements only, for speed.
27 */
28
29 static struct {
30 void (*handler)(int, void *, struct pt_regs *);
31 unsigned long flags;
32 void *dev_id;
33 const char *devname;
34 unsigned count;
35 } irq_tab[256];
36
37 /*
38 * void bvme6000_init_IRQ (void)
39 *
40 * Parameters: None
41 *
42 * Returns: Nothing
43 *
44 * This function is called during kernel startup to initialize
45 * the bvme6000 IRQ handling routines.
46 */
47
bvme6000_init_IRQ(void)48 void bvme6000_init_IRQ (void)
49 {
50 int i;
51
52 for (i = 0; i < 256; i++) {
53 irq_tab[i].handler = bvme6000_defhand;
54 irq_tab[i].flags = IRQ_FLG_STD;
55 irq_tab[i].dev_id = NULL;
56 irq_tab[i].devname = NULL;
57 irq_tab[i].count = 0;
58 }
59 }
60
bvme6000_request_irq(unsigned int irq,void (* handler)(int,void *,struct pt_regs *),unsigned long flags,const char * devname,void * dev_id)61 int bvme6000_request_irq(unsigned int irq,
62 void (*handler)(int, void *, struct pt_regs *),
63 unsigned long flags, const char *devname, void *dev_id)
64 {
65 if (irq > 255) {
66 printk("%s: Incorrect IRQ %d from %s\n", __FUNCTION__, irq, devname);
67 return -ENXIO;
68 }
69 #if 0
70 /* Nothing special about auto-vectored devices for the BVME6000,
71 * but treat it specially to avoid changes elsewhere.
72 */
73
74 if (irq >= VEC_INT1 && irq <= VEC_INT7)
75 return sys_request_irq(irq - VEC_SPUR, handler, flags,
76 devname, dev_id);
77 #endif
78 if (!(irq_tab[irq].flags & IRQ_FLG_STD)) {
79 if (irq_tab[irq].flags & IRQ_FLG_LOCK) {
80 printk("%s: IRQ %d from %s is not replaceable\n",
81 __FUNCTION__, irq, irq_tab[irq].devname);
82 return -EBUSY;
83 }
84 if (flags & IRQ_FLG_REPLACE) {
85 printk("%s: %s can't replace IRQ %d from %s\n",
86 __FUNCTION__, devname, irq, irq_tab[irq].devname);
87 return -EBUSY;
88 }
89 }
90 irq_tab[irq].handler = handler;
91 irq_tab[irq].flags = flags;
92 irq_tab[irq].dev_id = dev_id;
93 irq_tab[irq].devname = devname;
94 return 0;
95 }
96
bvme6000_free_irq(unsigned int irq,void * dev_id)97 void bvme6000_free_irq(unsigned int irq, void *dev_id)
98 {
99 if (irq > 255) {
100 printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
101 return;
102 }
103 #if 0
104 if (irq >= VEC_INT1 && irq <= VEC_INT7) {
105 sys_free_irq(irq - VEC_SPUR, dev_id);
106 return;
107 }
108 #endif
109 if (irq_tab[irq].dev_id != dev_id)
110 printk("%s: Removing probably wrong IRQ %d from %s\n",
111 __FUNCTION__, irq, irq_tab[irq].devname);
112
113 irq_tab[irq].handler = bvme6000_defhand;
114 irq_tab[irq].flags = IRQ_FLG_STD;
115 irq_tab[irq].dev_id = NULL;
116 irq_tab[irq].devname = NULL;
117 }
118
bvme6000_process_int(unsigned long vec,struct pt_regs * fp)119 void bvme6000_process_int (unsigned long vec, struct pt_regs *fp)
120 {
121 if (vec > 255)
122 printk ("bvme6000_process_int: Illegal vector %ld", vec);
123 else
124 {
125 irq_tab[vec].count++;
126 irq_tab[vec].handler(vec, irq_tab[vec].dev_id, fp);
127 }
128 }
129
bvme6000_get_irq_list(char * buf)130 int bvme6000_get_irq_list (char *buf)
131 {
132 int i, len = 0;
133
134 for (i = 0; i < 256; i++) {
135 if (irq_tab[i].count)
136 len += sprintf (buf+len, "Vec 0x%02x: %8d %s\n",
137 i, irq_tab[i].count,
138 irq_tab[i].devname ? irq_tab[i].devname : "free");
139 }
140 return len;
141 }
142
143
bvme6000_defhand(int irq,void * dev_id,struct pt_regs * fp)144 static void bvme6000_defhand (int irq, void *dev_id, struct pt_regs *fp)
145 {
146 printk ("Unknown interrupt 0x%02x\n", irq);
147 }
148
bvme6000_enable_irq(unsigned int irq)149 void bvme6000_enable_irq (unsigned int irq)
150 {
151 }
152
153
bvme6000_disable_irq(unsigned int irq)154 void bvme6000_disable_irq (unsigned int irq)
155 {
156 }
157
158