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 aa0d84d22585639bf5f42d22416305180450e844..90b6c063758be0cccced4213012f1ddc97688b7d 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 c55129f5760a112b18d33ab12b5ad8575fb271b1..eae5913db03c8f1e2d33d07b2f1ea0fb330e9ae7 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 f01806c940e14b8e62b3d54d0cd77c300e1a4040..4ac60cc3727bfdad83e79c366665b1005b30b7b9 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 d0c4e15b77949a09ab29ef6d507ef86031bdcb2e..b453c15d200a278669a374d649c17789d3dc3afc 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 f859ead49a8d26c89b2c2aa33a0dbeb57bc0fb1e..386bde8b2b2437dfeaacfd572184ccd6f9c7f586 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 32a52896822fe2f78ed7a59321769ac95b64188f..39e0a92f42516a5701c32291035573087f1b8263 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 17f99745f0e459fbb26d0307833686ca2f61b362..ebfecec958d7af4cf6ff3ade0c6c4d1b400c7536 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 6b45969567d4edf53bbd16315c40ab755cfbaf87..509e070cf29af680f675cfcc943dc6b51c76c2ad 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 041c5177e737be0a4a68fd3b30e4b8e3cca1febf..3807735a88d8cb890bfa75cb739797648efc65c1 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 934cc8c46bbc4cc33ed2e638e26d5d51f3771458..afb3e45e1e9767c6145eb1d05f47d80eae9ac4c3 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 b0090aac9642283ba4c62a00789edd92baab8ce7..cd8f0782a66bc474d1d4221fcf5da79e6ffaee07 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 83068322abd154004325093e1db9a7b24b9da8d7..3be7f3ac15733fbf669d41fb9eac3d9e1edc52f7 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 7bafbf2ec0f92712aac0a1a259b22e1dd3de4b7f..eebfd81c751974e5a82bfd0678a029bba1b65ab8 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 82a434510d83d458bf242f95663df565a1cf925f..f07751ab9b11af3748e0f8a4bf59a675a4799dbf 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 af41d8c810a87e15b384aa383371fe2505d7150a..cdce953c575b94d2b195808abad9942bb2d286a1 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,