2 * arch/ppc/syslib/xilinx_pic.c
4 * Interrupt controller driver for Xilinx Virtex-II Pro.
6 * Author: MontaVista Software, Inc.
9 * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
15 #include <linux/init.h>
16 #include <linux/irq.h>
18 #include <asm/xparameters.h>
19 #include <asm/ibm4xx.h>
21 /* No one else should require these constants, so define them locally here. */
22 #define ISR 0 /* Interrupt Status Register */
23 #define IPR 1 /* Interrupt Pending Register */
24 #define IER 2 /* Interrupt Enable Register */
25 #define IAR 3 /* Interrupt Acknowledge Register */
26 #define SIE 4 /* Set Interrupt Enable bits */
27 #define CIE 5 /* Clear Interrupt Enable bits */
28 #define IVR 6 /* Interrupt Vector Register */
29 #define MER 7 /* Master Enable Register */
31 #if XPAR_XINTC_USE_DCR == 0
32 static volatile u32 *intc;
33 #define intc_out_be32(addr, mask) out_be32((addr), (mask))
34 #define intc_in_be32(addr) in_be32((addr))
36 #define intc XPAR_INTC_0_BASEADDR
37 #define intc_out_be32(addr, mask) mtdcr((addr), (mask))
38 #define intc_in_be32(addr) mfdcr((addr))
42 xilinx_intc_enable(unsigned int irq)
44 unsigned long mask = (0x00000001 << (irq & 31));
45 pr_debug("enable: %d\n", irq);
46 intc_out_be32(intc + SIE, mask);
50 xilinx_intc_disable(unsigned int irq)
52 unsigned long mask = (0x00000001 << (irq & 31));
53 pr_debug("disable: %d\n", irq);
54 intc_out_be32(intc + CIE, mask);
58 xilinx_intc_disable_and_ack(unsigned int irq)
60 unsigned long mask = (0x00000001 << (irq & 31));
61 pr_debug("disable_and_ack: %d\n", irq);
62 intc_out_be32(intc + CIE, mask);
63 if (!(irq_desc[irq].status & IRQ_LEVEL))
64 intc_out_be32(intc + IAR, mask); /* ack edge triggered intr */
68 xilinx_intc_end(unsigned int irq)
70 unsigned long mask = (0x00000001 << (irq & 31));
72 pr_debug("end: %d\n", irq);
73 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) {
74 intc_out_be32(intc + SIE, mask);
75 /* ack level sensitive intr */
76 if (irq_desc[irq].status & IRQ_LEVEL)
77 intc_out_be32(intc + IAR, mask);
81 static struct hw_interrupt_type xilinx_intc = {
82 "Xilinx Interrupt Controller",
87 xilinx_intc_disable_and_ack,
93 xilinx_pic_get_irq(struct pt_regs *regs)
98 * NOTE: This function is the one that needs to be improved in
99 * order to handle multiple interrupt controllers. It currently
100 * is hardcoded to check for interrupts only on the first INTC.
103 irq = intc_in_be32(intc + IVR);
107 pr_debug("get_irq: %d\n", irq);
113 ppc4xx_pic_init(void)
118 * NOTE: The assumption here is that NR_IRQS is 32 or less
119 * (NR_IRQS is 32 for PowerPC 405 cores by default).
122 #error NR_IRQS > 32 not supported
125 #if XPAR_XINTC_USE_DCR == 0
126 intc = ioremap(XPAR_INTC_0_BASEADDR, 32);
128 printk(KERN_INFO "Xilinx INTC #0 at 0x%08lX mapped to 0x%08lX\n",
129 (unsigned long) XPAR_INTC_0_BASEADDR, (unsigned long) intc);
131 printk(KERN_INFO "Xilinx INTC #0 at 0x%08lX (DCR)\n",
132 (unsigned long) XPAR_INTC_0_BASEADDR);
136 * Disable all external interrupts until they are
137 * explicity requested.
139 intc_out_be32(intc + IER, 0);
141 /* Acknowledge any pending interrupts just in case. */
142 intc_out_be32(intc + IAR, ~(u32) 0);
144 /* Turn on the Master Enable. */
145 intc_out_be32(intc + MER, 0x3UL);
147 ppc_md.get_irq = xilinx_pic_get_irq;
149 for (i = 0; i < NR_IRQS; ++i) {
150 irq_desc[i].handler = &xilinx_intc;
152 if (XPAR_INTC_0_KIND_OF_INTR & (0x00000001 << i))
153 irq_desc[i].status &= ~IRQ_LEVEL;
155 irq_desc[i].status |= IRQ_LEVEL;