aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-12-07 02:22:47 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2011-12-07 02:22:47 -0500
commit48b1bf86c308532669571e929619e98a8d88ef54 (patch)
treef37beaafc114ca07e9fc807ca8544a4b5d5e3386
parent4666ca2aa344105da0da3afda48d987c82261c05 (diff)
parent09dc34a95bfbc6062e1e7de0b96175480924aea8 (diff)
Merge branch 'mpic' into next
-rw-r--r--arch/powerpc/include/asm/mpic.h14
-rw-r--r--arch/powerpc/platforms/44x/iss4xx.c2
-rw-r--r--arch/powerpc/platforms/85xx/corenet_ds.c26
-rw-r--r--arch/powerpc/platforms/85xx/ksi8560.c23
-rw-r--r--arch/powerpc/platforms/85xx/mpc8536_ds.c22
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ads.c22
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_cds.c24
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ds.c30
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_mds.c26
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_rdb.c31
-rw-r--r--arch/powerpc/platforms/85xx/p1010rdb.c21
-rw-r--r--arch/powerpc/platforms/85xx/p1022_ds.c30
-rw-r--r--arch/powerpc/platforms/85xx/p1023_rds.c27
-rw-r--r--arch/powerpc/platforms/85xx/sbc8548.c25
-rw-r--r--arch/powerpc/platforms/85xx/sbc8560.c22
-rw-r--r--arch/powerpc/platforms/85xx/smp.c1
-rw-r--r--arch/powerpc/platforms/85xx/smp.h15
-rw-r--r--arch/powerpc/platforms/85xx/socrates.c20
-rw-r--r--arch/powerpc/platforms/85xx/stx_gp3.c22
-rw-r--r--arch/powerpc/platforms/85xx/tqm85xx.c22
-rw-r--r--arch/powerpc/platforms/85xx/xes_mpc85xx.c28
-rw-r--r--arch/powerpc/platforms/86xx/pic.c18
-rw-r--r--arch/powerpc/platforms/cell/setup.c25
-rw-r--r--arch/powerpc/platforms/chrp/setup.c3
-rw-r--r--arch/powerpc/platforms/embedded6xx/holly.c23
-rw-r--r--arch/powerpc/platforms/embedded6xx/linkstation.c20
-rw-r--r--arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c24
-rw-r--r--arch/powerpc/platforms/embedded6xx/storcenter.c26
-rw-r--r--arch/powerpc/platforms/maple/setup.c2
-rw-r--r--arch/powerpc/platforms/pasemi/setup.c4
-rw-r--r--arch/powerpc/platforms/powermac/pic.c46
-rw-r--r--arch/powerpc/platforms/pseries/setup.c3
-rw-r--r--arch/powerpc/sysdev/mpic.c199
33 files changed, 225 insertions, 621 deletions
diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index e6fae49e0b74..67b4d9837236 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -251,6 +251,9 @@ struct mpic_irq_save {
251/* The instance data of a given MPIC */ 251/* The instance data of a given MPIC */
252struct mpic 252struct mpic
253{ 253{
254 /* The OpenFirmware dt node for this MPIC */
255 struct device_node *node;
256
254 /* The remapper for this MPIC */ 257 /* The remapper for this MPIC */
255 struct irq_host *irqhost; 258 struct irq_host *irqhost;
256 259
@@ -293,6 +296,9 @@ struct mpic
293 /* Register access method */ 296 /* Register access method */
294 enum mpic_reg_type reg_type; 297 enum mpic_reg_type reg_type;
295 298
299 /* The physical base address of the MPIC */
300 phys_addr_t paddr;
301
296 /* The various ioremap'ed bases */ 302 /* The various ioremap'ed bases */
297 struct mpic_reg_bank gregs; 303 struct mpic_reg_bank gregs;
298 struct mpic_reg_bank tmregs; 304 struct mpic_reg_bank tmregs;
@@ -331,11 +337,11 @@ struct mpic
331 * Note setting any ID (leaving those bits to 0) means standard MPIC 337 * Note setting any ID (leaving those bits to 0) means standard MPIC
332 */ 338 */
333 339
334/* This is the primary controller, only that one has IPIs and 340/*
335 * has afinity control. A non-primary MPIC always uses CPU0 341 * This is a secondary ("chained") controller; it only uses the CPU0
336 * registers only 342 * registers. Primary controllers have IPIs and affinity control.
337 */ 343 */
338#define MPIC_PRIMARY 0x00000001 344#define MPIC_SECONDARY 0x00000001
339 345
340/* Set this for a big-endian MPIC */ 346/* Set this for a big-endian MPIC */
341#define MPIC_BIG_ENDIAN 0x00000002 347#define MPIC_BIG_ENDIAN 0x00000002
diff --git a/arch/powerpc/platforms/44x/iss4xx.c b/arch/powerpc/platforms/44x/iss4xx.c
index 19395f18b1db..5b8cdbb82f80 100644
--- a/arch/powerpc/platforms/44x/iss4xx.c
+++ b/arch/powerpc/platforms/44x/iss4xx.c
@@ -71,7 +71,7 @@ static void __init iss4xx_init_irq(void)
71 /* The MPIC driver will get everything it needs from the 71 /* The MPIC driver will get everything it needs from the
72 * device-tree, just pass 0 to all arguments 72 * device-tree, just pass 0 to all arguments
73 */ 73 */
74 struct mpic *mpic = mpic_alloc(np, 0, MPIC_PRIMARY, 0, 0, 74 struct mpic *mpic = mpic_alloc(np, 0, 0, 0, 0,
75 " MPIC "); 75 " MPIC ");
76 BUG_ON(mpic == NULL); 76 BUG_ON(mpic == NULL);
77 mpic_init(mpic); 77 mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index c48b66187dda..07e3e6c47371 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -31,32 +31,18 @@
31#include <linux/of_platform.h> 31#include <linux/of_platform.h>
32#include <sysdev/fsl_soc.h> 32#include <sysdev/fsl_soc.h>
33#include <sysdev/fsl_pci.h> 33#include <sysdev/fsl_pci.h>
34#include "smp.h"
34 35
35void __init corenet_ds_pic_init(void) 36void __init corenet_ds_pic_init(void)
36{ 37{
37 struct mpic *mpic; 38 struct mpic *mpic;
38 struct resource r; 39 unsigned int flags = MPIC_BIG_ENDIAN |
39 struct device_node *np = NULL;
40 unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
41 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU; 40 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
42 41
43 np = of_find_node_by_type(np, "open-pic");
44
45 if (np == NULL) {
46 printk(KERN_ERR "Could not find open-pic node\n");
47 return;
48 }
49
50 if (of_address_to_resource(np, 0, &r)) {
51 printk(KERN_ERR "Failed to map mpic register space\n");
52 of_node_put(np);
53 return;
54 }
55
56 if (ppc_md.get_irq == mpic_get_coreint_irq) 42 if (ppc_md.get_irq == mpic_get_coreint_irq)
57 flags |= MPIC_ENABLE_COREINT; 43 flags |= MPIC_ENABLE_COREINT;
58 44
59 mpic = mpic_alloc(np, r.start, flags, 0, 256, " OpenPIC "); 45 mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC ");
60 BUG_ON(mpic == NULL); 46 BUG_ON(mpic == NULL);
61 47
62 mpic_init(mpic); 48 mpic_init(mpic);
@@ -65,10 +51,6 @@ void __init corenet_ds_pic_init(void)
65/* 51/*
66 * Setup the architecture 52 * Setup the architecture
67 */ 53 */
68#ifdef CONFIG_SMP
69void __init mpc85xx_smp_init(void);
70#endif
71
72void __init corenet_ds_setup_arch(void) 54void __init corenet_ds_setup_arch(void)
73{ 55{
74#ifdef CONFIG_PCI 56#ifdef CONFIG_PCI
@@ -77,9 +59,7 @@ void __init corenet_ds_setup_arch(void)
77#endif 59#endif
78 dma_addr_t max = 0xffffffff; 60 dma_addr_t max = 0xffffffff;
79 61
80#ifdef CONFIG_SMP
81 mpc85xx_smp_init(); 62 mpc85xx_smp_init();
82#endif
83 63
84#ifdef CONFIG_PCI 64#ifdef CONFIG_PCI
85 for_each_node_by_type(np, "pci") { 65 for_each_node_by_type(np, "pci") {
diff --git a/arch/powerpc/platforms/85xx/ksi8560.c b/arch/powerpc/platforms/85xx/ksi8560.c
index 0f3e68832657..20f75d7819c6 100644
--- a/arch/powerpc/platforms/85xx/ksi8560.c
+++ b/arch/powerpc/platforms/85xx/ksi8560.c
@@ -57,29 +57,10 @@ static void machine_restart(char *cmd)
57 57
58static void __init ksi8560_pic_init(void) 58static void __init ksi8560_pic_init(void)
59{ 59{
60 struct mpic *mpic; 60 struct mpic *mpic = mpic_alloc(NULL, 0,
61 struct resource r; 61 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
62 struct device_node *np;
63
64 np = of_find_node_by_type(NULL, "open-pic");
65
66 if (np == NULL) {
67 printk(KERN_ERR "Could not find open-pic node\n");
68 return;
69 }
70
71 if (of_address_to_resource(np, 0, &r)) {
72 printk(KERN_ERR "Could not map mpic register space\n");
73 of_node_put(np);
74 return;
75 }
76
77 mpic = mpic_alloc(np, r.start,
78 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
79 0, 256, " OpenPIC "); 62 0, 256, " OpenPIC ");
80 BUG_ON(mpic == NULL); 63 BUG_ON(mpic == NULL);
81 of_node_put(np);
82
83 mpic_init(mpic); 64 mpic_init(mpic);
84 65
85 mpc85xx_cpm2_pic_init(); 66 mpc85xx_cpm2_pic_init();
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 9ee6455c2f1e..cf266826682e 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -36,29 +36,11 @@
36 36
37void __init mpc8536_ds_pic_init(void) 37void __init mpc8536_ds_pic_init(void)
38{ 38{
39 struct mpic *mpic; 39 struct mpic *mpic = mpic_alloc(NULL, 0,
40 struct resource r; 40 MPIC_WANTS_RESET |
41 struct device_node *np;
42
43 np = of_find_node_by_type(NULL, "open-pic");
44 if (np == NULL) {
45 printk(KERN_ERR "Could not find open-pic node\n");
46 return;
47 }
48
49 if (of_address_to_resource(np, 0, &r)) {
50 printk(KERN_ERR "Failed to map mpic register space\n");
51 of_node_put(np);
52 return;
53 }
54
55 mpic = mpic_alloc(np, r.start,
56 MPIC_PRIMARY | MPIC_WANTS_RESET |
57 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS, 41 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
58 0, 256, " OpenPIC "); 42 0, 256, " OpenPIC ");
59 BUG_ON(mpic == NULL); 43 BUG_ON(mpic == NULL);
60 of_node_put(np);
61
62 mpic_init(mpic); 44 mpic_init(mpic);
63} 45}
64 46
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 986554b74d3f..3bebb5173bfc 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -50,28 +50,10 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
50 50
51static void __init mpc85xx_ads_pic_init(void) 51static void __init mpc85xx_ads_pic_init(void)
52{ 52{
53 struct mpic *mpic; 53 struct mpic *mpic = mpic_alloc(NULL, 0,
54 struct resource r; 54 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
55 struct device_node *np = NULL;
56
57 np = of_find_node_by_type(np, "open-pic");
58 if (!np) {
59 printk(KERN_ERR "Could not find open-pic node\n");
60 return;
61 }
62
63 if (of_address_to_resource(np, 0, &r)) {
64 printk(KERN_ERR "Could not map mpic register space\n");
65 of_node_put(np);
66 return;
67 }
68
69 mpic = mpic_alloc(np, r.start,
70 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
71 0, 256, " OpenPIC "); 55 0, 256, " OpenPIC ");
72 BUG_ON(mpic == NULL); 56 BUG_ON(mpic == NULL);
73 of_node_put(np);
74
75 mpic_init(mpic); 57 mpic_init(mpic);
76 58
77 mpc85xx_cpm2_pic_init(); 59 mpc85xx_cpm2_pic_init();
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index d993b66f1abf..40f03da616a9 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -188,30 +188,10 @@ static struct irqaction mpc85xxcds_8259_irqaction = {
188static void __init mpc85xx_cds_pic_init(void) 188static void __init mpc85xx_cds_pic_init(void)
189{ 189{
190 struct mpic *mpic; 190 struct mpic *mpic;
191 struct resource r; 191 mpic = mpic_alloc(NULL, 0,
192 struct device_node *np = NULL; 192 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
193
194 np = of_find_node_by_type(np, "open-pic");
195
196 if (np == NULL) {
197 printk(KERN_ERR "Could not find open-pic node\n");
198 return;
199 }
200
201 if (of_address_to_resource(np, 0, &r)) {
202 printk(KERN_ERR "Failed to map mpic register space\n");
203 of_node_put(np);
204 return;
205 }
206
207 mpic = mpic_alloc(np, r.start,
208 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
209 0, 256, " OpenPIC "); 193 0, 256, " OpenPIC ");
210 BUG_ON(mpic == NULL); 194 BUG_ON(mpic == NULL);
211
212 /* Return the mpic node */
213 of_node_put(np);
214
215 mpic_init(mpic); 195 mpic_init(mpic);
216} 196}
217 197
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 2113120c5a7d..eefbb91e1d61 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -35,6 +35,7 @@
35 35
36#include <sysdev/fsl_soc.h> 36#include <sysdev/fsl_soc.h>
37#include <sysdev/fsl_pci.h> 37#include <sysdev/fsl_pci.h>
38#include "smp.h"
38 39
39#include "mpc85xx.h" 40#include "mpc85xx.h"
40 41
@@ -62,43 +63,27 @@ static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
62void __init mpc85xx_ds_pic_init(void) 63void __init mpc85xx_ds_pic_init(void)
63{ 64{
64 struct mpic *mpic; 65 struct mpic *mpic;
65 struct resource r;
66 struct device_node *np;
67#ifdef CONFIG_PPC_I8259 66#ifdef CONFIG_PPC_I8259
67 struct device_node *np;
68 struct device_node *cascade_node = NULL; 68 struct device_node *cascade_node = NULL;
69 int cascade_irq; 69 int cascade_irq;
70#endif 70#endif
71 unsigned long root = of_get_flat_dt_root(); 71 unsigned long root = of_get_flat_dt_root();
72 72
73 np = of_find_node_by_type(NULL, "open-pic");
74 if (np == NULL) {
75 printk(KERN_ERR "Could not find open-pic node\n");
76 return;
77 }
78
79 if (of_address_to_resource(np, 0, &r)) {
80 printk(KERN_ERR "Failed to map mpic register space\n");
81 of_node_put(np);
82 return;
83 }
84
85 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) { 73 if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
86 mpic = mpic_alloc(np, r.start, 74 mpic = mpic_alloc(NULL, 0,
87 MPIC_PRIMARY |
88 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | 75 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
89 MPIC_SINGLE_DEST_CPU, 76 MPIC_SINGLE_DEST_CPU,
90 0, 256, " OpenPIC "); 77 0, 256, " OpenPIC ");
91 } else { 78 } else {
92 mpic = mpic_alloc(np, r.start, 79 mpic = mpic_alloc(NULL, 0,
93 MPIC_PRIMARY | MPIC_WANTS_RESET | 80 MPIC_WANTS_RESET |
94 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | 81 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
95 MPIC_SINGLE_DEST_CPU, 82 MPIC_SINGLE_DEST_CPU,
96 0, 256, " OpenPIC "); 83 0, 256, " OpenPIC ");
97 } 84 }
98 85
99 BUG_ON(mpic == NULL); 86 BUG_ON(mpic == NULL);
100 of_node_put(np);
101
102 mpic_init(mpic); 87 mpic_init(mpic);
103 88
104#ifdef CONFIG_PPC_I8259 89#ifdef CONFIG_PPC_I8259
@@ -154,9 +139,6 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
154/* 139/*
155 * Setup the architecture 140 * Setup the architecture
156 */ 141 */
157#ifdef CONFIG_SMP
158extern void __init mpc85xx_smp_init(void);
159#endif
160static void __init mpc85xx_ds_setup_arch(void) 142static void __init mpc85xx_ds_setup_arch(void)
161{ 143{
162#ifdef CONFIG_PCI 144#ifdef CONFIG_PCI
@@ -189,9 +171,7 @@ static void __init mpc85xx_ds_setup_arch(void)
189 ppc_md.pci_exclude_device = mpc85xx_exclude_device; 171 ppc_md.pci_exclude_device = mpc85xx_exclude_device;
190#endif 172#endif
191 173
192#ifdef CONFIG_SMP
193 mpc85xx_smp_init(); 174 mpc85xx_smp_init();
194#endif
195 175
196#ifdef CONFIG_SWIOTLB 176#ifdef CONFIG_SWIOTLB
197 if (memblock_end_of_DRAM() > max) { 177 if (memblock_end_of_DRAM() > max) {
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 495cfd988c1a..1d15a0cd2c82 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -51,6 +51,7 @@
51#include <asm/qe_ic.h> 51#include <asm/qe_ic.h>
52#include <asm/mpic.h> 52#include <asm/mpic.h>
53#include <asm/swiotlb.h> 53#include <asm/swiotlb.h>
54#include "smp.h"
54 55
55#include "mpc85xx.h" 56#include "mpc85xx.h"
56 57
@@ -155,10 +156,6 @@ static int mpc8568_mds_phy_fixups(struct phy_device *phydev)
155 * Setup the architecture 156 * Setup the architecture
156 * 157 *
157 */ 158 */
158#ifdef CONFIG_SMP
159extern void __init mpc85xx_smp_init(void);
160#endif
161
162#ifdef CONFIG_QUICC_ENGINE 159#ifdef CONFIG_QUICC_ENGINE
163static void __init mpc85xx_mds_reset_ucc_phys(void) 160static void __init mpc85xx_mds_reset_ucc_phys(void)
164{ 161{
@@ -363,9 +360,7 @@ static void __init mpc85xx_mds_setup_arch(void)
363 } 360 }
364#endif 361#endif
365 362
366#ifdef CONFIG_SMP
367 mpc85xx_smp_init(); 363 mpc85xx_smp_init();
368#endif
369 364
370 mpc85xx_mds_qe_init(); 365 mpc85xx_mds_qe_init();
371 366
@@ -439,26 +434,11 @@ machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
439 434
440static void __init mpc85xx_mds_pic_init(void) 435static void __init mpc85xx_mds_pic_init(void)
441{ 436{
442 struct mpic *mpic; 437 struct mpic *mpic = mpic_alloc(NULL, 0,
443 struct resource r; 438 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
444 struct device_node *np = NULL;
445
446 np = of_find_node_by_type(NULL, "open-pic");
447 if (!np)
448 return;
449
450 if (of_address_to_resource(np, 0, &r)) {
451 printk(KERN_ERR "Failed to map mpic register space\n");
452 of_node_put(np);
453 return;
454 }
455
456 mpic = mpic_alloc(np, r.start,
457 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
458 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU, 439 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
459 0, 256, " OpenPIC "); 440 0, 256, " OpenPIC ");
460 BUG_ON(mpic == NULL); 441 BUG_ON(mpic == NULL);
461 of_node_put(np);
462 442
463 mpic_init(mpic); 443 mpic_init(mpic);
464 mpc85xx_mds_qeic_init(); 444 mpc85xx_mds_qeic_init();
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 9feccbbd4d96..ccf520e890be 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -29,6 +29,7 @@
29 29
30#include <sysdev/fsl_soc.h> 30#include <sysdev/fsl_soc.h>
31#include <sysdev/fsl_pci.h> 31#include <sysdev/fsl_pci.h>
32#include "smp.h"
32 33
33#include "mpc85xx.h" 34#include "mpc85xx.h"
34 35
@@ -44,49 +45,28 @@
44void __init mpc85xx_rdb_pic_init(void) 45void __init mpc85xx_rdb_pic_init(void)
45{ 46{
46 struct mpic *mpic; 47 struct mpic *mpic;
47 struct resource r;
48 struct device_node *np;
49 unsigned long root = of_get_flat_dt_root(); 48 unsigned long root = of_get_flat_dt_root();
50 49
51 np = of_find_node_by_type(NULL, "open-pic");
52 if (np == NULL) {
53 printk(KERN_ERR "Could not find open-pic node\n");
54 return;
55 }
56
57 if (of_address_to_resource(np, 0, &r)) {
58 printk(KERN_ERR "Failed to map mpic register space\n");
59 of_node_put(np);
60 return;
61 }
62
63 if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) { 50 if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
64 mpic = mpic_alloc(np, r.start, 51 mpic = mpic_alloc(NULL, 0,
65 MPIC_PRIMARY |
66 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | 52 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
67 MPIC_SINGLE_DEST_CPU, 53 MPIC_SINGLE_DEST_CPU,
68 0, 256, " OpenPIC "); 54 0, 256, " OpenPIC ");
69 } else { 55 } else {
70 mpic = mpic_alloc(np, r.start, 56 mpic = mpic_alloc(NULL, 0,
71 MPIC_PRIMARY | MPIC_WANTS_RESET | 57 MPIC_WANTS_RESET |
72 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | 58 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
73 MPIC_SINGLE_DEST_CPU, 59 MPIC_SINGLE_DEST_CPU,
74 0, 256, " OpenPIC "); 60 0, 256, " OpenPIC ");
75 } 61 }
76 62
77 BUG_ON(mpic == NULL); 63 BUG_ON(mpic == NULL);
78 of_node_put(np);
79
80 mpic_init(mpic); 64 mpic_init(mpic);
81
82} 65}
83 66
84/* 67/*
85 * Setup the architecture 68 * Setup the architecture
86 */ 69 */
87#ifdef CONFIG_SMP
88extern void __init mpc85xx_smp_init(void);
89#endif
90static void __init mpc85xx_rdb_setup_arch(void) 70static void __init mpc85xx_rdb_setup_arch(void)
91{ 71{
92#ifdef CONFIG_PCI 72#ifdef CONFIG_PCI
@@ -104,10 +84,7 @@ static void __init mpc85xx_rdb_setup_arch(void)
104 84
105#endif 85#endif
106 86
107#ifdef CONFIG_SMP
108 mpc85xx_smp_init(); 87 mpc85xx_smp_init();
109#endif
110
111 printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n"); 88 printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n");
112} 89}
113 90
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index 2f479f88c1a0..894f1e84fef8 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -32,24 +32,9 @@
32 32
33void __init p1010_rdb_pic_init(void) 33void __init p1010_rdb_pic_init(void)
34{ 34{
35 struct mpic *mpic; 35 struct mpic *mpic = mpic_alloc(NULL, 0,
36 struct resource r; 36 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
37 struct device_node *np; 37 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
38
39 np = of_find_node_by_type(NULL, "open-pic");
40 if (np == NULL) {
41 printk(KERN_ERR "Could not find open-pic node\n");
42 return;
43 }
44
45 if (of_address_to_resource(np, 0, &r)) {
46 printk(KERN_ERR "Failed to map mpic register space\n");
47 of_node_put(np);
48 return;
49 }
50
51 mpic = mpic_alloc(np, r.start, MPIC_PRIMARY | MPIC_WANTS_RESET |
52 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
53 0, 256, " OpenPIC "); 38 0, 256, " OpenPIC ");
54 39
55 BUG_ON(mpic == NULL); 40 BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 2bf4342ab656..bb3d84f4046f 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -26,6 +26,7 @@
26#include <sysdev/fsl_soc.h> 26#include <sysdev/fsl_soc.h>
27#include <sysdev/fsl_pci.h> 27#include <sysdev/fsl_pci.h>
28#include <asm/fsl_guts.h> 28#include <asm/fsl_guts.h>
29#include "smp.h"
29 30
30#include "mpc85xx.h" 31#include "mpc85xx.h"
31 32
@@ -240,38 +241,15 @@ p1022ds_valid_monitor_port(enum fsl_diu_monitor_port port)
240 241
241void __init p1022_ds_pic_init(void) 242void __init p1022_ds_pic_init(void)
242{ 243{
243 struct mpic *mpic; 244 struct mpic *mpic = mpic_alloc(NULL, 0,
244 struct resource r; 245 MPIC_WANTS_RESET |
245 struct device_node *np;
246
247 np = of_find_node_by_type(NULL, "open-pic");
248 if (!np) {
249 pr_err("Could not find open-pic node\n");
250 return;
251 }
252
253 if (of_address_to_resource(np, 0, &r)) {
254 pr_err("Failed to map mpic register space\n");
255 of_node_put(np);
256 return;
257 }
258
259 mpic = mpic_alloc(np, r.start,
260 MPIC_PRIMARY | MPIC_WANTS_RESET |
261 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | 246 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
262 MPIC_SINGLE_DEST_CPU, 247 MPIC_SINGLE_DEST_CPU,
263 0, 256, " OpenPIC "); 248 0, 256, " OpenPIC ");
264
265 BUG_ON(mpic == NULL); 249 BUG_ON(mpic == NULL);
266 of_node_put(np);
267
268 mpic_init(mpic); 250 mpic_init(mpic);
269} 251}
270 252
271#ifdef CONFIG_SMP
272void __init mpc85xx_smp_init(void);
273#endif
274
275/* 253/*
276 * Setup the architecture 254 * Setup the architecture
277 */ 255 */
@@ -311,9 +289,7 @@ static void __init p1022_ds_setup_arch(void)
311 diu_ops.valid_monitor_port = p1022ds_valid_monitor_port; 289 diu_ops.valid_monitor_port = p1022ds_valid_monitor_port;
312#endif 290#endif
313 291
314#ifdef CONFIG_SMP
315 mpc85xx_smp_init(); 292 mpc85xx_smp_init();
316#endif
317 293
318#ifdef CONFIG_SWIOTLB 294#ifdef CONFIG_SWIOTLB
319 if (memblock_end_of_DRAM() > max) { 295 if (memblock_end_of_DRAM() > max) {
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index e76c4dceee23..e92a714d2f36 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -30,6 +30,7 @@
30#include <asm/prom.h> 30#include <asm/prom.h>
31#include <asm/udbg.h> 31#include <asm/udbg.h>
32#include <asm/mpic.h> 32#include <asm/mpic.h>
33#include "smp.h"
33 34
34#include <sysdev/fsl_soc.h> 35#include <sysdev/fsl_soc.h>
35#include <sysdev/fsl_pci.h> 36#include <sysdev/fsl_pci.h>
@@ -41,10 +42,6 @@
41 * Setup the architecture 42 * Setup the architecture
42 * 43 *
43 */ 44 */
44#ifdef CONFIG_SMP
45void __init mpc85xx_smp_init(void);
46#endif
47
48static void __init mpc85xx_rds_setup_arch(void) 45static void __init mpc85xx_rds_setup_arch(void)
49{ 46{
50 struct device_node *np; 47 struct device_node *np;
@@ -89,33 +86,15 @@ static void __init mpc85xx_rds_setup_arch(void)
89 fsl_add_bridge(np, 0); 86 fsl_add_bridge(np, 0);
90#endif 87#endif
91 88
92#ifdef CONFIG_SMP
93 mpc85xx_smp_init(); 89 mpc85xx_smp_init();
94#endif
95} 90}
96 91
97machine_device_initcall(p1023_rds, mpc85xx_common_publish_devices); 92machine_device_initcall(p1023_rds, mpc85xx_common_publish_devices);
98 93
99static void __init mpc85xx_rds_pic_init(void) 94static void __init mpc85xx_rds_pic_init(void)
100{ 95{
101 struct mpic *mpic; 96 struct mpic *mpic = mpic_alloc(NULL, 0,
102 struct resource r; 97 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
103 struct device_node *np = NULL;
104
105 np = of_find_node_by_type(NULL, "open-pic");
106 if (!np) {
107 printk(KERN_ERR "Could not find open-pic node\n");
108 return;
109 }
110
111 if (of_address_to_resource(np, 0, &r)) {
112 printk(KERN_ERR "Failed to map mpic register space\n");
113 of_node_put(np);
114 return;
115 }
116
117 mpic = mpic_alloc(np, r.start,
118 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
119 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU, 98 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
120 0, 256, " OpenPIC "); 99 0, 256, " OpenPIC ");
121 100
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index 845ed3b89462..184a50784617 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -54,31 +54,10 @@ static int sbc_rev;
54 54
55static void __init sbc8548_pic_init(void) 55static void __init sbc8548_pic_init(void)
56{ 56{
57 struct mpic *mpic; 57 struct mpic *mpic = mpic_alloc(NULL, 0,
58 struct resource r; 58 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
59 struct device_node *np = NULL;
60
61 np = of_find_node_by_type(np, "open-pic");
62
63 if (np == NULL) {
64 printk(KERN_ERR "Could not find open-pic node\n");
65 return;
66 }
67
68 if (of_address_to_resource(np, 0, &r)) {
69 printk(KERN_ERR "Failed to map mpic register space\n");
70 of_node_put(np);
71 return;
72 }
73
74 mpic = mpic_alloc(np, r.start,
75 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
76 0, 256, " OpenPIC "); 59 0, 256, " OpenPIC ");
77 BUG_ON(mpic == NULL); 60 BUG_ON(mpic == NULL);
78
79 /* Return the mpic node */
80 of_node_put(np);
81
82 mpic_init(mpic); 61 mpic_init(mpic);
83} 62}
84 63
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index e9a7ed228d73..940752e93051 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -41,28 +41,10 @@
41 41
42static void __init sbc8560_pic_init(void) 42static void __init sbc8560_pic_init(void)
43{ 43{
44 struct mpic *mpic; 44 struct mpic *mpic = mpic_alloc(NULL, 0,
45 struct resource r; 45 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
46 struct device_node *np = NULL;
47
48 np = of_find_node_by_type(np, "open-pic");
49 if (!np) {
50 printk(KERN_ERR "Could not find open-pic node\n");
51 return;
52 }
53
54 if (of_address_to_resource(np, 0, &r)) {
55 printk(KERN_ERR "Could not map mpic register space\n");
56 of_node_put(np);
57 return;
58 }
59
60 mpic = mpic_alloc(np, r.start,
61 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
62 0, 256, " OpenPIC "); 46 0, 256, " OpenPIC ");
63 BUG_ON(mpic == NULL); 47 BUG_ON(mpic == NULL);
64 of_node_put(np);
65
66 mpic_init(mpic); 48 mpic_init(mpic);
67 49
68 mpc85xx_cpm2_pic_init(); 50 mpc85xx_cpm2_pic_init();
diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index 2df4785ffd4e..ff4249044a3c 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -27,6 +27,7 @@
27 27
28#include <sysdev/fsl_soc.h> 28#include <sysdev/fsl_soc.h>
29#include <sysdev/mpic.h> 29#include <sysdev/mpic.h>
30#include "smp.h"
30 31
31extern void __early_start(void); 32extern void __early_start(void);
32 33
diff --git a/arch/powerpc/platforms/85xx/smp.h b/arch/powerpc/platforms/85xx/smp.h
new file mode 100644
index 000000000000..e2b44933ff19
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/smp.h
@@ -0,0 +1,15 @@
1#ifndef POWERPC_85XX_SMP_H_
2#define POWERPC_85XX_SMP_H_ 1
3
4#include <linux/init.h>
5
6#ifdef CONFIG_SMP
7void __init mpc85xx_smp_init(void);
8#else
9static inline void mpc85xx_smp_init(void)
10{
11 /* Nothing to do */
12}
13#endif
14
15#endif /* not POWERPC_85XX_SMP_H_ */
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index fec496ad79c0..18f635906b27 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -46,28 +46,12 @@
46 46
47static void __init socrates_pic_init(void) 47static void __init socrates_pic_init(void)
48{ 48{
49 struct mpic *mpic;
50 struct resource r;
51 struct device_node *np; 49 struct device_node *np;
52 50
53 np = of_find_node_by_type(NULL, "open-pic"); 51 struct mpic *mpic = mpic_alloc(NULL, 0,
54 if (!np) { 52 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
55 printk(KERN_ERR "Could not find open-pic node\n");
56 return;
57 }
58
59 if (of_address_to_resource(np, 0, &r)) {
60 printk(KERN_ERR "Could not map mpic register space\n");
61 of_node_put(np);
62 return;
63 }
64
65 mpic = mpic_alloc(np, r.start,
66 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
67 0, 256, " OpenPIC "); 53 0, 256, " OpenPIC ");
68 BUG_ON(mpic == NULL); 54 BUG_ON(mpic == NULL);
69 of_node_put(np);
70
71 mpic_init(mpic); 55 mpic_init(mpic);
72 56
73 np = of_find_compatible_node(NULL, NULL, "abb,socrates-fpga-pic"); 57 np = of_find_compatible_node(NULL, NULL, "abb,socrates-fpga-pic");
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index b44c936c2653..e9e5234b4e76 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -48,28 +48,10 @@
48 48
49static void __init stx_gp3_pic_init(void) 49static void __init stx_gp3_pic_init(void)
50{ 50{
51 struct mpic *mpic; 51 struct mpic *mpic = mpic_alloc(NULL, 0,
52 struct resource r; 52 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
53 struct device_node *np;
54
55 np = of_find_node_by_type(NULL, "open-pic");
56 if (!np) {
57 printk(KERN_ERR "Could not find open-pic node\n");
58 return;
59 }
60
61 if (of_address_to_resource(np, 0, &r)) {
62 printk(KERN_ERR "Could not map mpic register space\n");
63 of_node_put(np);
64 return;
65 }
66
67 mpic = mpic_alloc(np, r.start,
68 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
69 0, 256, " OpenPIC "); 53 0, 256, " OpenPIC ");
70 BUG_ON(mpic == NULL); 54 BUG_ON(mpic == NULL);
71 of_node_put(np);
72
73 mpic_init(mpic); 55 mpic_init(mpic);
74 56
75 mpc85xx_cpm2_pic_init(); 57 mpc85xx_cpm2_pic_init();
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 2418bf8d074b..bf7c89fb75bb 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -46,28 +46,10 @@
46 46
47static void __init tqm85xx_pic_init(void) 47static void __init tqm85xx_pic_init(void)
48{ 48{
49 struct mpic *mpic; 49 struct mpic *mpic = mpic_alloc(NULL, 0,
50 struct resource r; 50 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
51 struct device_node *np;
52
53 np = of_find_node_by_type(NULL, "open-pic");
54 if (!np) {
55 printk(KERN_ERR "Could not find open-pic node\n");
56 return;
57 }
58
59 if (of_address_to_resource(np, 0, &r)) {
60 printk(KERN_ERR "Could not map mpic register space\n");
61 of_node_put(np);
62 return;
63 }
64
65 mpic = mpic_alloc(np, r.start,
66 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
67 0, 256, " OpenPIC "); 51 0, 256, " OpenPIC ");
68 BUG_ON(mpic == NULL); 52 BUG_ON(mpic == NULL);
69 of_node_put(np);
70
71 mpic_init(mpic); 53 mpic_init(mpic);
72 54
73 mpc85xx_cpm2_pic_init(); 55 mpc85xx_cpm2_pic_init();
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index 4632c1b27da7..3a69f8b77de6 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -32,6 +32,7 @@
32 32
33#include <sysdev/fsl_soc.h> 33#include <sysdev/fsl_soc.h>
34#include <sysdev/fsl_pci.h> 34#include <sysdev/fsl_pci.h>
35#include "smp.h"
35 36
36#include "mpc85xx.h" 37#include "mpc85xx.h"
37 38
@@ -42,29 +43,11 @@
42 43
43void __init xes_mpc85xx_pic_init(void) 44void __init xes_mpc85xx_pic_init(void)
44{ 45{
45 struct mpic *mpic; 46 struct mpic *mpic = mpic_alloc(NULL, 0,
46 struct resource r; 47 MPIC_WANTS_RESET |
47 struct device_node *np;
48
49 np = of_find_node_by_type(NULL, "open-pic");
50 if (np == NULL) {
51 printk(KERN_ERR "Could not find open-pic node\n");
52 return;
53 }
54
55 if (of_address_to_resource(np, 0, &r)) {
56 printk(KERN_ERR "Failed to map mpic register space\n");
57 of_node_put(np);
58 return;
59 }
60
61 mpic = mpic_alloc(np, r.start,
62 MPIC_PRIMARY | MPIC_WANTS_RESET |
63 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS, 48 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
64 0, 256, " OpenPIC "); 49 0, 256, " OpenPIC ");
65 BUG_ON(mpic == NULL); 50 BUG_ON(mpic == NULL);
66 of_node_put(np);
67
68 mpic_init(mpic); 51 mpic_init(mpic);
69} 52}
70 53
@@ -138,9 +121,6 @@ static int primary_phb_addr;
138/* 121/*
139 * Setup the architecture 122 * Setup the architecture
140 */ 123 */
141#ifdef CONFIG_SMP
142extern void __init mpc85xx_smp_init(void);
143#endif
144static void __init xes_mpc85xx_setup_arch(void) 124static void __init xes_mpc85xx_setup_arch(void)
145{ 125{
146#ifdef CONFIG_PCI 126#ifdef CONFIG_PCI
@@ -174,9 +154,7 @@ static void __init xes_mpc85xx_setup_arch(void)
174 } 154 }
175#endif 155#endif
176 156
177#ifdef CONFIG_SMP
178 mpc85xx_smp_init(); 157 mpc85xx_smp_init();
179#endif
180} 158}
181 159
182machine_device_initcall(xes_mpc8572, mpc85xx_common_publish_devices); 160machine_device_initcall(xes_mpc8572, mpc85xx_common_publish_devices);
diff --git a/arch/powerpc/platforms/86xx/pic.c b/arch/powerpc/platforms/86xx/pic.c
index 8ef8960abda6..52bbfa031531 100644
--- a/arch/powerpc/platforms/86xx/pic.c
+++ b/arch/powerpc/platforms/86xx/pic.c
@@ -31,26 +31,16 @@ static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
31 31
32void __init mpc86xx_init_irq(void) 32void __init mpc86xx_init_irq(void)
33{ 33{
34 struct mpic *mpic;
35 struct device_node *np;
36 struct resource res;
37#ifdef CONFIG_PPC_I8259 34#ifdef CONFIG_PPC_I8259
35 struct device_node *np;
38 struct device_node *cascade_node = NULL; 36 struct device_node *cascade_node = NULL;
39 int cascade_irq; 37 int cascade_irq;
40#endif 38#endif
41 39
42 /* Determine PIC address. */ 40 struct mpic *mpic = mpic_alloc(NULL, 0,
43 np = of_find_node_by_type(NULL, "open-pic"); 41 MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
44 if (np == NULL) 42 MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
45 return;
46 of_address_to_resource(np, 0, &res);
47
48 mpic = mpic_alloc(np, res.start,
49 MPIC_PRIMARY | MPIC_WANTS_RESET |
50 MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
51 MPIC_SINGLE_DEST_CPU,
52 0, 256, " MPIC "); 43 0, 256, " MPIC ");
53 of_node_put(np);
54 BUG_ON(mpic == NULL); 44 BUG_ON(mpic == NULL);
55 45
56 mpic_init(mpic); 46 mpic_init(mpic);
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index 0fc9b7256126..62002a7edfed 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -184,24 +184,10 @@ static int __init cell_publish_devices(void)
184} 184}
185machine_subsys_initcall(cell, cell_publish_devices); 185machine_subsys_initcall(cell, cell_publish_devices);
186 186
187static void cell_mpic_cascade(unsigned int irq, struct irq_desc *desc)
188{
189 struct irq_chip *chip = irq_desc_get_chip(desc);
190 struct mpic *mpic = irq_desc_get_handler_data(desc);
191 unsigned int virq;
192
193 virq = mpic_get_one_irq(mpic);
194 if (virq != NO_IRQ)
195 generic_handle_irq(virq);
196
197 chip->irq_eoi(&desc->irq_data);
198}
199
200static void __init mpic_init_IRQ(void) 187static void __init mpic_init_IRQ(void)
201{ 188{
202 struct device_node *dn; 189 struct device_node *dn;
203 struct mpic *mpic; 190 struct mpic *mpic;
204 unsigned int virq;
205 191
206 for (dn = NULL; 192 for (dn = NULL;
207 (dn = of_find_node_by_name(dn, "interrupt-controller"));) { 193 (dn = of_find_node_by_name(dn, "interrupt-controller"));) {
@@ -211,19 +197,10 @@ static void __init mpic_init_IRQ(void)
211 /* The MPIC driver will get everything it needs from the 197 /* The MPIC driver will get everything it needs from the
212 * device-tree, just pass 0 to all arguments 198 * device-tree, just pass 0 to all arguments
213 */ 199 */
214 mpic = mpic_alloc(dn, 0, 0, 0, 0, " MPIC "); 200 mpic = mpic_alloc(dn, 0, MPIC_SECONDARY, 0, 0, " MPIC ");
215 if (mpic == NULL) 201 if (mpic == NULL)
216 continue; 202 continue;
217 mpic_init(mpic); 203 mpic_init(mpic);
218
219 virq = irq_of_parse_and_map(dn, 0);
220 if (virq == NO_IRQ)
221 continue;
222
223 printk(KERN_INFO "%s : hooking up to IRQ %d\n",
224 dn->full_name, virq);
225 irq_set_handler_data(virq, mpic);
226 irq_set_chained_handler(virq, cell_mpic_cascade);
227 } 204 }
228} 205}
229 206
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index 122786498419..f1f17bb2c33c 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -435,8 +435,7 @@ static void __init chrp_find_openpic(void)
435 if (len > 1) 435 if (len > 1)
436 isu_size = iranges[3]; 436 isu_size = iranges[3];
437 437
438 chrp_mpic = mpic_alloc(np, opaddr, MPIC_PRIMARY, 438 chrp_mpic = mpic_alloc(np, opaddr, 0, isu_size, 0, " MPIC ");
439 isu_size, 0, " MPIC ");
440 if (chrp_mpic == NULL) { 439 if (chrp_mpic == NULL) {
441 printk(KERN_ERR "Failed to allocate MPIC structure\n"); 440 printk(KERN_ERR "Failed to allocate MPIC structure\n");
442 goto bail; 441 goto bail;
diff --git a/arch/powerpc/platforms/embedded6xx/holly.c b/arch/powerpc/platforms/embedded6xx/holly.c
index 2e9bcf6444c8..9cfcf20c0560 100644
--- a/arch/powerpc/platforms/embedded6xx/holly.c
+++ b/arch/powerpc/platforms/embedded6xx/holly.c
@@ -148,30 +148,14 @@ static void __init holly_setup_arch(void)
148static void __init holly_init_IRQ(void) 148static void __init holly_init_IRQ(void)
149{ 149{
150 struct mpic *mpic; 150 struct mpic *mpic;
151 phys_addr_t mpic_paddr = 0;
152 struct device_node *tsi_pic;
153#ifdef CONFIG_PCI 151#ifdef CONFIG_PCI
154 unsigned int cascade_pci_irq; 152 unsigned int cascade_pci_irq;
155 struct device_node *tsi_pci; 153 struct device_node *tsi_pci;
156 struct device_node *cascade_node = NULL; 154 struct device_node *cascade_node = NULL;
157#endif 155#endif
158 156
159 tsi_pic = of_find_node_by_type(NULL, "open-pic"); 157 mpic = mpic_alloc(NULL, 0,
160 if (tsi_pic) { 158 MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
161 unsigned int size;
162 const void *prop = of_get_property(tsi_pic, "reg", &size);
163 mpic_paddr = of_translate_address(tsi_pic, prop);
164 }
165
166 if (mpic_paddr == 0) {
167 printk(KERN_ERR "%s: No tsi108 PIC found !\n", __func__);
168 return;
169 }
170
171 pr_debug("%s: tsi108 pic phys_addr = 0x%x\n", __func__, (u32) mpic_paddr);
172
173 mpic = mpic_alloc(tsi_pic, mpic_paddr,
174 MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
175 MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108, 159 MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
176 24, 160 24,
177 NR_IRQS-4, /* num_sources used */ 161 NR_IRQS-4, /* num_sources used */
@@ -179,7 +163,7 @@ static void __init holly_init_IRQ(void)
179 163
180 BUG_ON(mpic == NULL); 164 BUG_ON(mpic == NULL);
181 165
182 mpic_assign_isu(mpic, 0, mpic_paddr + 0x100); 166 mpic_assign_isu(mpic, 0, mpic->paddr + 0x100);
183 167
184 mpic_init(mpic); 168 mpic_init(mpic);
185 169
@@ -204,7 +188,6 @@ static void __init holly_init_IRQ(void)
204#endif 188#endif
205 /* Configure MPIC outputs to CPU0 */ 189 /* Configure MPIC outputs to CPU0 */
206 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0); 190 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
207 of_node_put(tsi_pic);
208} 191}
209 192
210void holly_show_cpuinfo(struct seq_file *m) 193void holly_show_cpuinfo(struct seq_file *m)
diff --git a/arch/powerpc/platforms/embedded6xx/linkstation.c b/arch/powerpc/platforms/embedded6xx/linkstation.c
index 244f997de791..bcfad92c9cec 100644
--- a/arch/powerpc/platforms/embedded6xx/linkstation.c
+++ b/arch/powerpc/platforms/embedded6xx/linkstation.c
@@ -81,29 +81,19 @@ static void __init linkstation_setup_arch(void)
81static void __init linkstation_init_IRQ(void) 81static void __init linkstation_init_IRQ(void)
82{ 82{
83 struct mpic *mpic; 83 struct mpic *mpic;
84 struct device_node *dnp;
85 const u32 *prop;
86 int size;
87 phys_addr_t paddr;
88 84
89 dnp = of_find_node_by_type(NULL, "open-pic"); 85 mpic = mpic_alloc(NULL, 0, MPIC_WANTS_RESET,
90 if (dnp == NULL) 86 4, 32, " EPIC ");
91 return;
92
93 prop = of_get_property(dnp, "reg", &size);
94 paddr = (phys_addr_t)of_translate_address(dnp, prop);
95
96 mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC ");
97 BUG_ON(mpic == NULL); 87 BUG_ON(mpic == NULL);
98 88
99 /* PCI IRQs */ 89 /* PCI IRQs */
100 mpic_assign_isu(mpic, 0, paddr + 0x10200); 90 mpic_assign_isu(mpic, 0, mpic->paddr + 0x10200);
101 91
102 /* I2C */ 92 /* I2C */
103 mpic_assign_isu(mpic, 1, paddr + 0x11000); 93 mpic_assign_isu(mpic, 1, mpic->paddr + 0x11000);
104 94
105 /* ttyS0, ttyS1 */ 95 /* ttyS0, ttyS1 */
106 mpic_assign_isu(mpic, 2, paddr + 0x11100); 96 mpic_assign_isu(mpic, 2, mpic->paddr + 0x11100);
107 97
108 mpic_init(mpic); 98 mpic_init(mpic);
109} 99}
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index f8f33e16c6b6..f3350d786f5b 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -102,31 +102,14 @@ static void __init mpc7448_hpc2_setup_arch(void)
102static void __init mpc7448_hpc2_init_IRQ(void) 102static void __init mpc7448_hpc2_init_IRQ(void)
103{ 103{
104 struct mpic *mpic; 104 struct mpic *mpic;
105 phys_addr_t mpic_paddr = 0;
106 struct device_node *tsi_pic;
107#ifdef CONFIG_PCI 105#ifdef CONFIG_PCI
108 unsigned int cascade_pci_irq; 106 unsigned int cascade_pci_irq;
109 struct device_node *tsi_pci; 107 struct device_node *tsi_pci;
110 struct device_node *cascade_node = NULL; 108 struct device_node *cascade_node = NULL;
111#endif 109#endif
112 110
113 tsi_pic = of_find_node_by_type(NULL, "open-pic"); 111 mpic = mpic_alloc(NULL, 0,
114 if (tsi_pic) { 112 MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
115 unsigned int size;
116 const void *prop = of_get_property(tsi_pic, "reg", &size);
117 mpic_paddr = of_translate_address(tsi_pic, prop);
118 }
119
120 if (mpic_paddr == 0) {
121 printk("%s: No tsi108 PIC found !\n", __func__);
122 return;
123 }
124
125 DBG("%s: tsi108 pic phys_addr = 0x%x\n", __func__,
126 (u32) mpic_paddr);
127
128 mpic = mpic_alloc(tsi_pic, mpic_paddr,
129 MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
130 MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108, 113 MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
131 24, 114 24,
132 NR_IRQS-4, /* num_sources used */ 115 NR_IRQS-4, /* num_sources used */
@@ -134,7 +117,7 @@ static void __init mpc7448_hpc2_init_IRQ(void)
134 117
135 BUG_ON(mpic == NULL); 118 BUG_ON(mpic == NULL);
136 119
137 mpic_assign_isu(mpic, 0, mpic_paddr + 0x100); 120 mpic_assign_isu(mpic, 0, mpic->paddr + 0x100);
138 121
139 mpic_init(mpic); 122 mpic_init(mpic);
140 123
@@ -159,7 +142,6 @@ static void __init mpc7448_hpc2_init_IRQ(void)
159#endif 142#endif
160 /* Configure MPIC outputs to CPU0 */ 143 /* Configure MPIC outputs to CPU0 */
161 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0); 144 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
162 of_node_put(tsi_pic);
163} 145}
164 146
165void mpc7448_hpc2_show_cpuinfo(struct seq_file *m) 147void mpc7448_hpc2_show_cpuinfo(struct seq_file *m)
diff --git a/arch/powerpc/platforms/embedded6xx/storcenter.c b/arch/powerpc/platforms/embedded6xx/storcenter.c
index f1eebcae9bf0..afa638834965 100644
--- a/arch/powerpc/platforms/embedded6xx/storcenter.c
+++ b/arch/powerpc/platforms/embedded6xx/storcenter.c
@@ -83,35 +83,17 @@ static void __init storcenter_setup_arch(void)
83static void __init storcenter_init_IRQ(void) 83static void __init storcenter_init_IRQ(void)
84{ 84{
85 struct mpic *mpic; 85 struct mpic *mpic;
86 struct device_node *dnp;
87 const void *prop;
88 int size;
89 phys_addr_t paddr;
90
91 dnp = of_find_node_by_type(NULL, "open-pic");
92 if (dnp == NULL)
93 return;
94
95 prop = of_get_property(dnp, "reg", &size);
96 if (prop == NULL) {
97 of_node_put(dnp);
98 return;
99 }
100
101 paddr = (phys_addr_t)of_translate_address(dnp, prop);
102 mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET,
103 16, 32, " OpenPIC ");
104
105 of_node_put(dnp);
106 86
87 mpic = mpic_alloc(NULL, 0, MPIC_WANTS_RESET,
88 16, 32, " OpenPIC ");
107 BUG_ON(mpic == NULL); 89 BUG_ON(mpic == NULL);
108 90
109 /* 91 /*
110 * 16 Serial Interrupts followed by 16 Internal Interrupts. 92 * 16 Serial Interrupts followed by 16 Internal Interrupts.
111 * I2C is the second internal, so it is at 17, 0x11020. 93 * I2C is the second internal, so it is at 17, 0x11020.
112 */ 94 */
113 mpic_assign_isu(mpic, 0, paddr + 0x10200); 95 mpic_assign_isu(mpic, 0, mpic->paddr + 0x10200);
114 mpic_assign_isu(mpic, 1, paddr + 0x11000); 96 mpic_assign_isu(mpic, 1, mpic->paddr + 0x11000);
115 97
116 mpic_init(mpic); 98 mpic_init(mpic);
117} 99}
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index 4c372047c94e..0bcbfe7b2c55 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -221,7 +221,7 @@ static void __init maple_init_IRQ(void)
221 unsigned long openpic_addr = 0; 221 unsigned long openpic_addr = 0;
222 int naddr, n, i, opplen, has_isus = 0; 222 int naddr, n, i, opplen, has_isus = 0;
223 struct mpic *mpic; 223 struct mpic *mpic;
224 unsigned int flags = MPIC_PRIMARY; 224 unsigned int flags = 0;
225 225
226 /* Locate MPIC in the device-tree. Note that there is a bug 226 /* Locate MPIC in the device-tree. Note that there is a bug
227 * in Maple device-tree where the type of the controller is 227 * in Maple device-tree where the type of the controller is
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
index 6f3558210554..98b7a7c13176 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -224,7 +224,7 @@ static __init void pas_init_IRQ(void)
224 openpic_addr = of_read_number(opprop, naddr); 224 openpic_addr = of_read_number(opprop, naddr);
225 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr); 225 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
226 226
227 mpic_flags = MPIC_PRIMARY | MPIC_LARGE_VECTORS | MPIC_NO_BIAS; 227 mpic_flags = MPIC_LARGE_VECTORS | MPIC_NO_BIAS;
228 228
229 nmiprop = of_get_property(mpic_node, "nmi-source", NULL); 229 nmiprop = of_get_property(mpic_node, "nmi-source", NULL);
230 if (nmiprop) 230 if (nmiprop)
@@ -234,7 +234,7 @@ static __init void pas_init_IRQ(void)
234 mpic_flags, 0, 0, "PASEMI-OPIC"); 234 mpic_flags, 0, 0, "PASEMI-OPIC");
235 BUG_ON(!mpic); 235 BUG_ON(!mpic);
236 236
237 mpic_assign_isu(mpic, 0, openpic_addr + 0x10000); 237 mpic_assign_isu(mpic, 0, mpic->paddr + 0x10000);
238 mpic_init(mpic); 238 mpic_init(mpic);
239 /* The NMI/MCK source needs to be prio 15 */ 239 /* The NMI/MCK source needs to be prio 15 */
240 if (nmiprop) { 240 if (nmiprop) {
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index 901bfbddc3dd..d8aedf135bb6 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -464,18 +464,6 @@ int of_irq_map_oldworld(struct device_node *device, int index,
464} 464}
465#endif /* CONFIG_PPC32 */ 465#endif /* CONFIG_PPC32 */
466 466
467static void pmac_u3_cascade(unsigned int irq, struct irq_desc *desc)
468{
469 struct irq_chip *chip = irq_desc_get_chip(desc);
470 struct mpic *mpic = irq_desc_get_handler_data(desc);
471 unsigned int cascade_irq = mpic_get_one_irq(mpic);
472
473 if (cascade_irq != NO_IRQ)
474 generic_handle_irq(cascade_irq);
475
476 chip->irq_eoi(&desc->irq_data);
477}
478
479static void __init pmac_pic_setup_mpic_nmi(struct mpic *mpic) 467static void __init pmac_pic_setup_mpic_nmi(struct mpic *mpic)
480{ 468{
481#if defined(CONFIG_XMON) && defined(CONFIG_PPC32) 469#if defined(CONFIG_XMON) && defined(CONFIG_PPC32)
@@ -498,14 +486,8 @@ static struct mpic * __init pmac_setup_one_mpic(struct device_node *np,
498 int master) 486 int master)
499{ 487{
500 const char *name = master ? " MPIC 1 " : " MPIC 2 "; 488 const char *name = master ? " MPIC 1 " : " MPIC 2 ";
501 struct resource r;
502 struct mpic *mpic; 489 struct mpic *mpic;
503 unsigned int flags = master ? MPIC_PRIMARY : 0; 490 unsigned int flags = master ? 0 : MPIC_SECONDARY;
504 int rc;
505
506 rc = of_address_to_resource(np, 0, &r);
507 if (rc)
508 return NULL;
509 491
510 pmac_call_feature(PMAC_FTR_ENABLE_MPIC, np, 0, 0); 492 pmac_call_feature(PMAC_FTR_ENABLE_MPIC, np, 0, 0);
511 493
@@ -519,7 +501,7 @@ static struct mpic * __init pmac_setup_one_mpic(struct device_node *np,
519 if (master && (flags & MPIC_BIG_ENDIAN)) 501 if (master && (flags & MPIC_BIG_ENDIAN))
520 flags |= MPIC_U3_HT_IRQS; 502 flags |= MPIC_U3_HT_IRQS;
521 503
522 mpic = mpic_alloc(np, r.start, flags, 0, 0, name); 504 mpic = mpic_alloc(np, 0, flags, 0, 0, name);
523 if (mpic == NULL) 505 if (mpic == NULL)
524 return NULL; 506 return NULL;
525 507
@@ -532,7 +514,6 @@ static int __init pmac_pic_probe_mpic(void)
532{ 514{
533 struct mpic *mpic1, *mpic2; 515 struct mpic *mpic1, *mpic2;
534 struct device_node *np, *master = NULL, *slave = NULL; 516 struct device_node *np, *master = NULL, *slave = NULL;
535 unsigned int cascade;
536 517
537 /* We can have up to 2 MPICs cascaded */ 518 /* We can have up to 2 MPICs cascaded */
538 for (np = NULL; (np = of_find_node_by_type(np, "open-pic")) 519 for (np = NULL; (np = of_find_node_by_type(np, "open-pic"))
@@ -568,27 +549,14 @@ static int __init pmac_pic_probe_mpic(void)
568 549
569 of_node_put(master); 550 of_node_put(master);
570 551
571 /* No slave, let's go out */ 552 /* Set up a cascaded controller, if present */
572 if (slave == NULL) 553 if (slave) {
573 return 0; 554 mpic2 = pmac_setup_one_mpic(slave, 0);
574 555 if (mpic2 == NULL)
575 /* Get/Map slave interrupt */ 556 printk(KERN_ERR "Failed to setup slave MPIC\n");
576 cascade = irq_of_parse_and_map(slave, 0);
577 if (cascade == NO_IRQ) {
578 printk(KERN_ERR "Failed to map cascade IRQ\n");
579 return 0;
580 }
581
582 mpic2 = pmac_setup_one_mpic(slave, 0);
583 if (mpic2 == NULL) {
584 printk(KERN_ERR "Failed to setup slave MPIC\n");
585 of_node_put(slave); 557 of_node_put(slave);
586 return 0;
587 } 558 }
588 irq_set_handler_data(cascade, mpic2);
589 irq_set_chained_handler(cascade, pmac_u3_cascade);
590 559
591 of_node_put(slave);
592 return 0; 560 return 0;
593} 561}
594 562
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index c3408ca8855e..01df08dbc43c 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -192,8 +192,7 @@ static void __init pseries_mpic_init_IRQ(void)
192 BUG_ON(openpic_addr == 0); 192 BUG_ON(openpic_addr == 0);
193 193
194 /* Setup the openpic driver */ 194 /* Setup the openpic driver */
195 mpic = mpic_alloc(pSeries_mpic_node, openpic_addr, 195 mpic = mpic_alloc(pSeries_mpic_node, openpic_addr, 0,
196 MPIC_PRIMARY,
197 16, 250, /* isu size, irq count */ 196 16, 250, /* isu size, irq count */
198 " MPIC "); 197 " MPIC ");
199 BUG_ON(mpic == NULL); 198 BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index b3fa3d7d4ab6..4e9ccb1015de 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -154,7 +154,7 @@ static inline unsigned int mpic_processor_id(struct mpic *mpic)
154{ 154{
155 unsigned int cpu = 0; 155 unsigned int cpu = 0;
156 156
157 if (mpic->flags & MPIC_PRIMARY) 157 if (!(mpic->flags & MPIC_SECONDARY))
158 cpu = hard_smp_processor_id(); 158 cpu = hard_smp_processor_id();
159 159
160 return cpu; 160 return cpu;
@@ -315,29 +315,25 @@ static void _mpic_map_mmio(struct mpic *mpic, phys_addr_t phys_addr,
315} 315}
316 316
317#ifdef CONFIG_PPC_DCR 317#ifdef CONFIG_PPC_DCR
318static void _mpic_map_dcr(struct mpic *mpic, struct device_node *node, 318static void _mpic_map_dcr(struct mpic *mpic, struct mpic_reg_bank *rb,
319 struct mpic_reg_bank *rb,
320 unsigned int offset, unsigned int size) 319 unsigned int offset, unsigned int size)
321{ 320{
322 const u32 *dbasep; 321 phys_addr_t phys_addr = dcr_resource_start(mpic->node, 0);
323 322 rb->dhost = dcr_map(mpic->node, phys_addr + offset, size);
324 dbasep = of_get_property(node, "dcr-reg", NULL);
325
326 rb->dhost = dcr_map(node, *dbasep + offset, size);
327 BUG_ON(!DCR_MAP_OK(rb->dhost)); 323 BUG_ON(!DCR_MAP_OK(rb->dhost));
328} 324}
329 325
330static inline void mpic_map(struct mpic *mpic, struct device_node *node, 326static inline void mpic_map(struct mpic *mpic,
331 phys_addr_t phys_addr, struct mpic_reg_bank *rb, 327 phys_addr_t phys_addr, struct mpic_reg_bank *rb,
332 unsigned int offset, unsigned int size) 328 unsigned int offset, unsigned int size)
333{ 329{
334 if (mpic->flags & MPIC_USES_DCR) 330 if (mpic->flags & MPIC_USES_DCR)
335 _mpic_map_dcr(mpic, node, rb, offset, size); 331 _mpic_map_dcr(mpic, rb, offset, size);
336 else 332 else
337 _mpic_map_mmio(mpic, phys_addr, rb, offset, size); 333 _mpic_map_mmio(mpic, phys_addr, rb, offset, size);
338} 334}
339#else /* CONFIG_PPC_DCR */ 335#else /* CONFIG_PPC_DCR */
340#define mpic_map(m,n,p,b,o,s) _mpic_map_mmio(m,p,b,o,s) 336#define mpic_map(m,p,b,o,s) _mpic_map_mmio(m,p,b,o,s)
341#endif /* !CONFIG_PPC_DCR */ 337#endif /* !CONFIG_PPC_DCR */
342 338
343 339
@@ -990,7 +986,7 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
990 986
991#ifdef CONFIG_SMP 987#ifdef CONFIG_SMP
992 else if (hw >= mpic->ipi_vecs[0]) { 988 else if (hw >= mpic->ipi_vecs[0]) {
993 WARN_ON(!(mpic->flags & MPIC_PRIMARY)); 989 WARN_ON(mpic->flags & MPIC_SECONDARY);
994 990
995 DBG("mpic: mapping as IPI\n"); 991 DBG("mpic: mapping as IPI\n");
996 irq_set_chip_data(virq, mpic); 992 irq_set_chip_data(virq, mpic);
@@ -1001,7 +997,7 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
1001#endif /* CONFIG_SMP */ 997#endif /* CONFIG_SMP */
1002 998
1003 if (hw >= mpic->timer_vecs[0] && hw <= mpic->timer_vecs[7]) { 999 if (hw >= mpic->timer_vecs[0] && hw <= mpic->timer_vecs[7]) {
1004 WARN_ON(!(mpic->flags & MPIC_PRIMARY)); 1000 WARN_ON(mpic->flags & MPIC_SECONDARY);
1005 1001
1006 DBG("mpic: mapping as timer\n"); 1002 DBG("mpic: mapping as timer\n");
1007 irq_set_chip_data(virq, mpic); 1003 irq_set_chip_data(virq, mpic);
@@ -1115,17 +1111,28 @@ static int mpic_host_xlate(struct irq_host *h, struct device_node *ct,
1115 return 0; 1111 return 0;
1116} 1112}
1117 1113
1114/* IRQ handler for a secondary MPIC cascaded from another IRQ controller */
1115static void mpic_cascade(unsigned int irq, struct irq_desc *desc)
1116{
1117 struct irq_chip *chip = irq_desc_get_chip(desc);
1118 struct mpic *mpic = irq_desc_get_handler_data(desc);
1119 unsigned int virq;
1120
1121 BUG_ON(!(mpic->flags & MPIC_SECONDARY));
1122
1123 virq = mpic_get_one_irq(mpic);
1124 if (virq != NO_IRQ)
1125 generic_handle_irq(virq);
1126
1127 chip->irq_eoi(&desc->irq_data);
1128}
1129
1118static struct irq_host_ops mpic_host_ops = { 1130static struct irq_host_ops mpic_host_ops = {
1119 .match = mpic_host_match, 1131 .match = mpic_host_match,
1120 .map = mpic_host_map, 1132 .map = mpic_host_map,
1121 .xlate = mpic_host_xlate, 1133 .xlate = mpic_host_xlate,
1122}; 1134};
1123 1135
1124static int mpic_reset_prohibited(struct device_node *node)
1125{
1126 return node && of_get_property(node, "pic-no-reset", NULL);
1127}
1128
1129/* 1136/*
1130 * Exported functions 1137 * Exported functions
1131 */ 1138 */
@@ -1137,27 +1144,60 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1137 unsigned int irq_count, 1144 unsigned int irq_count,
1138 const char *name) 1145 const char *name)
1139{ 1146{
1140 struct mpic *mpic; 1147 int i, psize, intvec_top;
1141 u32 greg_feature; 1148 struct mpic *mpic;
1142 const char *vers; 1149 u32 greg_feature;
1143 int i; 1150 const char *vers;
1144 int intvec_top; 1151 const u32 *psrc;
1145 u64 paddr = phys_addr; 1152
1153 /* Default MPIC search parameters */
1154 static const struct of_device_id __initconst mpic_device_id[] = {
1155 { .type = "open-pic", },
1156 { .compatible = "open-pic", },
1157 {},
1158 };
1159
1160 /*
1161 * If we were not passed a device-tree node, then perform the default
1162 * search for standardized a standardized OpenPIC.
1163 */
1164 if (node) {
1165 node = of_node_get(node);
1166 } else {
1167 node = of_find_matching_node(NULL, mpic_device_id);
1168 if (!node)
1169 return NULL;
1170 }
1171
1172 /* Pick the physical address from the device tree if unspecified */
1173 if (!phys_addr) {
1174 /* Check if it is DCR-based */
1175 if (of_get_property(node, "dcr-reg", NULL)) {
1176 flags |= MPIC_USES_DCR;
1177 } else {
1178 struct resource r;
1179 if (of_address_to_resource(node, 0, &r))
1180 goto err_of_node_put;
1181 phys_addr = r.start;
1182 }
1183 }
1146 1184
1147 mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL); 1185 mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL);
1148 if (mpic == NULL) 1186 if (mpic == NULL)
1149 return NULL; 1187 goto err_of_node_put;
1150 1188
1151 mpic->name = name; 1189 mpic->name = name;
1190 mpic->node = node;
1191 mpic->paddr = phys_addr;
1152 1192
1153 mpic->hc_irq = mpic_irq_chip; 1193 mpic->hc_irq = mpic_irq_chip;
1154 mpic->hc_irq.name = name; 1194 mpic->hc_irq.name = name;
1155 if (flags & MPIC_PRIMARY) 1195 if (!(flags & MPIC_SECONDARY))
1156 mpic->hc_irq.irq_set_affinity = mpic_set_affinity; 1196 mpic->hc_irq.irq_set_affinity = mpic_set_affinity;
1157#ifdef CONFIG_MPIC_U3_HT_IRQS 1197#ifdef CONFIG_MPIC_U3_HT_IRQS
1158 mpic->hc_ht_irq = mpic_irq_ht_chip; 1198 mpic->hc_ht_irq = mpic_irq_ht_chip;
1159 mpic->hc_ht_irq.name = name; 1199 mpic->hc_ht_irq.name = name;
1160 if (flags & MPIC_PRIMARY) 1200 if (!(flags & MPIC_SECONDARY))
1161 mpic->hc_ht_irq.irq_set_affinity = mpic_set_affinity; 1201 mpic->hc_ht_irq.irq_set_affinity = mpic_set_affinity;
1162#endif /* CONFIG_MPIC_U3_HT_IRQS */ 1202#endif /* CONFIG_MPIC_U3_HT_IRQS */
1163 1203
@@ -1194,28 +1234,22 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1194 mpic->spurious_vec = intvec_top; 1234 mpic->spurious_vec = intvec_top;
1195 1235
1196 /* Check for "big-endian" in device-tree */ 1236 /* Check for "big-endian" in device-tree */
1197 if (node && of_get_property(node, "big-endian", NULL) != NULL) 1237 if (of_get_property(mpic->node, "big-endian", NULL) != NULL)
1198 mpic->flags |= MPIC_BIG_ENDIAN; 1238 mpic->flags |= MPIC_BIG_ENDIAN;
1199 if (node && of_device_is_compatible(node, "fsl,mpic")) 1239 if (of_device_is_compatible(mpic->node, "fsl,mpic"))
1200 mpic->flags |= MPIC_FSL; 1240 mpic->flags |= MPIC_FSL;
1201 1241
1202 /* Look for protected sources */ 1242 /* Look for protected sources */
1203 if (node) { 1243 psrc = of_get_property(mpic->node, "protected-sources", &psize);
1204 int psize; 1244 if (psrc) {
1205 unsigned int bits, mapsize; 1245 /* Allocate a bitmap with one bit per interrupt */
1206 const u32 *psrc = 1246 unsigned int mapsize = BITS_TO_LONGS(intvec_top + 1);
1207 of_get_property(node, "protected-sources", &psize); 1247 mpic->protected = kzalloc(mapsize*sizeof(long), GFP_KERNEL);
1208 if (psrc) { 1248 BUG_ON(mpic->protected == NULL);
1209 psize /= 4; 1249 for (i = 0; i < psize/sizeof(u32); i++) {
1210 bits = intvec_top + 1; 1250 if (psrc[i] > intvec_top)
1211 mapsize = BITS_TO_LONGS(bits) * sizeof(unsigned long); 1251 continue;
1212 mpic->protected = kzalloc(mapsize, GFP_KERNEL); 1252 __set_bit(psrc[i], mpic->protected);
1213 BUG_ON(mpic->protected == NULL);
1214 for (i = 0; i < psize; i++) {
1215 if (psrc[i] > intvec_top)
1216 continue;
1217 __set_bit(psrc[i], mpic->protected);
1218 }
1219 } 1253 }
1220 } 1254 }
1221 1255
@@ -1224,42 +1258,32 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1224#endif 1258#endif
1225 1259
1226 /* default register type */ 1260 /* default register type */
1227 mpic->reg_type = (flags & MPIC_BIG_ENDIAN) ? 1261 if (flags & MPIC_BIG_ENDIAN)
1228 mpic_access_mmio_be : mpic_access_mmio_le; 1262 mpic->reg_type = mpic_access_mmio_be;
1229 1263 else
1230 /* If no physical address is passed in, a device-node is mandatory */ 1264 mpic->reg_type = mpic_access_mmio_le;
1231 BUG_ON(paddr == 0 && node == NULL);
1232 1265
1233 /* If no physical address passed in, check if it's dcr based */ 1266 /*
1234 if (paddr == 0 && of_get_property(node, "dcr-reg", NULL) != NULL) { 1267 * An MPIC with a "dcr-reg" property must be accessed that way, but
1268 * only if the kernel includes DCR support.
1269 */
1235#ifdef CONFIG_PPC_DCR 1270#ifdef CONFIG_PPC_DCR
1236 mpic->flags |= MPIC_USES_DCR; 1271 if (flags & MPIC_USES_DCR)
1237 mpic->reg_type = mpic_access_dcr; 1272 mpic->reg_type = mpic_access_dcr;
1238#else 1273#else
1239 BUG(); 1274 BUG_ON(flags & MPIC_USES_DCR);
1240#endif /* CONFIG_PPC_DCR */ 1275#endif
1241 }
1242
1243 /* If the MPIC is not DCR based, and no physical address was passed
1244 * in, try to obtain one
1245 */
1246 if (paddr == 0 && !(mpic->flags & MPIC_USES_DCR)) {
1247 const u32 *reg = of_get_property(node, "reg", NULL);
1248 BUG_ON(reg == NULL);
1249 paddr = of_translate_address(node, reg);
1250 BUG_ON(paddr == OF_BAD_ADDR);
1251 }
1252 1276
1253 /* Map the global registers */ 1277 /* Map the global registers */
1254 mpic_map(mpic, node, paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000); 1278 mpic_map(mpic, mpic->paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
1255 mpic_map(mpic, node, paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000); 1279 mpic_map(mpic, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
1256 1280
1257 /* Reset */ 1281 /* Reset */
1258 1282
1259 /* When using a device-node, reset requests are only honored if the MPIC 1283 /* When using a device-node, reset requests are only honored if the MPIC
1260 * is allowed to reset. 1284 * is allowed to reset.
1261 */ 1285 */
1262 if (mpic_reset_prohibited(node)) 1286 if (of_get_property(mpic->node, "pic-no-reset", NULL))
1263 mpic->flags |= MPIC_NO_RESET; 1287 mpic->flags |= MPIC_NO_RESET;
1264 1288
1265 if ((flags & MPIC_WANTS_RESET) && !(mpic->flags & MPIC_NO_RESET)) { 1289 if ((flags & MPIC_WANTS_RESET) && !(mpic->flags & MPIC_NO_RESET)) {
@@ -1307,7 +1331,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1307 for_each_possible_cpu(i) { 1331 for_each_possible_cpu(i) {
1308 unsigned int cpu = get_hard_smp_processor_id(i); 1332 unsigned int cpu = get_hard_smp_processor_id(i);
1309 1333
1310 mpic_map(mpic, node, paddr, &mpic->cpuregs[cpu], 1334 mpic_map(mpic, mpic->paddr, &mpic->cpuregs[cpu],
1311 MPIC_INFO(CPU_BASE) + cpu * MPIC_INFO(CPU_STRIDE), 1335 MPIC_INFO(CPU_BASE) + cpu * MPIC_INFO(CPU_STRIDE),
1312 0x1000); 1336 0x1000);
1313 } 1337 }
@@ -1315,16 +1339,21 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1315 /* Initialize main ISU if none provided */ 1339 /* Initialize main ISU if none provided */
1316 if (mpic->isu_size == 0) { 1340 if (mpic->isu_size == 0) {
1317 mpic->isu_size = mpic->num_sources; 1341 mpic->isu_size = mpic->num_sources;
1318 mpic_map(mpic, node, paddr, &mpic->isus[0], 1342 mpic_map(mpic, mpic->paddr, &mpic->isus[0],
1319 MPIC_INFO(IRQ_BASE), MPIC_INFO(IRQ_STRIDE) * mpic->isu_size); 1343 MPIC_INFO(IRQ_BASE), MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
1320 } 1344 }
1321 mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1); 1345 mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
1322 mpic->isu_mask = (1 << mpic->isu_shift) - 1; 1346 mpic->isu_mask = (1 << mpic->isu_shift) - 1;
1323 1347
1324 mpic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR, 1348 mpic->irqhost = irq_alloc_host(mpic->node, IRQ_HOST_MAP_LINEAR,
1325 isu_size ? isu_size : mpic->num_sources, 1349 isu_size ? isu_size : mpic->num_sources,
1326 &mpic_host_ops, 1350 &mpic_host_ops,
1327 flags & MPIC_LARGE_VECTORS ? 2048 : 256); 1351 flags & MPIC_LARGE_VECTORS ? 2048 : 256);
1352
1353 /*
1354 * FIXME: The code leaks the MPIC object and mappings here; this
1355 * is very unlikely to fail but it ought to be fixed anyways.
1356 */
1328 if (mpic->irqhost == NULL) 1357 if (mpic->irqhost == NULL)
1329 return NULL; 1358 return NULL;
1330 1359
@@ -1347,19 +1376,23 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1347 } 1376 }
1348 printk(KERN_INFO "mpic: Setting up MPIC \"%s\" version %s at %llx," 1377 printk(KERN_INFO "mpic: Setting up MPIC \"%s\" version %s at %llx,"
1349 " max %d CPUs\n", 1378 " max %d CPUs\n",
1350 name, vers, (unsigned long long)paddr, num_possible_cpus()); 1379 name, vers, (unsigned long long)mpic->paddr, num_possible_cpus());
1351 printk(KERN_INFO "mpic: ISU size: %d, shift: %d, mask: %x\n", 1380 printk(KERN_INFO "mpic: ISU size: %d, shift: %d, mask: %x\n",
1352 mpic->isu_size, mpic->isu_shift, mpic->isu_mask); 1381 mpic->isu_size, mpic->isu_shift, mpic->isu_mask);
1353 1382
1354 mpic->next = mpics; 1383 mpic->next = mpics;
1355 mpics = mpic; 1384 mpics = mpic;
1356 1385
1357 if (flags & MPIC_PRIMARY) { 1386 if (!(flags & MPIC_SECONDARY)) {
1358 mpic_primary = mpic; 1387 mpic_primary = mpic;
1359 irq_set_default_host(mpic->irqhost); 1388 irq_set_default_host(mpic->irqhost);
1360 } 1389 }
1361 1390
1362 return mpic; 1391 return mpic;
1392
1393err_of_node_put:
1394 of_node_put(node);
1395 return NULL;
1363} 1396}
1364 1397
1365void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, 1398void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
@@ -1369,7 +1402,7 @@ void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
1369 1402
1370 BUG_ON(isu_num >= MPIC_MAX_ISU); 1403 BUG_ON(isu_num >= MPIC_MAX_ISU);
1371 1404
1372 mpic_map(mpic, mpic->irqhost->of_node, 1405 mpic_map(mpic,
1373 paddr, &mpic->isus[isu_num], 0, 1406 paddr, &mpic->isus[isu_num], 0,
1374 MPIC_INFO(IRQ_STRIDE) * mpic->isu_size); 1407 MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
1375 1408
@@ -1385,8 +1418,7 @@ void __init mpic_set_default_senses(struct mpic *mpic, u8 *senses, int count)
1385 1418
1386void __init mpic_init(struct mpic *mpic) 1419void __init mpic_init(struct mpic *mpic)
1387{ 1420{
1388 int i; 1421 int i, cpu;
1389 int cpu;
1390 1422
1391 BUG_ON(mpic->num_sources == 0); 1423 BUG_ON(mpic->num_sources == 0);
1392 1424
@@ -1424,7 +1456,7 @@ void __init mpic_init(struct mpic *mpic)
1424 1456
1425 /* Do the HT PIC fixups on U3 broken mpic */ 1457 /* Do the HT PIC fixups on U3 broken mpic */
1426 DBG("MPIC flags: %x\n", mpic->flags); 1458 DBG("MPIC flags: %x\n", mpic->flags);
1427 if ((mpic->flags & MPIC_U3_HT_IRQS) && (mpic->flags & MPIC_PRIMARY)) { 1459 if ((mpic->flags & MPIC_U3_HT_IRQS) && !(mpic->flags & MPIC_SECONDARY)) {
1428 mpic_scan_ht_pics(mpic); 1460 mpic_scan_ht_pics(mpic);
1429 mpic_u3msi_init(mpic); 1461 mpic_u3msi_init(mpic);
1430 } 1462 }
@@ -1471,6 +1503,17 @@ void __init mpic_init(struct mpic *mpic)
1471 GFP_KERNEL); 1503 GFP_KERNEL);
1472 BUG_ON(mpic->save_data == NULL); 1504 BUG_ON(mpic->save_data == NULL);
1473#endif 1505#endif
1506
1507 /* Check if this MPIC is chained from a parent interrupt controller */
1508 if (mpic->flags & MPIC_SECONDARY) {
1509 int virq = irq_of_parse_and_map(mpic->node, 0);
1510 if (virq != NO_IRQ) {
1511 printk(KERN_INFO "%s: hooking up to IRQ %d\n",
1512 mpic->node->full_name, virq);
1513 irq_set_handler_data(virq, mpic);
1514 irq_set_chained_handler(virq, &mpic_cascade);
1515 }
1516 }
1474} 1517}
1475 1518
1476void __init mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio) 1519void __init mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio)