blob: cda49b12d7be9ce40520bcd55544351cf9a81d0e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Luis Alves99e08372012-12-04 23:04:49 +00002 * ints.c - Generic interrupt controller support
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
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 * Copyright 1996 Roman Zippel
9 * Copyright 1999 D. Jeff Dionne <jeff@rt-control.com>
10 */
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/types.h>
13#include <linux/kernel.h>
Greg Ungerer2502b6672007-07-19 01:49:12 -070014#include <linux/init.h>
Greg Ungerer8668fb52007-03-07 11:28:13 +100015#include <linux/interrupt.h>
Greg Ungerer2502b6672007-07-19 01:49:12 -070016#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/traps.h>
18#include <asm/io.h>
19#include <asm/machdep.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21#if defined(CONFIG_M68328)
22#include <asm/MC68328.h>
23#elif defined(CONFIG_M68EZ328)
24#include <asm/MC68EZ328.h>
25#elif defined(CONFIG_M68VZ328)
26#include <asm/MC68VZ328.h>
27#endif
28
29/* assembler routines */
30asmlinkage void system_call(void);
31asmlinkage void buserr(void);
32asmlinkage void trap(void);
33asmlinkage void trap3(void);
34asmlinkage void trap4(void);
35asmlinkage void trap5(void);
36asmlinkage void trap6(void);
37asmlinkage void trap7(void);
38asmlinkage void trap8(void);
39asmlinkage void trap9(void);
40asmlinkage void trap10(void);
41asmlinkage void trap11(void);
42asmlinkage void trap12(void);
43asmlinkage void trap13(void);
44asmlinkage void trap14(void);
45asmlinkage void trap15(void);
46asmlinkage void trap33(void);
47asmlinkage void trap34(void);
48asmlinkage void trap35(void);
49asmlinkage void trap36(void);
50asmlinkage void trap37(void);
51asmlinkage void trap38(void);
52asmlinkage void trap39(void);
53asmlinkage void trap40(void);
54asmlinkage void trap41(void);
55asmlinkage void trap42(void);
56asmlinkage void trap43(void);
57asmlinkage void trap44(void);
58asmlinkage void trap45(void);
59asmlinkage void trap46(void);
60asmlinkage void trap47(void);
Greg Ungerer8668fb52007-03-07 11:28:13 +100061asmlinkage irqreturn_t bad_interrupt(int, void *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062asmlinkage irqreturn_t inthandler(void);
63asmlinkage irqreturn_t inthandler1(void);
64asmlinkage irqreturn_t inthandler2(void);
65asmlinkage irqreturn_t inthandler3(void);
66asmlinkage irqreturn_t inthandler4(void);
67asmlinkage irqreturn_t inthandler5(void);
68asmlinkage irqreturn_t inthandler6(void);
69asmlinkage irqreturn_t inthandler7(void);
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071/* The 68k family did not have a good way to determine the source
72 * of interrupts until later in the family. The EC000 core does
73 * not provide the vector number on the stack, we vector everything
74 * into one vector and look in the blasted mask register...
75 * This code is designed to be fast, almost constant time, not clean!
76 */
77void process_int(int vec, struct pt_regs *fp)
78{
79 int irq;
80 int mask;
81
82 unsigned long pend = ISR;
83
84 while (pend) {
85 if (pend & 0x0000ffff) {
86 if (pend & 0x000000ff) {
87 if (pend & 0x0000000f) {
88 mask = 0x00000001;
89 irq = 0;
90 } else {
91 mask = 0x00000010;
92 irq = 4;
93 }
94 } else {
95 if (pend & 0x00000f00) {
96 mask = 0x00000100;
97 irq = 8;
98 } else {
99 mask = 0x00001000;
100 irq = 12;
101 }
102 }
103 } else {
104 if (pend & 0x00ff0000) {
105 if (pend & 0x000f0000) {
106 mask = 0x00010000;
107 irq = 16;
108 } else {
109 mask = 0x00100000;
110 irq = 20;
111 }
112 } else {
113 if (pend & 0x0f000000) {
114 mask = 0x01000000;
115 irq = 24;
116 } else {
117 mask = 0x10000000;
118 irq = 28;
119 }
120 }
121 }
122
123 while (! (mask & pend)) {
124 mask <<=1;
125 irq++;
126 }
127
Greg Ungerer2502b6672007-07-19 01:49:12 -0700128 do_IRQ(irq, fp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 pend &= ~mask;
130 }
131}
Greg Ungerer2502b6672007-07-19 01:49:12 -0700132
Thomas Gleixner39a17942011-02-06 23:39:14 +0000133static void intc_irq_unmask(struct irq_data *d)
Greg Ungerer2502b6672007-07-19 01:49:12 -0700134{
Thomas Gleixner39a17942011-02-06 23:39:14 +0000135 IMR &= ~(1 << d->irq);
Greg Ungerer2502b6672007-07-19 01:49:12 -0700136}
137
Thomas Gleixner39a17942011-02-06 23:39:14 +0000138static void intc_irq_mask(struct irq_data *d)
Greg Ungerer2502b6672007-07-19 01:49:12 -0700139{
Thomas Gleixner39a17942011-02-06 23:39:14 +0000140 IMR |= (1 << d->irq);
Greg Ungerer2502b6672007-07-19 01:49:12 -0700141}
142
Greg Ungerer1985d252009-05-01 16:54:49 +1000143static struct irq_chip intc_irq_chip = {
144 .name = "M68K-INTC",
Thomas Gleixner39a17942011-02-06 23:39:14 +0000145 .irq_mask = intc_irq_mask,
146 .irq_unmask = intc_irq_unmask,
Greg Ungerer1985d252009-05-01 16:54:49 +1000147};
148
149/*
150 * This function should be called during kernel startup to initialize
151 * the machine vector table.
152 */
Greg Ungerer622e9472011-06-23 15:52:25 +1000153void __init trap_init(void)
Greg Ungerer2502b6672007-07-19 01:49:12 -0700154{
Greg Ungerer1985d252009-05-01 16:54:49 +1000155 int i;
156
157 /* set up the vectors */
158 for (i = 72; i < 256; ++i)
159 _ramvec[i] = (e_vector) bad_interrupt;
160
161 _ramvec[32] = system_call;
162
163 _ramvec[65] = (e_vector) inthandler1;
164 _ramvec[66] = (e_vector) inthandler2;
165 _ramvec[67] = (e_vector) inthandler3;
166 _ramvec[68] = (e_vector) inthandler4;
167 _ramvec[69] = (e_vector) inthandler5;
168 _ramvec[70] = (e_vector) inthandler6;
169 _ramvec[71] = (e_vector) inthandler7;
Greg Ungerer622e9472011-06-23 15:52:25 +1000170}
171
172void __init init_IRQ(void)
173{
174 int i;
Greg Ungerer1985d252009-05-01 16:54:49 +1000175
176 IVR = 0x40; /* Set DragonBall IVR (interrupt base) to 64 */
177
178 /* turn off all interrupts */
179 IMR = ~0;
180
181 for (i = 0; (i < NR_IRQS); i++) {
Thomas Gleixner0b98b162011-03-28 13:31:17 +0200182 irq_set_chip(i, &intc_irq_chip);
183 irq_set_handler(i, handle_level_irq);
Greg Ungerer1985d252009-05-01 16:54:49 +1000184 }
Greg Ungerer2502b6672007-07-19 01:49:12 -0700185}
186