aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/86xx/pic.c
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2008-07-02 12:46:20 -0400
committerKumar Gala <galak@kernel.crashing.org>2008-07-14 08:55:41 -0400
commit98384c6cdd1fd593f399b6f879bae2cae70aad48 (patch)
tree02e289153fb30d0039b306db33fee92ee9be387d /arch/powerpc/platforms/86xx/pic.c
parenta5d28c8e64ff0bc77d38d9c19c6d8163e4c0ffaa (diff)
powerpc/86xx: Refactor pic init
Moved the pic initialization into its own common file and out of the board code. Also fixed the OF reference counting on the mpic node. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/platforms/86xx/pic.c')
-rw-r--r--arch/powerpc/platforms/86xx/pic.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/86xx/pic.c b/arch/powerpc/platforms/86xx/pic.c
new file mode 100644
index 000000000000..8881c5de500d
--- /dev/null
+++ b/arch/powerpc/platforms/86xx/pic.c
@@ -0,0 +1,78 @@
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
20static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
21{
22 unsigned int cascade_irq = i8259_irq();
23 if (cascade_irq != NO_IRQ)
24 generic_handle_irq(cascade_irq);
25 desc->chip->eoi(irq);
26}
27#endif /* CONFIG_PPC_I8259 */
28
29void __init mpc86xx_init_irq(void)
30{
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
38
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);
44
45 mpic = mpic_alloc(np, res.start,
46 MPIC_PRIMARY | MPIC_WANTS_RESET |
47 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
48 0, 256, " MPIC ");
49 of_node_put(np);
50 BUG_ON(mpic == NULL);
51
52 mpic_init(mpic);
53
54#ifdef CONFIG_PPC_I8259
55 /* Initialize i8259 controller */
56 for_each_node_by_type(np, "interrupt-controller")
57 if (of_device_is_compatible(np, "chrp,iic")) {
58 cascade_node = np;
59 break;
60 }
61
62 if (cascade_node == NULL) {
63 printk(KERN_DEBUG "Could not find i8259 PIC\n");
64 return;
65 }
66
67 cascade_irq = irq_of_parse_and_map(cascade_node, 0);
68 if (cascade_irq == NO_IRQ) {
69 printk(KERN_ERR "Failed to map cascade interrupt\n");
70 return;
71 }
72
73 i8259_init(cascade_node, 0);
74 of_node_put(cascade_node);
75
76 set_irq_chained_handler(cascade_irq, mpc86xx_8259_cascade);
77#endif
78}