linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] powerpc/85xx: separate cpm2 pic init
@ 2011-11-17 17:56 Dmitry Eremin-Solenikov
  2011-11-17 17:56 ` [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls Dmitry Eremin-Solenikov
                   ` (5 more replies)
  0 siblings, 6 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-17 17:56 UTC (permalink / raw)
  To: linuxppc-dev

Separate handling of CPM2 PIC initialization to mpc85xx_cpm2_pic_init()
function.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/platforms/85xx/Makefile         |    2 +
 arch/powerpc/platforms/85xx/ksi8560.c        |   29 +--------------
 arch/powerpc/platforms/85xx/mpc8536_ds.c     |    2 +
 arch/powerpc/platforms/85xx/mpc85xx.h        |    9 +++++
 arch/powerpc/platforms/85xx/mpc85xx_ads.c    |   34 ++----------------
 arch/powerpc/platforms/85xx/mpc85xx_cds.c    |    2 +
 arch/powerpc/platforms/85xx/mpc85xx_common.c |   49 ++++++++++++++++++++++++++
 arch/powerpc/platforms/85xx/mpc85xx_ds.c     |    2 +
 arch/powerpc/platforms/85xx/mpc85xx_mds.c    |    2 +
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c    |    2 +
 arch/powerpc/platforms/85xx/p1022_ds.c       |    2 +
 arch/powerpc/platforms/85xx/sbc8560.c        |   34 ++----------------
 arch/powerpc/platforms/85xx/socrates.c       |    1 +
 arch/powerpc/platforms/85xx/stx_gp3.c        |   37 ++------------------
 arch/powerpc/platforms/85xx/tqm85xx.c        |   37 ++------------------
 arch/powerpc/platforms/85xx/xes_mpc85xx.c    |    2 +
 16 files changed, 89 insertions(+), 157 deletions(-)
 create mode 100644 arch/powerpc/platforms/85xx/mpc85xx.h
 create mode 100644 arch/powerpc/platforms/85xx/mpc85xx_common.c

diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index bc5acb9..b6beec8 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -3,6 +3,8 @@
 #
 obj-$(CONFIG_SMP) += smp.o
 
+obj-y += mpc85xx_common.o
+
 obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
 obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
 obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
diff --git a/arch/powerpc/platforms/85xx/ksi8560.c b/arch/powerpc/platforms/85xx/ksi8560.c
index c46f935..bf9b1e5 100644
--- a/arch/powerpc/platforms/85xx/ksi8560.c
+++ b/arch/powerpc/platforms/85xx/ksi8560.c
@@ -35,6 +35,7 @@
 #include <asm/cpm2.h>
 #include <sysdev/cpm2_pic.h>
 
+#include "mpc85xx.h"
 
 #define KSI8560_CPLD_HVR		0x04 /* Hardware Version Register */
 #define KSI8560_CPLD_PVR		0x08 /* PLD Version Register */
@@ -54,25 +55,11 @@ static void machine_restart(char *cmd)
 	for (;;);
 }
 
-static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
-{
-	struct irq_chip *chip = irq_desc_get_chip(desc);
-	int cascade_irq;
-
-	while ((cascade_irq = cpm2_get_irq()) >= 0)
-		generic_handle_irq(cascade_irq);
-
-	chip->irq_eoi(&desc->irq_data);
-}
-
 static void __init ksi8560_pic_init(void)
 {
 	struct mpic *mpic;
 	struct resource r;
 	struct device_node *np;
-#ifdef CONFIG_CPM2
-	int irq;
-#endif
 
 	np = of_find_node_by_type(NULL, "open-pic");
 
@@ -95,19 +82,7 @@ static void __init ksi8560_pic_init(void)
 
 	mpic_init(mpic);
 
-#ifdef CONFIG_CPM2
-	/* Setup CPM2 PIC */
-	np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
-		return;
-	}
-	irq = irq_of_parse_and_map(np, 0);
-
-	cpm2_pic_init(np);
-	of_node_put(np);
-	irq_set_chained_handler(irq, cpm2_cascade);
-#endif
+	mpc85xx_cpm2_pic_init();
 }
 
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index f79f2f1..6a4b2c1 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -32,6 +32,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 void __init mpc8536_ds_pic_init(void)
 {
 	struct mpic *mpic;
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
new file mode 100644
index 0000000..fa55e8b
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -0,0 +1,9 @@
+#ifndef MPC85xx_H
+#define MPC85xx_H
+#ifdef CONFIG_CPM2
+extern void mpc85xx_cpm2_pic_init(void);
+#else
+static inline void __init mpc85xx_cpm2_pic_init(void) {}
+#endif /* CONFIG_CPM2 */
+
+#endif
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 3b2c9bb..8b8f7a2 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -35,6 +35,8 @@
 #include <sysdev/cpm2_pic.h>
 #endif
 
+#include "mpc85xx.h"
+
 #ifdef CONFIG_PCI
 static int mpc85xx_exclude_device(struct pci_controller *hose,
 				   u_char bus, u_char devfn)
@@ -46,29 +48,11 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
 }
 #endif /* CONFIG_PCI */
 
-#ifdef CONFIG_CPM2
-
-static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
-{
-	struct irq_chip *chip = irq_desc_get_chip(desc);
-	int cascade_irq;
-
-	while ((cascade_irq = cpm2_get_irq()) >= 0)
-		generic_handle_irq(cascade_irq);
-
-	chip->irq_eoi(&desc->irq_data);
-}
-
-#endif /* CONFIG_CPM2 */
-
 static void __init mpc85xx_ads_pic_init(void)
 {
 	struct mpic *mpic;
 	struct resource r;
 	struct device_node *np = NULL;
-#ifdef CONFIG_CPM2
-	int irq;
-#endif
 
 	np = of_find_node_by_type(np, "open-pic");
 	if (!np) {
@@ -90,19 +74,7 @@ static void __init mpc85xx_ads_pic_init(void)
 
 	mpic_init(mpic);
 
-#ifdef CONFIG_CPM2
-	/* Setup CPM2 PIC */
-	np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
-		return;
-	}
-	irq = irq_of_parse_and_map(np, 0);
-
-	cpm2_pic_init(np);
-	of_node_put(np);
-	irq_set_chained_handler(irq, cpm2_cascade);
-#endif
+	mpc85xx_cpm2_pic_init();
 }
 
 /*
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 2bf9978..93bf18a 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -47,6 +47,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 /* CADMUS info */
 /* xxx - galak, move into device tree */
 #define CADMUS_BASE (0xf8004000)
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_common.c b/arch/powerpc/platforms/85xx/mpc85xx_common.c
new file mode 100644
index 0000000..49d781c
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc85xx_common.c
@@ -0,0 +1,49 @@
+/*
+ * Routines common to most mpc85xx-based boards.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/of_platform.h>
+
+#include <sysdev/cpm2_pic.h>
+
+#include "mpc85xx.h"
+
+#ifdef CONFIG_CPM2
+static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
+{
+	struct irq_chip *chip = irq_desc_get_chip(desc);
+	int cascade_irq;
+
+	while ((cascade_irq = cpm2_get_irq()) >= 0)
+		generic_handle_irq(cascade_irq);
+
+	chip->irq_eoi(&desc->irq_data);
+}
+
+
+void __init mpc85xx_cpm2_pic_init(void)
+{
+	struct device_node *np;
+	int irq;
+
+	/* Setup CPM2 PIC */
+	np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
+	if (np == NULL) {
+		printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
+		return;
+	}
+	irq = irq_of_parse_and_map(np, 0);
+	if (irq == NO_IRQ) {
+		of_node_put(np);
+		printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");
+		return;
+	}
+
+	cpm2_pic_init(np);
+	of_node_put(np);
+	irq_set_chained_handler(irq, cpm2_cascade);
+}
+#endif
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 1b9a8cf..55075b9 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -36,6 +36,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 #undef DEBUG
 
 #ifdef DEBUG
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 973b3f4..2ee487a 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -53,6 +53,8 @@
 #include <asm/mpic.h>
 #include <asm/swiotlb.h>
 
+#include "mpc85xx.h"
+
 #undef DEBUG
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index f5ff911..824d2b6 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -30,6 +30,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 #undef DEBUG
 
 #ifdef DEBUG
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 6a0b973..00d93a4 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -27,6 +27,8 @@
 #include <sysdev/fsl_pci.h>
 #include <asm/fsl_guts.h>
 
+#include "mpc85xx.h"
+
 #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
 
 /*
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index cebd786..43711f8 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -32,34 +32,18 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 #ifdef CONFIG_CPM2
 #include <asm/cpm2.h>
 #include <sysdev/cpm2_pic.h>
 #endif
 
-#ifdef CONFIG_CPM2
-
-static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
-{
-	struct irq_chip *chip = irq_desc_get_chip(desc);
-	int cascade_irq;
-
-	while ((cascade_irq = cpm2_get_irq()) >= 0)
-		generic_handle_irq(cascade_irq);
-
-	chip->irq_eoi(&desc->irq_data);
-}
-
-#endif /* CONFIG_CPM2 */
-
 static void __init sbc8560_pic_init(void)
 {
 	struct mpic *mpic;
 	struct resource r;
 	struct device_node *np = NULL;
-#ifdef CONFIG_CPM2
-	int irq;
-#endif
 
 	np = of_find_node_by_type(np, "open-pic");
 	if (!np) {
@@ -81,19 +65,7 @@ static void __init sbc8560_pic_init(void)
 
 	mpic_init(mpic);
 
-#ifdef CONFIG_CPM2
-	/* Setup CPM2 PIC */
-	np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
-		return;
-	}
-	irq = irq_of_parse_and_map(np, 0);
-
-	cpm2_pic_init(np);
-	of_node_put(np);
-	irq_set_chained_handler(irq, cpm2_cascade);
-#endif
+	mpc85xx_cpm2_pic_init();
 }
 
 /*
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index 747d8fb..9d0fc28 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -41,6 +41,7 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
 #include "socrates_fpga_pic.h"
 
 static void __init socrates_pic_init(void)
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index 5387e9f..d24192b 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -40,20 +40,10 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 #ifdef CONFIG_CPM2
 #include <asm/cpm2.h>
-#include <sysdev/cpm2_pic.h>
-
-static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
-{
-	struct irq_chip *chip = irq_desc_get_chip(desc);
-	int cascade_irq;
-
-	while ((cascade_irq = cpm2_get_irq()) >= 0)
-		generic_handle_irq(cascade_irq);
-
-	chip->irq_eoi(&desc->irq_data);
-}
 #endif /* CONFIG_CPM2 */
 
 static void __init stx_gp3_pic_init(void)
@@ -61,9 +51,6 @@ static void __init stx_gp3_pic_init(void)
 	struct mpic *mpic;
 	struct resource r;
 	struct device_node *np;
-#ifdef CONFIG_CPM2
-	int irq;
-#endif
 
 	np = of_find_node_by_type(NULL, "open-pic");
 	if (!np) {
@@ -85,25 +72,7 @@ static void __init stx_gp3_pic_init(void)
 
 	mpic_init(mpic);
 
-#ifdef CONFIG_CPM2
-	/* Setup CPM2 PIC */
-	np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
-		return;
-	}
-	irq = irq_of_parse_and_map(np, 0);
-
-	if (irq == NO_IRQ) {
-		of_node_put(np);
-		printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");
-		return;
-	}
-
-	cpm2_pic_init(np);
-	of_node_put(np);
-	irq_set_chained_handler(irq, cpm2_cascade);
-#endif
+	mpc85xx_cpm2_pic_init();
 }
 
 /*
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 325de77..b9e53cc 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -38,20 +38,10 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 #ifdef CONFIG_CPM2
 #include <asm/cpm2.h>
-#include <sysdev/cpm2_pic.h>
-
-static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
-{
-	struct irq_chip *chip = irq_desc_get_chip(desc);
-	int cascade_irq;
-
-	while ((cascade_irq = cpm2_get_irq()) >= 0)
-		generic_handle_irq(cascade_irq);
-
-	chip->irq_eoi(&desc->irq_data);
-}
 #endif /* CONFIG_CPM2 */
 
 static void __init tqm85xx_pic_init(void)
@@ -59,9 +49,6 @@ static void __init tqm85xx_pic_init(void)
 	struct mpic *mpic;
 	struct resource r;
 	struct device_node *np;
-#ifdef CONFIG_CPM2
-	int irq;
-#endif
 
 	np = of_find_node_by_type(NULL, "open-pic");
 	if (!np) {
@@ -83,25 +70,7 @@ static void __init tqm85xx_pic_init(void)
 
 	mpic_init(mpic);
 
-#ifdef CONFIG_CPM2
-	/* Setup CPM2 PIC */
-	np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
-		return;
-	}
-	irq = irq_of_parse_and_map(np, 0);
-
-	if (irq == NO_IRQ) {
-		of_node_put(np);
-		printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");
-		return;
-	}
-
-	cpm2_pic_init(np);
-	of_node_put(np);
-	irq_set_chained_handler(irq, cpm2_cascade);
-#endif
+	mpc85xx_cpm2_pic_init();
 }
 
 /*
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index a9dc5e7..ab7025a 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -33,6 +33,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 /* A few bit definitions needed for fixups on some boards */
 #define MPC85xx_L2CTL_L2E		0x80000000 /* L2 enable */
 #define MPC85xx_L2CTL_L2I		0x40000000 /* L2 flash invalidate */
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls
  2011-11-17 17:56 [PATCH 1/6] powerpc/85xx: separate cpm2 pic init Dmitry Eremin-Solenikov
@ 2011-11-17 17:56 ` Dmitry Eremin-Solenikov
  2011-11-24  7:15   ` Kumar Gala
  2011-11-28 23:42   ` Tabi Timur-B04825
  2011-11-17 17:56 ` [PATCH 3/6] powerpc/85xx: separate MPIC handling code Dmitry Eremin-Solenikov
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-17 17:56 UTC (permalink / raw)
  To: linuxppc-dev

