2 * arch/ppc/syslib/gt64260_pic.c
4 * Interrupt controller support for Galileo's GT64260.
6 * Author: Chris Zankel <source@mvista.com>
7 * Modified by: Mark A. Greer <mgreer@mvista.com>
9 * Based on sources from Rabeeh Khoury / Galileo Technology
11 * 2001 (c) MontaVista, Software, Inc. This file is licensed under
12 * the terms of the GNU General Public License version 2. This program
13 * is licensed "as is" without any warranty of any kind, whether express
18 * This file contains the specific functions to support the GT64260
19 * interrupt controller.
21 * The GT64260 has two main interrupt registers (high and low) that
22 * summarizes the interrupts generated by the units of the GT64260.
23 * Each bit is assigned to an interrupt number, where the low register
24 * are assigned from IRQ0 to IRQ31 and the high cause register
26 * The GPP (General Purpose Port) interrupts are assigned from IRQ64 (GPP0)
28 * get_irq() returns the lowest interrupt number that is currently asserted.
31 * - This driver does not initialize the GPP when used as an interrupt
35 #include <linux/stddef.h>
36 #include <linux/init.h>
37 #include <linux/interrupt.h>
38 #include <linux/sched.h>
39 #include <linux/signal.h>
40 #include <linux/stddef.h>
41 #include <linux/delay.h>
42 #include <linux/irq.h>
45 #include <asm/system.h>
47 #include <asm/mv64x60.h>
48 #include <asm/machdep.h>
50 #define CPU_INTR_STR "gt64260 cpu interface error"
51 #define PCI0_INTR_STR "gt64260 pci 0 error"
52 #define PCI1_INTR_STR "gt64260 pci 1 error"
54 /* ========================== forward declaration ========================== */
56 static void gt64260_unmask_irq(unsigned int);
57 static void gt64260_mask_irq(unsigned int);
59 /* ========================== local declarations =========================== */
61 struct hw_interrupt_type gt64260_pic = {
62 .typename = " gt64260_pic ",
63 .enable = gt64260_unmask_irq,
64 .disable = gt64260_mask_irq,
65 .ack = gt64260_mask_irq,
66 .end = gt64260_unmask_irq,
69 u32 gt64260_irq_base = 0; /* GT64260 handles the next 96 IRQs from here */
71 static struct mv64x60_handle bh;
75 * This function initializes the interrupt controller. It assigns
76 * all interrupts from IRQ0 to IRQ95 to the gt64260 interrupt controller.
79 * We register all GPP inputs as interrupt source, but disable them.
82 gt64260_init_irq(void)
87 ppc_md.progress("gt64260_init_irq: enter", 0x0);
89 bh.v_base = mv64x60_get_bridge_vbase();
91 ppc_cached_irq_mask[0] = 0;
92 ppc_cached_irq_mask[1] = 0x0f000000; /* Enable GPP intrs */
93 ppc_cached_irq_mask[2] = 0;
95 /* disable all interrupts and clear current interrupts */
96 mv64x60_write(&bh, MV64x60_GPP_INTR_MASK, ppc_cached_irq_mask[2]);
97 mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, 0);
98 mv64x60_write(&bh, GT64260_IC_CPU_INTR_MASK_LO, ppc_cached_irq_mask[0]);
99 mv64x60_write(&bh, GT64260_IC_CPU_INTR_MASK_HI, ppc_cached_irq_mask[1]);
101 /* use the gt64260 for all (possible) interrupt sources */
102 for (i = gt64260_irq_base; i < (gt64260_irq_base + 96); i++)
103 irq_desc[i].handler = >64260_pic;
106 ppc_md.progress("gt64260_init_irq: exit", 0x0);
112 * This function returns the lowest interrupt number of all interrupts that
113 * are currently asserted.
116 * struct pt_regs* not used
118 * Output Variable(s):
122 * int <interrupt number> or -2 (bogus interrupt)
125 gt64260_get_irq(struct pt_regs *regs)
130 irq = mv64x60_read(&bh, GT64260_IC_MAIN_CAUSE_LO);
131 irq = __ilog2((irq & 0x3dfffffe) & ppc_cached_irq_mask[0]);
134 irq = mv64x60_read(&bh, GT64260_IC_MAIN_CAUSE_HI);
135 irq = __ilog2((irq & 0x0f000db7) & ppc_cached_irq_mask[1]);
138 irq = -2; /* bogus interrupt, should never happen */
141 irq_gpp = mv64x60_read(&bh,
142 MV64x60_GPP_INTR_CAUSE);
143 irq_gpp = __ilog2(irq_gpp &
144 ppc_cached_irq_mask[2]);
151 MV64x60_GPP_INTR_CAUSE,
159 (void)mv64x60_read(&bh, MV64x60_GPP_INTR_CAUSE);
164 return (gt64260_irq_base + irq);
167 /* gt64260_unmask_irq()
169 * This function enables an interrupt.
172 * unsigned int interrupt number (IRQ0...IRQ95).
174 * Output Variable(s):
181 gt64260_unmask_irq(unsigned int irq)
183 irq -= gt64260_irq_base;
186 if (irq > 63) /* unmask GPP irq */
187 mv64x60_write(&bh, MV64x60_GPP_INTR_MASK,
188 ppc_cached_irq_mask[2] |= (1 << (irq - 64)));
189 else /* mask high interrupt register */
190 mv64x60_write(&bh, GT64260_IC_CPU_INTR_MASK_HI,
191 ppc_cached_irq_mask[1] |= (1 << (irq - 32)));
192 else /* mask low interrupt register */
193 mv64x60_write(&bh, GT64260_IC_CPU_INTR_MASK_LO,
194 ppc_cached_irq_mask[0] |= (1 << irq));
196 (void)mv64x60_read(&bh, MV64x60_GPP_INTR_MASK);
200 /* gt64260_mask_irq()
202 * This function disables the requested interrupt.
205 * unsigned int interrupt number (IRQ0...IRQ95).
207 * Output Variable(s):
214 gt64260_mask_irq(unsigned int irq)
216 irq -= gt64260_irq_base;
219 if (irq > 63) /* mask GPP irq */
220 mv64x60_write(&bh, MV64x60_GPP_INTR_MASK,
221 ppc_cached_irq_mask[2] &= ~(1 << (irq - 64)));
222 else /* mask high interrupt register */
223 mv64x60_write(&bh, GT64260_IC_CPU_INTR_MASK_HI,
224 ppc_cached_irq_mask[1] &= ~(1 << (irq - 32)));
225 else /* mask low interrupt register */
226 mv64x60_write(&bh, GT64260_IC_CPU_INTR_MASK_LO,
227 ppc_cached_irq_mask[0] &= ~(1 << irq));
229 (void)mv64x60_read(&bh, MV64x60_GPP_INTR_MASK);
234 gt64260_cpu_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
236 printk(KERN_ERR "gt64260_cpu_error_int_handler: %s 0x%08x\n",
237 "Error on CPU interface - Cause regiser",
238 mv64x60_read(&bh, MV64x60_CPU_ERR_CAUSE));
239 printk(KERN_ERR "\tCPU error register dump:\n");
240 printk(KERN_ERR "\tAddress low 0x%08x\n",
241 mv64x60_read(&bh, MV64x60_CPU_ERR_ADDR_LO));
242 printk(KERN_ERR "\tAddress high 0x%08x\n",
243 mv64x60_read(&bh, MV64x60_CPU_ERR_ADDR_HI));
244 printk(KERN_ERR "\tData low 0x%08x\n",
245 mv64x60_read(&bh, MV64x60_CPU_ERR_DATA_LO));
246 printk(KERN_ERR "\tData high 0x%08x\n",
247 mv64x60_read(&bh, MV64x60_CPU_ERR_DATA_HI));
248 printk(KERN_ERR "\tParity 0x%08x\n",
249 mv64x60_read(&bh, MV64x60_CPU_ERR_PARITY));
250 mv64x60_write(&bh, MV64x60_CPU_ERR_CAUSE, 0);
255 gt64260_pci_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
258 unsigned int pci_bus = (unsigned int)dev_id;
260 if (pci_bus == 0) { /* Error on PCI 0 */
261 val = mv64x60_read(&bh, MV64x60_PCI0_ERR_CAUSE);
262 printk(KERN_ERR "%s: Error in PCI %d Interface\n",
263 "gt64260_pci_error_int_handler", pci_bus);
264 printk(KERN_ERR "\tPCI %d error register dump:\n", pci_bus);
265 printk(KERN_ERR "\tCause register 0x%08x\n", val);
266 printk(KERN_ERR "\tAddress Low 0x%08x\n",
267 mv64x60_read(&bh, MV64x60_PCI0_ERR_ADDR_LO));
268 printk(KERN_ERR "\tAddress High 0x%08x\n",
269 mv64x60_read(&bh, MV64x60_PCI0_ERR_ADDR_HI));
270 printk(KERN_ERR "\tAttribute 0x%08x\n",
271 mv64x60_read(&bh, MV64x60_PCI0_ERR_DATA_LO));
272 printk(KERN_ERR "\tCommand 0x%08x\n",
273 mv64x60_read(&bh, MV64x60_PCI0_ERR_CMD));
274 mv64x60_write(&bh, MV64x60_PCI0_ERR_CAUSE, ~val);
276 if (pci_bus == 1) { /* Error on PCI 1 */
277 val = mv64x60_read(&bh, MV64x60_PCI1_ERR_CAUSE);
278 printk(KERN_ERR "%s: Error in PCI %d Interface\n",
279 "gt64260_pci_error_int_handler", pci_bus);
280 printk(KERN_ERR "\tPCI %d error register dump:\n", pci_bus);
281 printk(KERN_ERR "\tCause register 0x%08x\n", val);
282 printk(KERN_ERR "\tAddress Low 0x%08x\n",
283 mv64x60_read(&bh, MV64x60_PCI1_ERR_ADDR_LO));
284 printk(KERN_ERR "\tAddress High 0x%08x\n",
285 mv64x60_read(&bh, MV64x60_PCI1_ERR_ADDR_HI));
286 printk(KERN_ERR "\tAttribute 0x%08x\n",
287 mv64x60_read(&bh, MV64x60_PCI1_ERR_DATA_LO));
288 printk(KERN_ERR "\tCommand 0x%08x\n",
289 mv64x60_read(&bh, MV64x60_PCI1_ERR_CMD));
290 mv64x60_write(&bh, MV64x60_PCI1_ERR_CAUSE, ~val);
296 gt64260_register_hdlrs(void)
300 /* Register CPU interface error interrupt handler */
301 if ((rc = request_irq(MV64x60_IRQ_CPU_ERR,
302 gt64260_cpu_error_int_handler, SA_INTERRUPT, CPU_INTR_STR, 0)))
303 printk(KERN_WARNING "Can't register cpu error handler: %d", rc);
305 mv64x60_write(&bh, MV64x60_CPU_ERR_MASK, 0);
306 mv64x60_write(&bh, MV64x60_CPU_ERR_MASK, 0x000000fe);
308 /* Register PCI 0 error interrupt handler */
309 if ((rc = request_irq(MV64360_IRQ_PCI0, gt64260_pci_error_int_handler,
310 SA_INTERRUPT, PCI0_INTR_STR, (void *)0)))
311 printk(KERN_WARNING "Can't register pci 0 error handler: %d",
314 mv64x60_write(&bh, MV64x60_PCI0_ERR_MASK, 0);
315 mv64x60_write(&bh, MV64x60_PCI0_ERR_MASK, 0x003c0c24);
317 /* Register PCI 1 error interrupt handler */
318 if ((rc = request_irq(MV64360_IRQ_PCI1, gt64260_pci_error_int_handler,
319 SA_INTERRUPT, PCI1_INTR_STR, (void *)1)))
320 printk(KERN_WARNING "Can't register pci 1 error handler: %d",
323 mv64x60_write(&bh, MV64x60_PCI1_ERR_MASK, 0);
324 mv64x60_write(&bh, MV64x60_PCI1_ERR_MASK, 0x003c0c24);
329 arch_initcall(gt64260_register_hdlrs);