2 * iop13xx IRQ handling / support functions
3 * Copyright (c) 2005-2006, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
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 for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
19 #include <linux/init.h>
20 #include <linux/interrupt.h>
21 #include <linux/list.h>
22 #include <linux/sysctl.h>
23 #include <asm/uaccess.h>
24 #include <asm/mach/irq.h>
26 #include <asm/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/arch/irqs.h>
30 /* INTCTL0 CP6 R0 Page 4
32 static inline u32 read_intctl_0(void)
35 asm volatile("mrc p6, 0, %0, c0, c4, 0":"=r" (val));
38 static inline void write_intctl_0(u32 val)
40 asm volatile("mcr p6, 0, %0, c0, c4, 0"::"r" (val));
43 /* INTCTL1 CP6 R1 Page 4
45 static inline u32 read_intctl_1(void)
48 asm volatile("mrc p6, 0, %0, c1, c4, 0":"=r" (val));
51 static inline void write_intctl_1(u32 val)
53 asm volatile("mcr p6, 0, %0, c1, c4, 0"::"r" (val));
56 /* INTCTL2 CP6 R2 Page 4
58 static inline u32 read_intctl_2(void)
61 asm volatile("mrc p6, 0, %0, c2, c4, 0":"=r" (val));
64 static inline void write_intctl_2(u32 val)
66 asm volatile("mcr p6, 0, %0, c2, c4, 0"::"r" (val));
69 /* INTCTL3 CP6 R3 Page 4
71 static inline u32 read_intctl_3(void)
74 asm volatile("mrc p6, 0, %0, c3, c4, 0":"=r" (val));
77 static inline void write_intctl_3(u32 val)
79 asm volatile("mcr p6, 0, %0, c3, c4, 0"::"r" (val));
82 /* INTSTR0 CP6 R0 Page 5
84 static inline u32 read_intstr_0(void)
87 asm volatile("mrc p6, 0, %0, c0, c5, 0":"=r" (val));
90 static inline void write_intstr_0(u32 val)
92 asm volatile("mcr p6, 0, %0, c0, c5, 0"::"r" (val));
95 /* INTSTR1 CP6 R1 Page 5
97 static inline u32 read_intstr_1(void)
100 asm volatile("mrc p6, 0, %0, c1, c5, 0":"=r" (val));
103 static void write_intstr_1(u32 val)
105 asm volatile("mcr p6, 0, %0, c1, c5, 0"::"r" (val));
108 /* INTSTR2 CP6 R2 Page 5
110 static inline u32 read_intstr_2(void)
113 asm volatile("mrc p6, 0, %0, c2, c5, 0":"=r" (val));
116 static void write_intstr_2(u32 val)
118 asm volatile("mcr p6, 0, %0, c2, c5, 0"::"r" (val));
121 /* INTSTR3 CP6 R3 Page 5
123 static inline u32 read_intstr_3(void)
126 asm volatile("mrc p6, 0, %0, c3, c5, 0":"=r" (val));
129 static void write_intstr_3(u32 val)
131 asm volatile("mcr p6, 0, %0, c3, c5, 0"::"r" (val));
134 /* INTBASE CP6 R0 Page 2
136 static inline u32 read_intbase(void)
139 asm volatile("mrc p6, 0, %0, c0, c2, 0":"=r" (val));
142 static void write_intbase(u32 val)
144 asm volatile("mcr p6, 0, %0, c0, c2, 0"::"r" (val));
147 /* INTSIZE CP6 R2 Page 2
149 static inline u32 read_intsize(void)
152 asm volatile("mrc p6, 0, %0, c2, c2, 0":"=r" (val));
155 static void write_intsize(u32 val)
157 asm volatile("mcr p6, 0, %0, c2, c2, 0"::"r" (val));
160 /* 0 = Interrupt Masked and 1 = Interrupt not masked */
162 iop13xx_irq_mask0 (unsigned int irq)
164 u32 cp_flags = iop13xx_cp6_save();
165 write_intctl_0(read_intctl_0() & ~(1 << (irq - 0)));
166 iop13xx_cp6_restore(cp_flags);
170 iop13xx_irq_mask1 (unsigned int irq)
172 u32 cp_flags = iop13xx_cp6_save();
173 write_intctl_1(read_intctl_1() & ~(1 << (irq - 32)));
174 iop13xx_cp6_restore(cp_flags);
178 iop13xx_irq_mask2 (unsigned int irq)
180 u32 cp_flags = iop13xx_cp6_save();
181 write_intctl_2(read_intctl_2() & ~(1 << (irq - 64)));
182 iop13xx_cp6_restore(cp_flags);
186 iop13xx_irq_mask3 (unsigned int irq)
188 u32 cp_flags = iop13xx_cp6_save();
189 write_intctl_3(read_intctl_3() & ~(1 << (irq - 96)));
190 iop13xx_cp6_restore(cp_flags);
194 iop13xx_irq_unmask0(unsigned int irq)
196 u32 cp_flags = iop13xx_cp6_save();
197 write_intctl_0(read_intctl_0() | (1 << (irq - 0)));
198 iop13xx_cp6_restore(cp_flags);
202 iop13xx_irq_unmask1(unsigned int irq)
204 u32 cp_flags = iop13xx_cp6_save();
205 write_intctl_1(read_intctl_1() | (1 << (irq - 32)));
206 iop13xx_cp6_restore(cp_flags);
210 iop13xx_irq_unmask2(unsigned int irq)
212 u32 cp_flags = iop13xx_cp6_save();
213 write_intctl_2(read_intctl_2() | (1 << (irq - 64)));
214 iop13xx_cp6_restore(cp_flags);
218 iop13xx_irq_unmask3(unsigned int irq)
220 u32 cp_flags = iop13xx_cp6_save();
221 write_intctl_3(read_intctl_3() | (1 << (irq - 96)));
222 iop13xx_cp6_restore(cp_flags);
225 static struct irq_chip iop13xx_irqchip1 = {
227 .ack = iop13xx_irq_mask0,
228 .mask = iop13xx_irq_mask0,
229 .unmask = iop13xx_irq_unmask0,
232 static struct irq_chip iop13xx_irqchip2 = {
234 .ack = iop13xx_irq_mask1,
235 .mask = iop13xx_irq_mask1,
236 .unmask = iop13xx_irq_unmask1,
239 static struct irq_chip iop13xx_irqchip3 = {
241 .ack = iop13xx_irq_mask2,
242 .mask = iop13xx_irq_mask2,
243 .unmask = iop13xx_irq_unmask2,
246 static struct irq_chip iop13xx_irqchip4 = {
248 .ack = iop13xx_irq_mask3,
249 .mask = iop13xx_irq_mask3,
250 .unmask = iop13xx_irq_unmask3,
253 void __init iop13xx_init_irq(void)
257 u32 cp_flags = iop13xx_cp6_save();
259 /* disable all interrupts */
265 /* treat all as IRQ */
271 /* initialize the interrupt vector generator */
272 write_intbase(INTBASE);
273 write_intsize(INTSIZE_4);
275 for(i = 0; i < NR_IOP13XX_IRQS; i++) {
277 set_irq_chip(i, &iop13xx_irqchip1);
279 set_irq_chip(i, &iop13xx_irqchip2);
281 set_irq_chip(i, &iop13xx_irqchip3);
283 set_irq_chip(i, &iop13xx_irqchip4);
285 set_irq_handler(i, handle_level_irq);
286 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
289 iop13xx_cp6_restore(cp_flags);