Commit | Line | Data |
---|---|---|
98384c6c KG |
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/system.h> | |
16 | #include <asm/mpic.h> | |
17 | #include <asm/i8259.h> | |
18 | ||
19 | #ifdef CONFIG_PPC_I8259 | |
20 | static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc) | |
21 | { | |
ec775d0e | 22 | struct irq_chip *chip = irq_desc_get_chip(desc); |
98384c6c | 23 | unsigned int cascade_irq = i8259_irq(); |
5b250889 | 24 | |
98384c6c KG |
25 | if (cascade_irq != NO_IRQ) |
26 | generic_handle_irq(cascade_irq); | |
5b250889 LB |
27 | |
28 | chip->irq_eoi(&desc->irq_data); | |
98384c6c KG |
29 | } |
30 | #endif /* CONFIG_PPC_I8259 */ | |
31 | ||
32 | void __init mpc86xx_init_irq(void) | |
33 | { | |
34 | struct mpic *mpic; | |
35 | struct device_node *np; | |
36 | struct resource res; | |
37 | #ifdef CONFIG_PPC_I8259 | |
38 | struct device_node *cascade_node = NULL; | |
39 | int cascade_irq; | |
40 | #endif | |
41 | ||
42 | /* Determine PIC address. */ | |
43 | np = of_find_node_by_type(NULL, "open-pic"); | |
44 | if (np == NULL) | |
45 | return; | |
46 | of_address_to_resource(np, 0, &res); | |
47 | ||
48 | mpic = mpic_alloc(np, res.start, | |
49 | MPIC_PRIMARY | MPIC_WANTS_RESET | | |
3c10c9c4 KG |
50 | MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | |
51 | MPIC_SINGLE_DEST_CPU, | |
98384c6c KG |
52 | 0, 256, " MPIC "); |
53 | of_node_put(np); | |
54 | BUG_ON(mpic == NULL); | |
55 | ||
56 | mpic_init(mpic); | |
57 | ||
58 | #ifdef CONFIG_PPC_I8259 | |
59 | /* Initialize i8259 controller */ | |
60 | for_each_node_by_type(np, "interrupt-controller") | |
61 | if (of_device_is_compatible(np, "chrp,iic")) { | |
62 | cascade_node = np; | |
63 | break; | |
64 | } | |
65 | ||
66 | if (cascade_node == NULL) { | |
67 | printk(KERN_DEBUG "Could not find i8259 PIC\n"); | |
68 | return; | |
69 | } | |
70 | ||
71 | cascade_irq = irq_of_parse_and_map(cascade_node, 0); | |
72 | if (cascade_irq == NO_IRQ) { | |
73 | printk(KERN_ERR "Failed to map cascade interrupt\n"); | |
74 | return; | |
75 | } | |
76 | ||
77 | i8259_init(cascade_node, 0); | |
78 | of_node_put(cascade_node); | |
79 | ||
ec775d0e | 80 | irq_set_chained_handler(cascade_irq, mpc86xx_8259_cascade); |
98384c6c KG |
81 | #endif |
82 | } |