85xx board files have a lot of duplication in *_publish_devices()/
*_declare_of_platform_devices() functions. Merge that into a single
function common to most of the boards.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/platforms/85xx/ksi8560.c        |   17 +---------
 arch/powerpc/platforms/85xx/mpc8536_ds.c     |   14 +-------
 arch/powerpc/platforms/85xx/mpc85xx.h        |    2 +
 arch/powerpc/platforms/85xx/mpc85xx_ads.c    |   18 +----------
 arch/powerpc/platforms/85xx/mpc85xx_cds.c    |   14 +-------
 arch/powerpc/platforms/85xx/mpc85xx_common.c |   16 +++++++++
 arch/powerpc/platforms/85xx/mpc85xx_ds.c     |   18 ++---------
 arch/powerpc/platforms/85xx/mpc85xx_mds.c    |   44 +------------------------
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c    |   16 +--------
 arch/powerpc/platforms/85xx/p1022_ds.c       |    5 +--
 arch/powerpc/platforms/85xx/sbc8548.c        |   18 ++---------
 arch/powerpc/platforms/85xx/sbc8560.c        |   18 +----------
 arch/powerpc/platforms/85xx/socrates.c       |   12 +------
 arch/powerpc/platforms/85xx/stx_gp3.c        |   14 +-------
 arch/powerpc/platforms/85xx/tqm85xx.c        |   14 +-------
 arch/powerpc/platforms/85xx/xes_mpc85xx.c    |   18 ++---------
 16 files changed, 40 insertions(+), 218 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/ksi8560.c b/arch/powerpc/platforms/85xx/ksi8560.c
index bf9b1e5..0f3e688 100644
--- a/arch/powerpc/platforms/85xx/ksi8560.c
+++ b/arch/powerpc/platforms/85xx/ksi8560.c
@@ -190,22 +190,7 @@ static void ksi8560_show_cpuinfo(struct seq_file *m)
 	seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
 }
 
-static struct of_device_id __initdata of_bus_ids[] = {
-	{ .type = "soc", },
-	{ .type = "simple-bus", },
-	{ .name = "cpm", },
-	{ .name = "localbus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init declare_of_platform_devices(void)
-{
-	of_platform_bus_probe(NULL, of_bus_ids, NULL);
-
-	return 0;
-}
-machine_device_initcall(ksi8560, declare_of_platform_devices);
+machine_device_initcall(ksi8560, mpc85xx_common_publish_devices);
 
 /*
  * Called very early, device-tree isn't unflattened
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 6a4b2c1..9ee6455 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -106,19 +106,7 @@ static void __init mpc8536_ds_setup_arch(void)
 	printk("MPC8536 DS board from Freescale Semiconductor\n");
 }
 
-static struct of_device_id __initdata mpc8536_ds_ids[] = {
-	{ .type = "soc", },
-	{ .compatible = "soc", },
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init mpc8536_ds_publish_devices(void)
-{
-	return of_platform_bus_probe(NULL, mpc8536_ds_ids, NULL);
-}
-machine_device_initcall(mpc8536_ds, mpc8536_ds_publish_devices);
+machine_device_initcall(mpc8536_ds, mpc85xx_common_publish_devices);
 
 machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier);
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index fa55e8b..2aa7c5d 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -1,5 +1,7 @@
 #ifndef MPC85xx_H
 #define MPC85xx_H
+extern int mpc85xx_common_publish_devices(void);
+
 #ifdef CONFIG_CPM2
 extern void mpc85xx_cpm2_pic_init(void);
 #else
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 8b8f7a2..986554b 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -193,23 +193,7 @@ static void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
 	seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
 }
 
-static struct of_device_id __initdata of_bus_ids[] = {
-	{ .name = "soc", },
-	{ .type = "soc", },
-	{ .name = "cpm", },
-	{ .name = "localbus", },
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init declare_of_platform_devices(void)
-{
-	of_platform_bus_probe(NULL, of_bus_ids, NULL);
-
-	return 0;
-}
-machine_device_initcall(mpc85xx_ads, declare_of_platform_devices);
+machine_device_initcall(mpc85xx_ads, mpc85xx_common_publish_devices);
 
 /*
  * Called very early, device-tree isn't unflattened
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 93bf18a..a268f43 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -333,19 +333,7 @@ static int __init mpc85xx_cds_probe(void)
         return of_flat_dt_is_compatible(root, "MPC85xxCDS");
 }
 
-static struct of_device_id __initdata of_bus_ids[] = {
-	{ .type = "soc", },
-	{ .compatible = "soc", },
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init declare_of_platform_devices(void)
-{
-	return of_platform_bus_probe(NULL, of_bus_ids, NULL);
-}
-machine_device_initcall(mpc85xx_cds, declare_of_platform_devices);
+machine_device_initcall(mpc85xx_cds, mpc85xx_common_publish_devices);
 
 define_machine(mpc85xx_cds) {
 	.name		= "MPC85xx CDS",
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_common.c b/arch/powerpc/platforms/85xx/mpc85xx_common.c
index 49d781c..fe40668 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_common.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_common.c
@@ -11,6 +11,22 @@
 
 #include "mpc85xx.h"
 
+static struct of_device_id __initdata mpc85xx_common_ids[] = {
+	{ .type = "soc", },
+	{ .compatible = "soc", },
+	{ .compatible = "simple-bus", },
+	{ .name = "cpm", },
+	{ .name = "localbus", },
+	{ .compatible = "gianfar", },
+	{ .compatible = "fsl,qe", },
+	{ .compatible = "fsl,cpm2", },
+	{},
+};
+
+int __init mpc85xx_common_publish_devices(void)
+{
+	return of_platform_bus_probe(NULL, mpc85xx_common_ids, NULL);
+}
 #ifdef CONFIG_CPM2
 static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 {
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 55075b9..2113120 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -221,21 +221,9 @@ static int __init mpc8544_ds_probe(void)
 	return 0;
 }
 
-static struct of_device_id __initdata mpc85xxds_ids[] = {
-	{ .type = "soc", },
-	{ .compatible = "soc", },
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init mpc85xxds_publish_devices(void)
-{
-	return of_platform_bus_probe(NULL, mpc85xxds_ids, NULL);
-}
-machine_device_initcall(mpc8544_ds, mpc85xxds_publish_devices);
-machine_device_initcall(mpc8572_ds, mpc85xxds_publish_devices);
-machine_device_initcall(p2020_ds, mpc85xxds_publish_devices);
+machine_device_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
+machine_device_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
+machine_device_initcall(p2020_ds, mpc85xx_common_publish_devices);
 
 machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
 machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 2ee487a..3beb00b 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -161,25 +161,6 @@ extern void __init mpc85xx_smp_init(void);
 #endif
 
 #ifdef CONFIG_QUICC_ENGINE
-static struct of_device_id mpc85xx_qe_ids[] __initdata = {
-	{ .type = "qe", },
-	{ .compatible = "fsl,qe", },
-	{ },
-};
-
-static void __init mpc85xx_publish_qe_devices(void)
-{
-	struct device_node *np;
-
-	np = of_find_compatible_node(NULL, NULL, "fsl,qe");
-	if (!of_device_is_available(np)) {
-		of_node_put(np);
-		return;
-	}
-
-	of_platform_bus_probe(NULL, mpc85xx_qe_ids, NULL);
-}
-
 static void __init mpc85xx_mds_reset_ucc_phys(void)
 {
 	struct device_node *np;
@@ -350,7 +331,6 @@ static void __init mpc85xx_mds_qeic_init(void)
 	of_node_put(np);
 }
 #else
-static void __init mpc85xx_publish_qe_devices(void) { }
 static void __init mpc85xx_mds_qe_init(void) { }
 static void __init mpc85xx_mds_qeic_init(void) { }
 #endif	/* CONFIG_QUICC_ENGINE */
@@ -432,24 +412,12 @@ machine_arch_initcall(mpc8568_mds, board_fixups);
 machine_arch_initcall(mpc8569_mds, board_fixups);
 
 static struct of_device_id mpc85xx_ids[] = {
-	{ .type = "soc", },
-	{ .compatible = "soc", },
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
 	{ .compatible = "fsl,rapidio-delta", },
 	{ .compatible = "fsl,mpc8548-guts", },
 	{ .compatible = "gpio-leds", },
 	{},
 };
 
-static struct of_device_id p1021_ids[] = {
-	{ .type = "soc", },
-	{ .compatible = "soc", },
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
 static int __init mpc85xx_publish_devices(void)
 {
 	if (machine_is(mpc8568_mds))
@@ -457,23 +425,15 @@ static int __init mpc85xx_publish_devices(void)
 	if (machine_is(mpc8569_mds))
 		simple_gpiochip_init("fsl,mpc8569mds-bcsr-gpio");
 
+	mpc85xx_common_publish_devices();
 	of_platform_bus_probe(NULL, mpc85xx_ids, NULL);
-	mpc85xx_publish_qe_devices();
-
-	return 0;
-}
-
-static int __init p1021_publish_devices(void)
-{
-	of_platform_bus_probe(NULL, p1021_ids, NULL);
-	mpc85xx_publish_qe_devices();
 
 	return 0;
 }
 
 machine_device_initcall(mpc8568_mds, mpc85xx_publish_devices);
 machine_device_initcall(mpc8569_mds, mpc85xx_publish_devices);
-machine_device_initcall(p1021_mds, p1021_publish_devices);
+machine_device_initcall(p1021_mds, mpc85xx_common_publish_devices);
 
 machine_arch_initcall(mpc8568_mds, swiotlb_setup_bus_notifier);
 machine_arch_initcall(mpc8569_mds, swiotlb_setup_bus_notifier);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 824d2b6..9feccbb 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -111,20 +111,8 @@ static void __init mpc85xx_rdb_setup_arch(void)
 	printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n");
 }
 
-static struct of_device_id __initdata mpc85xxrdb_ids[] = {
-	{ .type = "soc", },
-	{ .compatible = "soc", },
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init mpc85xxrdb_publish_devices(void)
-{
-	return of_platform_bus_probe(NULL, mpc85xxrdb_ids, NULL);
-}
-machine_device_initcall(p2020_rdb, mpc85xxrdb_publish_devices);
-machine_device_initcall(p1020_rdb, mpc85xxrdb_publish_devices);
+machine_device_initcall(p2020_rdb, mpc85xx_common_publish_devices);
+machine_device_initcall(p1020_rdb, mpc85xx_common_publish_devices);
 
 /*
  * Called very early, device-tree isn't unflattened
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 00d93a4..cacb4d4 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -330,10 +330,6 @@ static void __init p1022_ds_setup_arch(void)
 }
 
 static struct of_device_id __initdata p1022_ds_ids[] = {
-	{ .type = "soc", },
-	{ .compatible = "soc", },
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
 	/* So that the DMA channel nodes can be probed individually: */
 	{ .compatible = "fsl,eloplus-dma", },
 	{},
@@ -343,6 +339,7 @@ static int __init p1022_ds_publish_devices(void)
 {
 	return of_platform_bus_probe(NULL, p1022_ds_ids, NULL);
 }
+machine_device_initcall(p1022_ds, mpc85xx_common_publish_devices);
 machine_device_initcall(p1022_ds, p1022_ds_publish_devices);
 
 machine_arch_initcall(p1022_ds, swiotlb_setup_bus_notifier);
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index d07dcb7..35deaa9 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -49,6 +49,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 static int sbc_rev;
 
 static void __init sbc8548_pic_init(void)
@@ -150,21 +152,7 @@ static void sbc8548_show_cpuinfo(struct seq_file *m)
 	seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
 }
 
-static struct of_device_id __initdata of_bus_ids[] = {
-	{ .name = "soc", },
-	{ .type = "soc", },
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init declare_of_platform_devices(void)
-{
-	of_platform_bus_probe(NULL, of_bus_ids, NULL);
-
-	return 0;
-}
-machine_device_initcall(sbc8548, declare_of_platform_devices);
+machine_device_initcall(sbc8548, mpc85xx_common_publish_devices);
 
 /*
  * Called very early, device-tree isn't unflattened
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index 43711f8..e9a7ed2 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -180,23 +180,7 @@ static void sbc8560_show_cpuinfo(struct seq_file *m)
 	seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
 }
 
-static struct of_device_id __initdata of_bus_ids[] = {
-	{ .name = "soc", },
-	{ .type = "soc", },
-	{ .name = "cpm", },
-	{ .name = "localbus", },
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init declare_of_platform_devices(void)
-{
-	of_platform_bus_probe(NULL, of_bus_ids, NULL);
-
-	return 0;
-}
-machine_device_initcall(sbc8560, declare_of_platform_devices);
+machine_device_initcall(sbc8560, mpc85xx_common_publish_devices);
 
 /*
  * Called very early, device-tree isn't unflattened
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index 9d0fc28..fec496a 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -97,17 +97,7 @@ static void __init socrates_setup_arch(void)
 #endif
 }
 
-static struct of_device_id __initdata socrates_of_bus_ids[] = {
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init socrates_publish_devices(void)
-{
-	return of_platform_bus_probe(NULL, socrates_of_bus_ids, NULL);
-}
-machine_device_initcall(socrates, socrates_publish_devices);
+machine_device_initcall(socrates, mpc85xx_common_publish_devices);
 
 /*
  * Called very early, device-tree isn't unflattened
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index d24192b..b44c936 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -113,19 +113,7 @@ static void stx_gp3_show_cpuinfo(struct seq_file *m)
 	seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
 }
 
-static struct of_device_id __initdata of_bus_ids[] = {
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init declare_of_platform_devices(void)
-{
-	of_platform_bus_probe(NULL, of_bus_ids, NULL);
-
-	return 0;
-}
-machine_device_initcall(stx_gp3, declare_of_platform_devices);
+machine_device_initcall(stx_gp3, mpc85xx_common_publish_devices);
 
 /*
  * Called very early, device-tree isn't unflattened
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index b9e53cc..2418bf8 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -142,19 +142,7 @@ static void __init tqm85xx_ti1520_fixup(struct pci_dev *pdev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520,
 		tqm85xx_ti1520_fixup);
 
-static struct of_device_id __initdata of_bus_ids[] = {
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init declare_of_platform_devices(void)
-{
-	of_platform_bus_probe(NULL, of_bus_ids, NULL);
-
-	return 0;
-}
-machine_device_initcall(tqm85xx, declare_of_platform_devices);
+machine_device_initcall(tqm85xx, mpc85xx_common_publish_devices);
 
 static const char *board[] __initdata = {
 	"tqc,tqm8540",
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index ab7025a..4632c1b 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -179,21 +179,9 @@ static void __init xes_mpc85xx_setup_arch(void)
 #endif
 }
 
-static struct of_device_id __initdata xes_mpc85xx_ids[] = {
-	{ .type = "soc", },
-	{ .compatible = "soc", },
-	{ .compatible = "simple-bus", },
-	{ .compatible = "gianfar", },
-	{},
-};
-
-static int __init xes_mpc85xx_publish_devices(void)
-{
-	return of_platform_bus_probe(NULL, xes_mpc85xx_ids, NULL);
-}
-machine_device_initcall(xes_mpc8572, xes_mpc85xx_publish_devices);
-machine_device_initcall(xes_mpc8548, xes_mpc85xx_publish_devices);
-machine_device_initcall(xes_mpc8540, xes_mpc85xx_publish_devices);
+machine_device_initcall(xes_mpc8572, mpc85xx_common_publish_devices);
+machine_device_initcall(xes_mpc8548, mpc85xx_common_publish_devices);
+machine_device_initcall(xes_mpc8540, mpc85xx_common_publish_devices);
 
 /*
  * Called very early, device-tree isn't unflattened
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 3/6] powerpc/85xx: separate MPIC handling code
  2011-11-17 17:56 [PATCH 1/6] powerpc/85xx: separate cpm2 pic init Dmitry Eremin-Solenikov
  2011-11-17 17:56 ` [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls Dmitry Eremin-Solenikov
@ 2011-11-17 17:56 ` Dmitry Eremin-Solenikov
  2011-11-17 18:30   ` Lee Nipper
  2011-11-17 21:33   ` Scott Wood
  2011-11-17 17:56 ` [PATCH 4/6] powerpc/85xx: unify common parts of *_setup_arch Dmitry Eremin-Solenikov
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-17 17:56 UTC (permalink / raw)
  To: linuxppc-dev

All mpc85xx boards deal with MPIC initialization in more or less the
same way. The only difrerences are some flags (WANTS_RESET,
BROKEN_FRR_NIRQS, SINGLE_DEST_CPU), and some bugs like leaking device
node counter, etc. To minimize problems, switch all boards to use one
single instance of code.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/platforms/85xx/corenet_ds.c     |   29 +-------------
 arch/powerpc/platforms/85xx/ksi8560.c        |   25 +------------
 arch/powerpc/platforms/85xx/mpc8536_ds.c     |   25 +------------
 arch/powerpc/platforms/85xx/mpc85xx.h        |    1 +
 arch/powerpc/platforms/85xx/mpc85xx_ads.c    |   24 +-----------
 arch/powerpc/platforms/85xx/mpc85xx_cds.c    |   27 +-------------
 arch/powerpc/platforms/85xx/mpc85xx_common.c |   43 +++++++++++++++++++++
 arch/powerpc/platforms/85xx/mpc85xx_ds.c     |   53 +++++++-------------------
 arch/powerpc/platforms/85xx/mpc85xx_mds.c    |   23 +-----------
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c    |   37 +----------------
 arch/powerpc/platforms/85xx/p1010rdb.c       |   28 +------------
 arch/powerpc/platforms/85xx/p1022_ds.c       |   27 +-------------
 arch/powerpc/platforms/85xx/p1023_rds.c      |   28 +------------
 arch/powerpc/platforms/85xx/sbc8548.c        |   27 +-------------
 arch/powerpc/platforms/85xx/sbc8560.c        |   24 +-----------
 arch/powerpc/platforms/85xx/socrates.c       |   22 +----------
 arch/powerpc/platforms/85xx/stx_gp3.c        |   24 +-----------
 arch/powerpc/platforms/85xx/tqm85xx.c        |   24 +-----------
 arch/powerpc/platforms/85xx/xes_mpc85xx.c    |   25 +------------
 19 files changed, 82 insertions(+), 434 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index 802ad11..b4abc01 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -32,34 +32,11 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 void __init corenet_ds_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np = NULL;
-	unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
-				MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
-
-	np = of_find_node_by_type(np, "open-pic");
-
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	if (ppc_md.get_irq == mpic_get_coreint_irq)
-		flags |= MPIC_ENABLE_COREINT;
-
-	mpic = mpic_alloc(np, r.start, flags, 0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(0, 1, 1);
 }
 
 /*
diff --git a/arch/powerpc/platforms/85xx/ksi8560.c b/arch/powerpc/platforms/85xx/ksi8560.c
index 0f3e688..2f5c3bb 100644
--- a/arch/powerpc/platforms/85xx/ksi8560.c
+++ b/arch/powerpc/platforms/85xx/ksi8560.c
@@ -57,30 +57,7 @@ static void machine_restart(char *cmd)
 
 static void __init ksi8560_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
-			0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 0, 0);
 
 	mpc85xx_cpm2_pic_init();
 }
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 9ee6455..223bb7a 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -36,30 +36,7 @@
 
 void __init mpc8536_ds_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-			  MPIC_PRIMARY | MPIC_WANTS_RESET |
-			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
-			0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 1, 0);
 }
 
 /*
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index 2aa7c5d..466923b 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -1,6 +1,7 @@
 #ifndef MPC85xx_H
 #define MPC85xx_H
 extern int mpc85xx_common_publish_devices(void);
+extern void mpc85xx_init_mpic(bool reset, bool broken_frr, bool singledest);
 
 #ifdef CONFIG_CPM2
 extern void mpc85xx_cpm2_pic_init(void);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 986554b..37edba4 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -50,29 +50,7 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
 
 static void __init mpc85xx_ads_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np = NULL;
-
-	np = of_find_node_by_type(np, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
-			0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 0, 0);
 
 	mpc85xx_cpm2_pic_init();
 }
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index a268f43..aa42202 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -188,32 +188,7 @@ static struct irqaction mpc85xxcds_8259_irqaction = {
 
 static void __init mpc85xx_cds_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np = NULL;
-
-	np = of_find_node_by_type(np, "open-pic");
-
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
-			0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-
-	/* Return the mpic node */
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 0, 0);
 }
 
 #if defined(CONFIG_PPC_I8259) && defined(CONFIG_PCI)
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_common.c b/arch/powerpc/platforms/85xx/mpc85xx_common.c
index fe40668..7579e24 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_common.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_common.c
@@ -7,6 +7,9 @@
  */
 #include <linux/of_platform.h>
 
+#include <asm/machdep.h>
+#include <asm/mpic.h>
+
 #include <sysdev/cpm2_pic.h>
 
 #include "mpc85xx.h"
@@ -63,3 +66,43 @@ void __init mpc85xx_cpm2_pic_init(void)
 	irq_set_chained_handler(irq, cpm2_cascade);
 }
 #endif
