LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 07/10] powerpc/mpic: Don't open-code dcr_resource_start
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: devicetree-discuss, Milton Miller, Paul Mackerras, Kyle Moffett,
	Scott Wood
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

Don't open-code the OpenFirmware "dcr-reg" property lookup trying to map
DCR resources.  This makes the code a bit easier to read.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/sysdev/mpic.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 31a9ada..0342ab8 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -319,11 +319,8 @@ static void _mpic_map_dcr(struct mpic *mpic, struct device_node *node,
 			  struct mpic_reg_bank *rb,
 			  unsigned int offset, unsigned int size)
 {
-	const u32 *dbasep;
-
-	dbasep = of_get_property(node, "dcr-reg", NULL);
-
-	rb->dhost = dcr_map(node, *dbasep + offset, size);
+	phys_addr_t phys_addr = dcr_resource_start(node);
+	rb->dhost = dcr_map(mpic->node, phys_addr + offset, size);
 	BUG_ON(!DCR_MAP_OK(rb->dhost));
 }
 
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 08/10] powerpc/mpic: Put "pic-no-reset" test back into the MPIC code
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: devicetree-discuss, Milton Miller, Paul Mackerras, Kyle Moffett,
	Scott Wood
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

There's not really any reason to have this one-liner in a separate
static inline function, given that all the other similar tests are
already in the alloc_mpic() code.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/sysdev/mpic.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 0342ab8..8b4f022 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1120,11 +1120,6 @@ static struct irq_host_ops mpic_host_ops = {
 	.xlate = mpic_host_xlate,
 };
 
-static int mpic_reset_prohibited(struct device_node *node)
-{
-	return node && of_get_property(node, "pic-no-reset", NULL);
-}
-
 /*
  * Exported functions
  */
@@ -1269,7 +1264,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	/* When using a device-node, reset requests are only honored if the MPIC
 	 * is allowed to reset.
 	 */
-	if (mpic_reset_prohibited(node))
+	if (of_get_property(node, "pic-no-reset", NULL))
 		mpic->flags |= MPIC_NO_RESET;
 
 	if ((flags & MPIC_WANTS_RESET) && !(mpic->flags & MPIC_NO_RESET)) {
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 09/10] powerpc/mpic: Cache the device-tree node in "struct mpic"
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: devicetree-discuss, Milton Miller, Paul Mackerras, Kyle Moffett,
	Scott Wood
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

