xref: /openbmc/linux/arch/powerpc/platforms/86xx/pic.c (revision 95e9fd10)
1 /*
2  * Copyright 2008 Freescale Semiconductor, Inc.
3  *
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  */
9 
10 #include <linux/stddef.h>
11 #include <linux/kernel.h>
12 #include <linux/interrupt.h>
13 #include <linux/of_platform.h>
14 
15 #include <asm/mpic.h>
16 #include <asm/i8259.h>
17 
18 #ifdef CONFIG_PPC_I8259
19 static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
20 {
21 	struct irq_chip *chip = irq_desc_get_chip(desc);
22 	unsigned int cascade_irq = i8259_irq();
23 
24 	if (cascade_irq != NO_IRQ)
25 		generic_handle_irq(cascade_irq);
26 
27 	chip->irq_eoi(&desc->irq_data);
28 }
29 #endif	/* CONFIG_PPC_I8259 */
30 
31 void __init mpc86xx_init_irq(void)
32 {
33 #ifdef CONFIG_PPC_I8259
34 	struct device_node *np;
35 	struct device_node *cascade_node = NULL;
36 	int cascade_irq;
37 #endif
38 
39 	struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
40 			MPIC_SINGLE_DEST_CPU,
41 			0, 256, " MPIC     ");
42 	BUG_ON(mpic == NULL);
43 
44 	mpic_init(mpic);
45 
46 #ifdef CONFIG_PPC_I8259
47 	/* Initialize i8259 controller */
48 	for_each_node_by_type(np, "interrupt-controller")
49 		if (of_device_is_compatible(np, "chrp,iic")) {
50 			cascade_node = np;
51 			break;
52 		}
53 
54 	if (cascade_node == NULL) {
55 		printk(KERN_DEBUG "Could not find i8259 PIC\n");
56 		return;
57 	}
58 
59 	cascade_irq = irq_of_parse_and_map(cascade_node, 0);
60 	if (cascade_irq == NO_IRQ) {
61 		printk(KERN_ERR "Failed to map cascade interrupt\n");
62 		return;
63 	}
64 
65 	i8259_init(cascade_node, 0);
66 	of_node_put(cascade_node);
67 
68 	irq_set_chained_handler(cascade_irq, mpc86xx_8259_cascade);
69 #endif
70 }
71