+
+
+void __init mpc85xx_init_mpic(bool reset, bool broken_frr, bool singledest)
+{
+	struct mpic *mpic;
+	struct resource r;
+	struct device_node *np = NULL;
+	unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
+				MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
+
+	np = of_find_node_by_type(np, "open-pic");
+
+	if (np == NULL) {
+		printk(KERN_ERR "Could not find open-pic node\n");
+		return;
+	}
+
+	if (of_address_to_resource(np, 0, &r)) {
+		printk(KERN_ERR "Failed to map mpic register space\n");
+		of_node_put(np);
+		return;
+	}
+
+	if (reset)
+		flags |= MPIC_WANTS_RESET;
+	if (broken_frr)
+		flags |= MPIC_BROKEN_FRR_NIRQS;
+	if (singledest)
+		flags |= MPIC_SINGLE_DEST_CPU;
+	if (ppc_md.get_irq == mpic_get_coreint_irq)
+		flags |= MPIC_ENABLE_COREINT;
+
+	mpic = mpic_alloc(np, r.start, flags, 0, 256, " OpenPIC  ");
+	BUG_ON(mpic == NULL);
+
+	/* Return the mpic node */
+	of_node_put(np);
+
+	mpic_init(mpic);
+}
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 2113120..7e535da 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -57,51 +57,13 @@ static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
 	}
 	chip->irq_eoi(&desc->irq_data);
 }
-#endif	/* CONFIG_PPC_I8259 */
 
-void __init mpc85xx_ds_pic_init(void)
+static void __init mpc85xx_ds_i8259_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
-#ifdef CONFIG_PPC_I8259
 	struct device_node *cascade_node = NULL;
 	int cascade_irq;
-#endif
-	unsigned long root = of_get_flat_dt_root();
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
-		mpic = mpic_alloc(np, r.start,
-			MPIC_PRIMARY |
-			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
-			MPIC_SINGLE_DEST_CPU,
-			0, 256, " OpenPIC  ");
-	} else {
-		mpic = mpic_alloc(np, r.start,
-			  MPIC_PRIMARY | MPIC_WANTS_RESET |
-			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
-			  MPIC_SINGLE_DEST_CPU,
-			0, 256, " OpenPIC  ");
-	}
-
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
 
-#ifdef CONFIG_PPC_I8259
 	/* Initialize the i8259 controller */
 	for_each_node_by_type(np, "interrupt-controller")
 	    if (of_device_is_compatible(np, "chrp,iic")) {
@@ -126,7 +88,20 @@ void __init mpc85xx_ds_pic_init(void)
 	of_node_put(cascade_node);
 
 	irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
+}
+#else
+#define mpc85xx_ds_i8259_init do {} while (0)
 #endif	/* CONFIG_PPC_I8259 */
+
+void __init mpc85xx_ds_pic_init(void)
+{
+	unsigned long root = of_get_flat_dt_root();
+
+	mpc85xx_init_mpic(
+		!of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP"),
+		1, 1);
+
+	mpc85xx_ds_i8259_init();
 }
 
 #ifdef CONFIG_PCI
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 3beb00b..c49d31f 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -441,28 +441,7 @@ machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
 
 static void __init mpc85xx_mds_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np = NULL;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np)
-		return;
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
-			MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
-			0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 1, 1);
 	mpc85xx_mds_qeic_init();
 }
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 9feccbb..d9ac565 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -43,42 +43,11 @@
 
 void __init mpc85xx_rdb_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np;
 	unsigned long root = of_get_flat_dt_root();
 
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
-		mpic = mpic_alloc(np, r.start,
-			MPIC_PRIMARY |
-			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
-			MPIC_SINGLE_DEST_CPU,
-			0, 256, " OpenPIC  ");
-	} else {
-		mpic = mpic_alloc(np, r.start,
-		  MPIC_PRIMARY | MPIC_WANTS_RESET |
-		  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
-		  MPIC_SINGLE_DEST_CPU,
-		  0, 256, " OpenPIC  ");
-	}
-
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
-
+	mpc85xx_init_mpic(
+		!of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP"),
+		1, 1);
 }
 
 /*
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index d7387fa..9273c6a 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -28,33 +28,11 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 void __init p1010_rdb_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start, MPIC_PRIMARY | MPIC_WANTS_RESET |
-	  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
-	  0, 256, " OpenPIC  ");
-
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
-
+	mpc85xx_init_mpic(1, 1, 1);
 }
 
 
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index cacb4d4..6a7fc02 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -242,32 +242,7 @@ int p1022ds_set_sysfs_monitor_port(int val)
 
 void __init p1022_ds_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np) {
-		pr_err("Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		pr_err("Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-		MPIC_PRIMARY | MPIC_WANTS_RESET |
-		MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
-		MPIC_SINGLE_DEST_CPU,
-		0, 256, " OpenPIC  ");
-
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 1, 1);
 }
 
 #ifdef CONFIG_SMP
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index 835e0b3..f6fc2b7 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -34,6 +34,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 /* ************************************************************************
  *
  * Setup the architecture
@@ -111,31 +113,7 @@ machine_device_initcall(p1023_rds, p1023_publish_devices);
 
 static void __init mpc85xx_rds_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np = NULL;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-		MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
-		MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
-		0, 256, " OpenPIC  ");
-
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 1, 1);
 }
 
 static int __init p1023_rds_probe(void)
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index 35deaa9..862c16e 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -55,32 +55,7 @@ static int sbc_rev;
 
 static void __init sbc8548_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np = NULL;
-
-	np = of_find_node_by_type(np, "open-pic");
-
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
-			0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-
-	/* Return the mpic node */
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 0, 0);
 }
 
 /* Extract the HW Rev from the EPLD on the board */
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index e9a7ed2..b211b63 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -41,29 +41,7 @@
 
 static void __init sbc8560_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np = NULL;
-
-	np = of_find_node_by_type(np, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
-			0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 0, 0);
 
 	mpc85xx_cpm2_pic_init();
 }
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index fec496a..a390d67 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -46,29 +46,9 @@
 
 static void __init socrates_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
 	struct device_node *np;
 
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
-			0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 0, 0);
 
 	np = of_find_compatible_node(NULL, NULL, "abb,socrates-fpga-pic");
 	if (!np) {
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index b44c936..cdd2d35 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -48,29 +48,7 @@
 
 static void __init stx_gp3_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
-			0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 0, 0);
 
 	mpc85xx_cpm2_pic_init();
 }
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 2418bf8..800842b 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -46,29 +46,7 @@
 
 static void __init tqm85xx_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Could not map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
