powerpc/85xx: separate cpm2 pic init
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Thu, 17 Nov 2011 17:56:16 +0000 (21:56 +0400)
committerKumar Gala <galak@kernel.crashing.org>
Thu, 24 Nov 2011 08:01:41 +0000 (02:01 -0600)
Separate handling of CPM2 PIC initialization to mpc85xx_cpm2_pic_init()
function.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
16 files changed:
arch/powerpc/platforms/85xx/Makefile
arch/powerpc/platforms/85xx/ksi8560.c
arch/powerpc/platforms/85xx/mpc8536_ds.c
arch/powerpc/platforms/85xx/mpc85xx.h [new file with mode: 0644]
arch/powerpc/platforms/85xx/mpc85xx_ads.c
arch/powerpc/platforms/85xx/mpc85xx_cds.c
arch/powerpc/platforms/85xx/mpc85xx_common.c [new file with mode: 0644]
arch/powerpc/platforms/85xx/mpc85xx_ds.c
arch/powerpc/platforms/85xx/mpc85xx_mds.c
arch/powerpc/platforms/85xx/mpc85xx_rdb.c
arch/powerpc/platforms/85xx/p1022_ds.c
arch/powerpc/platforms/85xx/sbc8560.c
arch/powerpc/platforms/85xx/socrates.c
arch/powerpc/platforms/85xx/stx_gp3.c
arch/powerpc/platforms/85xx/tqm85xx.c
arch/powerpc/platforms/85xx/xes_mpc85xx.c

index bc5acb95917af5a35d6ceb561a277b4769f39483..b6beec8c837833f75a7346d9f798d01a4e1b222a 100644 (file)
@@ -3,6 +3,8 @@
 #
 obj-$(CONFIG_SMP) += smp.o
 
+obj-y += mpc85xx_common.o
+
 obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
 obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
 obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
index c46f9359be158678d8c28af191088220a50f7848..bf9b1e5f10f9398dd836f50854c9bcf288977309 100644 (file)
@@ -35,6 +35,7 @@
 #include <asm/cpm2.h>
 #include <sysdev/cpm2_pic.h>
 
+#include "mpc85xx.h"
 
 #define KSI8560_CPLD_HVR               0x04 /* Hardware Version Register */
 #define KSI8560_CPLD_PVR               0x08 /* PLD Version Register */
@@ -54,25 +55,11 @@ static void machine_restart(char *cmd)
        for (;;);
 }
 
-static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
-{
-       struct irq_chip *chip = irq_desc_get_chip(desc);
-       int cascade_irq;
-
-       while ((cascade_irq = cpm2_get_irq()) >= 0)
-               generic_handle_irq(cascade_irq);
-
-       chip->irq_eoi(&desc->irq_data);
-}
-
 static void __init ksi8560_pic_init(void)
 {
        struct mpic *mpic;
        struct resource r;
        struct device_node *np;
-#ifdef CONFIG_CPM2
-       int irq;
-#endif
 
        np = of_find_node_by_type(NULL, "open-pic");
 
@@ -95,19 +82,7 @@ static void __init ksi8560_pic_init(void)
 
        mpic_init(mpic);
 
-#ifdef CONFIG_CPM2
-       /* Setup CPM2 PIC */
-       np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
-       if (np == NULL) {
-               printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
-               return;
-       }
-       irq = irq_of_parse_and_map(np, 0);
-
-       cpm2_pic_init(np);
-       of_node_put(np);
-       irq_set_chained_handler(irq, cpm2_cascade);
-#endif
+       mpc85xx_cpm2_pic_init();
 }
 
 #ifdef CONFIG_CPM2
index f79f2f1021416c5a4e1f6a97ebe4cab9ff02d57b..6a4b2c1372f4adb4029964ed8b7904f48bc601a3 100644 (file)
@@ -32,6 +32,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 void __init mpc8536_ds_pic_init(void)
 {
        struct mpic *mpic;
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
new file mode 100644 (file)
index 0000000..fa55e8b
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef MPC85xx_H
+#define MPC85xx_H
+#ifdef CONFIG_CPM2
+extern void mpc85xx_cpm2_pic_init(void);
+#else
+static inline void __init mpc85xx_cpm2_pic_init(void) {}
+#endif /* CONFIG_CPM2 */
+
+#endif
index 3b2c9bb661998918f3ac1033fc4a19311ca910b2..8b8f7a20116676d3f21dccb2931a8864fcfcf13e 100644 (file)
@@ -35,6 +35,8 @@
 #include <sysdev/cpm2_pic.h>
 #endif
 
+#include "mpc85xx.h"
+
 #ifdef CONFIG_PCI
 static int mpc85xx_exclude_device(struct pci_controller *hose,
                                   u_char bus, u_char devfn)
@@ -46,29 +48,11 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
 }
 #endif /* CONFIG_PCI */
 
