2 * linux/arch/m68knommu/platform/68328/ints.c
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
8 * Copyright 1996 Roman Zippel
9 * Copyright 1999 D. Jeff Dionne <jeff@rt-control.com>
12 #include <linux/module.h>
13 #include <linux/types.h>
14 #include <linux/kernel.h>
15 #include <linux/sched.h>
16 #include <linux/kernel_stat.h>
17 #include <linux/errno.h>
19 #include <asm/system.h>
21 #include <asm/traps.h>
23 #include <asm/machdep.h>
24 #include <asm/setup.h>
26 #if defined(CONFIG_M68328)
27 #include <asm/MC68328.h>
28 #elif defined(CONFIG_M68EZ328)
29 #include <asm/MC68EZ328.h>
30 #elif defined(CONFIG_M68VZ328)
31 #include <asm/MC68VZ328.h>
34 /* assembler routines */
35 asmlinkage
void system_call(void);
36 asmlinkage
void buserr(void);
37 asmlinkage
void trap(void);
38 asmlinkage
void trap3(void);
39 asmlinkage
void trap4(void);
40 asmlinkage
void trap5(void);
41 asmlinkage
void trap6(void);
42 asmlinkage
void trap7(void);
43 asmlinkage
void trap8(void);
44 asmlinkage
void trap9(void);
45 asmlinkage
void trap10(void);
46 asmlinkage
void trap11(void);
47 asmlinkage
void trap12(void);
48 asmlinkage
void trap13(void);
49 asmlinkage
void trap14(void);
50 asmlinkage
void trap15(void);
51 asmlinkage
void trap33(void);
52 asmlinkage
void trap34(void);
53 asmlinkage
void trap35(void);
54 asmlinkage
void trap36(void);
55 asmlinkage
void trap37(void);
56 asmlinkage
void trap38(void);
57 asmlinkage
void trap39(void);
58 asmlinkage
void trap40(void);
59 asmlinkage
void trap41(void);
60 asmlinkage
void trap42(void);
61 asmlinkage
void trap43(void);
62 asmlinkage
void trap44(void);
63 asmlinkage
void trap45(void);
64 asmlinkage
void trap46(void);
65 asmlinkage
void trap47(void);
66 asmlinkage irqreturn_t
bad_interrupt(int, void *, struct pt_regs
*);
67 asmlinkage irqreturn_t
inthandler(void);
68 asmlinkage irqreturn_t
inthandler1(void);
69 asmlinkage irqreturn_t
inthandler2(void);
70 asmlinkage irqreturn_t
inthandler3(void);
71 asmlinkage irqreturn_t
inthandler4(void);
72 asmlinkage irqreturn_t
inthandler5(void);
73 asmlinkage irqreturn_t
inthandler6(void);
74 asmlinkage irqreturn_t
inthandler7(void);
76 extern e_vector
*_ramvec
;
78 /* The number of spurious interrupts */
79 volatile unsigned int num_spurious
;
80 unsigned int local_irq_count
[NR_CPUS
];
82 /* irq node variables for the 32 (potential) on chip sources */
83 static irq_node_t int_irq_list
[NR_IRQS
];
85 #if !defined(CONFIG_DRAGEN2)
86 asm (".global _start, __ramend/n/t"
89 ".long __ramend-4, _start, buserr, trap, trap, trap, trap, trap\n\t"
90 ".long trap, trap, trap, trap, trap, trap, trap, trap\n\t"
91 ".long trap, trap, trap, trap, trap, trap, trap, trap\n\t"
92 ".long trap, trap, trap, trap\n\t"
93 ".long trap, trap, trap, trap\n\t"
94 /*.long inthandler, inthandler, inthandler, inthandler
95 .long inthandler4, inthandler, inthandler, inthandler */
97 ".long system_call, trap, trap, trap, trap, trap, trap, trap\n\t"
98 ".long trap, trap, trap, trap, trap, trap, trap, trap\n\t"
99 ".long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n\t"
105 * This function should be called during kernel startup to initialize
106 * the IRQ handling routines.
112 /* set up the vectors */
113 for (i
= 72; i
< 256; ++i
)
114 _ramvec
[i
] = (e_vector
) bad_interrupt
;
116 _ramvec
[32] = system_call
;
118 _ramvec
[65] = (e_vector
) inthandler1
;
119 _ramvec
[66] = (e_vector
) inthandler2
;
120 _ramvec
[67] = (e_vector
) inthandler3
;
121 _ramvec
[68] = (e_vector
) inthandler4
;
122 _ramvec
[69] = (e_vector
) inthandler5
;
123 _ramvec
[70] = (e_vector
) inthandler6
;
124 _ramvec
[71] = (e_vector
) inthandler7
;
126 IVR
= 0x40; /* Set DragonBall IVR (interrupt base) to 64 */
128 /* initialize handlers */
129 for (i
= 0; i
< NR_IRQS
; i
++) {
130 int_irq_list
[i
].handler
= bad_interrupt
;
131 int_irq_list
[i
].flags
= IRQ_FLG_STD
;
132 int_irq_list
[i
].dev_id
= NULL
;
133 int_irq_list
[i
].devname
= NULL
;
136 /* turn off all interrupts */
142 irqreturn_t (*handler
)(int, void *, struct pt_regs
*),
147 if (irq
>= NR_IRQS
) {
148 printk (KERN_ERR
"%s: Unknown IRQ %d from %s\n", __FUNCTION__
, irq
, devname
);
152 if (!(int_irq_list
[irq
].flags
& IRQ_FLG_STD
)) {
153 if (int_irq_list
[irq
].flags
& IRQ_FLG_LOCK
) {
154 printk(KERN_ERR
"%s: IRQ %d from %s is not replaceable\n",
155 __FUNCTION__
, irq
, int_irq_list
[irq
].devname
);
158 if (flags
& IRQ_FLG_REPLACE
) {
159 printk(KERN_ERR
"%s: %s can't replace IRQ %d from %s\n",
160 __FUNCTION__
, devname
, irq
, int_irq_list
[irq
].devname
);
165 int_irq_list
[irq
].handler
= handler
;
166 int_irq_list
[irq
].flags
= flags
;
167 int_irq_list
[irq
].dev_id
= dev_id
;
168 int_irq_list
[irq
].devname
= devname
;
175 EXPORT_SYMBOL(request_irq
);
177 void free_irq(unsigned int irq
, void *dev_id
)
179 if (irq
>= NR_IRQS
) {
180 printk (KERN_ERR
"%s: Unknown IRQ %d\n", __FUNCTION__
, irq
);
184 if (int_irq_list
[irq
].dev_id
!= dev_id
)
185 printk(KERN_INFO
"%s: removing probably wrong IRQ %d from %s\n",
186 __FUNCTION__
, irq
, int_irq_list
[irq
].devname
);
188 int_irq_list
[irq
].handler
= bad_interrupt
;
189 int_irq_list
[irq
].flags
= IRQ_FLG_STD
;
190 int_irq_list
[irq
].dev_id
= NULL
;
191 int_irq_list
[irq
].devname
= NULL
;
196 EXPORT_SYMBOL(free_irq
);
198 int show_interrupts(struct seq_file
*p
, void *v
)
200 int i
= *(loff_t
*) v
;
203 if (int_irq_list
[i
].devname
) {
204 seq_printf(p
, "%3d: %10u ", i
, kstat_cpu(0).irqs
[i
]);
205 if (int_irq_list
[i
].flags
& IRQ_FLG_LOCK
)
209 seq_printf(p
, "%s\n", int_irq_list
[i
].devname
);
213 seq_printf(p
, " : %10u spurious\n", num_spurious
);
218 /* The 68k family did not have a good way to determine the source
219 * of interrupts until later in the family. The EC000 core does
220 * not provide the vector number on the stack, we vector everything
221 * into one vector and look in the blasted mask register...
222 * This code is designed to be fast, almost constant time, not clean!
224 void process_int(int vec
, struct pt_regs
*fp
)
229 unsigned long pend
= ISR
;
232 if (pend
& 0x0000ffff) {
233 if (pend
& 0x000000ff) {
234 if (pend
& 0x0000000f) {
242 if (pend
& 0x00000f00) {
251 if (pend
& 0x00ff0000) {
252 if (pend
& 0x000f0000) {
260 if (pend
& 0x0f000000) {
270 while (! (mask
& pend
)) {
275 kstat_cpu(0).irqs
[irq
]++;
277 if (int_irq_list
[irq
].handler
) {
278 int_irq_list
[irq
].handler(irq
, int_irq_list
[irq
].dev_id
, fp
);
280 printk(KERN_ERR
"unregistered interrupt %d!\nTurning it off in the IMR...\n", irq
);