-			0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 0, 0);
 
 	mpc85xx_cpm2_pic_init();
 }
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index 4632c1b..136b732 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -42,30 +42,7 @@
 
 void __init xes_mpc85xx_pic_init(void)
 {
-	struct mpic *mpic;
-	struct resource r;
-	struct device_node *np;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	if (of_address_to_resource(np, 0, &r)) {
-		printk(KERN_ERR "Failed to map mpic register space\n");
-		of_node_put(np);
-		return;
-	}
-
-	mpic = mpic_alloc(np, r.start,
-			  MPIC_PRIMARY | MPIC_WANTS_RESET |
-			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
-			0, 256, " OpenPIC  ");
-	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
-	mpic_init(mpic);
+	mpc85xx_init_mpic(1, 1, 0);
 }
 
 static void xes_mpc85xx_configure_l2(void __iomem *l2_base)
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 4/6] powerpc/85xx: unify common parts of *_setup_arch
  2011-11-17 17:56 [PATCH 1/6] powerpc/85xx: separate cpm2 pic init Dmitry Eremin-Solenikov
  2011-11-17 17:56 ` [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls Dmitry Eremin-Solenikov
  2011-11-17 17:56 ` [PATCH 3/6] powerpc/85xx: separate MPIC handling code Dmitry Eremin-Solenikov
@ 2011-11-17 17:56 ` Dmitry Eremin-Solenikov
  2011-11-17 17:56 ` [PATCH 5/6] powerpc/85xx: separate i8259 handling to common function Dmitry Eremin-Solenikov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-17 17:56 UTC (permalink / raw)
  To: linuxppc-dev

Refactor PCI, SWIOTLB and SMP handling out of board-specific setup_arch
functions. These tasks are more or less common to all boards and thus
can be moved to common place.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/platforms/85xx/corenet_ds.c     |   37 +------------------
 arch/powerpc/platforms/85xx/mpc8536_ds.c     |   33 +----------------
 arch/powerpc/platforms/85xx/mpc85xx.h        |    3 +
 arch/powerpc/platforms/85xx/mpc85xx_ads.c    |    9 +---
 arch/powerpc/platforms/85xx/mpc85xx_cds.c    |   18 +--------
 arch/powerpc/platforms/85xx/mpc85xx_common.c |   52 ++++++++++++++++++++++++++
 arch/powerpc/platforms/85xx/mpc85xx_ds.c     |   40 +-------------------
 arch/powerpc/platforms/85xx/mpc85xx_mds.c    |   40 +-------------------
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c    |   19 +---------
 arch/powerpc/platforms/85xx/p1010rdb.c       |   12 +-----
 arch/powerpc/platforms/85xx/p1022_ds.c       |   39 +-------------------
 arch/powerpc/platforms/85xx/p1023_rds.c      |   13 +------
 arch/powerpc/platforms/85xx/sbc8548.c        |   18 +--------
 arch/powerpc/platforms/85xx/sbc8560.c        |    9 +----
 arch/powerpc/platforms/85xx/socrates.c       |    9 +----
 arch/powerpc/platforms/85xx/stx_gp3.c        |    9 +----
 arch/powerpc/platforms/85xx/tqm85xx.c        |   19 +---------
 arch/powerpc/platforms/85xx/xes_mpc85xx.c    |   32 +---------------
 18 files changed, 74 insertions(+), 337 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index b4abc01..d782d55 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -42,45 +42,10 @@ void __init corenet_ds_pic_init(void)
 /*
  * Setup the architecture
  */
-#ifdef CONFIG_SMP
-void __init mpc85xx_smp_init(void);
-#endif
-
 void __init corenet_ds_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-	struct pci_controller *hose;
-#endif
-	dma_addr_t max = 0xffffffff;
-
-#ifdef CONFIG_SMP
-	mpc85xx_smp_init();
-#endif
-
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,p4080-pcie") ||
-		    of_device_is_compatible(np, "fsl,qoriq-pcie-v2.2")) {
-			fsl_add_bridge(np, 0);
-			hose = pci_find_hose_for_OF_device(np);
-			max = min(max, hose->dma_window_base_cur +
-					hose->dma_window_size);
-		}
-	}
-
-#ifdef CONFIG_PPC64
-	pci_devs_phb_init();
-#endif
-#endif
+	mpc85xx_setup_arch(MPC85xx_NO_PRIMARY_PHB);
 
-#ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
-		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
-#endif
 	pr_info("%s board from Freescale Semiconductor\n", ppc_md.name);
 }
 
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 223bb7a..8a7fc81 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -44,41 +44,10 @@ void __init mpc8536_ds_pic_init(void)
  */
 static void __init mpc8536_ds_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-	struct pci_controller *hose;
-#endif
-	dma_addr_t max = 0xffffffff;
-
 	if (ppc_md.progress)
 		ppc_md.progress("mpc8536_ds_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == 0x8000)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-
-			hose = pci_find_hose_for_OF_device(np);
-			max = min(max, hose->dma_window_base_cur +
-					hose->dma_window_size);
-		}
-	}
-
-#endif
-
-#ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
-		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
-#endif
+	mpc85xx_setup_arch(0x8000);
 
 	printk("MPC8536 DS board from Freescale Semiconductor\n");
 }
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index 466923b..e2a6631 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -9,4 +9,7 @@ extern void mpc85xx_cpm2_pic_init(void);
 static inline void __init mpc85xx_cpm2_pic_init(void) {}
 #endif /* CONFIG_CPM2 */
 
+#define MPC85xx_NO_PRIMARY_PHB 0xffff
+extern void mpc85xx_setup_arch(unsigned primary_phb_addr);
+
 #endif
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 37edba4..384b4cc 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -135,10 +135,6 @@ static void __init init_ioports(void)
 
 static void __init mpc85xx_ads_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
 
@@ -147,10 +143,9 @@ static void __init mpc85xx_ads_setup_arch(void)
 	init_ioports();
 #endif
 
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
-		fsl_add_bridge(np, 1);
+	mpc85xx_setup_arch(0x8000);
 
+#ifdef CONFIG_PCI
 	ppc_md.pci_exclude_device = mpc85xx_exclude_device;
 #endif
 }
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index aa42202..49366e7 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -245,10 +245,6 @@ machine_device_initcall(mpc85xx_cds, mpc85xx_cds_8259_attach);
  */
 static void __init mpc85xx_cds_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("mpc85xx_cds_setup_arch()", 0);
 
@@ -262,19 +258,9 @@ static void __init mpc85xx_cds_setup_arch(void)
 		ppc_md.progress(buf, 0);
 	}
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == 0x8000)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-		}
-	}
+	mpc85xx_setup_arch(0x8000);
 
+#ifdef CONFIG_PCI
 	ppc_md.pci_irq_fixup = mpc85xx_cds_pci_irq_fixup;
 	ppc_md.pci_exclude_device = mpc85xx_exclude_device;
 #endif
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_common.c b/arch/powerpc/platforms/85xx/mpc85xx_common.c
index 7579e24..87e61a3 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_common.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_common.c
@@ -5,12 +5,15 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/memblock.h>
 #include <linux/of_platform.h>
+#include <linux/pci.h>
 
 #include <asm/machdep.h>
 #include <asm/mpic.h>
 
 #include <sysdev/cpm2_pic.h>
+#include <sysdev/fsl_pci.h>
 
 #include "mpc85xx.h"
 
@@ -106,3 +109,52 @@ void __init mpc85xx_init_mpic(bool reset, bool broken_frr, bool singledest)
 
 	mpic_init(mpic);
 }
+
+#ifdef CONFIG_SMP
+extern void __init mpc85xx_smp_init(void);
+#endif
+
+void __init mpc85xx_setup_arch(unsigned primary_phb_addr)
+{
+	dma_addr_t max = 0xffffffff;
+
+#ifdef CONFIG_PCI
+	struct device_node *np;
+	struct pci_controller *hose;
+
+	for_each_node_by_type(np, "pci") {
+		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
+		    of_device_is_compatible(np, "fsl,mpc8548-pcie") ||
+		    of_device_is_compatible(np, "fsl,p2020-pcie") ||
+		    of_device_is_compatible(np, "fsl,p4080-pcie") ||
+		    of_device_is_compatible(np, "fsl,qoriq-pcie-v2.2")) {
+			struct resource rsrc;
+			of_address_to_resource(np, 0, &rsrc);
+			if ((rsrc.start & 0xfffff) == primary_phb_addr)
+				fsl_add_bridge(np, 1);
+			else
+				fsl_add_bridge(np, 0);
+
+			hose = pci_find_hose_for_OF_device(np);
+			max = min(max, hose->dma_window_base_cur +
+					hose->dma_window_size);
+		}
+	}
+
+#ifdef CONFIG_PPC64
+	pci_devs_phb_init();
+#endif
+#endif
+
+#ifdef CONFIG_SMP
+	mpc85xx_smp_init();
+#endif
+
+#ifdef CONFIG_SWIOTLB
+	if (memblock_end_of_DRAM() > max) {
+		ppc_swiotlb_enable = 1;
+		set_pci_dma_ops(&swiotlb_dma_ops);
+		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
+	}
+#endif
+}
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 7e535da..bd9931a 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -129,53 +129,17 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
 /*
  * Setup the architecture
  */
-#ifdef CONFIG_SMP
-extern void __init mpc85xx_smp_init(void);
-#endif
 static void __init mpc85xx_ds_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-	struct pci_controller *hose;
-#endif
-	dma_addr_t max = 0xffffffff;
-
 	if (ppc_md.progress)
 		ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie") ||
-		    of_device_is_compatible(np, "fsl,p2020-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == primary_phb_addr)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-
-			hose = pci_find_hose_for_OF_device(np);
-			max = min(max, hose->dma_window_base_cur +
-					hose->dma_window_size);
-		}
-	}
+	mpc85xx_setup_arch(primary_phb_addr);
 
+#ifdef CONFIG_PCI
 	ppc_md.pci_exclude_device = mpc85xx_exclude_device;
 #endif
 
-#ifdef CONFIG_SMP
-	mpc85xx_smp_init();
-#endif
-
-#ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
-		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
-#endif
-
 	printk("MPC85xx DS board from Freescale Semiconductor\n");
 }
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index c49d31f..1f5f1af 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -156,10 +156,6 @@ static int mpc8568_mds_phy_fixups(struct phy_device *phydev)
  * Setup the architecture
  *
  */
-#ifdef CONFIG_SMP
-extern void __init mpc85xx_smp_init(void);
-#endif
-
 #ifdef CONFIG_QUICC_ENGINE
 static void __init mpc85xx_mds_reset_ucc_phys(void)
 {
@@ -337,46 +333,12 @@ static void __init mpc85xx_mds_qeic_init(void) { }
 
 static void __init mpc85xx_mds_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct pci_controller *hose;
-	struct device_node *np;
-#endif
-	dma_addr_t max = 0xffffffff;
-
 	if (ppc_md.progress)
 		ppc_md.progress("mpc85xx_mds_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == 0x8000)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-
-			hose = pci_find_hose_for_OF_device(np);
-			max = min(max, hose->dma_window_base_cur +
-					hose->dma_window_size);
-		}
-	}
-#endif
-
-#ifdef CONFIG_SMP
-	mpc85xx_smp_init();
-#endif
+	mpc85xx_setup_arch(0x8000);
 
 	mpc85xx_mds_qe_init();
-
-#ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
-		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
-#endif
 }
 
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index d9ac565..82906b0 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -53,29 +53,12 @@ void __init mpc85xx_rdb_pic_init(void)
 /*
  * Setup the architecture
  */
-#ifdef CONFIG_SMP
-extern void __init mpc85xx_smp_init(void);
-#endif
 static void __init mpc85xx_rdb_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("mpc85xx_rdb_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8548-pcie"))
-			fsl_add_bridge(np, 0);
-	}
-
-#endif
-
-#ifdef CONFIG_SMP
-	mpc85xx_smp_init();
-#endif
+	mpc85xx_setup_arch(MPC85xx_NO_PRIMARY_PHB);
 
 	printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n");
 }
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index 9273c6a..832ed1d 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -41,20 +41,10 @@ void __init p1010_rdb_pic_init(void)
  */
 static void __init p1010_rdb_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("p1010_rdb_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,p1010-pcie"))
-			fsl_add_bridge(np, 0);
-	}
-
-#endif
+	mpc85xx_setup_arch(MPC85xx_NO_PRIMARY_PHB);
 
 	printk(KERN_INFO "P1010 RDB board from Freescale Semiconductor\n");
 }
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 6a7fc02..82da3dd 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -245,41 +245,14 @@ void __init p1022_ds_pic_init(void)
 	mpc85xx_init_mpic(1, 1, 1);
 }
 
-#ifdef CONFIG_SMP
-void __init mpc85xx_smp_init(void);
-#endif
-
 /*
  * Setup the architecture
  */
 static void __init p1022_ds_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-	dma_addr_t max = 0xffffffff;
-
 	if (ppc_md.progress)
 		ppc_md.progress("p1022_ds_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,p1022-pcie") {
-		struct resource rsrc;
-		struct pci_controller *hose;
-
-		of_address_to_resource(np, 0, &rsrc);
-
-		if ((rsrc.start & 0xfffff) == 0x8000)
-			fsl_add_bridge(np, 1);
-		else
-			fsl_add_bridge(np, 0);
-
-		hose = pci_find_hose_for_OF_device(np);
-		max = min(max, hose->dma_window_base_cur +
-			  hose->dma_window_size);
-	}
-#endif
-
 #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
 	diu_ops.get_pixel_format	= p1022ds_get_pixel_format;
 	diu_ops.set_gamma_table		= p1022ds_set_gamma_table;