Store the node pointer in the MPIC during initialization so that all of
the later operational code can just reuse the cached pointer.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/include/asm/mpic.h |    3 +++
 arch/powerpc/sysdev/mpic.c      |   32 ++++++++++++++++----------------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index a241076..db78b89 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -251,6 +251,9 @@ struct mpic_irq_save {
 /* The instance data of a given MPIC */
 struct mpic
 {
+	/* The OpenFirmware dt node for this MPIC */
+	struct device_node *node;
+
 	/* The remapper for this MPIC */
 	struct irq_host		*irqhost;
 
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 8b4f022..1826dae 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -315,26 +315,25 @@ static void _mpic_map_mmio(struct mpic *mpic, phys_addr_t phys_addr,
 }
 
 #ifdef CONFIG_PPC_DCR
-static void _mpic_map_dcr(struct mpic *mpic, struct device_node *node,
-			  struct mpic_reg_bank *rb,
+static void _mpic_map_dcr(struct mpic *mpic, struct mpic_reg_bank *rb,
 			  unsigned int offset, unsigned int size)
 {
-	phys_addr_t phys_addr = dcr_resource_start(node);
+	phys_addr_t phys_addr = dcr_resource_start(mpic->node);
 	rb->dhost = dcr_map(mpic->node, phys_addr + offset, size);
 	BUG_ON(!DCR_MAP_OK(rb->dhost));
 }
 
-static inline void mpic_map(struct mpic *mpic, struct device_node *node,
+static inline void mpic_map(struct mpic *mpic,
 			    phys_addr_t phys_addr, struct mpic_reg_bank *rb,
 			    unsigned int offset, unsigned int size)
 {
 	if (mpic->flags & MPIC_USES_DCR)
-		_mpic_map_dcr(mpic, node, rb, offset, size);
+		_mpic_map_dcr(mpic, rb, offset, size);
 	else
 		_mpic_map_mmio(mpic, phys_addr, rb, offset, size);
 }
 #else /* CONFIG_PPC_DCR */
-#define mpic_map(m,n,p,b,o,s)	_mpic_map_mmio(m,p,b,o,s)
+#define mpic_map(m,p,b,o,s)	_mpic_map_mmio(m,p,b,o,s)
 #endif /* !CONFIG_PPC_DCR */
 
 
@@ -1178,6 +1177,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 		return NULL;
 
 	mpic->name = name;
+	mpic->node = node;
 	mpic->paddr = phys_addr;
 
 	mpic->hc_irq = mpic_irq_chip;
@@ -1224,13 +1224,13 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	mpic->spurious_vec  = intvec_top;
 
 	/* Check for "big-endian" in device-tree */
-	if (of_get_property(node, "big-endian", NULL) != NULL)
+	if (of_get_property(mpic->node, "big-endian", NULL) != NULL)
 		mpic->flags |= MPIC_BIG_ENDIAN;
-	if (of_device_is_compatible(node, "fsl,mpic"))
+	if (of_device_is_compatible(mpic->node, "fsl,mpic"))
 		mpic->flags |= MPIC_FSL;
 
 	/* Look for protected sources */
-	psrc = of_get_property(node, "protected-sources", &psize);
+	psrc = of_get_property(mpic->node, "protected-sources", &psize);
 	if (psrc) {
 		/* Allocate a bitmap with one bit per interrupt */
 		unsigned int mapsize = BITS_TO_LONGS(intvec_top + 1);
@@ -1256,15 +1256,15 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 		mpic->reg_type = mpic_access_mmio_le;
 
 	/* Map the global registers */
-	mpic_map(mpic, node, mpic->paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
-	mpic_map(mpic, node, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
+	mpic_map(mpic, mpic->paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000);
+	mpic_map(mpic, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
 
 	/* Reset */
 
 	/* When using a device-node, reset requests are only honored if the MPIC
 	 * is allowed to reset.
 	 */
-	if (of_get_property(node, "pic-no-reset", NULL))
+	if (of_get_property(mpic->node, "pic-no-reset", NULL))
 		mpic->flags |= MPIC_NO_RESET;
 
 	if ((flags & MPIC_WANTS_RESET) && !(mpic->flags & MPIC_NO_RESET)) {
@@ -1306,7 +1306,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 
 	/* Map the per-CPU registers */
 	for (i = 0; i < mpic->num_cpus; i++) {
-		mpic_map(mpic, node, mpic->paddr, &mpic->cpuregs[i],
+		mpic_map(mpic, mpic->paddr, &mpic->cpuregs[i],
 			 MPIC_INFO(CPU_BASE) + i * MPIC_INFO(CPU_STRIDE),
 			 0x1000);
 	}
@@ -1314,13 +1314,13 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	/* Initialize main ISU if none provided */
 	if (mpic->isu_size == 0) {
 		mpic->isu_size = mpic->num_sources;
-		mpic_map(mpic, node, mpic->paddr, &mpic->isus[0],
+		mpic_map(mpic, mpic->paddr, &mpic->isus[0],
 			 MPIC_INFO(IRQ_BASE), MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
 	}
 	mpic->isu_shift = 1 + __ilog2(mpic->isu_size - 1);
 	mpic->isu_mask = (1 << mpic->isu_shift) - 1;
 
-	mpic->irqhost = irq_alloc_host(node, IRQ_HOST_MAP_LINEAR,
+	mpic->irqhost = irq_alloc_host(mpic->node, IRQ_HOST_MAP_LINEAR,
 				       isu_size ? isu_size : mpic->num_sources,
 				       &mpic_host_ops,
 				       flags & MPIC_LARGE_VECTORS ? 2048 : 256);
@@ -1368,7 +1368,7 @@ void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
 
 	BUG_ON(isu_num >= MPIC_MAX_ISU);
 
-	mpic_map(mpic, mpic->irqhost->of_node,
+	mpic_map(mpic,
 		 paddr, &mpic->isus[isu_num], 0,
 		 MPIC_INFO(IRQ_STRIDE) * mpic->isu_size);
 
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 00/10] powerpc/mpic: General cleanup patch series
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev; +Cc: Kyle Moffett

Hello,

I've been tinkering with a series of patches to clean up the PowerPC
MPIC/OpenPIC init recently as part of a new board port I'm working on.

It's reached the point where I'd like some feedback on the general
approach.  The code itself hasn't been tested at all yet, and probably
does not compile right now (though that is my next step).

(Oh, actually, the first patch isn't really even about the MPIC code,
it should probably be reviewed on its own; oh well...)

Please let me know what you think.

Cheers,
Kyle Moffett

--
Curious about my work on the Debian powerpcspe port?
I'm keeping a blog here: http://pureperl.blogspot.com/

^ permalink raw reply

* [RFC PATCH 01/10] powerpc/85xx: Move mpc85xx_smp_init() decl to a new "smp.h"
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev; +Cc: Paul Mackerras, Kyle Moffett
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

This removes a bunch of "extern" declarations and CONFIG_SMP ifdefs.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Kumar Gala <galak@kernel.crashing.org>
---
 arch/powerpc/platforms/85xx/corenet_ds.c  |    7 +------
 arch/powerpc/platforms/85xx/mpc85xx_ds.c  |    6 +-----
 arch/powerpc/platforms/85xx/mpc85xx_mds.c |    7 +------
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c |    7 +------
 arch/powerpc/platforms/85xx/p1022_ds.c    |    7 +------
 arch/powerpc/platforms/85xx/p1023_rds.c   |    5 +----
 arch/powerpc/platforms/85xx/smp.c         |    1 +
 arch/powerpc/platforms/85xx/smp.h         |   15 +++++++++++++++
 arch/powerpc/platforms/85xx/xes_mpc85xx.c |    6 +-----
 9 files changed, 23 insertions(+), 38 deletions(-)
 create mode 100644 arch/powerpc/platforms/85xx/smp.h

diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index 802ad11..435074d 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -31,6 +31,7 @@
 #include <linux/of_platform.h>
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
+#include "smp.h"
 
 void __init corenet_ds_pic_init(void)
 {
@@ -65,10 +66,6 @@ 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
@@ -77,9 +74,7 @@ void __init corenet_ds_setup_arch(void)
 #endif
 	dma_addr_t max = 0xffffffff;
 
-#ifdef CONFIG_SMP
 	mpc85xx_smp_init();
-#endif
 
 #ifdef CONFIG_PCI
 	for_each_node_by_type(np, "pci") {
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 1b9a8cf..52d2a3e 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -35,6 +35,7 @@
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
+#include "smp.h"
 
 #undef DEBUG
 
@@ -152,9 +153,6 @@ 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
@@ -187,9 +185,7 @@ static void __init mpc85xx_ds_setup_arch(void)
 	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) {
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 973b3f4..074be05 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -52,6 +52,7 @@
 #include <asm/qe_ic.h>
 #include <asm/mpic.h>
 #include <asm/swiotlb.h>
+#include "smp.h"
 
 #undef DEBUG
 #ifdef DEBUG
@@ -154,10 +155,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 struct of_device_id mpc85xx_qe_ids[] __initdata = {
 	{ .type = "qe", },
@@ -382,9 +379,7 @@ static void __init mpc85xx_mds_setup_arch(void)
 	}
 #endif
 
-#ifdef CONFIG_SMP
 	mpc85xx_smp_init();
-#endif
 
 	mpc85xx_mds_qe_init();
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index f5ff911..cd49898 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -29,6 +29,7 @@
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
+#include "smp.h"
 
 #undef DEBUG
 
@@ -82,9 +83,6 @@ 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
@@ -102,10 +100,7 @@ static void __init mpc85xx_rdb_setup_arch(void)
 
 #endif
 
-#ifdef CONFIG_SMP
 	mpc85xx_smp_init();
-#endif
-
 	printk(KERN_INFO "MPC85xx 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 266b3aa..7e90e24 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -26,6 +26,7 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 #include <asm/fsl_guts.h>
+#include "smp.h"
 
 #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
 
@@ -265,10 +266,6 @@ void __init p1022_ds_pic_init(void)
 	mpic_init(mpic);
 }
 
-#ifdef CONFIG_SMP
-void __init mpc85xx_smp_init(void);
-#endif
-
 /*
  * Setup the architecture
  */
@@ -309,9 +306,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) {
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index 835e0b3..5ab21f3 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -30,6 +30,7 @@
 #include <asm/prom.h>
 #include <asm/udbg.h>
 #include <asm/mpic.h>
+#include "smp.h"
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
@@ -39,10 +40,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;
diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index 5b9b901..4578112 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -27,6 +27,7 @@
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/mpic.h>
+#include "smp.h"
 
 extern void __early_start(void);
 
diff --git a/arch/powerpc/platforms/85xx/smp.h b/arch/powerpc/platforms/85xx/smp.h
new file mode 100644
index 0000000..e2b4493
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/smp.h
@@ -0,0 +1,15 @@
+#ifndef POWERPC_85XX_SMP_H_
+#define POWERPC_85XX_SMP_H_ 1
+
+#include <linux/init.h>
+
+#ifdef CONFIG_SMP
+void __init mpc85xx_smp_init(void);
+#else
+static inline void mpc85xx_smp_init(void)
+{
+	/* Nothing to do */
+}
+#endif
+
+#endif /* not POWERPC_85XX_SMP_H_ */
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index a9dc5e7..ce3f660 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -32,6 +32,7 @@
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
+#include "smp.h"
 
 /* A few bit definitions needed for fixups on some boards */
 #define MPC85xx_L2CTL_L2E		0x80000000 /* L2 enable */
@@ -136,9 +137,6 @@ static int primary_phb_addr;
 /*
  * 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
@@ -172,9 +170,7 @@ static void __init xes_mpc85xx_setup_arch(void)
 	}
 #endif
 
-#ifdef CONFIG_SMP
 	mpc85xx_smp_init();
-#endif
 }
 
 static struct of_device_id __initdata xes_mpc85xx_ids[] = {
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 05/10] powerpc/mpic: Search for open-pic device-tree node if NULL
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Milton Miller, Paul Mackerras, Kyle Moffett, Scott Wood,
	Thomas Gleixner
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

Almost all PowerPC platforms use a standard "open-pic" device node so
the mpic_alloc() function now accepts NULL for the device-node.  This
will cause it to perform a default search with of_find_matching_node().

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/platforms/85xx/corenet_ds.c          |   10 +---------
 arch/powerpc/platforms/85xx/ksi8560.c             |   13 ++-----------
 arch/powerpc/platforms/85xx/mpc8536_ds.c          |   13 +------------
 arch/powerpc/platforms/85xx/mpc85xx_ads.c         |   12 ++----------
 arch/powerpc/platforms/85xx/mpc85xx_cds.c         |   15 +--------------
 arch/powerpc/platforms/85xx/mpc85xx_ds.c          |   14 +++-----------
 arch/powerpc/platforms/85xx/mpc85xx_mds.c         |   10 +---------
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c         |   14 ++------------
 arch/powerpc/platforms/85xx/p1022_ds.c            |   14 +-------------
 arch/powerpc/platforms/85xx/sbc8548.c             |   16 +---------------
 arch/powerpc/platforms/85xx/sbc8560.c             |   13 ++-----------
 arch/powerpc/platforms/85xx/socrates.c            |   11 +----------
 arch/powerpc/platforms/85xx/stx_gp3.c             |   13 ++-----------
 arch/powerpc/platforms/85xx/tqm85xx.c             |   13 ++-----------
 arch/powerpc/platforms/85xx/xes_mpc85xx.c         |   13 +------------
 arch/powerpc/platforms/embedded6xx/holly.c        |   10 +---------
 arch/powerpc/platforms/embedded6xx/linkstation.c  |    8 ++------
 arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c |   10 +---------
 arch/powerpc/platforms/embedded6xx/storcenter.c   |   10 +---------
 arch/powerpc/sysdev/mpic.c                        |   19 +++++++++++++++++--
 20 files changed, 45 insertions(+), 206 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index 7893ad3..134e1f8 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -36,21 +36,13 @@
 void __init corenet_ds_pic_init(void)
 {
 	struct mpic *mpic;
-	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 (ppc_md.get_irq == mpic_get_coreint_irq)
 		flags |= MPIC_ENABLE_COREINT;
 
-	mpic = mpic_alloc(np, 0, flags, 0, 256, " OpenPIC  ");
+	mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/ksi8560.c b/arch/powerpc/platforms/85xx/ksi8560.c
index b20c07d..d49dbc4 100644
--- a/arch/powerpc/platforms/85xx/ksi8560.c
+++ b/arch/powerpc/platforms/85xx/ksi8560.c
@@ -68,24 +68,15 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 static void __init ksi8560_pic_init(void)
 {
 	struct mpic *mpic;
-	struct device_node *np;
 #ifdef CONFIG_CPM2
+	struct device_node *np;
 	int irq;
 #endif
 
-	np = of_find_node_by_type(NULL, "open-pic");
-
-	if (np == NULL) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 03173ba..2c928f0 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -34,22 +34,11 @@
 
 void __init mpc8536_ds_pic_init(void)
 {
-	struct mpic *mpic;
-	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;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			  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);
 }
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 5cb797b..2b443ba 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -64,23 +64,15 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 static void __init mpc85xx_ads_pic_init(void)
 {
 	struct mpic *mpic;
-	struct device_node *np = NULL;
 #ifdef CONFIG_CPM2
+	struct device_node *np = NULL;
 	int irq;
 #endif
 
-	np = of_find_node_by_type(np, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 69c1d0a..3a2436b 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -187,23 +187,10 @@ static struct irqaction mpc85xxcds_8259_irqaction = {
 static void __init mpc85xx_cds_pic_init(void)
 {
 	struct mpic *mpic;
-	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;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	mpic = mpic_alloc(NULL, 0,
 			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);
 }
 
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index b608da7..14fccaf 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -61,27 +61,21 @@ static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
 void __init mpc85xx_ds_pic_init(void)
 {
 	struct mpic *mpic;
-	struct device_node *np;
 #ifdef CONFIG_PPC_I8259
+	struct device_node *np;
 	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_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
-		mpic = mpic_alloc(np, 0,
+		mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	} else {
-		mpic = mpic_alloc(np, 0,
+		mpic = mpic_alloc(NULL, 0,
 			  MPIC_PRIMARY | MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			  MPIC_SINGLE_DEST_CPU,
@@ -89,8 +83,6 @@ void __init mpc85xx_ds_pic_init(void)
 	}
 
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_PPC_I8259
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 982f1a7..7ebd864 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -474,19 +474,11 @@ machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
 
 static void __init mpc85xx_mds_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np = NULL;
-
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np)
-		return;
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			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_mds_qeic_init();
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 67bd1d4..9edb2b1 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -43,23 +43,16 @@
 void __init mpc85xx_rdb_pic_init(void)
 {
 	struct mpic *mpic;
-	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_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
-		mpic = mpic_alloc(np, 0,
+		mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	} else {
-		mpic = mpic_alloc(np, 0,
+		mpic = mpic_alloc(NULL, 0,
 		  MPIC_PRIMARY | MPIC_WANTS_RESET |
 		  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 		  MPIC_SINGLE_DEST_CPU,
@@ -67,10 +60,7 @@ void __init mpc85xx_rdb_pic_init(void)
 	}
 
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
-
 }
 
 /*
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index d911aca..4279e83 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -238,24 +238,12 @@ int p1022ds_set_sysfs_monitor_port(int val)
 
 void __init p1022_ds_pic_init(void)
 {
-	struct mpic *mpic;
-	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;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 		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);
 }
 
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index daced7d..1b5597f 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -53,24 +53,10 @@ static int sbc_rev;
 
 static void __init sbc8548_pic_init(void)
 {
-	struct mpic *mpic;
-	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;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			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);
 }
 
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index bd8b6c9..20e68bb 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -54,24 +54,15 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 
 static void __init sbc8560_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np = NULL;
 #ifdef CONFIG_CPM2
+	struct device_node *np = NULL;
 	int irq;
 #endif
 
-	np = of_find_node_by_type(np, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index fb4bfd6..a9a45f6 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -45,21 +45,12 @@
 
 static void __init socrates_pic_init(void)
 {
-	struct mpic *mpic;
 	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;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 	np = of_find_compatible_node(NULL, NULL, "abb,socrates-fpga-pic");
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index 78aef45..55e941b 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -58,24 +58,15 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 
 static void __init stx_gp3_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np;
 #ifdef CONFIG_CPM2
+	struct device_node *np;
 	int irq;
 #endif
 
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 5775f4c..660769b 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -56,24 +56,15 @@ static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
 
 static void __init tqm85xx_pic_init(void)
 {
-	struct mpic *mpic;
-	struct device_node *np;
 #ifdef CONFIG_CPM2
+	struct device_node *np;
 	int irq;
 #endif
 
-	np = of_find_node_by_type(NULL, "open-pic");
-	if (!np) {
-		printk(KERN_ERR "Could not find open-pic node\n");
-		return;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
-	of_node_put(np);
-
 	mpic_init(mpic);
 
 #ifdef CONFIG_CPM2
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index fccf9aa..09b8ba0 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -41,22 +41,11 @@
 
 void __init xes_mpc85xx_pic_init(void)
 {
-	struct mpic *mpic;
-	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;
-	}
-
-	mpic = mpic_alloc(np, 0,
+	struct mpic *mpic = mpic_alloc(np, 0,
 			  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);
 }
 
diff --git a/arch/powerpc/platforms/embedded6xx/holly.c b/arch/powerpc/platforms/embedded6xx/holly.c
index 80b2e2a..edfc84f 100644
--- a/arch/powerpc/platforms/embedded6xx/holly.c
+++ b/arch/powerpc/platforms/embedded6xx/holly.c
@@ -147,20 +147,13 @@ static void __init holly_setup_arch(void)
 static void __init holly_init_IRQ(void)
 {
 	struct mpic *mpic;
-	struct device_node *tsi_pic;
 #ifdef CONFIG_PCI
 	unsigned int cascade_pci_irq;
 	struct device_node *tsi_pci;
 	struct device_node *cascade_node = NULL;
 #endif
 
-	tsi_pic = of_find_node_by_type(NULL, "open-pic");
-	if (!tsi_pic) {
-		printk(KERN_ERR "%s: No tsi108 PIC found !\n", __func__);
-		return;
-	}
-
-	mpic = mpic_alloc(tsi_pic, 0,
+	mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
 			MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
 			24,
@@ -194,7 +187,6 @@ static void __init holly_init_IRQ(void)
 #endif
 	/* Configure MPIC outputs to CPU0 */
 	tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
-	of_node_put(tsi_pic);
 }
 
 void holly_show_cpuinfo(struct seq_file *m)
diff --git a/arch/powerpc/platforms/embedded6xx/linkstation.c b/arch/powerpc/platforms/embedded6xx/linkstation.c
index 72b3685..502ff60 100644
--- a/arch/powerpc/platforms/embedded6xx/linkstation.c
+++ b/arch/powerpc/platforms/embedded6xx/linkstation.c
@@ -81,13 +81,9 @@ static void __init linkstation_setup_arch(void)
 static void __init linkstation_init_IRQ(void)
 {
 	struct mpic *mpic;
-	struct device_node *dnp;
 
-	dnp = of_find_node_by_type(NULL, "open-pic");
-	if (dnp == NULL)
-		return;
-
-	mpic = mpic_alloc(dnp, 0, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC     ");
+	mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
+			4, 32, " EPIC     ");
 	BUG_ON(mpic == NULL);
 
 	/* PCI IRQs */
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index 28082f9..1dd976e 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -101,20 +101,13 @@ static void __init mpc7448_hpc2_setup_arch(void)
 static void __init mpc7448_hpc2_init_IRQ(void)
 {
 	struct mpic *mpic;
-	struct device_node *tsi_pic;
 #ifdef CONFIG_PCI
 	unsigned int cascade_pci_irq;
 	struct device_node *tsi_pci;
 	struct device_node *cascade_node = NULL;
 #endif
 
-	tsi_pic = of_find_node_by_type(NULL, "open-pic");
-	if (!tsi_pic) {
-		printk("%s: No tsi108 PIC found !\n", __func__);
-		return;
-	}
-
-	mpic = mpic_alloc(tsi_pic, 0,
+	mpic = mpic_alloc(NULL, 0,
 			MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
 			MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
 			24,
@@ -148,7 +141,6 @@ static void __init mpc7448_hpc2_init_IRQ(void)
 #endif
 	/* Configure MPIC outputs to CPU0 */
 	tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
-	of_node_put(tsi_pic);
 }
 
 void mpc7448_hpc2_show_cpuinfo(struct seq_file *m)
diff --git a/arch/powerpc/platforms/embedded6xx/storcenter.c b/arch/powerpc/platforms/embedded6xx/storcenter.c
index 797870f..a233d91 100644
--- a/arch/powerpc/platforms/embedded6xx/storcenter.c
+++ b/arch/powerpc/platforms/embedded6xx/storcenter.c
@@ -83,17 +83,9 @@ static void __init storcenter_setup_arch(void)
 static void __init storcenter_init_IRQ(void)
 {
 	struct mpic *mpic;
-	struct device_node *dnp;
 
-	dnp = of_find_node_by_type(NULL, "open-pic");
-	if (dnp == NULL)
-		return;
-
-	mpic = mpic_alloc(dnp, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
+	mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
 			16, 32, " OpenPIC  ");
-
-	of_node_put(dnp);
-
 	BUG_ON(mpic == NULL);
 
 	/*
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 0ad7bf2..548ca16 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1145,8 +1145,23 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	const char *vers;
 	const u32 *psrc;
 
-	/* This code assumes that a non-NULL device node is passed in */
-	BUG_ON(!node);
+	/* Default MPIC search parameters */
+	static const struct of_device_id __initconst mpic_device_id[] = {
+		{ .type	      = "open-pic", },
+		{ .compatible = "open-pic", },
+		{},
+	};
+
+	/*
+	 * If we were not passed a device-tree node, then perform the default
+	 * search for standardized a standardized OpenPIC.
+	 */
+	if (!node)
+		node = of_find_matching_node(NULL, mpic_device_id);
+
+	/* Make sure we got *something* */
+	if (!node)
+		return NULL;
 
 	/* Pick the physical address from the device tree if unspecified */
 	if (!phys_addr) {
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 06/10] powerpc/mpic: Invert the meaning of MPIC_PRIMARY
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Thomas Gleixner, cbe-oss-dev, Lennert Buytenhek, Arnd Bergmann,
	Dmitry Eremin-Solenikov, Brian King, Milton Miller, Scott Wood,
	Paul Mackerras, Anton Blanchard, Kyle Moffett, Olof Johansson,
	Nishanth Aravamudan
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

It turns out that there are only 2 in-tree platforms which use MPICs
which are not "primary":  IBM Cell and PowerMac.  To reduce the
complexity of the typical board setup code, invert the MPIC_PRIMARY bit
into MPIC_SECONDARY.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/include/asm/mpic.h                   |    8 ++++----
 arch/powerpc/platforms/44x/iss4xx.c               |    2 +-
 arch/powerpc/platforms/85xx/corenet_ds.c          |    2 +-
 arch/powerpc/platforms/85xx/ksi8560.c             |    2 +-
 arch/powerpc/platforms/85xx/mpc8536_ds.c          |    2 +-
 arch/powerpc/platforms/85xx/mpc85xx_ads.c         |    3 +--
 arch/powerpc/platforms/85xx/mpc85xx_cds.c         |    2 +-
 arch/powerpc/platforms/85xx/mpc85xx_ds.c          |    3 +--
 arch/powerpc/platforms/85xx/mpc85xx_mds.c         |    2 +-
 arch/powerpc/platforms/85xx/mpc85xx_rdb.c         |    3 +--
 arch/powerpc/platforms/85xx/p1010rdb.c            |    2 +-
 arch/powerpc/platforms/85xx/p1022_ds.c            |    2 +-
 arch/powerpc/platforms/85xx/p1023_rds.c           |    2 +-
 arch/powerpc/platforms/85xx/sbc8548.c             |    2 +-
 arch/powerpc/platforms/85xx/sbc8560.c             |    2 +-
 arch/powerpc/platforms/85xx/socrates.c            |    2 +-
 arch/powerpc/platforms/85xx/stx_gp3.c             |    2 +-
 arch/powerpc/platforms/85xx/tqm85xx.c             |    2 +-
 arch/powerpc/platforms/85xx/xes_mpc85xx.c         |    2 +-
 arch/powerpc/platforms/86xx/pic.c                 |    2 +-
 arch/powerpc/platforms/cell/setup.c               |    2 +-
 arch/powerpc/platforms/chrp/setup.c               |    3 +--
 arch/powerpc/platforms/embedded6xx/holly.c        |    2 +-
 arch/powerpc/platforms/embedded6xx/linkstation.c  |    2 +-
 arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c |    2 +-
 arch/powerpc/platforms/embedded6xx/storcenter.c   |    2 +-
 arch/powerpc/platforms/maple/setup.c              |    2 +-
 arch/powerpc/platforms/pasemi/setup.c             |    2 +-
 arch/powerpc/platforms/powermac/pic.c             |    2 +-
 arch/powerpc/platforms/pseries/setup.c            |    3 +--
 arch/powerpc/sysdev/mpic.c                        |   14 +++++++-------
 31 files changed, 40 insertions(+), 45 deletions(-)

diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index 49bab41..a241076 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -336,11 +336,11 @@ struct mpic
  * Note setting any ID (leaving those bits to 0) means standard MPIC
  */
 
-/* This is the primary controller, only that one has IPIs and
- * has afinity control. A non-primary MPIC always uses CPU0
- * registers only
+/*
+ * This is a secondary ("chained") controller; it only uses the CPU0
+ * registers.  Primary controllers have IPIs and affinity control.
  */
-#define MPIC_PRIMARY			0x00000001
+#define MPIC_SECONDARY			0x00000001
 
 /* Set this for a big-endian MPIC */
 #define MPIC_BIG_ENDIAN			0x00000002
diff --git a/arch/powerpc/platforms/44x/iss4xx.c b/arch/powerpc/platforms/44x/iss4xx.c
index 19395f1..5b8cdbb 100644
--- a/arch/powerpc/platforms/44x/iss4xx.c
+++ b/arch/powerpc/platforms/44x/iss4xx.c
@@ -71,7 +71,7 @@ static void __init iss4xx_init_irq(void)
 		/* The MPIC driver will get everything it needs from the
 		 * device-tree, just pass 0 to all arguments
 		 */
-		struct mpic *mpic = mpic_alloc(np, 0, MPIC_PRIMARY, 0, 0,
+		struct mpic *mpic = mpic_alloc(np, 0, 0, 0, 0,
 					       " MPIC     ");
 		BUG_ON(mpic == NULL);
 		mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index 134e1f8..7b737a9 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -36,7 +36,7 @@
 void __init corenet_ds_pic_init(void)
 {
 	struct mpic *mpic;
-	unsigned int flags = MPIC_PRIMARY | MPIC_BIG_ENDIAN |
+	unsigned int flags = MPIC_BIG_ENDIAN |
 				MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU;
 
 	if (ppc_md.get_irq == mpic_get_coreint_irq)
diff --git a/arch/powerpc/platforms/85xx/ksi8560.c b/arch/powerpc/platforms/85xx/ksi8560.c
index d49dbc4..278962b 100644
--- a/arch/powerpc/platforms/85xx/ksi8560.c
+++ b/arch/powerpc/platforms/85xx/ksi8560.c
@@ -74,7 +74,7 @@ static void __init ksi8560_pic_init(void)
 #endif
 
 	mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 2c928f0..d1aece5 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -35,7 +35,7 @@
 void __init mpc8536_ds_pic_init(void)
 {
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			  MPIC_PRIMARY | MPIC_WANTS_RESET |
+			  MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 2b443ba..65a3de4 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -69,8 +69,7 @@ static void __init mpc85xx_ads_pic_init(void)
 	int irq;
 #endif
 
-	mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+	mpic = mpic_alloc(NULL, 0, MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 3a2436b..081821d 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -188,7 +188,7 @@ static void __init mpc85xx_cds_pic_init(void)
 {
 	struct mpic *mpic;
 	mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 14fccaf..5298137 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -70,13 +70,12 @@ void __init mpc85xx_ds_pic_init(void)
 
 	if (of_flat_dt_is_compatible(root, "fsl,MPC8572DS-CAMP")) {
 		mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	} else {
 		mpic = mpic_alloc(NULL, 0,
-			  MPIC_PRIMARY | MPIC_WANTS_RESET |
+			  MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			  MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 7ebd864..b7d9636 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -475,7 +475,7 @@ machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
 static void __init mpc85xx_mds_pic_init(void)
 {
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
 			MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index 9edb2b1..a3cf5d1 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -47,13 +47,12 @@ void __init mpc85xx_rdb_pic_init(void)
 
 	if (of_flat_dt_is_compatible(root, "fsl,MPC85XXRDB-CAMP")) {
 		mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " OpenPIC  ");
 	} else {
 		mpic = mpic_alloc(NULL, 0,
-		  MPIC_PRIMARY | MPIC_WANTS_RESET |
+		  MPIC_WANTS_RESET |
 		  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 		  MPIC_SINGLE_DEST_CPU,
 		  0, 256, " OpenPIC  ");
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index 5ffca27..f6c3ffc 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -39,7 +39,7 @@ void __init p1010_rdb_pic_init(void)
 		return;
 	}
 
-	mpic = mpic_alloc(np, NULL, MPIC_PRIMARY | MPIC_WANTS_RESET |
+	mpic = mpic_alloc(np, NULL, MPIC_WANTS_RESET |
 	  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
 	  0, 256, " OpenPIC  ");
 
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 4279e83..73e79ba 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -239,7 +239,7 @@ int p1022ds_set_sysfs_monitor_port(int val)
 void __init p1022_ds_pic_init(void)
 {
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-		MPIC_PRIMARY | MPIC_WANTS_RESET |
+		MPIC_WANTS_RESET |
 		MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 		MPIC_SINGLE_DEST_CPU,
 		0, 256, " OpenPIC  ");
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index 30a5adb..1a916eb 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -118,7 +118,7 @@ static void __init mpc85xx_rds_pic_init(void)
 	}
 
 	mpic = mpic_alloc(np, NULL,
-		MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
+		MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
 		MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
 		0, 256, " OpenPIC  ");
 
diff --git a/arch/powerpc/platforms/85xx/sbc8548.c b/arch/powerpc/platforms/85xx/sbc8548.c
index 1b5597f..bf8b8ff 100644
--- a/arch/powerpc/platforms/85xx/sbc8548.c
+++ b/arch/powerpc/platforms/85xx/sbc8548.c
@@ -54,7 +54,7 @@ static int sbc_rev;
 static void __init sbc8548_pic_init(void)
 {
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/sbc8560.c b/arch/powerpc/platforms/85xx/sbc8560.c
index 20e68bb..7a43fb4 100644
--- a/arch/powerpc/platforms/85xx/sbc8560.c
+++ b/arch/powerpc/platforms/85xx/sbc8560.c
@@ -60,7 +60,7 @@ static void __init sbc8560_pic_init(void)
 #endif
 
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/socrates.c b/arch/powerpc/platforms/85xx/socrates.c
index a9a45f6..94bd256 100644
--- a/arch/powerpc/platforms/85xx/socrates.c
+++ b/arch/powerpc/platforms/85xx/socrates.c
@@ -48,7 +48,7 @@ static void __init socrates_pic_init(void)
 	struct device_node *np;
 
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/stx_gp3.c b/arch/powerpc/platforms/85xx/stx_gp3.c
index 55e941b..e0c88b3 100644
--- a/arch/powerpc/platforms/85xx/stx_gp3.c
+++ b/arch/powerpc/platforms/85xx/stx_gp3.c
@@ -64,7 +64,7 @@ static void __init stx_gp3_pic_init(void)
 #endif
 
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 660769b..2f6479a 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -62,7 +62,7 @@ static void __init tqm85xx_pic_init(void)
 #endif
 
 	struct mpic *mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+			MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 	mpic_init(mpic);
diff --git a/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
index 09b8ba0..d95e765 100644
--- a/arch/powerpc/platforms/85xx/xes_mpc85xx.c
+++ b/arch/powerpc/platforms/85xx/xes_mpc85xx.c
@@ -42,7 +42,7 @@
 void __init xes_mpc85xx_pic_init(void)
 {
 	struct mpic *mpic = mpic_alloc(np, 0,
-			  MPIC_PRIMARY | MPIC_WANTS_RESET |
+			  MPIC_WANTS_RESET |
 			  MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
 			0, 256, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/platforms/86xx/pic.c b/arch/powerpc/platforms/86xx/pic.c
index f85c8f0..78e50c9 100644
--- a/arch/powerpc/platforms/86xx/pic.c
+++ b/arch/powerpc/platforms/86xx/pic.c
@@ -44,7 +44,7 @@ void __init mpc86xx_init_irq(void)
 		return;
 
 	mpic = mpic_alloc(np, 0,
-			MPIC_PRIMARY | MPIC_WANTS_RESET |
+			MPIC_WANTS_RESET |
 			MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
 			MPIC_SINGLE_DEST_CPU,
 			0, 256, " MPIC     ");
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index c73cf4c..392cbdb 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -210,7 +210,7 @@ static void __init mpic_init_IRQ(void)
 		/* The MPIC driver will get everything it needs from the
 		 * device-tree, just pass 0 to all arguments
 		 */
-		mpic = mpic_alloc(dn, 0, 0, 0, 0, " MPIC     ");
+		mpic = mpic_alloc(dn, 0, MPIC_SECONDARY, 0, 0, " MPIC     ");
 		if (mpic == NULL)
 			continue;
 		mpic_init(mpic);
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index 1227864..f1f17bb 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -435,8 +435,7 @@ static void __init chrp_find_openpic(void)
 	if (len > 1)
 		isu_size = iranges[3];
 
-	chrp_mpic = mpic_alloc(np, opaddr, MPIC_PRIMARY,
-			       isu_size, 0, " MPIC    ");
+	chrp_mpic = mpic_alloc(np, opaddr, 0, isu_size, 0, " MPIC    ");
 	if (chrp_mpic == NULL) {
 		printk(KERN_ERR "Failed to allocate MPIC structure\n");
 		goto bail;
diff --git a/arch/powerpc/platforms/embedded6xx/holly.c b/arch/powerpc/platforms/embedded6xx/holly.c
index edfc84f..e8c1429 100644
--- a/arch/powerpc/platforms/embedded6xx/holly.c
+++ b/arch/powerpc/platforms/embedded6xx/holly.c
@@ -154,7 +154,7 @@ static void __init holly_init_IRQ(void)
 #endif
 
 	mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
+			MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
 			MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
 			24,
 			NR_IRQS-4, /* num_sources used */
diff --git a/arch/powerpc/platforms/embedded6xx/linkstation.c b/arch/powerpc/platforms/embedded6xx/linkstation.c
index 502ff60..bcfad92 100644
--- a/arch/powerpc/platforms/embedded6xx/linkstation.c
+++ b/arch/powerpc/platforms/embedded6xx/linkstation.c
@@ -82,7 +82,7 @@ static void __init linkstation_init_IRQ(void)
 {
 	struct mpic *mpic;
 
-	mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
+	mpic = mpic_alloc(NULL, 0, MPIC_WANTS_RESET,
 			4, 32, " EPIC     ");
 	BUG_ON(mpic == NULL);
 
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index 1dd976e..32376b5 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -108,7 +108,7 @@ static void __init mpc7448_hpc2_init_IRQ(void)
 #endif
 
 	mpic = mpic_alloc(NULL, 0,
-			MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
+			MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
 			MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
 			24,
 			NR_IRQS-4, /* num_sources used */
diff --git a/arch/powerpc/platforms/embedded6xx/storcenter.c b/arch/powerpc/platforms/embedded6xx/storcenter.c
index a233d91..6b3fffe 100644
--- a/arch/powerpc/platforms/embedded6xx/storcenter.c
+++ b/arch/powerpc/platforms/embedded6xx/storcenter.c
@@ -84,7 +84,7 @@ static void __init storcenter_init_IRQ(void)
 {
 	struct mpic *mpic;
 
-	mpic = mpic_alloc(NULL, 0, MPIC_PRIMARY | MPIC_WANTS_RESET,
+	mpic = mpic_alloc(NULL, 0, MPIC_WANTS_RESET,
 			16, 32, " OpenPIC  ");
 	BUG_ON(mpic == NULL);
 
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index 5b3388b..a14ac90 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -220,7 +220,7 @@ static void __init maple_init_IRQ(void)
 	unsigned long openpic_addr = 0;
 	int naddr, n, i, opplen, has_isus = 0;
 	struct mpic *mpic;
-	unsigned int flags = MPIC_PRIMARY;
+	unsigned int flags = 0;
 
 	/* Locate MPIC in the device-tree. Note that there is a bug
 	 * in Maple device-tree where the type of the controller is
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
index 883757e..851bdab 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -223,7 +223,7 @@ static __init void pas_init_IRQ(void)
 	openpic_addr = of_read_number(opprop, naddr);
 	printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
 
-	mpic_flags = MPIC_PRIMARY | MPIC_LARGE_VECTORS | MPIC_NO_BIAS;
+	mpic_flags = MPIC_LARGE_VECTORS | MPIC_NO_BIAS;
 
 	nmiprop = of_get_property(mpic_node, "nmi-source", NULL);
 	if (nmiprop)
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index fe360f7c..f4dc247 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -501,7 +501,7 @@ static struct mpic * __init pmac_setup_one_mpic(struct device_node *np,
 {
 	const char *name = master ? " MPIC 1   " : " MPIC 2   ";
 	struct mpic *mpic;
-	unsigned int flags = master ? MPIC_PRIMARY : 0;
+	unsigned int flags = master ? 0 : MPIC_SECONDARY;
 	int rc;
 
 	pmac_call_feature(PMAC_FTR_ENABLE_MPIC, np, 0, 0);
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 0969fd9..172980c 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -192,8 +192,7 @@ static void __init pseries_mpic_init_IRQ(void)
 	BUG_ON(openpic_addr == 0);
 
 	/* Setup the openpic driver */
-	mpic = mpic_alloc(pSeries_mpic_node, openpic_addr,
-			  MPIC_PRIMARY,
+	mpic = mpic_alloc(pSeries_mpic_node, openpic_addr, 0,
 			  16, 250, /* isu size, irq count */
 			  " MPIC     ");
 	BUG_ON(mpic == NULL);
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 548ca16..31a9ada 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -154,7 +154,7 @@ static inline unsigned int mpic_processor_id(struct mpic *mpic)
 {
 	unsigned int cpu = 0;
 
-	if (mpic->flags & MPIC_PRIMARY)
+	if (!(mpic->flags & MPIC_SECONDARY))
 		cpu = hard_smp_processor_id();
 
 	return cpu;
@@ -992,7 +992,7 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
 
 #ifdef CONFIG_SMP
 	else if (hw >= mpic->ipi_vecs[0]) {
-		WARN_ON(!(mpic->flags & MPIC_PRIMARY));
+		WARN_ON(mpic->flags & MPIC_SECONDARY);
 
 		DBG("mpic: mapping as IPI\n");
 		irq_set_chip_data(virq, mpic);
@@ -1003,7 +1003,7 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
 #endif /* CONFIG_SMP */
 
 	if (hw >= mpic->timer_vecs[0] && hw <= mpic->timer_vecs[7]) {
-		WARN_ON(!(mpic->flags & MPIC_PRIMARY));
+		WARN_ON(mpic->flags & MPIC_SECONDARY);
 
 		DBG("mpic: mapping as timer\n");
 		irq_set_chip_data(virq, mpic);
@@ -1190,12 +1190,12 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 
 	mpic->hc_irq = mpic_irq_chip;
 	mpic->hc_irq.name = name;
-	if (flags & MPIC_PRIMARY)
+	if (!(flags & MPIC_SECONDARY))
 		mpic->hc_irq.irq_set_affinity = mpic_set_affinity;
 #ifdef CONFIG_MPIC_U3_HT_IRQS
 	mpic->hc_ht_irq = mpic_irq_ht_chip;
 	mpic->hc_ht_irq.name = name;
-	if (flags & MPIC_PRIMARY)
+	if (!(flags & MPIC_SECONDARY))
 		mpic->hc_ht_irq.irq_set_affinity = mpic_set_affinity;
 #endif /* CONFIG_MPIC_U3_HT_IRQS */
 
@@ -1361,7 +1361,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
 	mpic->next = mpics;
 	mpics = mpic;
 
-	if (flags & MPIC_PRIMARY) {
+	if (!(flags & MPIC_SECONDARY)) {
 		mpic_primary = mpic;
 		irq_set_default_host(mpic->irqhost);
 	}
@@ -1431,7 +1431,7 @@ void __init mpic_init(struct mpic *mpic)
 
 	/* Do the HT PIC fixups on U3 broken mpic */
 	DBG("MPIC flags: %x\n", mpic->flags);
-	if ((mpic->flags & MPIC_U3_HT_IRQS) && (mpic->flags & MPIC_PRIMARY)) {
+	if ((mpic->flags & MPIC_U3_HT_IRQS) && !(mpic->flags & MPIC_SECONDARY)) {
 		mpic_scan_ht_pics(mpic);
 		mpic_u3msi_init(mpic);
 	}
-- 
1.7.2.5

^ permalink raw reply related

* [RFC PATCH 10/10] powerpc/mpic: Add in-core support for cascaded MPICs
From: Kyle Moffett @ 2011-10-31 21:10 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: cbe-oss-dev, Arnd Bergmann, Milton Miller, Paul Mackerras,
	Kyle Moffett, Scott Wood
In-Reply-To: <1320095411-20667-1-git-send-email-Kyle.D.Moffett@boeing.com>

The Cell and PowerMac platforms use virtually identical cascaded-IRQ
setup code, so just merge it into the core.  This does the obvious thing
when an MPIC device-node specifies an "interrupts" property.

Signed-off-by: Kyle Moffett <Kyle.D.Moffett@boeing.com>
---
 arch/powerpc/platforms/cell/setup.c   |   22 --------------------
 arch/powerpc/platforms/powermac/pic.c |   36 ++++----------------------------
 arch/powerpc/sysdev/mpic.c            |   27 ++++++++++++++++++++++-
 3 files changed, 30 insertions(+), 55 deletions(-)

diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index 392cbdb..8708a71 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -183,19 +183,6 @@ static int __init cell_publish_devices(void)
 }
 machine_subsys_initcall(cell, cell_publish_devices);
 
-static void cell_mpic_cascade(unsigned int irq, struct irq_desc *desc)
-{
-	struct irq_chip *chip = irq_desc_get_chip(desc);
-	struct mpic *mpic = irq_desc_get_handler_data(desc);
-	unsigned int virq;
-
-	virq = mpic_get_one_irq(mpic);
-	if (virq != NO_IRQ)
-		generic_handle_irq(virq);
-
-	chip->irq_eoi(&desc->irq_data);
-}
-
 static void __init mpic_init_IRQ(void)
 {
 	struct device_node *dn;
@@ -214,15 +201,6 @@ static void __init mpic_init_IRQ(void)
 		if (mpic == NULL)
 			continue;
 		mpic_init(mpic);
-
-		virq = irq_of_parse_and_map(dn, 0);
-		if (virq == NO_IRQ)
-			continue;
-
-		printk(KERN_INFO "%s : hooking up to IRQ %d\n",
-		       dn->full_name, virq);
-		irq_set_handler_data(virq, mpic);
-		irq_set_chained_handler(virq, cell_mpic_cascade);
 	}
 }
 
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index f4dc247..e02cd79 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -466,18 +466,6 @@ int of_irq_map_oldworld(struct device_node *device, int index,
 }
 #endif /* CONFIG_PPC32 */
 
-static void pmac_u3_cascade(unsigned int irq, struct irq_desc *desc)
-{
-	struct irq_chip *chip = irq_desc_get_chip(desc);
-	struct mpic *mpic = irq_desc_get_handler_data(desc);
-	unsigned int cascade_irq = mpic_get_one_irq(mpic);
-
-	if (cascade_irq != NO_IRQ)
-		generic_handle_irq(cascade_irq);
-
-	chip->irq_eoi(&desc->irq_data);
-}
-
 static void __init pmac_pic_setup_mpic_nmi(struct mpic *mpic)
 {
 #if defined(CONFIG_XMON) && defined(CONFIG_PPC32)
@@ -529,7 +517,6 @@ static int __init pmac_pic_probe_mpic(void)
 {
 	struct mpic *mpic1, *mpic2;
 	struct device_node *np, *master = NULL, *slave = NULL;
-	unsigned int cascade;
 
 	/* We can have up to 2 MPICs cascaded */
 	for (np = NULL; (np = of_find_node_by_type(np, "open-pic"))
@@ -565,27 +552,14 @@ static int __init pmac_pic_probe_mpic(void)
 
 	of_node_put(master);
 
-	/* No slave, let's go out */
-	if (slave == NULL)
-		return 0;
-
-	/* Get/Map slave interrupt */
-	cascade = irq_of_parse_and_map(slave, 0);
-	if (cascade == NO_IRQ) {
-		printk(KERN_ERR "Failed to map cascade IRQ\n");
-		return 0;
-	}
-
-	mpic2 = pmac_setup_one_mpic(slave, 0);
-	if (mpic2 == NULL) {
-		printk(KERN_ERR "Failed to setup slave MPIC\n");
+	/* Set up a cascaded controller, if present */
+	if (slave) {
+		mpic2 = pmac_setup_one_mpic(slave, 0);
+		if (mpic2 == NULL)
+			printk(KERN_ERR "Failed to setup slave MPIC\n");
 		of_node_put(slave);
-		return 0;
 	}
-	irq_set_handler_data(cascade, mpic2);
-	irq_set_chained_handler(cascade, pmac_u3_cascade);
 
-	of_node_put(slave);
 	return 0;
 }
 
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 1826dae..d5cf276 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1113,6 +1113,21 @@ static int mpic_host_xlate(struct irq_host *h, struct device_node *ct,
 	return 0;
 }
 
+/* IRQ handler for a secondary MPIC cascaded from another IRQ controller */
+static void mpic_cascade(unsigned int irq, struct irq_desc *desc)
+{
+	struct irq_chip *chip = irq_desc_get_chip(desc);
+	struct mpic *mpic = irq_desc_get_handler_data(desc);
+
+	BUG_ON(!(mpic->flags & MPIC_SECONDARY));
+
+	unsigned int virq = mpic_get_one_irq(mpic);
+	if (virq != NO_IRQ)
+		generic_handle_irq(virq);
+
+	chip->irq_eoi(&desc->irq_data);
+}
+
 static struct irq_host_ops mpic_host_ops = {
 	.match = mpic_host_match,
 	.map = mpic_host_map,
@@ -1384,8 +1399,7 @@ void __init mpic_set_default_senses(struct mpic *mpic, u8 *senses, int count)
 
 void __init mpic_init(struct mpic *mpic)
 {
-	int i;
-	int cpu;
+	int i, cpu, virq;
 
 	BUG_ON(mpic->num_sources == 0);
 
@@ -1470,6 +1484,15 @@ void __init mpic_init(struct mpic *mpic)
 				  GFP_KERNEL);
 	BUG_ON(mpic->save_data == NULL);
 #endif
+
+	/* Check if this MPIC is chained from a parent interrupt controller */
+	virq = irq_of_parse_and_map(mpic->node, 0);
+	if (virq != NO_IRQ) {
+		printk(KERN_INFO "%s: hooking up to IRQ %d\n",
+				dn->full_name, virq);
+		irq_set_handler_data(virq, mpic);
+		irq_set_chained_handler(virq, &mpic_cascade);
+	}
 }
 
 void __init mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio)
-- 
1.7.2.5

^ permalink raw reply related

* [PATCH] [v3] powerpc/fsl_msi: add support for the fsl, msi property in PCI nodes
From: Timur Tabi @ 2011-10-31 22:06 UTC (permalink / raw)
  To: kumar.gala, scottwood, miltonm, tglx, benh, linuxppc-dev, michael

On Freescale parts with multiple MSI controllers, the controllers are
combined into one "pool" of interrupts.  Whenever a device requests an MSI
interrupt, the next available interrupt from the pool is selected,
regardless of which MSI controller the interrupt is from.  This works
because each PCI bus has an ATMU to all of CCSR, so any PCI device can
access any MSI interrupt register.

The fsl,msi property is used to specify that a given PCI bus should only
use a specific MSI device.  This is necessary, for example, with the
Freescale hypervisor, because the MSI devices are assigned to specific
partitions.

Ideally, we'd like to be able to assign MSI devices to PCI busses within
the MSI or PCI layers.  However, there does not appear to be a mechanism
to do that.  Whenever the MSI layer wants to allocate an MSI interrupt to
a PCI device, it just calls arch_setup_msi_irqs().  It would be nice if we
could register an MSI device with a specific PCI bus.

So instead we remember the phandles of each MSI device, and we use that to
limit our search for an available interrupt.  Whenever we are asked to
allocate a new interrupt for a PCI device, we check the fsl,msi property
of the PCI bus for that device.  If it exists, then as we are looping over
all MSI devices, we skip the ones that don't have a matching phandle.

Signed-off-by: Timur Tabi <timur@freescale.com>
---

v3: added check for invalid fsl,msi phandles

 arch/powerpc/sysdev/fsl_msi.c |   39 +++++++++++++++++++++++++++++++++++++++
 arch/powerpc/sysdev/fsl_msi.h |    3 +++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index e5c344d..89548e0 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -148,14 +148,47 @@ static void fsl_compose_msi_msg(struct pci_dev *pdev, int hwirq,
 
 static int fsl_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
 {
+	struct pci_controller *hose = pci_bus_to_host(pdev->bus);
+	struct device_node *np;
+	phandle phandle = 0;
 	int rc, hwirq = -ENOMEM;
 	unsigned int virq;
 	struct msi_desc *entry;
 	struct msi_msg msg;
 	struct fsl_msi *msi_data;
 
+	/*
+	 * If the PCI node has an fsl,msi property, then we need to use it
+	 * to find the specific MSI.
+	 */
+	np = of_parse_phandle(hose->dn, "fsl,msi", 0);
+	if (np) {
+		if (of_device_is_compatible(np, "fsl,mpic-msi"))
+			phandle = np->phandle;
+		else {
+			dev_err(&pdev->dev, "node %s has an invalid fsl,msi"
+				" phandle\n", hose->dn->full_name);
+			return -EINVAL;
+		}
+	}
+
 	list_for_each_entry(entry, &pdev->msi_list, list) {
+		/*
+		 * Loop over all the MSI devices until we find one that has an
+		 * available interrupt.
+		 */
 		list_for_each_entry(msi_data, &msi_head, list) {
+			/*
+			 * If the PCI node has an fsl,msi property, then we
+			 * restrict our search to the corresponding MSI node.
+			 * The simplest way is to skip over MSI nodes with the
+			 * wrong phandle. Under the Freescale hypervisor, this
+			 * has the additional benefit of skipping over MSI
+			 * nodes that are not mapped in the PAMU.
+			 */
+			if (phandle && (phandle != msi_data->phandle))
+				continue;
+
 			hwirq = msi_bitmap_alloc_hwirqs(&msi_data->bitmap, 1);
 			if (hwirq >= 0)
 				break;
@@ -370,6 +403,12 @@ static int __devinit fsl_of_msi_probe(struct platform_device *dev)
 
 	msi->msiir_offset = features->msiir_offset + (res.start & 0xfffff);
 
+	/*
+	 * Remember the phandle, so that we can match with any PCI nodes
+	 * that have an "fsl,msi" property.
+	 */
+	msi->phandle = dev->dev.of_node->phandle;
+
 	rc = fsl_msi_init_allocator(msi);
 	if (rc) {
 		dev_err(&dev->dev, "Error allocating MSI bitmap\n");
diff --git a/arch/powerpc/sysdev/fsl_msi.h b/arch/powerpc/sysdev/fsl_msi.h
index 1313abb..b5d25ba 100644
--- a/arch/powerpc/sysdev/fsl_msi.h
+++ b/arch/powerpc/sysdev/fsl_msi.h
@@ -13,6 +13,7 @@
 #ifndef _POWERPC_SYSDEV_FSL_MSI_H
 #define _POWERPC_SYSDEV_FSL_MSI_H
 
+#include <linux/of.h>
 #include <asm/msi_bitmap.h>
 
 #define NR_MSI_REG		8
@@ -36,6 +37,8 @@ struct fsl_msi {
 	struct msi_bitmap bitmap;
 
 	struct list_head list;          /* support multiple MSI banks */
+
+	phandle phandle;
 };
 
 #endif /* _POWERPC_SYSDEV_FSL_MSI_H */
-- 
1.7.3.4

^ permalink raw reply related

* Re: [PATCH] powerpc/iommu: remove default window before creating larger window
From: Nishanth Aravamudan @ 2011-10-31 22:47 UTC (permalink / raw)
  To: benh; +Cc: miltonm, paulus, linuxppc-dev
In-Reply-To: <20111026224323.GA15685@us.ibm.com>

Hi Ben,

Please don't take this patch :)

While, it does work around some issues I'm tracking down, it can lead
to worse ones if we are unable to configure the larger DMA window, or if
some functions in a PE don't use 64-bit DMA masks.

Thanks,
Nish

On 26.10.2011 [15:43:23 -0700], Nishanth Aravamudan wrote:
> The DDW feature relies on there being sufficient TCE space to allocate
> for the requested DMA window size. The default window uses up some of
> that space, though, and it is recommended to first remove the default
> window and then allocate the larger window advertised by firmware. Do
> this by abstracting out parts of remove_ddw into a function that does
> not assume an existing larger window has been created.
> 
> Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
> ---
>  arch/powerpc/platforms/pseries/iommu.c |   35 +++++++++++++++++++++++--------
>  1 files changed, 26 insertions(+), 9 deletions(-)
> 
> Is there a better way to get the default window's LIOBN than to call
> of_parse_dma_window?
> 
> diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
> index 01faab9..afcc04c 100644
> --- a/arch/powerpc/platforms/pseries/iommu.c
> +++ b/arch/powerpc/platforms/pseries/iommu.c
> @@ -655,6 +655,21 @@ static int __init disable_ddw_setup(char *str)
>  
>  early_param("disable_ddw", disable_ddw_setup);
>  
> +static void __remove_ddw(struct device_node *np, const u32 *ddw_avail, u64 liobn)
> +{
> +	int ret;
> +
> +	ret = rtas_call(ddw_avail[2], 1, 1, NULL, liobn);
> +	if (ret)
> +		pr_warning("%s: failed to remove direct window: rtas returned "
> +			"%d to ibm,remove-pe-dma-window(%x) %llx\n",
> +			np->full_name, ret, ddw_avail[2], liobn);
> +	else
> +		pr_debug("%s: successfully removed direct window: rtas returned "
> +			"%d to ibm,remove-pe-dma-window(%x) %llx\n",
> +			np->full_name, ret, ddw_avail[2], liobn);
> +}
> +
>  static void remove_ddw(struct device_node *np)
>  {
>  	struct dynamic_dma_window_prop *dwp;
> @@ -684,15 +699,7 @@ static void remove_ddw(struct device_node *np)
>  		pr_debug("%s successfully cleared tces in window.\n",
>  			 np->full_name);
>  
> -	ret = rtas_call(ddw_avail[2], 1, 1, NULL, liobn);
> -	if (ret)
> -		pr_warning("%s: failed to remove direct window: rtas returned "
> -			"%d to ibm,remove-pe-dma-window(%x) %llx\n",
> -			np->full_name, ret, ddw_avail[2], liobn);
> -	else
> -		pr_debug("%s: successfully removed direct window: rtas returned "
> -			"%d to ibm,remove-pe-dma-window(%x) %llx\n",
> -			np->full_name, ret, ddw_avail[2], liobn);
> +	__remove_ddw(np, ddw_avail, liobn);
>  
>  delprop:
>  	ret = prom_remove_property(np, win64);
> @@ -843,6 +850,8 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
>  	struct direct_window *window;
>  	struct property *win64;
>  	struct dynamic_dma_window_prop *ddwprop;
> +	const void *dma_window = NULL;
> +	unsigned long liobn, offset, size;
>  
>  	mutex_lock(&direct_window_init_mutex);
>  
> @@ -918,6 +927,14 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
>  		goto out_free_prop;
>  	}
>  
> +	/*
> +	 * To maximize the resources available to the create RTAS call,
> +	 * delete the existing DMA window
> +	 */
> +	dma_window = of_get_property(pdn, "ibm,dma-window", NULL);
> +	of_parse_dma_window(pdn, dma_window, &liobn, &offset, &size);
> +	__remove_ddw(pdn, ddw_avail, liobn);
> +
>  	ret = create_ddw(dev, ddw_avail, &create, page_shift, len);
>  	if (ret != 0)
>  		goto out_free_prop;
> -- 
> 1.7.5.4
> 
> 
> -- 
> Nishanth Aravamudan <nacc@us.ibm.com>
> IBM Linux Technology Center

-- 
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center

^ permalink raw reply

* Re: powerpc 476, Little-endian, pte fault
From: Santosh Kumar @ 2011-11-01  3:02 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: linuxppc-dev, Michael Neuling, Ian Munsie, linux-kernel
In-Reply-To: <1320060214.30202.34.camel@pasglop>

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

I have attached the patch with only the relevant changes.

The patch is not based on uLIBC patch.

Glibc doesnt support little endian for PPC, but after minor changes to
makefile i got it working. With the compiler i am using i could get
2.6.31 on ppc440 working. I am using the same compiler as 476 & 440
instruction is almost the same.

Thanks
Santosh Kumar .A

Vision without Action is a daydream... Action without Vision is a nightmare...



On 31 October 2011 16:53, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> On Mon, 2011-10-31 at 20:49 +1100, Michael Neuling wrote:
>> > I have built a cross compiler for ppc440 in little endian mode and
>> > using it to build the kernel.
>> >
>> > Yes i am running Linux in Little-Endian. This is the first user space
>> > process. I wrote the below program and running it as init from
>> > /sbin/init. I have also set the permissions with chmod +s.
>> >
>> > main()
>> > {
>> >
>> > while(1){
>> > printf("hello world");
>> > sleep(1);
>> >  }
>> > }
>>
>> Does libc even support little endian on PPC?
>
> Ian did a port a while back for uClibc, is that at least partially based
> on it ?
>
>> > I have attached the patch.
>>
>> This is a pretty huge patch:
>>
>>  115 files changed, 44479 insertions(+), 7398 deletions(-)
>>
>> It seems to include a new platform as well as a bunch of unrelated junk.
>>
>> I suggest you need to break this down into something more digestible.
>> Like remove all the junk in the patch.  Then add the support for the new
>> platform (invader? platform).  Then start looking at little endian.
>> Unless you do this, it's unlikely anyone here is going to be able to
>> help.
>>
>> When you get to the little endian work, you might want to take a look at
>> this patch series from Ian Munsie:
>>
>> http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-October/086165.html
>
> Right, the new patch should be if possible based on Ian's series or at
> least a cleaned / rebased variant of it. Then split in bits so we can
> review it properly.
>
> Cheers,
> Ben.
>
>> Mikey
>> _______________________________________________
>> Linuxppc-dev mailing list
>> Linuxppc-dev@lists.ozlabs.org
>> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
>
>

[-- Attachment #2: linux_ppc_476.patch --]
[-- Type: application/octet-stream, Size: 42386 bytes --]

diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/div64.S ../linux-2.6.39.4/arch/powerpc/boot/div64.S
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/div64.S	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/boot/div64.S	2011-10-22 14:16:46.616117143 +0530
@@ -17,8 +17,13 @@
 
 	.globl __div64_32
 __div64_32:
+#ifdef CONFIG_INVADER
+	lwz	r5,4(r3)	# get the dividend into r5/r6
+	lwz	r6,0(r3)
+#else
 	lwz	r5,0(r3)	# get the dividend into r5/r6
 	lwz	r6,4(r3)
+#endif
 	cmplw	r5,r4
 	li	r7,0
 	li	r8,0
@@ -53,7 +58,12 @@
 	mullw	r10,r0,r4	# and get the remainder
 	add	r8,r8,r0
 	subf	r6,r10,r6
+#ifdef CONFIG_INVADER
 4:	stw	r7,0(r3)	# return the quotient in *r3
 	stw	r8,4(r3)
+#else
+4:	stw	r7,0(r3)	# return the quotient in *r3
+	stw	r8,4(r3)
+#endif
 	mr	r3,r6		# return the remainder in r3
 	blr
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/Makefile ../linux-2.6.39.4/arch/powerpc/boot/Makefile
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/Makefile	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/boot/Makefile	2011-10-22 06:47:05.354137527 +0530
@@ -37,7 +37,7 @@
 
 DTC_FLAGS	?= -p 1024
 
-$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
+$(obj)/4xx.o: BOOTCFLAGS += -mcpu=440
 $(obj)/ebony.o: BOOTCFLAGS += -mcpu=405
 $(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
 $(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=405
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/wrapper ../linux-2.6.39.4/arch/powerpc/boot/wrapper
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/boot/wrapper	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/boot/wrapper	2011-10-22 06:38:26.286134445 +0530
@@ -38,6 +38,7 @@
 dts=
 cacheit=
 binary=
+gzip=
 gzip=.gz
 
 # cross-compilation prefix
@@ -50,7 +51,6 @@
 object=arch/powerpc/boot
 objbin=$object
 dtc=scripts/dtc/dtc
-
 # directory for working files
 tmpdir=.
 
@@ -260,7 +260,6 @@
 	vmz="$vmz.$$"
     fi
 fi
-
 vmz="$vmz$gzip"
 
 # Extract kernel version information, some platforms want to include
@@ -277,12 +276,13 @@
 case "$platform" in
 uboot)
     rm -f "$ofile"
-    ${MKIMAGE} -A ppc -O linux -T kernel -C gzip -a $membase -e $membase \
+    ${MKIMAGE} -A ppc -O linux -T kernel -a $membase -e $membase \
 	$uboot_version -d "$vmz" "$ofile"
     if [ -z "$cacheit" ]; then
 	rm -f "$vmz"
     fi
     exit 0
+    echo "not exiting"
     ;;
 esac
 
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/bitops.h ../linux-2.6.39.4/arch/powerpc/include/asm/bitops.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/bitops.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/bitops.h	2011-10-22 06:38:25.203141637 +0530
@@ -318,13 +318,34 @@
 	return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
 }
 
+static inline unsigned long find_next_zero_bit_le(const void *addr,
+                unsigned long size, unsigned long offset)
+{
+        return find_next_zero_bit(addr, size, offset);
+}
+
+static inline unsigned long find_next_bit_le(const void *addr,
+                unsigned long size, unsigned long offset)
+{
+        return find_next_bit(addr, size, offset);
+}
+
+static inline unsigned long find_first_zero_bit_le(const void *addr,
+                unsigned long size)
+{
+        return find_first_zero_bit(addr, size);
+}
+
 #define find_first_zero_bit_le(addr, size) \
 	find_next_zero_bit_le((addr), (size), 0)
+/*
 unsigned long find_next_zero_bit_le(const void *addr,
 				    unsigned long size, unsigned long offset);
 
 unsigned long find_next_bit_le(const void *addr,
 				    unsigned long size, unsigned long offset);
+*/
+
 /* Bitmap functions for the ext2 filesystem */
 
 #define ext2_set_bit_atomic(lock, nr, addr) \
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/byteorder.h ../linux-2.6.39.4/arch/powerpc/include/asm/byteorder.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/byteorder.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/byteorder.h	2011-10-22 06:38:25.254182204 +0530
@@ -7,6 +7,12 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
+
+#ifdef CONFIG_INVADER
+#include <linux/byteorder/little_endian.h>
+#else
 #include <linux/byteorder/big_endian.h>
+#endif
+
 
 #endif /* _ASM_POWERPC_BYTEORDER_H */
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/elf.h ../linux-2.6.39.4/arch/powerpc/include/asm/elf.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/elf.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/elf.h	2011-10-22 06:38:25.140139532 +0530
@@ -118,13 +118,21 @@
 # define ELF_GREG_TYPE	elf_greg_t32
 # define ELF_ARCH	EM_PPC
 # define ELF_CLASS	ELFCLASS32
+#ifdef CONFIG_INVADER
+# define ELF_DATA	ELFDATA2LSB
+#else
 # define ELF_DATA	ELFDATA2MSB
+#endif
 #endif /* __powerpc64__ */
 
 #ifndef ELF_ARCH
 # define ELF_ARCH	EM_PPC64
 # define ELF_CLASS	ELFCLASS64
+#ifdef CONFIG_INVADER
+# define ELF_DATA	ELFDATA2LSB
+#else
 # define ELF_DATA	ELFDATA2MSB
+#endif
   typedef elf_greg_t64 elf_greg_t;
   typedef elf_gregset_t64 elf_gregset_t;
 #else

 iff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/pgtable-ppc32.h ../linux-2.6.39.4/arch/powerpc/include/asm/pgtable-ppc32.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/pgtable-ppc32.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/pgtable-ppc32.h	2011-10-28 13:54:33.350779238 +0530
@@ -63,8 +63,12 @@
 #ifdef CONFIG_HIGHMEM
 #define KVIRT_TOP	PKMAP_BASE
 #else
+#ifdef CONFIG_INVADER
+#define KVIRT_TOP	(0xbe000000UL)	
+#else
 #define KVIRT_TOP	(0xfe000000UL)	/* for now, could be FIXMAP_BASE ? */
 #endif
+#endif
 
 /*
  * ioremap_bot starts at that address. Early ioremaps move down from there,
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/prom.h ../linux-2.6.39.4/arch/powerpc/include/asm/prom.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/prom.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/prom.h	2011-10-22 06:38:25.211141792 +0530
@@ -20,6 +20,10 @@
 #include <asm/irq.h>
 #include <asm/atomic.h>
 
+#ifdef CONFIG_INVADER
+#include <asm/io.h>
+#endif
+
 #define HAVE_ARCH_DEVTREE_FIXUPS
 
 #ifdef CONFIG_PPC32
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/reg.h ../linux-2.6.39.4/arch/powerpc/include/asm/reg.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/include/asm/reg.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/include/asm/reg.h	2011-10-22 06:38:25.222139709 +0530
@@ -839,7 +839,11 @@
 #define PVR_403GC	0x00200200
 #define PVR_403GCX	0x00201400
 #define PVR_405GP	0x40110000
+#ifdef CONFIG_INVADER
+#define PVR_476		0x7ff52080
+#else
 #define PVR_476		0x11a52000
+#endif
 #define PVR_STB03XXX	0x40310000
 #define PVR_NP405H	0x41410000
 #define PVR_NP405L	0x41610000
 
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/cacheinfo.c ../linux-2.6.39.4/arch/powerpc/kernel/cacheinfo.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/cacheinfo.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/cacheinfo.c	2011-10-24 17:02:11.354148243 +0530
@@ -203,7 +203,12 @@
 	if (!cache_size)
 		return -ENODEV;
 
+	printk("cache size: 0x%u\n", be32_to_cpup(cache_size));
+#ifdef CONFIG_INVADER
+	*ret = be32_to_cpup(cache_size);
+#else
 	*ret = *cache_size;
+#endif
 	return 0;
 }
 
@@ -238,7 +243,12 @@
 	if (!line_size)
 		return -ENODEV;
 
+	printk("lne size: 0x%u\n", be32_to_cpup(line_size));
+#ifdef CONFIG_INVADER
+	*ret = be32_to_cpup(line_size);
+#else
 	*ret = *line_size;
+#endif
 	return 0;
 }
 
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/cputable.c ../linux-2.6.39.4/arch/powerpc/kernel/cputable.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/cputable.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/cputable.c	2011-10-22 06:38:27.763108473 +0530
@@ -1853,6 +1853,22 @@
 		.machine_check		= machine_check_47x,
 		.platform		= "ppc470",
 	},
+#ifdef CONFIG_INVADER
+        { /* 476 others */
+                .pvr_mask               = 0xffffffff,
+                .pvr_value              = 0x7ff52080,
+                .cpu_name               = "476fp",
+                .cpu_features           = CPU_FTRS_47X,
+                .cpu_user_features      = COMMON_USER_BOOKE |
+                        PPC_FEATURE_HAS_FPU,
+                .mmu_features           = MMU_FTR_TYPE_47x |
+                        MMU_FTR_USE_TLBIVAX_BCAST | MMU_FTR_LOCK_BCAST_INVAL,
+                .icache_bsize           = 32,
+                .dcache_bsize           = 32,
+                .machine_check          = machine_check_47x,
+                .platform               = "ppc470",
+        },
+#endif
 	{	/* default match */
 		.pvr_mask		= 0x00000000,
 		.pvr_value		= 0x00000000,
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/head_44x.S ../linux-2.6.39.4/arch/powerpc/kernel/head_44x.S
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/head_44x.S	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/head_44x.S	2011-10-30 16:00:57.409103255 +0530
@@ -259,8 +259,14 @@
 
 	/* Compute pte address */
 	rlwimi  r12, r10, PPC44x_PTE_ADD_SHIFT, PPC44x_PTE_ADD_MASK_BIT, 28
+
+#ifdef CONFIG_INVADER
+	lwz	r11, 4(r12)		/* Get high word of pte entry */
+	lwz	r12, 0(r12)		/* Get low word of pte entry */
+#else
 	lwz	r11, 0(r12)		/* Get high word of pte entry */
 	lwz	r12, 4(r12)		/* Get low word of pte entry */
+#endif
 
 	lis	r10,tlb_44x_index@ha
 
@@ -355,8 +361,13 @@
 
 	/* Compute pte address */
 	rlwimi	r12, r10, PPC44x_PTE_ADD_SHIFT, PPC44x_PTE_ADD_MASK_BIT, 28
+#ifdef CONFIG_INVADER
+	lwz	r11, 4(r12)		/* Get high word of pte entry */
+	lwz	r12, 0(r12)		/* Get low word of pte entry */
+#else
 	lwz	r11, 0(r12)		/* Get high word of pte entry */
 	lwz	r12, 4(r12)		/* Get low word of pte entry */
+#endif
 
 	lis	r10,tlb_44x_index@ha
 
@@ -508,8 +519,12 @@
 	/* Compute pte address */
 	rlwimi  r12,r10,PPC44x_PTE_ADD_SHIFT,PPC44x_PTE_ADD_MASK_BIT,28
 	beq	2f			/* Bail if no table */
-	lwz	r11,0(r12)		/* Get high word of pte entry */
 
+#ifdef CONFIG_INVADER
+	lwz	r11,4(r12)		/* Get high word of pte entry */
+#else
+	lwz	r11,0(r12)		/* Get high word of pte entry */
+#endif
 	/* XXX can we do better ? maybe insert a known 0 bit from r11 into the
 	 * bottom of r12 to create a data dependency... We can also use r10
 	 * as destination nowadays
@@ -517,8 +532,12 @@
 #ifdef CONFIG_SMP
 	lwsync
 #endif
-	lwz	r12,4(r12)		/* Get low word of pte entry */
 
+#ifdef CONFIG_INVADER
+	lwz	r12,0(r12)		/* Get low word of pte entry */
+#else
+	lwz	r12,4(r12)		/* Get low word of pte entry */
+#endif
 	andc.	r13,r13,r12		/* Check permission */
 
 	 /* Jump to common tlb load */
@@ -592,15 +611,23 @@
 	rlwimi  r12,r10,PPC44x_PTE_ADD_SHIFT,PPC44x_PTE_ADD_MASK_BIT,28
 	beq	2f			/* Bail if no table */
 
+#ifdef CONFIG_INVADER
+	lwz	r11,4(r12)		/* Get high word of pte entry */
+#else
 	lwz	r11,0(r12)		/* Get high word of pte entry */
+#endif
 	/* XXX can we do better ? maybe insert a known 0 bit from r11 into the
 	 * bottom of r12 to create a data dependency... We can also use r10
 	 * as destination nowadays
 	 */
-#ifdef CONFIG_SMP
+#ifndef CONFIG_SMP
 	lwsync
 #endif
+#ifdef CONFIG_INVADER
+	lwz	r11,0(r12)		/* Get high word of pte entry */
+#else
 	lwz	r12,4(r12)		/* Get low word of pte entry */
+#endif
 
 	andc.	r13,r13,r12		/* Check permission */
 
@@ -638,8 +665,12 @@
 	rlwimi	r10,r12,29,30,30		/* DIRTY -> SW position */
 	and	r11,r12,r10			/* Mask PTE bits to keep */
 	andi.	r10,r12,_PAGE_USER		/* User page ? */
+#ifdef CONFIG_INVADER
+	ori	r11,r11,PPC47x_TLB2_E
+#endif
 	beq	1f				/* nope, leave U bits empty */
 	rlwimi	r11,r11,3,26,28			/* yes, copy S bits to U */
+
 1:	tlbwe	r11,r13,2
 
 	/* Done...restore registers and get out of here.
@@ -935,6 +966,13 @@
  */
 
 head_start_47x:
+//	.align
+	nop
+	nop
+	nop
+	
+	li r3, 0x3
+	rlwinm r23, r3, 1, 31, 31
 	/* Load our current PID->MMUCR TID and MSR IS->MMUCR STS */
 	mfspr	r3,SPRN_PID			/* Get PID */
 	mfmsr	r4				/* Get MSR */
@@ -964,8 +1002,7 @@
 clear_all_utlb_entries:
 
 	#; Set initial values.
-
-	addis		r3,0,0x8000
+	addis		r3,0,0xa000	/* Invader change: quick fix?? */
 	addi		r4,0,0
 	addi		r5,0,0
 	b		clear_utlb_entry
@@ -976,6 +1013,7 @@
 
 clear_utlb_entry:
 
+//	isync	//not needed ??
 	tlbwe		r4,r3,0
 	tlbwe		r5,r3,1
 	tlbwe		r5,r3,2
@@ -987,12 +1025,15 @@
 	cmpwi		r4,0
 	bne		clear_utlb_entry
 
-	#; Restore original entry.
 
+	#; Restore original entry.
+#ifndef CONFIG_INVDER
+// Invader change 
 	oris	r23,r23,0x8000  /* specify the way */
 	tlbwe		r24,r23,0
 	tlbwe		r25,r23,1
 	tlbwe		r26,r23,2
+#endif
 
 /*
  * Configure and load pinned entry into TLB for the kernel core
@@ -1018,7 +1059,12 @@
 					/* ERPN is 0 for first 4GB page */
 	/* Word 2 */
 	li	r5,0
+#ifdef CONFIG_INVADER
+	ori	r5,r5,(PPC47x_TLB2_S_RWX|PPC47x_TLB2_E)
+#else
 	ori	r5,r5,PPC47x_TLB2_S_RWX
+#endif
+
 #ifdef CONFIG_SMP
 	ori	r5,r5,PPC47x_TLB2_M
 #endif
@@ -1062,14 +1108,19 @@
 
 	/* Word 0 */
 	lis	r3,PPC44x_EARLY_DEBUG_VIRTADDR@h
-	ori	r3,r3,PPC47x_TLB0_VALID | PPC47x_TLB0_TS | PPC47x_TLB0_1M
+	ori	r3,r3, (PPC47x_TLB0_VALID | PPC47x_TLB0_TS | PPC47x_TLB0_1M)
 
 	/* Word 1 */
 	lis	r4,CONFIG_PPC_EARLY_DEBUG_44x_PHYSLOW@h
 	ori	r4,r4,CONFIG_PPC_EARLY_DEBUG_44x_PHYSHIGH
 
-	/* Word 2 */
+#ifdef CONFIG_INVADER
+	/* Removing M flag as there is no SMP support for now*/
+	li	r5,(PPC47x_TLB2_S_RW | PPC47x_TLB2_I | PPC47x_TLB2_G | PPC47x_TLB2_E)
+
+#else
 	li	r5,(PPC47x_TLB2_S_RW | PPC47x_TLB2_IMG)
+#endif
 
 	/* Bolted in way 0, bolt slot 5, we -hope- we don't hit the same
 	 * congruence class as the kernel, we need to make sure of it at
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/irq.c ../linux-2.6.39.4/arch/powerpc/kernel/irq.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/irq.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/irq.c	2011-10-24 16:36:08.295113827 +0530
@@ -757,7 +757,11 @@
 
 	/* If host has no translation, then we assume interrupt line */
 	if (host->ops->xlate == NULL)
+#ifdef CONFIG_INVADER
+		hwirq = be32_to_cpu(intspec[0]);
+#else
 		hwirq = intspec[0];
+#endif
 	else {
 		if (host->ops->xlate(host, controller, intspec, intsize,
 				     &hwirq, &type))
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/misc_32.S ../linux-2.6.39.4/arch/powerpc/kernel/misc_32.S
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/misc_32.S	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/misc_32.S	2011-10-26 15:51:22.562068744 +0530
@@ -60,6 +60,32 @@
 /*
  * This returns the high 64 bits of the product of two 64-bit numbers.
  */
+
+#ifdef CONFIG_INVADER
+_GLOBAL(mulhdu)
+       cmpwi   r5,0
+       cmpwi   cr1,r4,0
+       mr      r10,r3
+       mulhwu  r3,r3,r6
+       beq     1f
+       mulhwu  r0,r10,r5
+       mullw   r7,r10,r6
+       addc    r7,r0,r7
+       addze   r3,r3
+1:     beqlr   cr1             /* all done if high part of A is 0 */
+       mr      r10,r4
+       mullw   r9,r4,r6
+       mulhwu  r4,r4,r6
+       beq     2f
+       mullw   r0,r10,r5
+       mulhwu  r8,r10,r5
+       addc    r7,r0,r7
+       adde    r3,r3,r8
+       addze   r4,r4
+2:     addc    r3,r3,r9
+       addze   r4,r4
+       blr
+#else
 _GLOBAL(mulhdu)
 	cmpwi	r6,0
 	cmpwi	cr1,r3,0
@@ -83,6 +109,7 @@
 2:	addc	r4,r4,r9
 	addze	r3,r3
 	blr
+#endif
 
 /*
  * sub_reloc_offset(x) returns x - reloc_offset().
@@ -605,6 +632,42 @@
  *  lshrdi3: logical right shift
  *  ashldi3: left shift
  */
+#ifdef CONFIG_INVADER
+_GLOBAL(__ashrdi3)
+       subfic  r6,r5,32
+       srw     r3,r3,r5        # LSW = count > 31 ? 0 : LSW >> count
+       addi    r7,r5,32        # could be xori, or addi with -32
+       slw     r6,r4,r6        # t1 = count > 31 ? 0 : MSW << (32-count)
+       rlwinm  r8,r7,0,32      # t3 = (count < 32) ? 32 : 0
+       sraw    r7,r4,r7        # t2 = MSW >> (count-32)
+       or      r3,r3,r6        # LSW |= t1
+       slw     r7,r7,r8        # t2 = (count < 32) ? 0 : t2
+       sraw    r4,r4,r5        # MSW = MSW >> count
+       or      r3,r3,r7        # LSW |= t2
+       blr
+
+_GLOBAL(__ashldi3)
+       subfic  r6,r5,32
+       slw     r4,r4,r5        # MSW = count > 31 ? 0 : MSW << count
+       addi    r7,r5,32        # could be xori, or addi with -32
+       srw     r6,r3,r6        # t1 = count > 31 ? 0 : LSW >> (32-count)
+       slw     r7,r3,r7        # t2 = count < 32 ? 0 : LSW << (count-32)
+       or      r4,r4,r6        # MSW |= t1
+       slw     r3,r3,r5        # LSW = LSW << count
+       or      r4,r4,r7        # MSW |= t2
+       blr
+
+_GLOBAL(__lshrdi3)
+       subfic  r6,r5,32
+       srw     r3,r3,r5        # LSW = count > 31 ? 0 : LSW >> count
+       addi    r7,r5,32        # could be xori, or addi with -32
+       slw     r6,r4,r6        # t1 = count > 31 ? 0 : MSW << (32-count)
+       srw     r7,r4,r7        # t2 = count < 32 ? 0 : MSW >> (count-32)
+       or      r3,r3,r6        # LSW |= t1
+       srw     r4,r4,r5        # MSW = MSW >> count
+       or      r3,r3,r7        # LSW |= t2
+       blr
+#else
 _GLOBAL(__ashrdi3)
 	subfic	r6,r5,32
 	srw	r4,r4,r5	# LSW = count > 31 ? 0 : LSW >> count
@@ -639,6 +702,7 @@
 	srw	r3,r3,r5	# MSW = MSW >> count
 	or	r4,r4,r7	# LSW |= t2
 	blr
+#endif 
 
 /*
  * 64-bit comparison: __ucmpdi2(u64 a, u64 b)
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/module_32.c ../linux-2.6.39.4/arch/powerpc/kernel/module_32.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/module_32.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/module_32.c	2011-10-22 06:38:27.155103324 +0530
@@ -46,9 +46,15 @@
 	r_addend = 0;
 	for (i = 0; i < num; i++)
 		/* Only count 24-bit relocs, others don't need stubs */
+#ifdef CONFIG_INVADER
+		if ( ((ELF32_R_TYPE(rela[i].r_info) == R_PPC_REL24) && (ELF32_R_TYPE(rela[i].r_info) == R_PPC_REL14) &&
+		    (r_info != ELF32_R_SYM(rela[i].r_info) ||
+		     r_addend != rela[i].r_addend)) ) {
+#else
 		if (ELF32_R_TYPE(rela[i].r_info) == R_PPC_REL24 &&
 		    (r_info != ELF32_R_SYM(rela[i].r_info) ||
 		     r_addend != rela[i].r_addend)) {
+#endif
 			_count_relocs++;
 			r_info = ELF32_R_SYM(rela[i].r_info);
 			r_addend = rela[i].r_addend;
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/prom.c ../linux-2.6.39.4/arch/powerpc/kernel/prom.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/prom.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/prom.c	2011-10-22 12:32:28.777113831 +0530
@@ -103,6 +103,8 @@
 		memcpy(p, initial_boot_params, size);
 		initial_boot_params = (struct boot_param_header *)p;
 		DBG("Moved device tree to 0x%p\n", p);
+// invader debug
+		printk("Moved device tree to 0x%p\n", p);
 	}
 
 	DBG("<- move_device_tree\n");
@@ -300,7 +302,7 @@
 		 */
 		if (initial_boot_params && initial_boot_params->version >= 2) {
 			if (intserv[i] ==
-					initial_boot_params->boot_cpuid_phys) {
+					be32_to_cpu(initial_boot_params->boot_cpuid_phys)) {
 				found = 1;
 				break;
 			}
@@ -344,8 +346,14 @@
 		 * it uses 0x0f000001.
 		 */
 		prop = of_get_flat_dt_prop(node, "cpu-version", NULL);
+		printk(KERN_DEBUG "INVADER PVR: 0x%x\n", be32_to_cpup(prop));
+#ifdef CONFIG_INVADER
+		if (prop && (be32_to_cpup(prop) & 0xff000000) == 0x0f000000)
+			identify_cpu(0, be32_to_cpup(prop));
+#else
 		if (prop && (*prop & 0xff000000) == 0x0f000000)
 			identify_cpu(0, *prop);
+#endif
 
 		identical_pvr_fixup(node);
 	}
@@ -478,6 +486,7 @@
 				if ((base + size) > 0x80000000ul)
 					size = 0x80000000ul - base;
 			}
+			printk(KERN_DEBUG "memblk Add1 base: 0x%llx, size: 0x%llx", base, size);
 			memblock_add(base, size);
 		} while (--rngs);
 	}
@@ -516,6 +525,7 @@
 	memstart_addr = min((u64)memstart_addr, base);
 
 	/* Add the chunk to the MEMBLOCK list */
+	printk(KERN_DEBUG "memblk Add2 base: 0x%llx, size: 0x%llx", base, size);
 	memblock_add(base, size);
 }
 
@@ -541,12 +551,18 @@
 	unsigned long self_base;
 	unsigned long self_size;
 
+	// Invader Change
 	reserve_map = (u64 *)(((unsigned long)initial_boot_params) +
+#ifdef CONFIG_INVADER
+					be32_to_cpu(initial_boot_params->off_mem_rsvmap));
+#else
 					initial_boot_params->off_mem_rsvmap);
+#endif
 
 	/* before we do anything, lets reserve the dt blob */
 	self_base = __pa((unsigned long)initial_boot_params);
-	self_size = initial_boot_params->totalsize;
+	self_size = be32_to_cpu(initial_boot_params->totalsize);
+
 	memblock_reserve(self_base, self_size);
 
 #ifdef CONFIG_BLK_DEV_INITRD
@@ -560,13 +576,18 @@
 	 * Handle the case where we might be booting from an old kexec
 	 * image that setup the mem_rsvmap as pairs of 32-bit values
 	 */
-	if (*reserve_map > 0xffffffffull) {
+	if (be64_to_cpu(*reserve_map) > 0xffffffffull) {
 		u32 base_32, size_32;
 		u32 *reserve_map_32 = (u32 *)reserve_map;
 
 		while (1) {
+#ifdef CONFIG_INVADER
+			base_32 = be32_to_cpu(*(reserve_map_32++));
+			size_32 = be32_to_cpu(*(reserve_map_32++));
+#else
 			base_32 = *(reserve_map_32++);
 			size_32 = *(reserve_map_32++);
+#endif
 			if (size_32 == 0)
 				break;
 			/* skip if the reservation is for the blob */
@@ -579,11 +600,17 @@
 	}
 #endif
 	while (1) {
+// Invader Changes
+#ifdef CONFIG_INVADER
+		base = be64_to_cpu(*(reserve_map++));
+		size = be64_to_cpu(*(reserve_map++));
+#else
 		base = *(reserve_map++);
 		size = *(reserve_map++);
+#endif
 		if (size == 0)
 			break;
-		DBG("reserving: %llx -> %llx\n", base, size);
+		DBG("reserving2: %llx -> %llx\n", base, size);
 		memblock_reserve(base, size);
 	}
 }
@@ -912,8 +939,8 @@
 {
 	struct dentry *d;
 
-	flat_dt_blob.data = initial_boot_params;
-	flat_dt_blob.size = initial_boot_params->totalsize;
+	flat_dt_blob.data = (initial_boot_params);
+	flat_dt_blob.size = be32_to_cpu(initial_boot_params->totalsize);
 
 	d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR,
 				powerpc_debugfs_root, &flat_dt_blob);
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/prom_init.c ../linux-2.6.39.4/arch/powerpc/kernel/prom_init.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/prom_init.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/prom_init.c	2011-10-22 06:38:27.610103651 +0530
@@ -789,7 +789,11 @@
 } fake_elf = {
 	.elfhdr = {
 		.e_ident = { 0x7f, 'E', 'L', 'F',
+#ifdef CONFIG_INVADER
+			     ELFCLASS32, ELFDATA2LSB, EV_CURRENT },
+#else
 			     ELFCLASS32, ELFDATA2MSB, EV_CURRENT },
+#endif
 		.e_type = ET_EXEC,	/* yeah right */
 		.e_machine = EM_PPC,
 		.e_version = EV_CURRENT,

diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/vmlinux.lds.S ../linux-2.6.39.4/arch/powerpc/kernel/vmlinux.lds.S
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/kernel/vmlinux.lds.S	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/kernel/vmlinux.lds.S	2011-10-22 06:38:27.713103244 +0530
@@ -34,11 +34,15 @@
 jiffies = jiffies_64;
 #else
 OUTPUT_ARCH(powerpc:common)
+#ifdef CONFIG_INVADER
 jiffies = jiffies_64 + 4;
+#else
+jiffies = jiffies_64 + 4;
+#endif
 #endif
 SECTIONS
 {
-	. = 0;
+	. = 0x00;
 	reloc_start = .;
 
 	. = KERNELBASE;
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/lib/div64.S ../linux-2.6.39.4/arch/powerpc/lib/div64.S
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/lib/div64.S	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/lib/div64.S	2011-10-22 06:38:28.053112501 +0530
@@ -17,8 +17,13 @@
 #include <asm/processor.h>
 
 _GLOBAL(__div64_32)
+#ifdef CONFIG_INVADER
+	lwz	r5,4(r3)	# get the dividend into r5/r6
+	lwz	r6,0(r3)
+#else
 	lwz	r5,0(r3)	# get the dividend into r5/r6
 	lwz	r6,4(r3)
+#endif
 	cmplw	r5,r4
 	li	r7,0
 	li	r8,0
@@ -53,7 +58,12 @@
 	mullw	r10,r0,r4	# and get the remainder
 	add	r8,r8,r0
 	subf	r6,r10,r6
+#ifdef CONFIG_INVADER
+4:	stw	r7,4(r3)	# return the quotient in *r3
+	stw	r8,0(r3)
+#else
 4:	stw	r7,0(r3)	# return the quotient in *r3
 	stw	r8,4(r3)
+#endif
 	mr	r3,r6		# return the remainder in r3
 	blr
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/Makefile ../linux-2.6.39.4/arch/powerpc/Makefile
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/Makefile	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/Makefile	2011-10-22 06:42:29.464137538 +0530
@@ -17,8 +17,8 @@
 # Set default 32 bits cross compilers for vdso and boot wrapper
 CROSS32_COMPILE ?=
 
-CROSS32CC		:= $(CROSS32_COMPILE)gcc
-CROSS32AR		:= $(CROSS32_COMPILE)ar
+CROSS32CC		:= $(CROSS32_COMPILE)gcc -mlittle-endian -mno-mfcrf
+CROSS32AR		:= $(CROSS32_COMPILE)ar -EL
 
 ifeq ($(HAS_BIARCH),y)
 ifeq ($(CROSS32_COMPILE),)
@@ -57,9 +57,9 @@
 UTS_MACHINE := $(OLDARCH)
 
 ifeq ($(HAS_BIARCH),y)
-override AS	+= -a$(CONFIG_WORD_SIZE)
-override LD	+= -m elf$(CONFIG_WORD_SIZE)ppc
-override CC	+= -m$(CONFIG_WORD_SIZE)
+override AS	+= -a$(CONFIG_WORD_SIZE) -mlittle-endian
+override LD	+= -m elf$(CONFIG_WORD_SIZE)ppc -EL
+override CC	+= -m$(CONFIG_WORD_SIZE) -mlittle-endian -mno-mfcrf
 override AR	:= GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR)
 endif
 
@@ -68,10 +68,10 @@
 LDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-yy)
 
 CFLAGS-$(CONFIG_PPC64)	:= -mminimal-toc -mtraceback=none  -mcall-aixdesc
-CFLAGS-$(CONFIG_PPC32)	:= -ffixed-r2 -mmultiple
+CFLAGS-$(CONFIG_PPC32)	:= -ffixed-r2
 KBUILD_CPPFLAGS	+= -Iarch/$(ARCH)
 KBUILD_AFLAGS	+= -Iarch/$(ARCH)
-KBUILD_CFLAGS	+= -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y)
+KBUILD_CFLAGS	+= -msoft-float -pipe -Iarch/$(ARCH) $(CFLAGS-y) 
 CPP		= $(CC) -E $(KBUILD_CFLAGS)
 
 CHECKFLAGS	+= -m$(CONFIG_WORD_SIZE) -D__powerpc__ -D__powerpc$(CONFIG_WORD_SIZE)__
@@ -119,7 +119,7 @@
 
 # Never use string load/store instructions as they are
 # often slow when they are implemented at all
-KBUILD_CFLAGS		+= -mno-string
+#KBUILD_CFLAGS		+= -mno-string
 
 ifeq ($(CONFIG_6xx),y)
 KBUILD_CFLAGS		+= -mcpu=powerpc
@@ -130,7 +130,7 @@
 KBUILD_CFLAGS		+= -mno-sched-epilog
 endif
 
-cpu-as-$(CONFIG_4xx)		+= -Wa,-m405
+cpu-as-$(CONFIG_4xx)		+= -Wa,-m440
 cpu-as-$(CONFIG_6xx)		+= -Wa,-maltivec
 cpu-as-$(CONFIG_POWER4)		+= -Wa,-maltivec
 cpu-as-$(CONFIG_E500)		+= -Wa,-me500
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/mm/44x_mmu.c ../linux-2.6.39.4/arch/powerpc/mm/44x_mmu.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/mm/44x_mmu.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/mm/44x_mmu.c	2011-10-24 17:26:29.012226884 +0530
@@ -165,7 +165,12 @@
 		"tlbwe	%0,%3,2\n"
 		:
 		: "r" (PPC47x_TLB2_SW | PPC47x_TLB2_SR |
+#ifdef CONFIG_INVADER
+		       PPC47x_TLB2_SX | PPC47x_TLB2_E
+#else
 		       PPC47x_TLB2_SX
+#endif
+
 #ifdef CONFIG_SMP
 		       | PPC47x_TLB2_M
 #endif
@@ -223,6 +228,7 @@
 	 */
 	BUG_ON(first_memblock_base != 0);
 
+	printk(KERN_DEBUG "setup_initial_memory_limit: 0x%llx, 0x%llx\n", first_memblock_base, first_memblock_size);
 	/* 44x has a 256M TLB entry pinned at boot */
 	memblock_set_current_limit(min_t(u64, first_memblock_size, PPC_PIN_SIZE));
 }
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/invader_setup.c ../linux-2.6.39.4/arch/powerpc/platforms/invader/invader_setup.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/invader_setup.c	1970-01-01 05:30:00.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/platforms/invader/invader_setup.c	2011-10-24 15:53:49.024532082 +0530
@@ -0,0 +1,87 @@
+/*
+	LSI HEADER ???
+*/
+
+#include <linux/init.h>
+#include <linux/of_platform.h>
+
+#include <asm/machdep.h>
+#include <asm/prom.h>
+#include <asm/udbg.h>
+#include <asm/time.h>
+#include <asm/mpic.h>
+#include <asm/ppc4xx.h>
+#include <asm/irq.h>
+#include <asm/pci-bridge.h>
+
+#define DEBUG 1
+
+static struct of_device_id invader_of_bus_ids[] = {
+	{ .compatible = "ibm,plb6", },
+        { .compatible = "simple-bus", },
+	{ .compatible = "chrp,open-pic", },
+	{},
+};
+
+static int __init invader_device_probe(void)
+{
+        of_platform_bus_probe(NULL, invader_of_bus_ids, NULL);
+
+        return 0;
+}
+machine_device_initcall(invader, invader_device_probe);
+
+static int __init invader_probe(void)
+{
+	unsigned long root = of_get_flat_dt_root();
+
+	if (!of_flat_dt_is_compatible(root, "LSI,Invader"))
+		return 0;
+
+	ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
+
+	return 1;
+}
+
+static void __init invader_init_irq(void)
+{
+        struct mpic *mpic;
+        struct resource r;
+        struct device_node *np = NULL;
+
+        /* Find top level interrupt controller */
+        for_each_node_with_property(np, "interrupt-controller") {
+                if (of_get_property(np, "interrupts", NULL) == NULL)
+                        break;
+        }
+        if (np == NULL)
+                panic("Invader: Can't find top level interrupt controller");
+
+        if (of_device_is_compatible(np, "chrp,open-pic")) {
+                /* The MPIC driver will get everything it needs from the
+                 * device-tree, just pass 0 to all arguments
+                 */
+                mpic = mpic_alloc(np, 0, MPIC_PRIMARY|MPIC_WANTS_RESET, 0, 0, " MPIC ");
+                BUG_ON(mpic == NULL);
+                mpic_init(mpic);
+                ppc_md.get_irq = mpic_get_irq;
+        } else
+                panic("Invader: Unrecognized top level interrupt controller");
+
+	printk("\n\n\t\t\tMPIC initialized\n\n\n");
+}
+
+static void __init invader_progress(char *s, unsigned short hex)
+{
+        printk("*** %04x : %s\n", hex, s ? s : "");
+}
+
+define_machine(invader) {
+	.name			= "Invader",
+	.probe			= invader_probe,
+        .progress               = invader_progress,
+        .init_IRQ       	= invader_init_irq,
+        .get_irq        	= mpic_get_irq,
+        .calibrate_decr         = generic_calibrate_decr,
+        .restart                = ppc4xx_reset_system,
+};
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/Kconfig ../linux-2.6.39.4/arch/powerpc/platforms/invader/Kconfig
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/Kconfig	1970-01-01 05:30:00.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/platforms/invader/Kconfig	2011-10-22 06:38:25.833134467 +0530
@@ -0,0 +1,8 @@
+config INVADER
+	bool "Invader"
+	depends on PPC_47x
+	help 
+	  This option enabled support for LSI PPC476 "Invader"
+		evaluation board.
+
+
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/Makefile ../linux-2.6.39.4/arch/powerpc/platforms/invader/Makefile
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/invader/Makefile	1970-01-01 05:30:00.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/platforms/invader/Makefile	2011-10-22 06:38:25.828374811 +0530
@@ -0,0 +1 @@
+obj-$(CONFIG_INVADER)       += invader_setup.o
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/Kconfig ../linux-2.6.39.4/arch/powerpc/platforms/Kconfig
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/Kconfig	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/platforms/Kconfig	2011-10-22 06:38:26.083147732 +0530
@@ -20,6 +20,7 @@
 source "arch/powerpc/platforms/44x/Kconfig"
 source "arch/powerpc/platforms/40x/Kconfig"
 source "arch/powerpc/platforms/amigaone/Kconfig"
+source "arch/powerpc/platforms/invader/Kconfig"
 
 config KVM_GUEST
 	bool "KVM Guest support"
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/Makefile ../linux-2.6.39.4/arch/powerpc/platforms/Makefile
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/platforms/Makefile	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/platforms/Makefile	2011-10-22 06:38:25.910151396 +0530
@@ -22,3 +22,4 @@
 obj-$(CONFIG_PPC_PS3)		+= ps3/
 obj-$(CONFIG_EMBEDDED6xx)	+= embedded6xx/
 obj-$(CONFIG_AMIGAONE)		+= amigaone/
+obj-$(CONFIG_INVADER)		+= invader/
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/dcr.c ../linux-2.6.39.4/arch/powerpc/sysdev/dcr.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/dcr.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/sysdev/dcr.c	2011-10-24 16:41:24.331106125 +0530
@@ -133,7 +133,12 @@
 	if (dr == NULL || ds & 1 || index >= (ds / 8))
 		return 0;
 
+	printk(KERN_DEBUG " dcr-reg: 0x%x", be32_to_cpu(dr[index * 2]));
+#ifdef CONFIG_INVADER
+	return be32_to_cpu(dr[index * 2]);
+#else
 	return dr[index * 2];
+#endif
 }
 EXPORT_SYMBOL_GPL(dcr_resource_start);
 
@@ -145,7 +150,12 @@
 	if (dr == NULL || ds & 1 || index >= (ds / 8))
 		return 0;
 
+	printk(KERN_DEBUG " dcr-reg2: 0x%x", be32_to_cpu(dr[index * 2]+1));
+#ifdef CONFIG_INVADER
+	return be32_to_cpu(dr[index * 2 + 1]);
+#else
 	return dr[index * 2 + 1];
+#endif
 }
 EXPORT_SYMBOL_GPL(dcr_resource_len);
 
@@ -177,6 +187,8 @@
 
 	/* Maybe could do some better range checking here */
 	ret = of_translate_address(dp, p);
+	
+	printk(KERN_DEBUG " translate-dcr-reg: 0x%llx", ret);
 	if (ret != OF_BAD_ADDR)
 		ret += (u64)(stride) * (u64)dcr_n;
 	if (out_stride)
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/mpic.c ../linux-2.6.39.4/arch/powerpc/sysdev/mpic.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/mpic.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/sysdev/mpic.c	2011-10-25 18:07:53.637770104 +0530
@@ -296,7 +296,7 @@
 
 	dbasep = of_get_property(node, "dcr-reg", NULL);
 
-	rb->dhost = dcr_map(node, *dbasep + offset, size);
+	rb->dhost = dcr_map(node, be32_to_cpup(dbasep) + offset, size);
 	BUG_ON(!DCR_MAP_OK(rb->dhost));
 }
 
@@ -1179,8 +1179,9 @@
 	 */
 	if (paddr == 0 && !(mpic->flags & MPIC_USES_DCR)) {
 		const u32 *reg = of_get_property(node, "reg", NULL);
+		printk(KERN_DEBUG "mpic: reg: 0x%x\n", *reg);
 		BUG_ON(reg == NULL);
-		paddr = of_translate_address(node, reg);
+		paddr = be32_to_cpu(of_translate_address(node, reg));
 		BUG_ON(paddr == OF_BAD_ADDR);
 	}
 
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/ppc4xx_soc.c ../linux-2.6.39.4/arch/powerpc/sysdev/ppc4xx_soc.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/arch/powerpc/sysdev/ppc4xx_soc.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/arch/powerpc/sysdev/ppc4xx_soc.c	2011-10-25 18:04:40.509769915 +0530
@@ -93,7 +93,11 @@
 		of_node_put(np);
 		return -ENODEV;
 	}
+#ifdef CONFIG_INVADER
+	l2_size = be32_to_cpu(prop[0]);
+#else
 	l2_size = prop[0];
+#endif
 
 	/* Map DCRs */
 	dcrreg = of_get_property(np, "dcr-reg", &len);
@@ -103,8 +107,13 @@
 		of_node_put(np);
 		return -ENODEV;
 	}
+#ifdef CONFIG_INVADER
+	dcrbase_isram = be32_to_cpu(dcrreg[0]);
+	dcrbase_l2c = be32_to_cpu(dcrreg[2]);
+#else
 	dcrbase_isram = dcrreg[0];
 	dcrbase_l2c = dcrreg[2];
+#endif
 
 	/* Get and map irq number from device tree */
 	irq = irq_of_parse_and_map(np, 0);
@@ -199,6 +208,7 @@
 	struct device_node *np;
 	u32 reset_type = DBCR0_RST_SYSTEM;
 	const u32 *prop;
+	u32	propVal=0;
 
 	np = of_find_node_by_type(NULL, "cpu");
 	if (np) {
@@ -210,8 +220,17 @@
 		 * 2 - PPC4xx chip reset
 		 * 3 - PPC4xx system reset (default)
 		 */
+#ifdef CONFIG_INVADER
+		if (prop)
+		{
+			propVal = be32_to_cpup(prop);
+			if (((propVal>= 1) && (propVal <= 3)))
+				reset_type = propVal << 28;
+		}
+#else
 		if ((prop) && ((prop[0] >= 1) && (prop[0] <= 3)))
 			reset_type = prop[0] << 28;
+#endif
 	}
 
 	mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | reset_type);
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/fs/ext2/balloc.c ../linux-2.6.39.4/fs/ext2/balloc.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/fs/ext2/balloc.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/fs/ext2/balloc.c	2011-10-22 06:38:04.625107806 +0530
@@ -18,6 +18,9 @@
 #include <linux/buffer_head.h>
 #include <linux/capability.h>
 
+#ifdef CONFIG_INVADER
+//#include <asm-generic/bitops/le.h>
+#endif
 /*
  * balloc.c contains the blocks allocation and deallocation routines
  */
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/include/asm-generic/bitops/non-atomic.h ../linux-2.6.39.4/include/asm-generic/bitops/non-atomic.h
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/include/asm-generic/bitops/non-atomic.h	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/include/asm-generic/bitops/non-atomic.h	2011-10-22 12:40:27.954406170 +0530
@@ -105,4 +105,25 @@
 	return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
 }
 
+static inline int test_bit_dbg(int nr, const volatile unsigned long *addr, volatile unsigned long *ret, volatile unsigned long *ret1, volatile unsigned long *ret2)
+{
+	if(ret)
+		*ret = (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
+
+	if (ret1)
+		*ret1 = 1UL&(*ret);
+
+	if (ret2)
+		*ret2 = 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
+
+#ifdef CONFIG_INVADER
+        return (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
+#else
+        return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
+#endif
+}
+
+
+
+
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/init/main.c ../linux-2.6.39.4/init/main.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/init/main.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/init/main.c	2011-10-30 14:04:41.250103375 +0530
@@ -664,7 +664,8 @@
 	int count = preempt_count();
 	int ret;
 
-	if (initcall_debug)
+//	if (initcall_debug)
+	if (1)
 		ret = do_one_initcall_debug(fn);
 	else
 		ret = fn();
@@ -729,6 +730,7 @@
 static void run_init_process(const char *init_filename)
 {
 	argv_init[0] = init_filename;
+	printk(KERN_DEBUG "RUNNING run_init_process %s\n", init_filename);
 	kernel_execve(init_filename, argv_init, envp_init);
 }
 
@@ -747,6 +749,7 @@
 
 	current->signal->flags |= SIGNAL_UNKILLABLE;
 
+	printk(KERN_DEBUG "ramdisk_execute_command: %s, execute_command: %s\n",ramdisk_execute_command ,execute_command);
 	if (ramdisk_execute_command) {
 		run_init_process(ramdisk_execute_command);
 		printk(KERN_WARNING "Failed to execute %s\n",
@@ -765,10 +768,10 @@
 					"defaults...\n", execute_command);
 	}
 	run_init_process("/sbin/init");
-	run_init_process("/etc/init");
+/*	run_init_process("/etc/init");
 	run_init_process("/bin/init");
 	run_init_process("/bin/sh");
-
+*/
 	panic("No init found.  Try passing init= option to kernel. "
 	      "See Linux Documentation/init.txt for guidance.");
 }
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/kernel/printk.c ../linux-2.6.39.4/kernel/printk.c
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/kernel/printk.c	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/kernel/printk.c	2011-10-24 11:52:01.814164824 +0530
@@ -1485,7 +1485,9 @@
 	}
 	console_unlock();
 	console_sysfs_notify();
-
+#ifdef CONFIG_INVADER
+	keep_bootcon = 1;
+#endif
 	/*
 	 * By unregistering the bootconsoles after we enable the real console
 	 * we get the "console xxx enabled" message on all the consoles -
diff -uNr ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/Makefile ../linux-2.6.39.4/Makefile
--- ../../../crosscompiler_with_gdb_c_c++_objc/work/linux-2.6.39.4/Makefile	2011-08-04 01:13:28.000000000 +0530
+++ ../linux-2.6.39.4/Makefile	2011-10-22 06:39:21.397105230 +0530
@@ -237,6 +237,7 @@
 
 HOSTCC       = gcc
 HOSTCXX      = g++
+#Invader Changes
 HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
 HOSTCXXFLAGS = -O2
 
@@ -320,9 +321,9 @@
 
 # Make variables (CC, etc...)
 
-AS		= $(CROSS_COMPILE)as
-LD		= $(CROSS_COMPILE)ld
-CC		= $(CROSS_COMPILE)gcc
+AS		= $(CROSS_COMPILE)as -mlittle-endian
+LD		= $(CROSS_COMPILE)ld -EL
+CC		= $(CROSS_COMPILE)gcc -mlittle-endian -mno-mfcrf
 CPP		= $(CC) -E
 AR		= $(CROSS_COMPILE)ar
 NM		= $(CROSS_COMPILE)nm
@@ -359,10 +360,12 @@
 		   -fno-strict-aliasing -fno-common \
 		   -Werror-implicit-function-declaration \
 		   -Wno-format-security \
-		   -fno-delete-null-pointer-checks
+		   -fno-delete-null-pointer-checks \
+		   -mlittle-endian \
+		   -fsigned-char
 KBUILD_AFLAGS_KERNEL :=
 KBUILD_CFLAGS_KERNEL :=
-KBUILD_AFLAGS   := -D__ASSEMBLY__
+KBUILD_AFLAGS   := -D__ASSEMBLY__ -mlittle-endian
 KBUILD_AFLAGS_MODULE  := -DMODULE
 KBUILD_CFLAGS_MODULE  := -DMODULE
 KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
@@ -545,6 +548,7 @@
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS	+= -Os
 else
+#Invader Changes
 KBUILD_CFLAGS	+= -O2
 endif
 


^ permalink raw reply

* What does rmo/tce stand for in powerpc?
From: Ryan Wang @ 2011-11-01  6:25 UTC (permalink / raw)
  To: linuxppc-dev

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

Hi,

In kernel source comments, I saw the words:
''

alloc_top is set to the top of RMO, eventually shrink down if the
<http://lxr.linux.no/linux+*/arch/powerpc/kernel/prom_init.c#L972>TCEs
overlap

''

I wonder what does RMO mean, and TCE?

thanks,

[-- Attachment #2: Type: text/html, Size: 484 bytes --]

^ permalink raw reply

* Re: powerpc 476, Little-endian, pte fault
From: Peter Bergner @ 2011-11-01 13:44 UTC (permalink / raw)
  To: Santosh Kumar; +Cc: Michael Neuling, Ian Munsie, linux-kernel, linuxppc-dev
In-Reply-To: <CAJw04pBpXsTS4=FeG5ZF3nqORXhiOZ=3V60cFCuJfgTiJcCh2g@mail.gmail.com>

On Tue, 2011-11-01 at 08:32 +0530, Santosh Kumar wrote:
> I am using the same compiler as 476 & 440 instruction is almost the same.

Well the 476 implements ISA 2.05, which I think has added a fair amount
over the 440.  Not to mention the 476 core that has been released has
a FP unit.  I'll note that GCC has support for a 476 with and without
a FP unit, even though AFAIK, we only ship one with a FP unit.
The relevant options are -mcpu=476 (no FP unit) and -mcpu=476fp
(with FP unit).  Basically, -mcpu=476 is equivalent to
-mcpu=476fp -msoft-float.



> @@ -53,7 +58,12 @@
>         mullw   r10,r0,r4       # and get the remainder
>         add     r8,r8,r0
>         subf    r6,r10,r6
> +#ifdef CONFIG_INVADER
>  4:     stw     r7,0(r3)        # return the quotient in *r3
>         stw     r8,4(r3)
> +#else
> +4:     stw     r7,0(r3)        # return the quotient in *r3
> +       stw     r8,4(r3)
> +#endif
>         mr      r3,r6           # return the remainder in r3
>         blr

This looks like a typo, since you didn't actually swap the offsets
on the stw's like you did in all of the other patch hunks.


Peter

^ permalink raw reply

* Re: powerpc 476, Little-endian, pte fault
From: Santosh Kumar @ 2011-11-01 17:14 UTC (permalink / raw)
  To: Peter Bergner; +Cc: Michael Neuling, Ian Munsie, linux-kernel, linuxppc-dev
In-Reply-To: <1320155074.2996.190.camel@otta>

> The relevant options are -mcpu=3D476 (no FP unit) and -mcpu=3D476fp> (wit=
h FP unit). =A0Basically, -mcpu=3D476 is equivalent to> -mcpu=3D476fp -msof=
t-float.
Yes what you have mentioned is right.

I had a problem configuring the GCC for 476 in little endian mode,
therefore I am using 440 compiler. As this compiler doesn't accept
-mcpu=3D476 i am using -mcpu=3D440.

So is this PTE fault related to the compiler options?

Thanks,
Santosh Kumar .A

On 1 November 2011 19:14, Peter Bergner <bergner@vnet.ibm.com> wrote:
> On Tue, 2011-11-01 at 08:32 +0530, Santosh Kumar wrote:
>> I am using the same compiler as 476 & 440 instruction is almost the same=
.
>
> Well the 476 implements ISA 2.05, which I think has added a fair amount
> over the 440. =A0Not to mention the 476 core that has been released has
> a FP unit. =A0I'll note that GCC has support for a 476 with and without
> a FP unit, even though AFAIK, we only ship one with a FP unit.
> The relevant options are -mcpu=3D476 (no FP unit) and -mcpu=3D476fp
> (with FP unit). =A0Basically, -mcpu=3D476 is equivalent to
> -mcpu=3D476fp -msoft-float.
>
>
>
>> @@ -53,7 +58,12 @@
>> =A0 =A0 =A0 =A0 mullw =A0 r10,r0,r4 =A0 =A0 =A0 # and get the remainder
>> =A0 =A0 =A0 =A0 add =A0 =A0 r8,r8,r0
>> =A0 =A0 =A0 =A0 subf =A0 =A0r6,r10,r6
>> +#ifdef CONFIG_INVADER
>> =A04: =A0 =A0 stw =A0 =A0 r7,0(r3) =A0 =A0 =A0 =A0# return the quotient =
in *r3
>> =A0 =A0 =A0 =A0 stw =A0 =A0 r8,4(r3)
>> +#else
>> +4: =A0 =A0 stw =A0 =A0 r7,0(r3) =A0 =A0 =A0 =A0# return the quotient in=
 *r3
>> + =A0 =A0 =A0 stw =A0 =A0 r8,4(r3)
>> +#endif
>> =A0 =A0 =A0 =A0 mr =A0 =A0 =A0r3,r6 =A0 =A0 =A0 =A0 =A0 # return the rem=
ainder in r3
>> =A0 =A0 =A0 =A0 blr
>
> This looks like a typo, since you didn't actually swap the offsets
> on the stw's like you did in all of the other patch hunks.
>
>
> Peter
>
>
>
>

^ permalink raw reply

* Re: What does rmo/tce stand for in powerpc?
From: Nishanth Aravamudan @ 2011-11-01 17:25 UTC (permalink / raw)
  To: Ryan Wang; +Cc: linuxppc-dev
In-Reply-To: <CAPxxNQnhXaKJ5ve-=0qwChuuvDj_027RM2pSD43DEf6BZbaHDA@mail.gmail.com>

Hi Ryan,

On 01.11.2011 [14:25:43 +0800], Ryan Wang wrote:
> Hi,
> 
> In kernel source comments, I saw the words:
> ''
> 
> alloc_top is set to the top of RMO, eventually shrink down if the
> <http://lxr.linux.no/linux+*/arch/powerpc/kernel/prom_init.c#L972>TCEs
> overlap
> 
> ''
> 
> I wonder what does RMO mean, and TCE?

RMO = Real Mode Offset -- deprecated in terms of Real Mode Area in PAPR.

TCE = Translation Control Entry

You should be able to find descriptions of both in PAPR.

Thanks,
Nish

-- 
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center

^ permalink raw reply

* Re: powerpc 476, Little-endian, pte fault
From: Peter Bergner @ 2011-11-01 18:44 UTC (permalink / raw)
  To: Santosh Kumar; +Cc: Michael Neuling, Ian Munsie, linux-kernel, linuxppc-dev
In-Reply-To: <CAJw04pA3mDOgHrOvPxeXR8Fw6Jn1kBz9qSrgq2vJ7HPpyQwSbg@mail.gmail.com>

On Tue, 2011-11-01 at 22:44 +0530, Santosh Kumar wrote:
> I had a problem configuring the GCC for 476 in little endian mode,

What type of problem?  I assume the binutils you are building
against has 476 support too, correct?  You'll need that.


> So is this PTE fault related to the compiler options?

This could be caused by anything, but I highly doubt this is
caused by a compiler option issue.  My $$ are that you either
have a bug in your kernel patch or there are more places in
the kernel source that need patching.

Peter

^ permalink raw reply

* Re: Regression: patch " hvc_console: display printk messages on console." causing infinite loop with 3.2-rc0 + Xen.
From: Stephen Rothwell @ 2011-11-02  1:13 UTC (permalink / raw)
  To: Greg KH
  Cc: xen-devel, Konrad Rzeszutek Wilk, Rusty Russell, miche,
	linux-kernel, virtualization, Linus, Anton Blanchard, Amit Shah,
	ppc-dev
In-Reply-To: <20111027054806.GA1377@suse.de>

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

Hi Greg,

On Thu, 27 Oct 2011 07:48:06 +0200 Greg KH <gregkh@suse.de> wrote:
>
> On Thu, Oct 27, 2011 at 01:30:08AM -0400, Konrad Rzeszutek Wilk wrote:
> > Hey Miche.
> > 
> > The git commit 361162459f62dc0826b82c9690a741a940f457f0:
> > 
> >     hvc_console: display printk messages on console.
> > 
> > is causing an infinite loop when booting Linux under Xen, as so:
> 
> Ick, not good, thanks for letting us know.

Indeed. I am wondering why it was put in a tree and sent to Linus without
any Acks or even being replied to by anyone.  It appeared in the tty tree
between Oct 14 and Oct 25 (while I was unfortunately on vacation).  If
anyone had tried to boot this on any PowerPC server, it would have been
immediately obvious (as it was when I booted Linus' tree last night).

And the original author expressed doubts as to his understanding of how
it should all work anyway.

Just a little more care, please.

I would vote for reverting the original and having it resubmitted with
corrections at some later date.
-- 
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

* [PATCH] powerpc/usb: use ioremap instead of base plus offset to access regs
From: Shaohui Xie @ 2011-11-02  7:08 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linux-usb, Shaohui Xie

Below are codes for accessing usb sysif_regs in driver:

	usb_sys_regs = (struct usb_sys_interface *)
		((u32)dr_regs + USB_DR_SYS_OFFSET);

these codes work in 32-bit, but in 64-bit, accessing members of 'usb_sys_regs'
will cause call trace like below:

Unable to handle kernel paging request for data at address 0x8817a500
Faulting instruction address: 0x800000000011bae8
Oops: Kernel access of bad area, sig: 11 [#1]
SMP NR_CPUS=2 P5020 DS
Modules linked in: fsl_usb2_udc(+)
NIP: 800000000011bae8 LR: 800000000011efb8 CTR: c0000000000ef500
REGS: c0000000f3e2f350 TRAP: 0300   Not tainted  (3.0.6-00001-g0700776)
MSR: 0000000080029000 <EE,ME,CE>  CR: 24000222  XER: 00000000
DEAR: 000000008817a500, ESR: 0000000000000000
TASK = c0000000fb3b8840[3466] 'insmod' THREAD: c0000000f3e2c000 CPU: 1
GPR00: 0000000000000002 c0000000f3e2f5d0 80000000001286b8 c0000000fb2e7c00
GPR04: 00000000000000d0 0000000000000000 c0000000f8b026c0 0000000000000041
GPR08: 0000000000000000 000000008817a400 c000000007653d28 0000000000000000
GPR12: 800000000011f3a8 c00000000ffff400 0000000000000000 0000000000000000
GPR16: 0000000000000000 000000007ff9eee4 0000000000000000 0000000000000000
GPR20: 0000000000000000 00000000100e2645 0000000000000001 0000000000000000
GPR24: c0000000f8b72c10 80000000001208e8 c0000000fb2e7c00 0000000000000000
GPR28: 0000000000000000 c0000000fb2e7c00 8000000000128198 80000000001208e8
NIP [800000000011bae8] .dr_controller_setup+0x318/0x360 [fsl_usb2_udc]
LR [800000000011efb8] .fsl_udc_probe+0x3b4/0x630 [fsl_usb2_udc]
Call Trace:
[c0000000f3e2f5d0] [c0000000f3e2f660] 0xc0000000f3e2f660 (unreliable)
[c0000000f3e2f660] [800000000011efb8] .fsl_udc_probe+0x3b4/0x630 [fsl_usb2_udc]
[c0000000f3e2f730] [c0000000002f2960] .platform_drv_probe+0x30/0x50
[c0000000f3e2f7a0] [c0000000002f0df0] .driver_probe_device+0xe0/0x230
[c0000000f3e2f840] [c0000000002f104c] .__driver_attach+0x10c/0x110
[c0000000f3e2f8d0] [c0000000002ef83c] .bus_for_each_dev+0x7c/0xd0
[c0000000f3e2f970] [c0000000002f08c8] .driver_attach+0x28/0x40
[c0000000f3e2f9f0] [c0000000002f02c0] .bus_add_driver+0xd0/0x310
[c0000000f3e2faa0] [c0000000002f15dc] .driver_register+0x9c/0x1a0
[c0000000f3e2fb40] [c0000000002f2dc0] .platform_driver_register+0x60/0x80
[c0000000f3e2fbc0] [c0000000002f2e14] .platform_driver_probe+0x34/0xf0
[c0000000f3e2fc50] [800000000011f26c] .udc_init+0x38/0x894 [fsl_usb2_udc]
[c0000000f3e2fcd0] [c000000000000eb0] .do_one_initcall+0x60/0x1e0
[c0000000f3e2fd90] [c00000000008a7b0] .SyS_init_module+0xd0/0x220
[c0000000f3e2fe30] [c0000000000005a0] syscall_exit+0x0/0x2c
Instruction dump:
eba1ffe8 ebc1fff0 ebe1fff8 7c0803a6 4e800020 6529c000 793c0020 4bfffdac
65291000 793c0020 e93f0010 7c0004ac
 0c000000 4c00012c 60000204
 ---[ end trace d152129396f60c53 ]---

Signed-off-by: Shaohui Xie <Shaohui.Xie@freescale.com>
---
 drivers/usb/gadget/fsl_udc_core.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c
index c81fbad..c656d2c 100644
--- a/drivers/usb/gadget/fsl_udc_core.c
+++ b/drivers/usb/gadget/fsl_udc_core.c
@@ -263,9 +263,11 @@ static int dr_controller_setup(struct fsl_udc *udc)
 		/* fall through */
 	case FSL_USB2_PHY_UTMI:
 #ifdef CONFIG_FSL_SOC_BOOKE
+	if (udc->pdata->have_sysif_regs) {
 		setbits32(&usb_sys_regs->control, USB_CTRL_UTMI_PHY_EN |
 			       USB_CTRL_USB_EN);
 		udelay(10*1000);  /* delay for PHY clk to ready */
+	}
 #endif
 		portctrl |= PORTSCX_PTS_UTMI;
 		break;
@@ -986,7 +988,7 @@ static int fsl_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 					queue);
 
 			/* Point the QH to the first TD of next request */
-			fsl_writel((u32) next_req->head, &qh->curr_dtd_ptr);
+			fsl_writel(*(u32 *) next_req->head, &qh->curr_dtd_ptr);
 		}
 
 		/* The request hasn't been processed, patch up the TD chain */
@@ -2497,8 +2499,8 @@ static int __init fsl_udc_probe(struct platform_device *pdev)
 
 #ifndef CONFIG_ARCH_MXC
 	if (pdata->have_sysif_regs)
-		usb_sys_regs = (struct usb_sys_interface *)
-				((u32)dr_regs + USB_DR_SYS_OFFSET);
+		usb_sys_regs = ioremap(res->start + USB_DR_SYS_OFFSET,
+				sizeof(struct usb_sys_interface)/sizeof(int));
 #endif
 
 	/* Initialize USB clocks */
-- 
1.6.4

^ permalink raw reply related

* RE: [PATCH] powerpc/usb: use ioremap instead of base plus offset to access regs
From: David Laight @ 2011-11-02  9:06 UTC (permalink / raw)
  To: Shaohui Xie, linuxppc-dev; +Cc: linux-usb
In-Reply-To: <1320217708-32658-1-git-send-email-Shaohui.Xie@freescale.com>

=20
>  #ifndef CONFIG_ARCH_MXC
>  	if (pdata->have_sysif_regs)
> -		usb_sys_regs =3D (struct usb_sys_interface *)
> -				((u32)dr_regs + USB_DR_SYS_OFFSET);
> +		usb_sys_regs =3D ioremap(res->start + USB_DR_SYS_OFFSET,
> +				sizeof(struct
usb_sys_interface)/sizeof(int));
>  #endif

That ioremap() doesn't look right.
Isn't the 'size' in bytes??
(Although it will only matter if it crosses a page boundary.)
Mind you, I'd have though the original ioremap() should
have covered the entire structure??

	David

^ permalink raw reply

* RE: [PATCH] powerpc/usb: use ioremap instead of base plus offset to access regs
From: Xie Shaohui-B21989 @ 2011-11-02  9:39 UTC (permalink / raw)
  To: David Laight, linuxppc-dev@lists.ozlabs.org; +Cc: linux-usb@vger.kernel.org
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6D8AE9E@saturn3.aculab.com>

>-----Original Message-----
>From: David Laight [mailto:David.Laight@ACULAB.COM]
>Sent: Wednesday, November 02, 2011 5:07 PM
>To: Xie Shaohui-B21989; linuxppc-dev@lists.ozlabs.org
>Cc: linux-usb@vger.kernel.org
>Subject: RE: [PATCH] powerpc/usb: use ioremap instead of base plus offset
>to access regs
>
>
>>  #ifndef CONFIG_ARCH_MXC
>>  	if (pdata->have_sysif_regs)
>> -		usb_sys_regs =3D (struct usb_sys_interface *)
>> -				((u32)dr_regs + USB_DR_SYS_OFFSET);
>> +		usb_sys_regs =3D ioremap(res->start + USB_DR_SYS_OFFSET,
>> +				sizeof(struct
>usb_sys_interface)/sizeof(int));
>>  #endif
>
>That ioremap() doesn't look right.
>Isn't the 'size' in bytes??
[Xie Shaohui] Yes, should not use sizeof(int).

>(Although it will only matter if it crosses a page boundary.) Mind you,
>I'd have though the original ioremap() should have covered the entire
>structure??
[Xie Shaohui] The original ioremap() did cover the entire structure, but th=
e sysif_regs are not defined in dr_regs,
So regs of sysif_regs cannot be accessed as a member of a structure, curren=
t driver handle this by type casting, this did work in 32-bit, but in 64-bi=
t, this is not safe. So I use ioremap() to cover it again.


Best Regards,=20
Shaohui Xie

^ permalink raw reply

* Re: What does rmo/tce stand for in powerpc?
From: Ryan Wang @ 2011-11-02 11:17 UTC (permalink / raw)
  To: Nishanth Aravamudan; +Cc: linuxppc-dev
In-Reply-To: <20111101172531.GG16267@us.ibm.com>

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

2011/11/2 Nishanth Aravamudan <nacc@us.ibm.com>

> Hi Ryan,
>
> On 01.11.2011 [14:25:43 +0800], Ryan Wang wrote:
> > Hi,
> >
> > In kernel source comments, I saw the words:
> > ''
> >
> > alloc_top is set to the top of RMO, eventually shrink down if the
> > <http://lxr.linux.no/linux+*/arch/powerpc/kernel/prom_init.c#L972>TCEs
> > overlap
> >
> > ''
> >
> > I wonder what does RMO mean, and TCE?
>
> RMO = Real Mode Offset -- deprecated in terms of Real Mode Area in PAPR.
>
> TCE = Translation Control Entry
>
> You should be able to find descriptions of both in PAPR.
>

Thanks Nish!

But I searched <Power.orgTM Standard for Embedded Power ArchitectureTM
Platform Requirements> and failed to found the concept RMO or Real Mode
Offset.

Will you please give me some hints to the docs?Thanks,



>
> Thanks,
> Nish
>
> --
> Nishanth Aravamudan <nacc@us.ibm.com>
> IBM Linux Technology Center
>
>

[-- Attachment #2: Type: text/html, Size: 1706 bytes --]

^ permalink raw reply

* Re: What does rmo/tce stand for in powerpc?
From: Nishanth Aravamudan @ 2011-11-02 18:30 UTC (permalink / raw)
  To: Ryan Wang; +Cc: linuxppc-dev
In-Reply-To: <CAPxxNQ=TkMFhzBeLi9bt5Fo7gygoM2V61EHYRzKqcMetaG2qnQ@mail.gmail.com>

On 02.11.2011 [19:17:20 +0800], Ryan Wang wrote:
> 2011/11/2 Nishanth Aravamudan <nacc@us.ibm.com>
> 
> > Hi Ryan,
> >
> > On 01.11.2011 [14:25:43 +0800], Ryan Wang wrote:
> > > Hi,
> > >
> > > In kernel source comments, I saw the words:
> > > ''
> > >
> > > alloc_top is set to the top of RMO, eventually shrink down if the
> > > <http://lxr.linux.no/linux+*/arch/powerpc/kernel/prom_init.c#L972>TCEs
> > > overlap
> > >
> > > ''
> > >
> > > I wonder what does RMO mean, and TCE?
> >
> > RMO = Real Mode Offset -- deprecated in terms of Real Mode Area in PAPR.
> >
> > TCE = Translation Control Entry
> >
> > You should be able to find descriptions of both in PAPR.
> >
> 
> Thanks Nish!
> 
> But I searched <Power.orgTM Standard for Embedded Power ArchitectureTM
> Platform Requirements> and failed to found the concept RMO or Real Mode
> Offset.
> 
> Will you please give me some hints to the docs??Thanks,

Section 14.1.1 Real Mode Accesses in PAPR 2.4

Thanks,
Nish

-- 
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center

^ permalink raw reply

* Re: What does rmo/tce stand for in powerpc?
From: Scott Wood @ 2011-11-02 19:19 UTC (permalink / raw)
  To: Ryan Wang; +Cc: Nishanth Aravamudan, linuxppc-dev
In-Reply-To: <CAPxxNQ=TkMFhzBeLi9bt5Fo7gygoM2V61EHYRzKqcMetaG2qnQ@mail.gmail.com>

On 11/02/2011 06:17 AM, Ryan Wang wrote:
>=20
>=20
> 2011/11/2 Nishanth Aravamudan <nacc@us.ibm.com <mailto:nacc@us.ibm.com>=
>
>=20
>     Hi Ryan,
>=20
>     On 01.11.2011 [14:25:43 +0800], Ryan Wang wrote:
>     > Hi,
>     >
>     > In kernel source comments, I saw the words:
>     > ''
>     >
>     > alloc_top is set to the top of RMO, eventually shrink down if the
>     > <http://lxr.linux.no/linux+*/arch/powerpc/kernel/prom_init.c#L972
>     <http://lxr.linux.no/linux+*/arch/powerpc/kernel/prom_init.c#L972>>=
TCEs
>     > overlap
>     >
>     > ''
>     >
>     > I wonder what does RMO mean, and TCE?
>=20
>     RMO =3D Real Mode Offset -- deprecated in terms of Real Mode Area i=
n PAPR.
>=20
>     TCE =3D Translation Control Entry
>=20
>     You should be able to find descriptions of both in PAPR.
>=20
>=20
> Thanks Nish!
>=20
> But I searched <Power.orgTM Standard for Embedded Power ArchitectureTM
> Platform Requirements> and failed to found the concept RMO or Real Mode
> Offset.
>=20
> Will you please give me some hints to the docs=EF=BC=9FThanks,

ePAPR and PAPR are not the same thing.

It looks like PAPR is only available to power.org members.

-Scott

^ permalink raw reply

* Support for multiple MSI interrupts on MPC8377
From: Giffel, Brad @ 2011-11-02 21:02 UTC (permalink / raw)
  To: linuxppc-dev

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

I'm working a project using a Spartan 6 FPGA with a PCIe interface and
MSI interrupts.  I want to use multiple MSI interrupts (MSI-X is not
supported in the FPGA PCIe core) but the current Linux distribution
(3.0.8) prevents that (lines 23 to 25 in arch/powerpc/kernel/msi.c).

 

What's the story here?  Is the code in place but not tested?  I tried
commenting out those lines but a request_irq() called failed for the
second interrupt requested.  Am I wasting my time here?  Should I
re-architect to use a single MSI interrupt?

 

            Thanks,

            - Brad

 


[-- Attachment #2: Type: text/html, Size: 2583 bytes --]

^ permalink raw reply

* [PATCH RFC 0/3] Support multiple VirtioConsoles.
From: Miche Baker-Harvey @ 2011-11-02 22:19 UTC (permalink / raw)
  To: Stephen Rothwell, Greg Kroah-Hartman, Konrad Rzeszutek Wilk,
	Benjamin Herrenschmidt, Rusty Russell, Miche Baker-Harvey,
	linux-kernel, Mike Waychison, xen-devel, Anton Blanchard,
	Amit Shah, virtualization, ppc-dev

This patchset applies to linux-next/next-20111102.

This series implements support for multiple virtio_consoles using KVM.

This patchset addresses several issues associated with trying to
establish multiple virtio consoles. 

I'm trying to start a guest via KVM that supports multiple virtual
consoles, with getty's on each, and with some being console devices.

These patches let me establish more than one VirtioConsole (I'm
running eight at the moment), and enable console output appearing on
one of them.  It still doesn't successfully generate console output on
multiple VirtioConsoles.

Let me apologise for my last patch having gotten into Linus' tree, and
leaving other people to deal with crashes.  I had meant to be asking
for guidance, but I didn't mark it as "RFC".

This series reflects the input from Konrad Rzeszutek, Amit Shah, Stephen
Boyd, and Rusty Russell.  I think we do have to limit hvc_alloc() to one
thread.

I would appreciate any comments or feedback, or accept if appropriate.

Thanks,
Miche Baker-Harvey

---

Miche Baker-Harvey (3):
      virtio_console:  Fix locking of vtermno.
      hvc_init():  Enforce one-time initialization.
      Use separate struct console structure for each hvc_console.


 drivers/char/virtio_console.c |    9 ++++++---
 drivers/tty/hvc/hvc_console.c |   33 +++++++++++++++++++++++++++++++--
 drivers/tty/hvc/hvc_console.h |    1 +
 3 files changed, 38 insertions(+), 5 deletions(-)

-- 

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox