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 write_intctl_0(read_intctl_0() & ~(1 << (irq - 0)));
168 iop13xx_irq_mask1 (unsigned int irq)
170 write_intctl_1(read_intctl_1() & ~(1 << (irq - 32)));
174 iop13xx_irq_mask2 (unsigned int irq)
176 write_intctl_2(read_intctl_2() & ~(1 << (irq - 64)));
180 iop13xx_irq_mask3 (unsigned int irq)
182 write_intctl_3(read_intctl_3() & ~(1 << (irq - 96)));
186 iop13xx_irq_unmask0(unsigned int irq)
188 write_intctl_0(read_intctl_0() | (1 << (irq - 0)));
192 iop13xx_irq_unmask1(unsigned int irq)
194 write_intctl_1(read_intctl_1() | (1 << (irq - 32)));
198 iop13xx_irq_unmask2(unsigned int irq)
200 write_intctl_2(read_intctl_2() | (1 << (irq - 64)));
204 iop13xx_irq_unmask3(unsigned int irq)
206 write_intctl_3(read_intctl_3() | (1 << (irq - 96)));
209 static struct irq_chip iop13xx_irqchip1 = {
211 .ack = iop13xx_irq_mask0,
212 .mask = iop13xx_irq_mask0,
213 .unmask = iop13xx_irq_unmask0,
216 static struct irq_chip iop13xx_irqchip2 = {
218 .ack = iop13xx_irq_mask1,
219 .mask = iop13xx_irq_mask1,
220 .unmask = iop13xx_irq_unmask1,
223 static struct irq_chip iop13xx_irqchip3 = {
225 .ack = iop13xx_irq_mask2,
226 .mask = iop13xx_irq_mask2,
227 .unmask = iop13xx_irq_unmask2,
230 static struct irq_chip iop13xx_irqchip4 = {
232 .ack = iop13xx_irq_mask3,
233 .mask = iop13xx_irq_mask3,
234 .unmask = iop13xx_irq_unmask3,
237 extern void iop_init_cp6_handler(void);
239 void __init iop13xx_init_irq(void)
243 iop_init_cp6_handler();
245 /* disable all interrupts */
251 /* treat all as IRQ */
257 /* initialize the interrupt vector generator */
258 write_intbase(INTBASE);
259 write_intsize(INTSIZE_4);
261 for(i = 0; i < NR_IOP13XX_IRQS; i++) {
263 set_irq_chip(i, &iop13xx_irqchip1);
265 set_irq_chip(i, &iop13xx_irqchip2);
267 set_irq_chip(i, &iop13xx_irqchip3);
269 set_irq_chip(i, &iop13xx_irqchip4);
271 set_irq_handler(i, handle_level_irq);
272 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);