powerpc/83xx: consolidate init_IRQ functions
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Fri, 22 Jul 2011 19:55:42 +0000 (23:55 +0400)
committerKumar Gala <galak@kernel.crashing.org>
Thu, 24 Nov 2011 08:01:40 +0000 (02:01 -0600)
On mpc83xx platform nearly all _init_IRQ functions look alike. They either
just setup ipic, or setup ipic and QE PIC. Separate this to special functions
to be either referenced from ppc_md, or called from board file.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
15 files changed:
arch/powerpc/platforms/83xx/asp834x.c
arch/powerpc/platforms/83xx/km83xx.c
arch/powerpc/platforms/83xx/misc.c
arch/powerpc/platforms/83xx/mpc830x_rdb.c
arch/powerpc/platforms/83xx/mpc831x_rdb.c
arch/powerpc/platforms/83xx/mpc832x_mds.c
arch/powerpc/platforms/83xx/mpc832x_rdb.c
arch/powerpc/platforms/83xx/mpc834x_itx.c
arch/powerpc/platforms/83xx/mpc834x_mds.c
arch/powerpc/platforms/83xx/mpc836x_mds.c
arch/powerpc/platforms/83xx/mpc836x_rdk.c
arch/powerpc/platforms/83xx/mpc837x_mds.c
arch/powerpc/platforms/83xx/mpc837x_rdb.c
arch/powerpc/platforms/83xx/mpc83xx.h
arch/powerpc/platforms/83xx/sbc834x.c

index aa0d84d..90b6c06 100644 (file)
@@ -36,24 +36,6 @@ static void __init asp834x_setup_arch(void)
        mpc834x_usb_cfg();
 }
 
-static void __init asp834x_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       of_node_put(np);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-}
-
 static struct __initdata of_device_id asp8347_ids[] = {
        { .type = "soc", },
        { .compatible = "soc", },
@@ -82,7 +64,7 @@ define_machine(asp834x) {
        .name                   = "ASP8347E",
        .probe                  = asp834x_probe,
        .setup_arch             = asp834x_setup_arch,
-       .init_IRQ               = asp834x_init_IRQ,
+       .init_IRQ               = mpc83xx_ipic_init_IRQ,
        .get_irq                = ipic_get_irq,
        .restart                = mpc83xx_restart,
        .time_init              = mpc83xx_time_init,
index c55129f..eae5913 100644 (file)
@@ -140,37 +140,6 @@ static int __init kmeter_declare_of_platform_devices(void)
 }
 machine_device_initcall(mpc83xx_km, kmeter_declare_of_platform_devices);
 
-static void __init mpc83xx_km_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_compatible_node(NULL, NULL, "fsl,pq2pro-pic");
-       if (!np) {
-               np = of_find_node_by_type(NULL, "ipic");
-               if (!np)
-                       return;
-       }
-
-       ipic_init(np, 0);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-       of_node_put(np);
-
-#ifdef CONFIG_QUICC_ENGINE
-       np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
-       if (!np) {
-               np = of_find_node_by_type(NULL, "qeic");
-               if (!np)
-                       return;
-       }
-       qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
-       of_node_put(np);
-#endif                         /* CONFIG_QUICC_ENGINE */
-}
-
 /* list of the supported boards */
 static char *board[] __initdata = {
        "Keymile,KMETER1",
@@ -198,7 +167,7 @@ define_machine(mpc83xx_km) {
        .name           = "mpc83xx-km-platform",
        .probe          = mpc83xx_km_probe,
        .setup_arch     = mpc83xx_km_setup_arch,
-       .init_IRQ       = mpc83xx_km_init_IRQ,
+       .init_IRQ       = mpc83xx_ipic_and_qe_init_IRQ,
        .get_irq        = ipic_get_irq,
        .restart        = mpc83xx_restart,
        .time_init      = mpc83xx_time_init,
index f01806c..4ac60cc 100644 (file)
 
 #include <linux/stddef.h>
 #include <linux/kernel.h>
+#include <linux/of_platform.h>
 
 #include <asm/io.h>
 #include <asm/hw_irq.h>
+#include <asm/ipic.h>
+#include <asm/qe_ic.h>
 #include <sysdev/fsl_soc.h>
 
 #include "mpc83xx.h"
@@ -65,3 +68,46 @@ long __init mpc83xx_time_init(void)
 
        return 0;
 }
+
+void __init mpc83xx_ipic_init_IRQ(void)
+{
+       struct device_node *np;
+
+       /* looking for fsl,pq2pro-pic which is asl compatible with fsl,ipic */
+       np = of_find_compatible_node(NULL, NULL, "fsl,ipic");
+       if (!np)
+               np = of_find_node_by_type(NULL, "ipic");
+       if (!np)
+               return;
+
+       ipic_init(np, 0);
+
+       of_node_put(np);
+
+       /* Initialize the default interrupt mapping priorities,
+        * in case the boot rom changed something on us.
+        */
+       ipic_set_default_priority();
+}
+
+#ifdef CONFIG_QUICC_ENGINE
+void __init mpc83xx_qe_init_IRQ(void)
+{
+       struct device_node *np;
+
+       np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
+       if (!np) {
+               np = of_find_node_by_type(NULL, "qeic");
+               if (!np)
+                       return;
+       }
+       qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
+       of_node_put(np);
+}
+
+void __init mpc83xx_ipic_and_qe_init_IRQ(void)
+{
+       mpc83xx_ipic_init_IRQ();
+       mpc83xx_qe_init_IRQ();
+}
+#endif /* CONFIG_QUICC_ENGINE */
index d0c4e15..b453c15 100644 (file)
@@ -41,22 +41,6 @@ static void __init mpc830x_rdb_setup_arch(void)
        mpc831x_usb_cfg();
 }
 
