First Support on Ginger and OMAP TI
[linux-ginger.git] / arch / powerpc / platforms / 86xx / pic.c
blob668275d9e668b73f2c99a7577f20c44cbd950f03
1 /*
2 * Copyright 2008 Freescale Semiconductor, Inc.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 */
10 #include <linux/stddef.h>
11 #include <linux/kernel.h>
12 #include <linux/interrupt.h>
13 #include <linux/of_platform.h>
15 #include <asm/system.h>
16 #include <asm/mpic.h>
17 #include <asm/i8259.h>
19 #ifdef CONFIG_PPC_I8259
20 static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
22 unsigned int cascade_irq = i8259_irq();
23 if (cascade_irq != NO_IRQ)
24 generic_handle_irq(cascade_irq);
25 desc->chip->eoi(irq);
27 #endif /* CONFIG_PPC_I8259 */
29 void __init mpc86xx_init_irq(void)
31 struct mpic *mpic;
32 struct device_node *np;
33 struct resource res;
34 #ifdef CONFIG_PPC_I8259
35 struct device_node *cascade_node = NULL;
36 int cascade_irq;
37 #endif
39 /* Determine PIC address. */
40 np = of_find_node_by_type(NULL, "open-pic");
41 if (np == NULL)
42 return;
43 of_address_to_resource(np, 0, &res);
45 mpic = mpic_alloc(np, res.start,
46 MPIC_PRIMARY | MPIC_WANTS_RESET |
47 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
48 MPIC_SINGLE_DEST_CPU,
49 0, 256, " MPIC ");
50 of_node_put(np);
51 BUG_ON(mpic == NULL);
53 mpic_init(mpic);
55 #ifdef CONFIG_PPC_I8259
56 /* Initialize i8259 controller */
57 for_each_node_by_type(np, "interrupt-controller")
58 if (of_device_is_compatible(np, "chrp,iic")) {
59 cascade_node = np;
60 break;
63 if (cascade_node == NULL) {
64 printk(KERN_DEBUG "Could not find i8259 PIC\n");
65 return;
68 cascade_irq = irq_of_parse_and_map(cascade_node, 0);
69 if (cascade_irq == NO_IRQ) {
70 printk(KERN_ERR "Failed to map cascade interrupt\n");
71 return;
74 i8259_init(cascade_node, 0);
75 of_node_put(cascade_node);
77 set_irq_chained_handler(cascade_irq, mpc86xx_8259_cascade);
78 #endif