@@ -289,17 +262,7 @@ static void __init p1022_ds_setup_arch(void)
 	diu_ops.set_sysfs_monitor_port	= p1022ds_set_sysfs_monitor_port;
 #endif
 
-#ifdef CONFIG_SMP
-	mpc85xx_smp_init();
-#endif
-
-#ifdef CONFIG_SWIOTLB
-	if (memblock_end_of_DRAM() > max) {
-		ppc_swiotlb_enable = 1;
-		set_pci_dma_ops(&swiotlb_dma_ops);
-		ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-	}
-#endif
+	mpc85xx_setup_arch(0x8000);
 
 	pr_info("Freescale P1022 DS reference board\n");
 }
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index f6fc2b7..0098775 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -41,10 +41,6 @@
  * Setup the architecture
  *
  */
-#ifdef CONFIG_SMP
-void __init mpc85xx_smp_init(void);
-#endif
-
 static void __init mpc85xx_rds_setup_arch(void)
 {
 	struct device_node *np;
@@ -84,14 +80,7 @@ static void __init mpc85xx_rds_setup_arch(void)
 		}
 	}
 
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,p1023-pcie")
-		fsl_add_bridge(np, 0);
-#endif
-
-#ifdef CONFIG_SMP
-	mpc85xx_smp_init();
-#endif
+	mpc85xx_setup_arch(MPC85xx_NO_PRIMARY_PHB);
 }
 
 static struct of_device_id p1023_ids[] = {
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index 862c16e..e948b4c 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -87,26 +87,10 @@ static int __init sbc8548_hw_rev(void)
  */
 static void __init sbc8548_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("sbc8548_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == 0x8000)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-		}
-	}
-#endif
+	mpc85xx_setup_arch(0x8000);
 	sbc_rev = sbc8548_hw_rev();
 }
 
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index b211b63..b0c62f0 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -124,10 +124,6 @@ static void __init init_ioports(void)
 
 static void __init sbc8560_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("sbc8560_setup_arch()", 0);
 
@@ -136,10 +132,7 @@ static void __init sbc8560_setup_arch(void)
 	init_ioports();
 #endif
 
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
-		fsl_add_bridge(np, 1);
-#endif
+	mpc85xx_setup_arch(0x8000);
 }
 
 static void sbc8560_show_cpuinfo(struct seq_file *m)
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index a390d67..67535a5 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -64,17 +64,10 @@ static void __init socrates_pic_init(void)
  */
 static void __init socrates_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("socrates_setup_arch()", 0);
 
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
-		fsl_add_bridge(np, 1);
-#endif
+	mpc85xx_setup_arch(0x8000);
 }
 
 machine_device_initcall(socrates, mpc85xx_common_publish_devices);
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index cdd2d35..18a9fc5 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -58,10 +58,6 @@ static void __init stx_gp3_pic_init(void)
  */
 static void __init stx_gp3_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("stx_gp3_setup_arch()", 0);
 
@@ -69,10 +65,7 @@ static void __init stx_gp3_setup_arch(void)
 	cpm2_reset();
 #endif
 
-#ifdef CONFIG_PCI
-	for_each_compatible_node(np, "pci", "fsl,mpc8540-pci")
-		fsl_add_bridge(np, 1);
-#endif
+	mpc85xx_setup_arch(0x8000);
 }
 
 static void stx_gp3_show_cpuinfo(struct seq_file *m)
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 800842b..56c5518 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -56,10 +56,6 @@ static void __init tqm85xx_pic_init(void)
  */
 static void __init tqm85xx_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
-
 	if (ppc_md.progress)
 		ppc_md.progress("tqm85xx_setup_arch()", 0);
 
@@ -67,20 +63,7 @@ static void __init tqm85xx_setup_arch(void)
 	cpm2_reset();
 #endif
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			if (!of_address_to_resource(np, 0, &rsrc)) {
-				if ((rsrc.start & 0xfffff) == 0x8000)
-					fsl_add_bridge(np, 1);
-				else
-					fsl_add_bridge(np, 0);
-			}
-		}
-	}
-#endif
+	mpc85xx_setup_arch(0x8000);
 }
 
 static void tqm85xx_show_cpuinfo(struct seq_file *m)
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index 136b732..e1ddff5 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -108,21 +108,13 @@ static void xes_mpc85xx_fixups(void)
 	}
 }
 
-#ifdef CONFIG_PCI
 static int primary_phb_addr;
-#endif
 
 /*
  * Setup the architecture
  */
-#ifdef CONFIG_SMP
-extern void __init mpc85xx_smp_init(void);
-#endif
 static void __init xes_mpc85xx_setup_arch(void)
 {
-#ifdef CONFIG_PCI
-	struct device_node *np;
-#endif
 	struct device_node *root;
 	const char *model = "Unknown";
 
@@ -137,23 +129,7 @@ static void __init xes_mpc85xx_setup_arch(void)
 
 	xes_mpc85xx_fixups();
 
-#ifdef CONFIG_PCI
-	for_each_node_by_type(np, "pci") {
-		if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
-		    of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
-			struct resource rsrc;
-			of_address_to_resource(np, 0, &rsrc);
-			if ((rsrc.start & 0xfffff) == primary_phb_addr)
-				fsl_add_bridge(np, 1);
-			else
-				fsl_add_bridge(np, 0);
-		}
-	}
-#endif
-
-#ifdef CONFIG_SMP
-	mpc85xx_smp_init();
-#endif
+	mpc85xx_setup_arch(primary_phb_addr);
 }
 
 machine_device_initcall(xes_mpc8572, mpc85xx_common_publish_devices);
@@ -168,9 +144,7 @@ static int __init xes_mpc8572_probe(void)
 	unsigned long root = of_get_flat_dt_root();
 
 	if (of_flat_dt_is_compatible(root, "xes,MPC8572")) {
-#ifdef CONFIG_PCI
 		primary_phb_addr = 0x8000;
-#endif
 		return 1;
 	} else {
 		return 0;
@@ -182,9 +156,7 @@ static int __init xes_mpc8548_probe(void)
 	unsigned long root = of_get_flat_dt_root();
 
 	if (of_flat_dt_is_compatible(root, "xes,MPC8548")) {
-#ifdef CONFIG_PCI
 		primary_phb_addr = 0xb000;
-#endif
 		return 1;
 	} else {
 		return 0;
@@ -196,9 +168,7 @@ static int __init xes_mpc8540_probe(void)
 	unsigned long root = of_get_flat_dt_root();
 
 	if (of_flat_dt_is_compatible(root, "xes,MPC8540")) {
-#ifdef CONFIG_PCI
 		primary_phb_addr = 0xb000;
-#endif
 		return 1;
 	} else {
 		return 0;
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 5/6] powerpc/85xx: separate i8259 handling to common function
  2011-11-17 17:56 [PATCH 1/6] powerpc/85xx: separate cpm2 pic init Dmitry Eremin-Solenikov
                   ` (2 preceding siblings ...)
  2011-11-17 17:56 ` [PATCH 4/6] powerpc/85xx: unify common parts of *_setup_arch Dmitry Eremin-Solenikov
@ 2011-11-17 17:56 ` Dmitry Eremin-Solenikov
  2011-11-17 17:56 ` [PATCH 6/6] poewrpc/85xx: headers cleanup Dmitry Eremin-Solenikov
  2011-11-24  7:15 ` [PATCH 1/6] powerpc/85xx: separate cpm2 pic init Kumar Gala
  5 siblings, 0 replies; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-17 17:56 UTC (permalink / raw)
  To: linuxppc-dev

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/platforms/85xx/mpc85xx.h        |    4 +++
 arch/powerpc/platforms/85xx/mpc85xx_cds.c    |   25 +-----------------
 arch/powerpc/platforms/85xx/mpc85xx_common.c |   36 ++++++++++++++++++++++++++
 arch/powerpc/platforms/85xx/mpc85xx_ds.c     |   27 +------------------
 4 files changed, 42 insertions(+), 50 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
index e2a6631..1bf61f3 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx.h
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -12,4 +12,8 @@ static inline void __init mpc85xx_cpm2_pic_init(void) {}
 #define MPC85xx_NO_PRIMARY_PHB 0xffff
 extern void mpc85xx_setup_arch(unsigned primary_phb_addr);
 
+#ifdef CONFIG_PPC_I8259
+extern int mpc85xx_i8259_setup_irq(void);
+#endif
+
 #endif
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 49366e7..0e551d7 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -195,30 +195,7 @@ static void __init mpc85xx_cds_pic_init(void)
 static int mpc85xx_cds_8259_attach(void)
 {
 	int ret;
-	struct device_node *np = NULL;
-	struct device_node *cascade_node = NULL;
-	int cascade_irq;
-
-	/* Initialize the i8259 controller */
-	for_each_node_by_type(np, "interrupt-controller")
-		if (of_device_is_compatible(np, "chrp,iic")) {
-			cascade_node = np;
-			break;
-		}
-
-	if (cascade_node == NULL) {
-		printk(KERN_DEBUG "Could not find i8259 PIC\n");
-		return -ENODEV;
-	}
-
-	cascade_irq = irq_of_parse_and_map(cascade_node, 0);
-	if (cascade_irq == NO_IRQ) {
-		printk(KERN_ERR "Failed to map cascade interrupt\n");
-		return -ENXIO;
-	}
-
-	i8259_init(cascade_node, 0);
-	of_node_put(cascade_node);
+	int cascade_irq = mpc85xx_i8259_setup_irq();
 
 	/*
 	 *  Hook the interrupt to make sure desc->action is never NULL.
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_common.c b/arch/powerpc/platforms/85xx/mpc85xx_common.c
index 87e61a3..1602c7a 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_common.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_common.c
@@ -9,6 +9,7 @@
 #include <linux/of_platform.h>
 #include <linux/pci.h>
 
+#include <asm/i8259.h>
 #include <asm/machdep.h>
 #include <asm/mpic.h>
 
@@ -158,3 +159,38 @@ void __init mpc85xx_setup_arch(unsigned primary_phb_addr)
 	}
 #endif
 }
+
+#ifdef CONFIG_PPC_I8259
+int __init mpc85xx_i8259_setup_irq(void)
+{
+	struct device_node *np;
+	struct device_node *cascade_node = NULL;
+	int cascade_irq;
+
+	/* Initialize the i8259 controller */
+	for_each_node_by_type(np, "interrupt-controller")
+		if (of_device_is_compatible(np, "chrp,iic")) {
+			cascade_node = np;
+			break;
+		}
+
+	if (cascade_node == NULL) {
+		printk(KERN_DEBUG "Could not find i8259 PIC\n");
+		return -ENODEV;
+	}
+
+	cascade_irq = irq_of_parse_and_map(cascade_node, 0);
+	if (cascade_irq == NO_IRQ) {
+		printk(KERN_ERR "Failed to map cascade interrupt\n");
+		return -ENXIO;
+	}
+
+	pr_debug("%s: cascade mapped to irq %d\n", __func__, cascade_irq);
+
+	i8259_init(cascade_node, 0);
+	of_node_put(cascade_node);
+
+	return cascade_irq;
+}
+
+#endif
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index bd9931a..246d33a 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -60,32 +60,7 @@ static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
 
 static void __init mpc85xx_ds_i8259_init(void)
 {
-	struct device_node *np;
-	struct device_node *cascade_node = NULL;
-	int cascade_irq;
-
-	/* Initialize the i8259 controller */
-	for_each_node_by_type(np, "interrupt-controller")
-	    if (of_device_is_compatible(np, "chrp,iic")) {
-		cascade_node = np;
-		break;
-	}
-
-	if (cascade_node == NULL) {
-		printk(KERN_DEBUG "Could not find i8259 PIC\n");
-		return;
-	}
-
-	cascade_irq = irq_of_parse_and_map(cascade_node, 0);
-	if (cascade_irq == NO_IRQ) {
-		printk(KERN_ERR "Failed to map cascade interrupt\n");
-		return;
-	}
-
-	DBG("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
-
-	i8259_init(cascade_node, 0);
-	of_node_put(cascade_node);
+	int cascade_irq = mpc85xx_i8259_setup_irq();
 
 	irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
 }
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 6/6] poewrpc/85xx: headers cleanup
  2011-11-17 17:56 [PATCH 1/6] powerpc/85xx: separate cpm2 pic init Dmitry Eremin-Solenikov
                   ` (3 preceding siblings ...)
  2011-11-17 17:56 ` [PATCH 5/6] powerpc/85xx: separate i8259 handling to common function Dmitry Eremin-Solenikov
@ 2011-11-17 17:56 ` Dmitry Eremin-Solenikov
  2011-11-17 21:22   ` Stephen Rothwell
  2011-11-24  7:15 ` [PATCH 1/6] powerpc/85xx: separate cpm2 pic init Kumar Gala
  5 siblings, 1 reply; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-17 17:56 UTC (permalink / raw)
  To: linuxppc-dev

Drop lots of unused headers after board files merge/splitup

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 arch/powerpc/platforms/85xx/corenet_ds.c  |   17 ---------------
 arch/powerpc/platforms/85xx/ksi8560.c     |   16 ---------------
 arch/powerpc/platforms/85xx/mpc8536_ds.c  |   13 ------------
 arch/powerpc/platforms/85xx/mpc85xx_ads.c |   10 ---------
 arch/powerpc/platforms/85xx/mpc85xx_cds.c |   23 ---------------------
 arch/powerpc/platforms/85xx/mpc85xx_ds.c  |   12 -----------
 arch/powerpc/platforms/85xx/mpc85xx_mds.c |   31 +++-------------------------
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c |   12 -----------
 arch/powerpc/platforms/85xx/p1010rdb.c    |   10 ---------
 arch/powerpc/platforms/85xx/p1022_ds.c    |    5 +--
 arch/powerpc/platforms/85xx/p1023_rds.c   |   13 ------------
 arch/powerpc/platforms/85xx/p2041_rdb.c   |   15 +-------------
 arch/powerpc/platforms/85xx/p3041_ds.c    |   15 +-------------
 arch/powerpc/platforms/85xx/p3060_qds.c   |    8 ++----
 arch/powerpc/platforms/85xx/p4080_ds.c    |   14 +------------
 arch/powerpc/platforms/85xx/p5020_ds.c    |   15 +-------------
 arch/powerpc/platforms/85xx/sbc8548.c     |   28 --------------------------
 arch/powerpc/platforms/85xx/sbc8560.c     |   15 +-------------
 arch/powerpc/platforms/85xx/socrates.c    |   15 +-------------
 arch/powerpc/platforms/85xx/stx_gp3.c     |   15 +-------------
 arch/powerpc/platforms/85xx/tqm85xx.c     |   13 +-----------
 arch/powerpc/platforms/85xx/xes_mpc85xx.c |   14 -------------
 22 files changed, 17 insertions(+), 312 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index d782d55..8028d37 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -11,26 +11,9 @@
  * option) any later version.
  */
 
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/memblock.h>
-
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/ppc-pci.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
-#include <asm/udbg.h>
-#include <asm/mpic.h>
 
 #include <linux/of_platform.h>
-#include <sysdev/fsl_soc.h>
-#include <sysdev/fsl_pci.h>
 
 #include "mpc85xx.h"
 
diff --git a/arch/powerpc/platforms/85xx/ksi8560.c b/arch/powerpc/platforms/85xx/ksi8560.c
index 2f5c3bb..2c7f9d9 100644
--- a/arch/powerpc/platforms/85xx/ksi8560.c
+++ b/arch/powerpc/platforms/85xx/ksi8560.c
@@ -12,28 +12,12 @@
  *
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
 #include <linux/of_platform.h>
 
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
 #include <asm/mpic.h>
-#include <mm/mmu_decl.h>
-#include <asm/udbg.h>
-#include <asm/prom.h>
-
-#include <sysdev/fsl_soc.h>
-#include <sysdev/fsl_pci.h>
 
 #include <asm/cpm2.h>
-#include <sysdev/cpm2_pic.h>
 
 #include "mpc85xx.h"
 
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 8a7fc81..cc46db4 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -9,22 +9,9 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/interrupt.h>
 #include <linux/of_platform.h>
-#include <linux/memblock.h>
 
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
 #include <asm/swiotlb.h>
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 384b4cc..27298ec 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -11,20 +11,11 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
 #include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
 #include <linux/of_platform.h>
 
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
 #include <asm/mpic.h>
-#include <mm/mmu_decl.h>
 #include <asm/udbg.h>
 
 #include <sysdev/fsl_soc.h>
@@ -32,7 +23,6 @@
 
 #ifdef CONFIG_CPM2
 #include <asm/cpm2.h>
-#include <sysdev/cpm2_pic.h>
 #endif
 
 #include "mpc85xx.h"
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 0e551d7..b9bb364 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -11,35 +11,12 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
 #include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/major.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/initrd.h>
-#include <linux/module.h>
 #include <linux/interrupt.h>
-#include <linux/fsl_devices.h>
 #include <linux/of_platform.h>
 
-#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <linux/atomic.h>
-#include <asm/time.h>
-#include <asm/io.h>
 #include <asm/machdep.h>
-#include <asm/ipic.h>
-#include <asm/pci-bridge.h>
 #include <asm/irq.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
 #include <asm/i8259.h>
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 246d33a..f43537c 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -12,26 +12,14 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
 #include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
 #include <linux/interrupt.h>
 #include <linux/of_platform.h>
-#include <linux/memblock.h>
 
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
 #include <asm/i8259.h>
-#include <asm/swiotlb.h>
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 1f5f1af..69a80b8 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -16,42 +16,19 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/major.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/initrd.h>
-#include <linux/module.h>
-#include <linux/fsl_devices.h>
 #include <linux/of_platform.h>
 #include <linux/of_device.h>
 #include <linux/phy.h>
-#include <linux/memblock.h>
 
-#include <asm/system.h>
-#include <linux/atomic.h>
-#include <asm/time.h>
-#include <asm/io.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/irq.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
-#include <sysdev/fsl_soc.h>
-#include <sysdev/fsl_pci.h>
-#include <sysdev/simple_gpio.h>
 #include <asm/qe.h>
 #include <asm/qe_ic.h>
 #include <asm/mpic.h>
-#include <asm/swiotlb.h>
+
+#include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
+#include <sysdev/simple_gpio.h>
 
 #include "mpc85xx.h"
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 82906b0..b6578a5 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -9,21 +9,9 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/interrupt.h>
 #include <linux/of_platform.h>
 
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
 
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index 832ed1d..d68c5f8 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -9,19 +9,9 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
 #include <linux/of_platform.h>
 
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
 
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 82da3dd..fd2ec71 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -18,14 +18,13 @@
 
 #include <linux/pci.h>
 #include <linux/of_platform.h>
-#include <linux/memblock.h>
 #include <asm/div64.h>
+#include <asm/udbg.h>
 #include <asm/mpic.h>
-#include <asm/swiotlb.h>
+#include <asm/fsl_guts.h>
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
-#include <asm/fsl_guts.h>
 
 #include "mpc85xx.h"
 
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index 0098775..f14b315 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -12,22 +12,9 @@
  * option) any later version.
  */
 
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/pci.h>
-#include <linux/delay.h>
-#include <linux/module.h>
-#include <linux/fsl_devices.h>
 #include <linux/of_platform.h>