-static void __init mpc830x_rdb_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-}
-
 static const char *board[] __initdata = {
        "MPC8308RDB",
        "fsl,mpc8308rdb",
@@ -89,7 +73,7 @@ define_machine(mpc830x_rdb) {
        .name                   = "MPC830x RDB",
        .probe                  = mpc830x_rdb_probe,
        .setup_arch             = mpc830x_rdb_setup_arch,
-       .init_IRQ               = mpc830x_rdb_init_IRQ,
+       .init_IRQ               = mpc83xx_ipic_init_IRQ,
        .get_irq                = ipic_get_irq,
        .restart                = mpc83xx_restart,
        .time_init              = mpc83xx_time_init,
index f859ead..386bde8 100644 (file)
@@ -44,22 +44,6 @@ static void __init mpc831x_rdb_setup_arch(void)
        mpc831x_usb_cfg();
 }
 
-static void __init mpc831x_rdb_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-}
-
 static const char *board[] __initdata = {
        "MPC8313ERDB",
        "fsl,mpc8315erdb",
@@ -92,7 +76,7 @@ define_machine(mpc831x_rdb) {
        .name                   = "MPC831x RDB",
        .probe                  = mpc831x_rdb_probe,
        .setup_arch             = mpc831x_rdb_setup_arch,
-       .init_IRQ               = mpc831x_rdb_init_IRQ,
+       .init_IRQ               = mpc83xx_ipic_init_IRQ,
        .get_irq                = ipic_get_irq,
        .restart                = mpc83xx_restart,
        .time_init              = mpc83xx_time_init,
index 32a5289..39e0a92 100644 (file)
@@ -119,34 +119,6 @@ static int __init mpc832x_declare_of_platform_devices(void)
 }
 machine_device_initcall(mpc832x_mds, mpc832x_declare_of_platform_devices);
 
-static void __init mpc832x_sys_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-       of_node_put(np);
-
-#ifdef CONFIG_QUICC_ENGINE
-       np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
-       if (!np) {
-               np = of_find_node_by_type(NULL, "qeic");
-               if (!np)
-                       return;
-       }
-       qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
-       of_node_put(np);
-#endif                         /* CONFIG_QUICC_ENGINE */
-}
-
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
@@ -161,7 +133,7 @@ define_machine(mpc832x_mds) {
        .name           = "MPC832x MDS",
        .probe          = mpc832x_sys_probe,
        .setup_arch     = mpc832x_sys_setup_arch,
-       .init_IRQ       = mpc832x_sys_init_IRQ,
+       .init_IRQ       = mpc83xx_ipic_and_qe_init_IRQ,
        .get_irq        = ipic_get_irq,
        .restart        = mpc83xx_restart,
        .time_init      = mpc83xx_time_init,
index 17f9974..ebfecec 100644 (file)
@@ -236,35 +236,6 @@ static int __init mpc832x_declare_of_platform_devices(void)
 }
 machine_device_initcall(mpc832x_rdb, mpc832x_declare_of_platform_devices);
 
-static void __init mpc832x_rdb_init_IRQ(void)
-{
-
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-       of_node_put(np);
-
-#ifdef CONFIG_QUICC_ENGINE
-       np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
-       if (!np) {
-               np = of_find_node_by_type(NULL, "qeic");
-               if (!np)
-                       return;
-       }
-       qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
-       of_node_put(np);
-#endif                         /* CONFIG_QUICC_ENGINE */
-}
-
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
@@ -279,7 +250,7 @@ define_machine(mpc832x_rdb) {
        .name           = "MPC832x RDB",
        .probe          = mpc832x_rdb_probe,
        .setup_arch     = mpc832x_rdb_setup_arch,
-       .init_IRQ       = mpc832x_rdb_init_IRQ,
+       .init_IRQ       = mpc83xx_ipic_and_qe_init_IRQ,
        .get_irq        = ipic_get_irq,
        .restart        = mpc83xx_restart,
        .time_init      = mpc83xx_time_init,
index 6b45969..509e070 100644 (file)
@@ -74,22 +74,6 @@ static void __init mpc834x_itx_setup_arch(void)
        mpc834x_usb_cfg();
 }
 
-static void __init mpc834x_itx_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-}
-
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
@@ -104,7 +88,7 @@ define_machine(mpc834x_itx) {
        .name                   = "MPC834x ITX",
        .probe                  = mpc834x_itx_probe,
        .setup_arch             = mpc834x_itx_setup_arch,
-       .init_IRQ               = mpc834x_itx_init_IRQ,
+       .init_IRQ               = mpc83xx_ipic_init_IRQ,
        .get_irq                = ipic_get_irq,
        .restart                = mpc83xx_restart,
        .time_init              = mpc83xx_time_init,
index 041c517..3807735 100644 (file)
@@ -92,22 +92,6 @@ static void __init mpc834x_mds_setup_arch(void)
        mpc834xemds_usb_cfg();
 }
 
-static void __init mpc834x_mds_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-}
-
 static struct of_device_id mpc834x_ids[] = {
        { .type = "soc", },
        { .compatible = "soc", },
@@ -137,7 +121,7 @@ define_machine(mpc834x_mds) {
        .name                   = "MPC834x MDS",
        .probe                  = mpc834x_mds_probe,
        .setup_arch             = mpc834x_mds_setup_arch,
-       .init_IRQ               = mpc834x_mds_init_IRQ,
+       .init_IRQ               = mpc83xx_ipic_init_IRQ,
        .get_irq                = ipic_get_irq,
        .restart                = mpc83xx_restart,
        .time_init              = mpc83xx_time_init,
index 934cc8c..afb3e45 100644 (file)
@@ -226,34 +226,6 @@ err:
 machine_arch_initcall(mpc836x_mds, mpc836x_usb_cfg);
 #endif /* CONFIG_QE_USB */
 
-static void __init mpc836x_mds_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-       of_node_put(np);
-
-#ifdef CONFIG_QUICC_ENGINE
-       np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
-       if (!np) {
-               np = of_find_node_by_type(NULL, "qeic");
-               if (!np)
-                       return;
-       }
-       qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
-       of_node_put(np);
-#endif                         /* CONFIG_QUICC_ENGINE */
-}
-
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
@@ -268,7 +240,7 @@ define_machine(mpc836x_mds) {
        .name           = "MPC836x MDS",
        .probe          = mpc836x_mds_probe,
        .setup_arch     = mpc836x_mds_setup_arch,
-       .init_IRQ       = mpc836x_mds_init_IRQ,
+       .init_IRQ       = mpc83xx_ipic_and_qe_init_IRQ,
        .get_irq        = ipic_get_irq,
        .restart        = mpc83xx_restart,
        .time_init      = mpc83xx_time_init,
index b0090aa..cd8f078 100644 (file)
@@ -56,32 +56,6 @@ static void __init mpc836x_rdk_setup_arch(void)
 #endif
 }
 
-static void __init mpc836x_rdk_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_compatible_node(NULL, NULL, "fsl,ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       /*
-        * Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-       of_node_put(np);
-#ifdef CONFIG_QUICC_ENGINE
-       np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
-       if (!np)
-               return;
-
-       qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);
-       of_node_put(np);
-#endif
-}
-
 /*
  * Called very early, MMU is off, device-tree isn't unflattened.
  */
