2 * linux/arch/arm/mach-iop3xx/iop331-irq.c
4 * Generic IOP331 IRQ handling functionality
6 * Author: Dave Jiang <dave.jiang@intel.com>
7 * Copyright (C) 2003 Intel Corp.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
15 #include <linux/init.h>
16 #include <linux/interrupt.h>
17 #include <linux/list.h>
19 #include <asm/mach/irq.h>
21 #include <asm/hardware.h>
23 #include <asm/mach-types.h>
25 static u32 iop331_mask0
= 0;
26 static u32 iop331_mask1
= 0;
28 static inline void intctl_write0(u32 val
)
31 asm volatile("mcr p6,0,%0,c0,c0,0"::"r" (val
));
34 static inline void intctl_write1(u32 val
)
37 asm volatile("mcr p6,0,%0,c1,c0,0"::"r" (val
));
40 static inline void intstr_write0(u32 val
)
43 asm volatile("mcr p6,0,%0,c2,c0,0"::"r" (val
));
46 static inline void intstr_write1(u32 val
)
49 asm volatile("mcr p6,0,%0,c3,c0,0"::"r" (val
));
53 iop331_irq_mask1 (unsigned int irq
)
55 iop331_mask0
&= ~(1 << (irq
- IOP331_IRQ_OFS
));
56 intctl_write0(iop331_mask0
);
60 iop331_irq_mask2 (unsigned int irq
)
62 iop331_mask1
&= ~(1 << (irq
- IOP331_IRQ_OFS
- 32));
63 intctl_write1(iop331_mask1
);
67 iop331_irq_unmask1(unsigned int irq
)
69 iop331_mask0
|= (1 << (irq
- IOP331_IRQ_OFS
));
70 intctl_write0(iop331_mask0
);
74 iop331_irq_unmask2(unsigned int irq
)
76 iop331_mask1
|= (1 << (irq
- IOP331_IRQ_OFS
- 32));
77 intctl_write1(iop331_mask1
);
80 struct irqchip iop331_irqchip1
= {
81 .ack
= iop331_irq_mask1
,
82 .mask
= iop331_irq_mask1
,
83 .unmask
= iop331_irq_unmask1
,
86 struct irqchip iop331_irqchip2
= {
87 .ack
= iop331_irq_mask2
,
88 .mask
= iop331_irq_mask2
,
89 .unmask
= iop331_irq_unmask2
,
92 void __init
iop331_init_irq(void)
96 /* Enable access to coprocessor 6 for dealing with IRQs.
98 * Basically, the Intel documentation here is poor. It appears that
99 * you need to set the bit to be able to access the coprocessor from
100 * SVC mode. Whether that allows access from user space or not is
104 "mrc p15, 0, %0, c15, c1, 0\n\t"
106 "mcr p15, 0, %0, c15, c1, 0\n\t"
107 /* The action is delayed, so we have to do this: */
108 "mrc p15, 0, %0, c15, c1, 0\n\t"
111 : "=r" (tmp
) : "i" (1 << 6) );
113 intctl_write0(0); // disable all interrupts
115 intstr_write0(0); // treat all as IRQ
117 if(machine_is_iq80331()) // all interrupts are inputs to chip
118 *IOP331_PCIIRSR
= 0x0f;
120 for(i
= IOP331_IRQ_OFS
; i
< NR_IOP331_IRQS
; i
++)
122 set_irq_chip(i
, (i
< 32) ? &iop331_irqchip1
: &iop331_irqchip2
);
123 set_irq_handler(i
, do_level_IRQ
);
124 set_irq_flags(i
, IRQF_VALID
| IRQF_PROBE
);