-#include <linux/of_device.h>
 
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
 
diff --git a/arch/powerpc/platforms/85xx/p2041_rdb.c b/arch/powerpc/platforms/85xx/p2041_rdb.c
index eda6ed5..985ee0e 100644
--- a/arch/powerpc/platforms/85xx/p2041_rdb.c
+++ b/arch/powerpc/platforms/85xx/p2041_rdb.c
@@ -9,26 +9,13 @@
  * option) any later version.
  */
 
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/phy.h>
-
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
+#include <asm/ehv_pic.h>
 
-#include <linux/of_platform.h>
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
-#include <asm/ehv_pic.h>
 
 #include "corenet_ds.h"
 
diff --git a/arch/powerpc/platforms/85xx/p3041_ds.c b/arch/powerpc/platforms/85xx/p3041_ds.c
index 96d99a3..b969c1f 100644
--- a/arch/powerpc/platforms/85xx/p3041_ds.c
+++ b/arch/powerpc/platforms/85xx/p3041_ds.c
@@ -11,26 +11,13 @@
  * option) any later version.
  */
 
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/phy.h>
-
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
+#include <asm/ehv_pic.h>
 
-#include <linux/of_platform.h>
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
-#include <asm/ehv_pic.h>
 
 #include "corenet_ds.h"
 
diff --git a/arch/powerpc/platforms/85xx/p3060_qds.c b/arch/powerpc/platforms/85xx/p3060_qds.c
index 01dcf44..318a2de 100644
--- a/arch/powerpc/platforms/85xx/p3060_qds.c
+++ b/arch/powerpc/platforms/85xx/p3060_qds.c
@@ -9,16 +9,14 @@
  * option) any later version.
  */
 
-#include <linux/kernel.h>
-#include <linux/interrupt.h>
-#include <linux/phy.h>
 #include <asm/machdep.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
-#include <linux/of_platform.h>
+#include <asm/ehv_pic.h>
+
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
-#include <asm/ehv_pic.h>
+
 #include "corenet_ds.h"
 
 /*
diff --git a/arch/powerpc/platforms/85xx/p4080_ds.c b/arch/powerpc/platforms/85xx/p4080_ds.c
index d1b21d7..bd5ded3 100644
--- a/arch/powerpc/platforms/85xx/p4080_ds.c
+++ b/arch/powerpc/platforms/85xx/p4080_ds.c
@@ -11,25 +11,13 @@
  * option) any later version.
  */
 
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
+#include <asm/ehv_pic.h>
 
-#include <linux/of_platform.h>
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
-#include <asm/ehv_pic.h>
 
 #include "corenet_ds.h"
 
diff --git a/arch/powerpc/platforms/85xx/p5020_ds.c b/arch/powerpc/platforms/85xx/p5020_ds.c
index e8cba50..1ff0277 100644
--- a/arch/powerpc/platforms/85xx/p5020_ds.c
+++ b/arch/powerpc/platforms/85xx/p5020_ds.c
@@ -11,26 +11,13 @@
  * option) any later version.
  */
 
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/phy.h>
-
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
+#include <asm/ehv_pic.h>
 
-#include <linux/of_platform.h>
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
-#include <asm/ehv_pic.h>
 
 #include "corenet_ds.h"
 
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index e948b4c..32f5d4d 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -14,35 +14,7 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/reboot.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/major.h>
-#include <linux/console.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/initrd.h>
-#include <linux/module.h>
-#include <linux/interrupt.h>
-#include <linux/fsl_devices.h>
-#include <linux/of_platform.h>
-
-#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <linux/atomic.h>
-#include <asm/time.h>
-#include <asm/io.h>
 #include <asm/machdep.h>
-#include <asm/ipic.h>
-#include <asm/pci-bridge.h>
-#include <asm/irq.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
 
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index b0c62f0..adae8a5 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -13,21 +13,9 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/of_platform.h>
-
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/mpic.h>
-#include <mm/mmu_decl.h>
 #include <asm/udbg.h>
+#include <asm/mpic.h>
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
@@ -36,7 +24,6 @@
 
 #ifdef CONFIG_CPM2
 #include <asm/cpm2.h>
-#include <sysdev/cpm2_pic.h>
 #endif
 
 static void __init sbc8560_pic_init(void)
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index 67535a5..d414ce7 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -21,22 +21,9 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/of_platform.h>
-
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/mpic.h>
-#include <asm/prom.h>
-#include <mm/mmu_decl.h>
 #include <asm/udbg.h>
+#include <asm/mpic.h>
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index 18a9fc5..407abba 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -20,22 +20,9 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/of_platform.h>
-
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/mpic.h>
-#include <asm/prom.h>
-#include <mm/mmu_decl.h>
 #include <asm/udbg.h>
+#include <asm/mpic.h>
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 56c5518..3d89453 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -18,22 +18,11 @@
  * option) any later version.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
 #include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/of_platform.h>
 
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <asm/mpic.h>
-#include <asm/prom.h>
-#include <mm/mmu_decl.h>
 #include <asm/udbg.h>
+#include <asm/mpic.h>
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index e1ddff5..77b6a37 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -12,21 +12,7 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/stddef.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/kdev_t.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/interrupt.h>
-#include <linux/of_platform.h>
-
-#include <asm/system.h>
-#include <asm/time.h>
 #include <asm/machdep.h>
-#include <asm/pci-bridge.h>
-#include <mm/mmu_decl.h>
-#include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
 
-- 
1.7.7.1

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/6] powerpc/85xx: separate MPIC handling code
  2011-11-17 17:56 ` [PATCH 3/6] powerpc/85xx: separate MPIC handling code Dmitry Eremin-Solenikov
@ 2011-11-17 18:30   ` Lee Nipper
  2011-11-17 18:43     ` Dmitry Eremin-Solenikov
  2011-11-17 21:33   ` Scott Wood
  1 sibling, 1 reply; 22+ messages in thread
From: Lee Nipper @ 2011-11-17 18:30 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linuxppc-dev

On Thu, Nov 17, 2011 at 11:56 AM, Dmitry Eremin-Solenikov
<dbaryshkov@gmail.com> wrote:
> All mpc85xx boards deal with MPIC initialization in more or less the
> same way. The only difrerences are some flags (WANTS_RESET,
> BROKEN_FRR_NIRQS, SINGLE_DEST_CPU), and some bugs like leaking device
> node counter, etc. To minimize problems, switch all boards to use one
> single instance of code.
>
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

<snip>

> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_common.c b/arch/powerpc/=
platforms/85xx/mpc85xx_common.c
> index fe40668..7579e24 100644
> --- a/arch/powerpc/platforms/85xx/mpc85xx_common.c
> +++ b/arch/powerpc/platforms/85xx/mpc85xx_common.c
> @@ -7,6 +7,9 @@
> =A0*/
> =A0#include <linux/of_platform.h>
>
> +#include <asm/machdep.h>
> +#include <asm/mpic.h>
> +
> =A0#include <sysdev/cpm2_pic.h>
>
> =A0#include "mpc85xx.h"
> @@ -63,3 +66,43 @@ void __init mpc85xx_cpm2_pic_init(void)
> =A0 =A0 =A0 =A0irq_set_chained_handler(irq, cpm2_cascade);
> =A0}
> =A0#endif
> +
> +
> +void __init mpc85xx_init_mpic(bool reset, bool broken_frr, bool singlede=
st)
> +{
> + =A0 =A0 =A0 struct mpic *mpic;
> + =A0 =A0 =A0 struct resource r;
> + =A0 =A0 =A0 struct device_node *np =3D NULL;
> + =A0 =A0 =A0 unsigned int flags =3D MPIC_PRIMARY | MPIC_BIG_ENDIAN |
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 MPIC_BROKEN=
_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;

since parameters broken_frr and singledest are used later,
flags should probably be just:

        =A0 =A0 unsigned int flags =3D MPIC_PRIMARY | MPIC_BIG_ENDIAN;

> +
> + =A0 =A0 =A0 np =3D of_find_node_by_type(np, "open-pic");
> +
> + =A0 =A0 =A0 if (np =3D=3D NULL) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR "Could not find open-pic no=
de\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
> + =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 if (of_address_to_resource(np, 0, &r)) {
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 printk(KERN_ERR "Failed to map mpic registe=
r space\n");
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 of_node_put(np);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
> + =A0 =A0 =A0 }
> +
> + =A0 =A0 =A0 if (reset)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 flags |=3D MPIC_WANTS_RESET;
> + =A0 =A0 =A0 if (broken_frr)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 flags |=3D MPIC_BROKEN_FRR_NIRQS;
> + =A0 =A0 =A0 if (singledest)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 flags |=3D MPIC_SINGLE_DEST_CPU;
> + =A0 =A0 =A0 if (ppc_md.get_irq =3D=3D mpic_get_coreint_irq)
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 flags |=3D MPIC_ENABLE_COREINT;
> +
> + =A0 =A0 =A0 mpic =3D mpic_alloc(np, r.start, flags, 0, 256, " OpenPIC =
=A0");
> + =A0 =A0 =A0 BUG_ON(mpic =3D=3D NULL);
> +
> + =A0 =A0 =A0 /* Return the mpic node */
> + =A0 =A0 =A0 of_node_put(np);
> +
> + =A0 =A0 =A0 mpic_init(mpic);
> +}

<snip>

> --
> 1.7.7.1

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/6] powerpc/85xx: separate MPIC handling code
  2011-11-17 18:30   ` Lee Nipper
@ 2011-11-17 18:43     ` Dmitry Eremin-Solenikov
  2011-11-17 21:20       ` Stephen Rothwell
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-17 18:43 UTC (permalink / raw)
  To: lee.nipper; +Cc: linuxppc-dev

On 11/17/2011 10:30 PM, Lee Nipper wrote:
> On Thu, Nov 17, 2011 at 11:56 AM, Dmitry Eremin-Solenikov
> <dbaryshkov@gmail.com>  wrote:
>> All mpc85xx boards deal with MPIC initialization in more or less the
>> same way. The only difrerences are some flags (WANTS_RESET,
>> BROKEN_FRR_NIRQS, SINGLE_DEST_CPU), and some bugs like leaking device
>> node counter, etc. To minimize problems, switch all boards to use one
>> single instance of code.
>>
>> Signed-off-by: Dmitry Eremin-Solenikov<dbaryshkov@gmail.com>
>
> <snip>
>
>> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_common.c b/arch/powerpc/platforms/85xx/mpc85xx_common.c
>> index fe40668..7579e24 100644
>> --- a/arch/powerpc/platforms/85xx/mpc85xx_common.c
>> +++ b/arch/powerpc/platforms/85xx/mpc85xx_common.c
>> @@ -7,6 +7,9 @@
>>   */
>>   #include<linux/of_platform.h>
>>
>> +#include<asm/machdep.h>
>> +#include<asm/mpic.h>
>> +
>>   #include<sysdev/cpm2_pic.h>
>>
>>   #include "mpc85xx.h"
>> @@ -63,3 +66,43 @@ void __init mpc85xx_cpm2_pic_init(void)
>>         irq_set_chained_handler(irq, cpm2_cascade);
>>   }
>>   #endif
>> +
>> +
>> +void __init mpc85xx_init_mpic(bool reset, bool broken_frr, bool singledest)
>> +{
>> +       struct mpic *mpic;
>> +       struct resource r;
>> +       struct device_node *np = NULL;
>> +       unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
>> +                               MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
>
> since parameters broken_frr and singledest are used later,
> flags should probably be just:
>
>              unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN;

Yes, forgot about this when cleaning up. Sorry.

>
>> +
>> +       np = of_find_node_by_type(np, "open-pic");
>> +
>> +       if (np == NULL) {
>> +               printk(KERN_ERR "Could not find open-pic node\n");
>> +               return;
>> +       }
>> +
>> +       if (of_address_to_resource(np, 0,&r)) {
>> +               printk(KERN_ERR "Failed to map mpic register space\n");
>> +               of_node_put(np);
>> +               return;
>> +       }
>> +
>> +       if (reset)
>> +               flags |= MPIC_WANTS_RESET;
>> +       if (broken_frr)
>> +               flags |= MPIC_BROKEN_FRR_NIRQS;
>> +       if (singledest)
>> +               flags |= MPIC_SINGLE_DEST_CPU;
>> +       if (ppc_md.get_irq == mpic_get_coreint_irq)
>> +               flags |= MPIC_ENABLE_COREINT;
>> +
>> +       mpic = mpic_alloc(np, r.start, flags, 0, 256, " OpenPIC  ");
>> +       BUG_ON(mpic == NULL);
>> +
>> +       /* Return the mpic node */
>> +       of_node_put(np);
>> +
>> +       mpic_init(mpic);
>> +}
>
> <snip>
>
>> --
>> 1.7.7.1


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/6] powerpc/85xx: separate MPIC handling code
  2011-11-17 18:43     ` Dmitry Eremin-Solenikov
@ 2011-11-17 21:20       ` Stephen Rothwell
  0 siblings, 0 replies; 22+ messages in thread
From: Stephen Rothwell @ 2011-11-17 21:20 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linuxppc-dev, lee.nipper

[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]

Hi Dmitry,

On Thu, 17 Nov 2011 22:43:35 +0400 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
>
> On 11/17/2011 10:30 PM, Lee Nipper wrote:
> > On Thu, Nov 17, 2011 at 11:56 AM, Dmitry Eremin-Solenikov
> > <dbaryshkov@gmail.com>  wrote:
> >> All mpc85xx boards deal with MPIC initialization in more or less the
> >> same way. The only difrerences are some flags (WANTS_RESET,
> >> BROKEN_FRR_NIRQS, SINGLE_DEST_CPU), and some bugs like leaking device
> >> node counter, etc. To minimize problems, switch all boards to use one
> >> single instance of code.
> >>
> >> Signed-off-by: Dmitry Eremin-Solenikov<dbaryshkov@gmail.com>
> >
> > <snip>
> >
> > since parameters broken_frr and singledest are used later,
> > flags should probably be just:
> >
> >              unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN;
> 
> Yes, forgot about this when cleaning up. Sorry.

Since the three arguments to this function are just used to set flags,
maybe it would be better to just pass in the extra flags required in each
case as a single argument.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 6/6] poewrpc/85xx: headers cleanup
  2011-11-17 17:56 ` [PATCH 6/6] poewrpc/85xx: headers cleanup Dmitry Eremin-Solenikov
@ 2011-11-17 21:22   ` Stephen Rothwell
  0 siblings, 0 replies; 22+ messages in thread
From: Stephen Rothwell @ 2011-11-17 21:22 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

Hi Dmitry,

On Thu, 17 Nov 2011 21:56:21 +0400 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> wrote:
>
> Drop lots of unused headers after board files merge/splitup

Again, I am concerned that you may have removed too many includes (though
I didn't explicitly check this time).

In general, these clean ups look great.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 3/6] powerpc/85xx: separate MPIC handling code
  2011-11-17 17:56 ` [PATCH 3/6] powerpc/85xx: separate MPIC handling code Dmitry Eremin-Solenikov
  2011-11-17 18:30   ` Lee Nipper
@ 2011-11-17 21:33   ` Scott Wood
  1 sibling, 0 replies; 22+ messages in thread
From: Scott Wood @ 2011-11-17 21:33 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linuxppc-dev

On Thu, Nov 17, 2011 at 09:56:18PM +0400, Dmitry Eremin-Solenikov wrote:
> All mpc85xx boards deal with MPIC initialization in more or less the
> same way. The only difrerences are some flags (WANTS_RESET,
> BROKEN_FRR_NIRQS, SINGLE_DEST_CPU), and some bugs like leaking device
> node counter, etc. To minimize problems, switch all boards to use one
> single instance of code.

SINGLE_DEST_CPU should apply to all 85xx (the boards that omit it are
probably non-SMP where it doesn't matter), and probably BROKEN_FRR_NIRQS
as well (shouldn't hurt, at least).

> +	mpc85xx_init_mpic(0, 1, 1);

This is awkward to read, named flags are better -- and already exist for
this. :-)

Something like this should be clearer and still allow any override the
board wishes (such as for 85xx CAMP):

#define MPC85XX_MPIC_FLAGS (...)

most_boards:

mpc85xx_init_mpic(MPC85XX_MPIC_FLAGS)

85xx CAMP:

mpc85xx_init_mpic(MPC85XX_MPIC_FLAGS & ~MPIC_WANTS_RESET);

-Scott

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 1/6] powerpc/85xx: separate cpm2 pic init
  2011-11-17 17:56 [PATCH 1/6] powerpc/85xx: separate cpm2 pic init Dmitry Eremin-Solenikov
                   ` (4 preceding siblings ...)
  2011-11-17 17:56 ` [PATCH 6/6] poewrpc/85xx: headers cleanup Dmitry Eremin-Solenikov
@ 2011-11-24  7:15 ` Kumar Gala
  5 siblings, 0 replies; 22+ messages in thread
From: Kumar Gala @ 2011-11-24  7:15 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linuxppc-dev


On Nov 17, 2011, at 11:56 AM, Dmitry Eremin-Solenikov wrote:

> Separate handling of CPM2 PIC initialization to =
mpc85xx_cpm2_pic_init()
> function.
>=20
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
> arch/powerpc/platforms/85xx/Makefile         |    2 +
> arch/powerpc/platforms/85xx/ksi8560.c        |   29 +--------------
> arch/powerpc/platforms/85xx/mpc8536_ds.c     |    2 +
> arch/powerpc/platforms/85xx/mpc85xx.h        |    9 +++++
> arch/powerpc/platforms/85xx/mpc85xx_ads.c    |   34 ++----------------
> arch/powerpc/platforms/85xx/mpc85xx_cds.c    |    2 +
> arch/powerpc/platforms/85xx/mpc85xx_common.c |   49 =
++++++++++++++++++++++++++
> arch/powerpc/platforms/85xx/mpc85xx_ds.c     |    2 +
> arch/powerpc/platforms/85xx/mpc85xx_mds.c    |    2 +
> arch/powerpc/platforms/85xx/mpc85xx_rdb.c    |    2 +
> arch/powerpc/platforms/85xx/p1022_ds.c       |    2 +
> arch/powerpc/platforms/85xx/sbc8560.c        |   34 ++----------------
> arch/powerpc/platforms/85xx/socrates.c       |    1 +
> arch/powerpc/platforms/85xx/stx_gp3.c        |   37 =
++------------------
> arch/powerpc/platforms/85xx/tqm85xx.c        |   37 =
++------------------
> arch/powerpc/platforms/85xx/xes_mpc85xx.c    |    2 +
> 16 files changed, 89 insertions(+), 157 deletions(-)
> create mode 100644 arch/powerpc/platforms/85xx/mpc85xx.h
> create mode 100644 arch/powerpc/platforms/85xx/mpc85xx_common.c

applied to next

- k=

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls
  2011-11-17 17:56 ` [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls Dmitry Eremin-Solenikov
@ 2011-11-24  7:15   ` Kumar Gala
  2011-11-28 23:42   ` Tabi Timur-B04825
  1 sibling, 0 replies; 22+ messages in thread
From: Kumar Gala @ 2011-11-24  7:15 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: linuxppc-dev


On Nov 17, 2011, at 11:56 AM, Dmitry Eremin-Solenikov wrote:

> 85xx board files have a lot of duplication in *_publish_devices()/
> *_declare_of_platform_devices() functions. Merge that into a single
> function common to most of the boards.
>=20
> Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
> ---
> arch/powerpc/platforms/85xx/ksi8560.c        |   17 +---------
> arch/powerpc/platforms/85xx/mpc8536_ds.c     |   14 +-------
> arch/powerpc/platforms/85xx/mpc85xx.h        |    2 +
> arch/powerpc/platforms/85xx/mpc85xx_ads.c    |   18 +----------
> arch/powerpc/platforms/85xx/mpc85xx_cds.c    |   14 +-------
> arch/powerpc/platforms/85xx/mpc85xx_common.c |   16 +++++++++
> arch/powerpc/platforms/85xx/mpc85xx_ds.c     |   18 ++---------
> arch/powerpc/platforms/85xx/mpc85xx_mds.c    |   44 =
+------------------------
> arch/powerpc/platforms/85xx/mpc85xx_rdb.c    |   16 +--------
> arch/powerpc/platforms/85xx/p1022_ds.c       |    5 +--
> arch/powerpc/platforms/85xx/sbc8548.c        |   18 ++---------
> arch/powerpc/platforms/85xx/sbc8560.c        |   18 +----------
> arch/powerpc/platforms/85xx/socrates.c       |   12 +------
> arch/powerpc/platforms/85xx/stx_gp3.c        |   14 +-------
> arch/powerpc/platforms/85xx/tqm85xx.c        |   14 +-------
> arch/powerpc/platforms/85xx/xes_mpc85xx.c    |   18 ++---------
> 16 files changed, 40 insertions(+), 218 deletions(-)

applied to next

- k=

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls
  2011-11-17 17:56 ` [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls Dmitry Eremin-Solenikov
  2011-11-24  7:15   ` Kumar Gala
@ 2011-11-28 23:42   ` Tabi Timur-B04825
  2011-11-29 15:48     ` Kumar Gala
  1 sibling, 1 reply; 22+ messages in thread
From: Tabi Timur-B04825 @ 2011-11-28 23:42 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov; +Cc: Gala Kumar-B11780, linuxppc-dev@lists.ozlabs.org

On Thu, Nov 17, 2011 at 11:56 AM, Dmitry Eremin-Solenikov
<dbaryshkov@gmail.com> wrote:

> diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platfo=
rms/85xx/p1022_ds.c
> index 00d93a4..cacb4d4 100644
> --- a/arch/powerpc/platforms/85xx/p1022_ds.c
> +++ b/arch/powerpc/platforms/85xx/p1022_ds.c
> @@ -330,10 +330,6 @@ static void __init p1022_ds_setup_arch(void)
> =A0}
>
> =A0static struct of_device_id __initdata p1022_ds_ids[] =3D {
> - =A0 =A0 =A0 { .type =3D "soc", },
> - =A0 =A0 =A0 { .compatible =3D "soc", },
> - =A0 =A0 =A0 { .compatible =3D "simple-bus", },
> - =A0 =A0 =A0 { .compatible =3D "gianfar", },
> =A0 =A0 =A0 =A0/* So that the DMA channel nodes can be probed individuall=
y: */
> =A0 =A0 =A0 =A0{ .compatible =3D "fsl,eloplus-dma", },
> =A0 =A0 =A0 =A0{},
> @@ -343,6 +339,7 @@ static int __init p1022_ds_publish_devices(void)
> =A0{
> =A0 =A0 =A0 =A0return of_platform_bus_probe(NULL, p1022_ds_ids, NULL);
> =A0}
> +machine_device_initcall(p1022_ds, mpc85xx_common_publish_devices);
> =A0machine_device_initcall(p1022_ds, p1022_ds_publish_devices);

I don't think this is working. =A0I need to investigate some more to be
sure, but it looks like this is not picking up "fsl,eloplus-dma".
None of the DMA channels are being probed in the audio driver
(sound/soc/fsl_dma.c).

--
Timur Tabi
Linux kernel developer at Freescale=

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls
  2011-11-28 23:42   ` Tabi Timur-B04825
@ 2011-11-29 15:48     ` Kumar Gala
  2011-11-29 16:17       ` Timur Tabi
  0 siblings, 1 reply; 22+ messages in thread
From: Kumar Gala @ 2011-11-29 15:48 UTC (permalink / raw)
  To: Tabi Timur-B04825
  Cc: Dmitry Eremin-Solenikov, Gala Kumar-B11780,
	linuxppc-dev@lists.ozlabs.org


On Nov 28, 2011, at 5:42 PM, Tabi Timur-B04825 wrote:

> On Thu, Nov 17, 2011 at 11:56 AM, Dmitry Eremin-Solenikov
> <dbaryshkov@gmail.com> wrote:
>=20
>> diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c =
b/arch/powerpc/platforms/85xx/p1022_ds.c
>> index 00d93a4..cacb4d4 100644
>> --- a/arch/powerpc/platforms/85xx/p1022_ds.c
>> +++ b/arch/powerpc/platforms/85xx/p1022_ds.c
>> @@ -330,10 +330,6 @@ static void __init p1022_ds_setup_arch(void)
>>  }
>>=20
>>  static struct of_device_id __initdata p1022_ds_ids[] =3D {
>> -       { .type =3D "soc", },
>> -       { .compatible =3D "soc", },
>> -       { .compatible =3D "simple-bus", },
>> -       { .compatible =3D "gianfar", },
>>        /* So that the DMA channel nodes can be probed individually: =
*/
>>        { .compatible =3D "fsl,eloplus-dma", },
>>        {},
>> @@ -343,6 +339,7 @@ static int __init p1022_ds_publish_devices(void)
>>  {
>>        return of_platform_bus_probe(NULL, p1022_ds_ids, NULL);
>>  }
>> +machine_device_initcall(p1022_ds, mpc85xx_common_publish_devices);
>>  machine_device_initcall(p1022_ds, p1022_ds_publish_devices);
>=20
> I don't think this is working.  I need to investigate some more to be
> sure, but it looks like this is not picking up "fsl,eloplus-dma".
> None of the DMA channels are being probed in the audio driver
> (sound/soc/fsl_dma.c).

Hmm, that's odd.  Should see if the issues exists before the change.

- k=

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls
  2011-11-29 15:48     ` Kumar Gala
@ 2011-11-29 16:17       ` Timur Tabi
  2011-11-29 16:20         ` Timur Tabi
  0 siblings, 1 reply; 22+ messages in thread
From: Timur Tabi @ 2011-11-29 16:17 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Dmitry Eremin-Solenikov, Gala Kumar-B11780,
	linuxppc-dev@lists.ozlabs.org

Kumar Gala wrote:

>> I don't think this is working.  I need to investigate some more to be
>> sure, but it looks like this is not picking up "fsl,eloplus-dma".
>> None of the DMA channels are being probed in the audio driver
>> (sound/soc/fsl_dma.c).
> 
> Hmm, that's odd.  Should see if the issues exists before the change.

If I move the "fsl,eloplus-dma" into mpc85xx_common_ids[], then everything works.

I suspect there's some kind of state machine in of_platform_bus_probe() that allows it to find the DMA channel nodes if it's scanned everything else first.  I'm trying to debug it now.

-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls
  2011-11-29 16:17       ` Timur Tabi
@ 2011-11-29 16:20         ` Timur Tabi
  2011-11-29 16:38           ` Kumar Gala
  2011-11-29 19:46           ` Scott Wood
  0 siblings, 2 replies; 22+ messages in thread
From: Timur Tabi @ 2011-11-29 16:20 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Dmitry Eremin-Solenikov, Gala Kumar-B11780,
	linuxppc-dev@lists.ozlabs.org

Timur Tabi wrote:

> If I move the "fsl,eloplus-dma" into mpc85xx_common_ids[], then everything works.
> 
> I suspect there's some kind of state machine in of_platform_bus_probe() that allows it to find the DMA channel nodes if it's scanned everything else first.  I'm trying to debug it now.

So why do we need mpc85xx_common_ids[] at all?  Why can't of_platform_bus_probe() just scan the entire tree?

-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls
  2011-11-29 16:20         ` Timur Tabi
@ 2011-11-29 16:38           ` Kumar Gala
  2011-11-29 18:52             ` Timur Tabi
  2011-11-29 19:46           ` Scott Wood
  1 sibling, 1 reply; 22+ messages in thread
From: Kumar Gala @ 2011-11-29 16:38 UTC (permalink / raw)
  To: Timur Tabi, Benjamin Herrenschmidt
  Cc: Dmitry Eremin-Solenikov, Gala Kumar-B11780,
	linuxppc-dev@lists.ozlabs.org


On Nov 29, 2011, at 10:20 AM, Timur Tabi wrote:

> Timur Tabi wrote:
>=20
>> If I move the "fsl,eloplus-dma" into mpc85xx_common_ids[], then =
everything works.
>>=20
>> I suspect there's some kind of state machine in =
of_platform_bus_probe() that allows it to find the DMA channel nodes if =
it's scanned everything else first.  I'm trying to debug it now.
>=20
> So why do we need mpc85xx_common_ids[] at all?  Why can't =
of_platform_bus_probe() just scan the entire tree?

Ben would probably have to answer that.  I can't remember why he wanted =
it.  I'm sure he has a good reason.

- k=

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls
  2011-11-29 16:38           ` Kumar Gala
@ 2011-11-29 18:52             ` Timur Tabi
  2011-11-29 19:59               ` Kumar Gala
  0 siblings, 1 reply; 22+ messages in thread
From: Timur Tabi @ 2011-11-29 18:52 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Dmitry Eremin-Solenikov, Gala Kumar-B11780,
	linuxppc-dev@lists.ozlabs.org

Kumar Gala wrote:
> Ben would probably have to answer that.  I can't remember why he wanted it.  I'm sure he has a good reason.

Well, I'm not sure what's going on with the code.  I *think* what's happening is that the first call of_platform_bus_probe() is scanning most, but not all, of the tree, and it's somehow reserving all of those nodes.  Then we call of_platform_bus_probe() again, but it never finds the DMA nodes.  of_platform_bus_probe() never actually calls of_platform_bus_create() this time around.  Perhaps the recursive nature of of_platform_bus_create() is part of the problem.

The only fix I can think of is to move "fsl,eloplus-dma" into mpc85xx_common_ids[].  I'll post a patch that does that, and we can discuss it.

-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls
  2011-11-29 16:20         ` Timur Tabi
  2011-11-29 16:38           ` Kumar Gala
@ 2011-11-29 19:46           ` Scott Wood
  1 sibling, 0 replies; 22+ messages in thread
From: Scott Wood @ 2011-11-29 19:46 UTC (permalink / raw)
  To: Timur Tabi
  Cc: Dmitry Eremin-Solenikov, Gala Kumar-B11780,
	linuxppc-dev@lists.ozlabs.org

On 11/29/2011 10:20 AM, Timur Tabi wrote:
> Timur Tabi wrote:
> 
>> If I move the "fsl,eloplus-dma" into mpc85xx_common_ids[], then everything works.
>>
>> I suspect there's some kind of state machine in of_platform_bus_probe() that allows it to find the DMA channel nodes if it's scanned everything else first.  I'm trying to debug it now.

Probably mpc85xx_common_ids[] can probe the soc node but not the dma
node, and the p1022-specific list can probe the dma node but not the soc
node, so it doesn't get to the dma node.

> So why do we need mpc85xx_common_ids[] at all?  Why can't of_platform_bus_probe() just scan the entire tree?

That would generate a lot of useless platform devices that are either
not really devices, or duplicate a device sitting on another bus (i2c,
pci, etc).  It could also result in a device being probed and matching a
driver, when the device is unavailable in a way that is more complicated
than status = "disabled" (such as p1022 muxing), or otherwise requires
special handling.

-Scott

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls
  2011-11-29 18:52             ` Timur Tabi
@ 2011-11-29 19:59               ` Kumar Gala
  2011-11-29 22:53                 ` Timur Tabi
  0 siblings, 1 reply; 22+ messages in thread
From: Kumar Gala @ 2011-11-29 19:59 UTC (permalink / raw)
  To: Timur Tabi
  Cc: Dmitry Eremin-Solenikov, Gala Kumar-B11780,
	linuxppc-dev@lists.ozlabs.org


On Nov 29, 2011, at 12:52 PM, Timur Tabi wrote:

> Kumar Gala wrote:
>> Ben would probably have to answer that.  I can't remember why he =
wanted it.  I'm sure he has a good reason.
>=20
> Well, I'm not sure what's going on with the code.  I *think* what's =
happening is that the first call of_platform_bus_probe() is scanning =
most, but not all, of the tree, and it's somehow reserving all of those =
nodes.  Then we call of_platform_bus_probe() again, but it never finds =
the DMA nodes.  of_platform_bus_probe() never actually calls =
of_platform_bus_create() this time around.  Perhaps the recursive nature =
of of_platform_bus_create() is part of the problem.
>=20
> The only fix I can think of is to move "fsl,eloplus-dma" into =
mpc85xx_common_ids[].  I'll post a patch that does that, and we can =
discuss it.

what if you make the p1022_ds_ids call first?  Maybe we need to add =
'soc' to p1022_ds_ids list

- k=

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls
  2011-11-29 19:59               ` Kumar Gala
@ 2011-11-29 22:53                 ` Timur Tabi
  0 siblings, 0 replies; 22+ messages in thread
From: Timur Tabi @ 2011-11-29 22:53 UTC (permalink / raw)
  To: Kumar Gala
  Cc: Dmitry Eremin-Solenikov, Gala Kumar-B11780,
	linuxppc-dev@lists.ozlabs.org

Kumar Gala wrote:
>> > The only fix I can think of is to move "fsl,eloplus-dma" into mpc85xx_common_ids[].  I'll post a patch that does that, and we can discuss it.

> what if you make the p1022_ds_ids call first?  Maybe we need to add 'soc' to p1022_ds_ids list

Reversing the calls does not help.  p1022_ds_ids[] is ignored either way.  The same problem exists in mpc85xx_publish_devices(), so this patch breaks several boards.

Copying lines into p1022_ds_ids[] causes kernel BUGS() like this:

sysfs: cannot create duplicate filename '/devices/e0005000.localbus'

because we end up duplicating probes.

-- 
Timur Tabi
Linux kernel developer at Freescale

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2011-11-29 22:53 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-17 17:56 [PATCH 1/6] powerpc/85xx: separate cpm2 pic init Dmitry Eremin-Solenikov
2011-11-17 17:56 ` [PATCH 2/6] powerpc/85xx: consolidate of_platform_bus_probe calls Dmitry Eremin-Solenikov
2011-11-24  7:15   ` Kumar Gala
2011-11-28 23:42   ` Tabi Timur-B04825
2011-11-29 15:48     ` Kumar Gala
2011-11-29 16:17       ` Timur Tabi
2011-11-29 16:20         ` Timur Tabi
2011-11-29 16:38           ` Kumar Gala
2011-11-29 18:52             ` Timur Tabi
2011-11-29 19:59               ` Kumar Gala
2011-11-29 22:53                 ` Timur Tabi
2011-11-29 19:46           ` Scott Wood
2011-11-17 17:56 ` [PATCH 3/6] powerpc/85xx: separate MPIC handling code Dmitry Eremin-Solenikov
2011-11-17 18:30   ` Lee Nipper
2011-11-17 18:43     ` Dmitry Eremin-Solenikov
2011-11-17 21:20       ` Stephen Rothwell
2011-11-17 21:33   ` Scott Wood
2011-11-17 17:56 ` [PATCH 4/6] powerpc/85xx: unify common parts of *_setup_arch Dmitry Eremin-Solenikov
2011-11-17 17:56 ` [PATCH 5/6] powerpc/85xx: separate i8259 handling to common function Dmitry Eremin-Solenikov
2011-11-17 17:56 ` [PATCH 6/6] poewrpc/85xx: headers cleanup Dmitry Eremin-Solenikov
2011-11-17 21:22   ` Stephen Rothwell
2011-11-24  7:15 ` [PATCH 1/6] powerpc/85xx: separate cpm2 pic init Kumar Gala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).