@@ -96,7 +70,7 @@ define_machine(mpc836x_rdk) {
        .name           = "MPC836x RDK",
        .probe          = mpc836x_rdk_probe,
        .setup_arch     = mpc836x_rdk_setup_arch,
-       .init_IRQ       = mpc836x_rdk_init_IRQ,
+       .init_IRQ       = mpc83xx_ipic_and_qe_init_IRQ,
        .get_irq        = ipic_get_irq,
        .restart        = mpc83xx_restart,
        .time_init      = mpc83xx_time_init,
index 8306832..3be7f3a 100644 (file)
@@ -112,22 +112,6 @@ static int __init mpc837x_declare_of_platform_devices(void)
 }
 machine_device_initcall(mpc837x_mds, mpc837x_declare_of_platform_devices);
 
-static void __init mpc837x_mds_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_compatible_node(NULL, NULL, "fsl,ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-}
-
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
@@ -142,7 +126,7 @@ define_machine(mpc837x_mds) {
        .name                   = "MPC837x MDS",
        .probe                  = mpc837x_mds_probe,
        .setup_arch             = mpc837x_mds_setup_arch,
-       .init_IRQ               = mpc837x_mds_init_IRQ,
+       .init_IRQ               = mpc83xx_ipic_init_IRQ,
        .get_irq                = ipic_get_irq,
        .restart                = mpc83xx_restart,
        .time_init              = mpc83xx_time_init,
index 7bafbf2..eebfd81 100644 (file)
@@ -85,22 +85,6 @@ static int __init mpc837x_declare_of_platform_devices(void)
 }
 machine_device_initcall(mpc837x_rdb, mpc837x_declare_of_platform_devices);
 
-static void __init mpc837x_rdb_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_compatible_node(NULL, NULL, "fsl,ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-}
-
 static const char *board[] __initdata = {
        "fsl,mpc8377rdb",
        "fsl,mpc8378rdb",
@@ -121,7 +105,7 @@ define_machine(mpc837x_rdb) {
        .name                   = "MPC837x RDB/WLAN",
        .probe                  = mpc837x_rdb_probe,
        .setup_arch             = mpc837x_rdb_setup_arch,
-       .init_IRQ               = mpc837x_rdb_init_IRQ,
+       .init_IRQ               = mpc83xx_ipic_init_IRQ,
        .get_irq                = ipic_get_irq,
        .restart                = mpc83xx_restart,
        .time_init              = mpc83xx_time_init,
index 82a4345..f07751a 100644 (file)
@@ -70,5 +70,14 @@ extern long mpc83xx_time_init(void);
 extern int mpc837x_usb_cfg(void);
 extern int mpc834x_usb_cfg(void);
 extern int mpc831x_usb_cfg(void);
+extern void mpc83xx_ipic_init_IRQ(void);
+#ifdef CONFIG_QUICC_ENGINE
+extern void mpc83xx_qe_init_IRQ(void);
+extern void mpc83xx_ipic_and_qe_init_IRQ(void);
+#else
+static inline void __init mpc83xx_qe_init_IRQ(void) {}
+#define mpc83xx_ipic_and_qe_init_IRQ mpc83xx_ipic_init_IRQ
+#endif /* CONFIG_QUICC_ENGINE */
+
 
 #endif                         /* __MPC83XX_H__ */
index af41d8c..cdce953 100644 (file)
@@ -62,24 +62,6 @@ static void __init sbc834x_setup_arch(void)
 
 }
 
-static void __init sbc834x_init_IRQ(void)
-{
-       struct device_node *np;
-
-       np = of_find_node_by_type(NULL, "ipic");
-       if (!np)
-               return;
-
-       ipic_init(np, 0);
-
-       /* Initialize the default interrupt mapping priorities,
-        * in case the boot rom changed something on us.
-        */
-       ipic_set_default_priority();
-
-       of_node_put(np);
-}
-
 static struct __initdata of_device_id sbc834x_ids[] = {
        { .type = "soc", },
        { .compatible = "soc", },
@@ -109,7 +91,7 @@ define_machine(sbc834x) {
        .name                   = "SBC834x",
        .probe                  = sbc834x_probe,
        .setup_arch             = sbc834x_setup_arch,
-       .init_IRQ               = sbc834x_init_IRQ,
+       .init_IRQ               = mpc83xx_ipic_init_IRQ,
        .get_irq                = ipic_get_irq,
        .restart                = mpc83xx_restart,
        .time_init              = mpc83xx_time_init,