aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/lasat/interrupt.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/lasat/interrupt.c')
-rw-r--r--arch/mips/lasat/interrupt.c160
1 files changed, 160 insertions, 0 deletions
diff --git a/arch/mips/lasat/interrupt.c b/arch/mips/lasat/interrupt.c
new file mode 100644
index 000000000000..1148a2d20aa7
--- /dev/null
+++ b/arch/mips/lasat/interrupt.c
@@ -0,0 +1,160 @@
1/*
2 * Carsten Langgaard, carstenl@mips.com
3 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
4 *
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 *
18 * Routines for generic manipulation of the interrupts found on the
19 * Lasat boards.
20 */
21#include <linux/init.h>
22#include <linux/sched.h>
23#include <linux/slab.h>
24#include <linux/interrupt.h>
25#include <linux/kernel_stat.h>
26
27#include <asm/bootinfo.h>
28#include <asm/irq.h>
29#include <asm/lasat/lasatint.h>
30#include <asm/gdb-stub.h>
31
32static volatile int *lasat_int_status = NULL;
33static volatile int *lasat_int_mask = NULL;
34static volatile int lasat_int_mask_shift;
35
36extern asmlinkage void lasatIRQ(void);
37
38void disable_lasat_irq(unsigned int irq_nr)
39{
40 unsigned long flags;
41
42 local_irq_save(flags);
43 *lasat_int_mask &= ~(1 << irq_nr) << lasat_int_mask_shift;
44 local_irq_restore(flags);
45}
46
47void enable_lasat_irq(unsigned int irq_nr)
48{
49 unsigned long flags;
50
51 local_irq_save(flags);
52 *lasat_int_mask |= (1 << irq_nr) << lasat_int_mask_shift;
53 local_irq_restore(flags);
54}
55
56static unsigned int startup_lasat_irq(unsigned int irq)
57{
58 enable_lasat_irq(irq);
59
60 return 0; /* never anything pending */
61}
62
63#define shutdown_lasat_irq disable_lasat_irq
64
65#define mask_and_ack_lasat_irq disable_lasat_irq
66
67static void end_lasat_irq(unsigned int irq)
68{
69 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
70 enable_lasat_irq(irq);
71}
72
73static struct hw_interrupt_type lasat_irq_type = {
74 "Lasat",
75 startup_lasat_irq,
76 shutdown_lasat_irq,
77 enable_lasat_irq,
78 disable_lasat_irq,
79 mask_and_ack_lasat_irq,
80 end_lasat_irq,
81 NULL
82};
83
84static inline int ls1bit32(unsigned int x)
85{
86 int b = 31, s;
87
88 s = 16; if (x << 16 == 0) s = 0; b -= s; x <<= s;
89 s = 8; if (x << 8 == 0) s = 0; b -= s; x <<= s;
90 s = 4; if (x << 4 == 0) s = 0; b -= s; x <<= s;
91 s = 2; if (x << 2 == 0) s = 0; b -= s; x <<= s;
92 s = 1; if (x << 1 == 0) s = 0; b -= s;
93
94 return b;
95}
96
97static unsigned long (* get_int_status)(void);
98
99static unsigned long get_int_status_100(void)
100{
101 return *lasat_int_status & *lasat_int_mask;
102}
103
104static unsigned long get_int_status_200(void)
105{
106 unsigned long int_status;
107
108 int_status = *lasat_int_status;
109 int_status &= (int_status >> LASATINT_MASK_SHIFT_200) & 0xffff;
110 return int_status;
111}
112
113void lasat_hw0_irqdispatch(struct pt_regs *regs)
114{
115 unsigned long int_status;
116 int irq;
117
118 int_status = get_int_status();
119
120 /* if int_status == 0, then the interrupt has already been cleared */
121 if (int_status) {
122 irq = ls1bit32(int_status);
123
124 do_IRQ(irq, regs);
125 }
126}
127
128void __init arch_init_irq(void)
129{
130 int i;
131
132 switch (mips_machtype) {
133 case MACH_LASAT_100:
134 lasat_int_status = (void *)LASAT_INT_STATUS_REG_100;
135 lasat_int_mask = (void *)LASAT_INT_MASK_REG_100;
136 lasat_int_mask_shift = LASATINT_MASK_SHIFT_100;
137 get_int_status = get_int_status_100;
138 *lasat_int_mask = 0;
139 break;
140 case MACH_LASAT_200:
141 lasat_int_status = (void *)LASAT_INT_STATUS_REG_200;
142 lasat_int_mask = (void *)LASAT_INT_MASK_REG_200;
143 lasat_int_mask_shift = LASATINT_MASK_SHIFT_200;
144 get_int_status = get_int_status_200;
145 *lasat_int_mask &= 0xffff;
146 break;
147 default:
148 panic("arch_init_irq: mips_machtype incorrect");
149 }
150
151 /* Now safe to set the exception vector. */
152 set_except_vector(0, lasatIRQ);
153
154 for (i = 0; i <= LASATINT_END; i++) {
155 irq_desc[i].status = IRQ_DISABLED;
156 irq_desc[i].action = 0;
157 irq_desc[i].depth = 1;
158 irq_desc[i].handler = &lasat_irq_type;
159 }
160}