WIP FPC-III support
[linux/fpc-iii.git] / arch / powerpc / platforms / 86xx / pic.c
blob2c32c3488afbb64cf5e6fc31da28451063779b0c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright 2008 Freescale Semiconductor, Inc.
4 */
6 #include <linux/stddef.h>
7 #include <linux/kernel.h>
8 #include <linux/interrupt.h>
9 #include <linux/of_irq.h>
10 #include <linux/of_platform.h>
12 #include <asm/mpic.h>
13 #include <asm/i8259.h>
15 #ifdef CONFIG_PPC_I8259
16 static void mpc86xx_8259_cascade(struct irq_desc *desc)
18 struct irq_chip *chip = irq_desc_get_chip(desc);
19 unsigned int cascade_irq = i8259_irq();
21 if (cascade_irq)
22 generic_handle_irq(cascade_irq);
24 chip->irq_eoi(&desc->irq_data);
26 #endif /* CONFIG_PPC_I8259 */
28 void __init mpc86xx_init_irq(void)
30 #ifdef CONFIG_PPC_I8259
31 struct device_node *np;
32 struct device_node *cascade_node = NULL;
33 int cascade_irq;
34 #endif
36 struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
37 MPIC_SINGLE_DEST_CPU,
38 0, 256, " MPIC ");
39 BUG_ON(mpic == NULL);
41 mpic_init(mpic);
43 #ifdef CONFIG_PPC_I8259
44 /* Initialize i8259 controller */
45 for_each_node_by_type(np, "interrupt-controller")
46 if (of_device_is_compatible(np, "chrp,iic")) {
47 cascade_node = np;
48 break;
51 if (cascade_node == NULL) {
52 printk(KERN_DEBUG "Could not find i8259 PIC\n");
53 return;
56 cascade_irq = irq_of_parse_and_map(cascade_node, 0);
57 if (!cascade_irq) {
58 printk(KERN_ERR "Failed to map cascade interrupt\n");
59 return;
62 i8259_init(cascade_node, 0);
63 of_node_put(cascade_node);
65 irq_set_chained_handler(cascade_irq, mpc86xx_8259_cascade);
66 #endif