-#ifdef CONFIG_CPM2
-
-static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
-{
-       struct irq_chip *chip = irq_desc_get_chip(desc);
-       int cascade_irq;
-
-       while ((cascade_irq = cpm2_get_irq()) >= 0)
-               generic_handle_irq(cascade_irq);
-
-       chip->irq_eoi(&desc->irq_data);
-}
-
-#endif /* CONFIG_CPM2 */
-
 static void __init mpc85xx_ads_pic_init(void)
 {
        struct mpic *mpic;
        struct resource r;
        struct device_node *np = NULL;
-#ifdef CONFIG_CPM2
-       int irq;
-#endif
 
        np = of_find_node_by_type(np, "open-pic");
        if (!np) {
@@ -90,19 +74,7 @@ static void __init mpc85xx_ads_pic_init(void)
 
        mpic_init(mpic);
 
-#ifdef CONFIG_CPM2
-       /* Setup CPM2 PIC */
-       np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
-       if (np == NULL) {
-               printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
-               return;
-       }
-       irq = irq_of_parse_and_map(np, 0);
-
-       cpm2_pic_init(np);
-       of_node_put(np);
-       irq_set_chained_handler(irq, cpm2_cascade);
-#endif
+       mpc85xx_cpm2_pic_init();
 }
 
 /*
index 66cb8d64079fa9e692fdd6deac3909ab05aa67d0..4f68bb7b381f85b0f40eec7c090a5352ad25e991 100644 (file)
@@ -46,6 +46,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 /* CADMUS info */
 /* xxx - galak, move into device tree */
 #define CADMUS_BASE (0xf8004000)
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_common.c b/arch/powerpc/platforms/85xx/mpc85xx_common.c
new file mode 100644 (file)
index 0000000..49d781c
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Routines common to most mpc85xx-based boards.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/of_platform.h>
+
+#include <sysdev/cpm2_pic.h>
+
+#include "mpc85xx.h"
+
+#ifdef CONFIG_CPM2
+static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
+{
+       struct irq_chip *chip = irq_desc_get_chip(desc);
+       int cascade_irq;
+
+       while ((cascade_irq = cpm2_get_irq()) >= 0)
+               generic_handle_irq(cascade_irq);
+
+       chip->irq_eoi(&desc->irq_data);
+}
+
+
+void __init mpc85xx_cpm2_pic_init(void)
+{
+       struct device_node *np;
+       int irq;
+
+       /* Setup CPM2 PIC */
+       np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
+       if (np == NULL) {
+               printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
+               return;
+       }
+       irq = irq_of_parse_and_map(np, 0);
+       if (irq == NO_IRQ) {
+               of_node_put(np);
+               printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");
+               return;
+       }
+
+       cpm2_pic_init(np);
+       of_node_put(np);
+       irq_set_chained_handler(irq, cpm2_cascade);
+}
+#endif
index 1b9a8cf1873ab5df082029b3fa8358bb46efd8da..55075b966b622a839d5667e2ede03f28e1e14b57 100644 (file)
@@ -36,6 +36,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 #undef DEBUG
 
 #ifdef DEBUG
index 7968ceda06335fe416181104c8aeb169f655140a..9270da42b8bf4fe9497d389eaedbe37f058f9458 100644 (file)
@@ -52,6 +52,8 @@
 #include <asm/mpic.h>
 #include <asm/swiotlb.h>
 
+#include "mpc85xx.h"
+
 #undef DEBUG
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
index f5ff9110c97eab335f3be66570e1adc4b2b84260..824d2b676d56a637a71943fc73f01d82d3ff17bb 100644 (file)
@@ -30,6 +30,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 #undef DEBUG
 
 #ifdef DEBUG
index fda15716fada03eb80cbc0a4761b55a6dffbe47c..c75ec1c8ea6596b1e11cb99fb60d854614e941e1 100644 (file)
@@ -27,6 +27,8 @@
 #include <sysdev/fsl_pci.h>
 #include <asm/fsl_guts.h>
 
+#include "mpc85xx.h"
+
 #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
 
 /*
index cebd786dc3340be03adc63a11814574653b2688e..43711f89577834285ea55b8f335234dff4925cab 100644 (file)
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 #ifdef CONFIG_CPM2
 #include <asm/cpm2.h>
 #include <sysdev/cpm2_pic.h>
 #endif
 
-#ifdef CONFIG_CPM2
-
-static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
-{
-       struct irq_chip *chip = irq_desc_get_chip(desc);
-       int cascade_irq;
-
-       while ((cascade_irq = cpm2_get_irq()) >= 0)
-               generic_handle_irq(cascade_irq);
-
-       chip->irq_eoi(&desc->irq_data);
-}
-
-#endif /* CONFIG_CPM2 */
-
 static void __init sbc8560_pic_init(void)
 {
        struct mpic *mpic;
        struct resource r;
        struct device_node *np = NULL;
-#ifdef CONFIG_CPM2
-       int irq;
-#endif
 
        np = of_find_node_by_type(np, "open-pic");
        if (!np) {
@@ -81,19 +65,7 @@ static void __init sbc8560_pic_init(void)
 
        mpic_init(mpic);
 
-#ifdef CONFIG_CPM2
-       /* Setup CPM2 PIC */
-       np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
-       if (np == NULL) {
-               printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
-               return;
-       }
-       irq = irq_of_parse_and_map(np, 0);
-
-       cpm2_pic_init(np);
-       of_node_put(np);
-       irq_set_chained_handler(irq, cpm2_cascade);
-#endif
+       mpc85xx_cpm2_pic_init();
 }
 
 /*
index 747d8fb3ab82af2c5e26ddfd3e91966bb799bbc3..9d0fc283c1a10b76dddaaac89567f0ae62c5f22d 100644 (file)
@@ -41,6 +41,7 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
 #include "socrates_fpga_pic.h"
 
 static void __init socrates_pic_init(void)
index 5387e9f06bdba34b772f66cd174bcb17a6b963f7..d24192b708235fba7c04be9b53a4514b7c56224d 100644 (file)
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 #ifdef CONFIG_CPM2
 #include <asm/cpm2.h>
-#include <sysdev/cpm2_pic.h>
-
-static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
-{
-       struct irq_chip *chip = irq_desc_get_chip(desc);
-       int cascade_irq;
-
-       while ((cascade_irq = cpm2_get_irq()) >= 0)
-               generic_handle_irq(cascade_irq);
-
-       chip->irq_eoi(&desc->irq_data);
-}
 #endif /* CONFIG_CPM2 */
 
 static void __init stx_gp3_pic_init(void)
@@ -61,9 +51,6 @@ static void __init stx_gp3_pic_init(void)
        struct mpic *mpic;
        struct resource r;
        struct device_node *np;
-#ifdef CONFIG_CPM2
-       int irq;
-#endif
 
        np = of_find_node_by_type(NULL, "open-pic");
        if (!np) {
@@ -85,25 +72,7 @@ static void __init stx_gp3_pic_init(void)
 
        mpic_init(mpic);
 
-#ifdef CONFIG_CPM2
-       /* Setup CPM2 PIC */
-       np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
-       if (np == NULL) {
-               printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
-               return;
-       }
-       irq = irq_of_parse_and_map(np, 0);
-
-       if (irq == NO_IRQ) {
-               of_node_put(np);
-               printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");
-               return;
-       }
-
-       cpm2_pic_init(np);
-       of_node_put(np);
-       irq_set_chained_handler(irq, cpm2_cascade);
-#endif
+       mpc85xx_cpm2_pic_init();
 }
 
 /*
index 325de772725a6076a747dfc08ce132f8a34e67c4..b9e53ccf114366545997de76c95e348e973148b2 100644 (file)
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 #ifdef CONFIG_CPM2
 #include <asm/cpm2.h>
-#include <sysdev/cpm2_pic.h>
-
-static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)
-{
-       struct irq_chip *chip = irq_desc_get_chip(desc);
-       int cascade_irq;
-
-       while ((cascade_irq = cpm2_get_irq()) >= 0)
-               generic_handle_irq(cascade_irq);
-
-       chip->irq_eoi(&desc->irq_data);
-}
 #endif /* CONFIG_CPM2 */
 
 static void __init tqm85xx_pic_init(void)
@@ -59,9 +49,6 @@ static void __init tqm85xx_pic_init(void)
        struct mpic *mpic;
        struct resource r;
        struct device_node *np;
-#ifdef CONFIG_CPM2
-       int irq;
-#endif
 
        np = of_find_node_by_type(NULL, "open-pic");
        if (!np) {
@@ -83,25 +70,7 @@ static void __init tqm85xx_pic_init(void)
 
        mpic_init(mpic);
 
-#ifdef CONFIG_CPM2
-       /* Setup CPM2 PIC */
-       np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");
-       if (np == NULL) {
-               printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");
-               return;
-       }
-       irq = irq_of_parse_and_map(np, 0);
-
-       if (irq == NO_IRQ) {
-               of_node_put(np);
-               printk(KERN_ERR "PIC init: got no IRQ for cpm cascade\n");
-               return;
-       }
-
-       cpm2_pic_init(np);
-       of_node_put(np);
-       irq_set_chained_handler(irq, cpm2_cascade);
-#endif
+       mpc85xx_cpm2_pic_init();
 }
 
 /*
index a9dc5e795123b00d7ff27fcc086559e7702066d7..ab7025a7e9a512ed9b5120de25e1ff74fc93f783 100644 (file)
@@ -33,6 +33,8 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#include "mpc85xx.h"
+
 /* A few bit definitions needed for fixups on some boards */
 #define MPC85xx_L2CTL_L2E              0x80000000 /* L2 enable */
 #define MPC85xx_L2CTL_L2I              0x40000000 /* L2 flash invalidate */