]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
soc: fsl: qe: move calls of qe_ic_init out of arch/powerpc/
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Thu, 28 Nov 2019 14:55:17 +0000 (15:55 +0100)
committerLi Yang <leoyang.li@nxp.com>
Mon, 9 Dec 2019 19:54:31 +0000 (13:54 -0600)
Having to call qe_ic_init() from platform-specific code makes it
awkward to allow building the QE drivers for ARM. It's also a needless
duplication of code, and slightly error-prone: Instead of the caller
needing to know the details of whether the QUICC Engine High and QUICC
Engine Low are actually the same interrupt (see e.g. the machine_is()
in mpc85xx_mds_qeic_init), just let the init function choose the
appropriate handlers after it has parsed the DT and figured it out. If
the two interrupts are distinct, use separate handlers, otherwise use
the handler which first checks the CHIVEC register (for the high
priority interrupts), then the CIVEC.

All existing callers pass 0 for flags, so continue to do that from the
new single caller. Later cleanups will remove that argument
from qe_ic_init and simplify the body, as well as make qe_ic_init into
a proper init function for an IRQCHIP_DECLARE, eliminating the need to
manually look up the fsl,qe-ic node.

Reviewed-by: Timur Tabi <timur@kernel.org>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
13 files changed:
arch/powerpc/platforms/83xx/km83xx.c
arch/powerpc/platforms/83xx/misc.c
arch/powerpc/platforms/83xx/mpc832x_mds.c
arch/powerpc/platforms/83xx/mpc832x_rdb.c
arch/powerpc/platforms/83xx/mpc836x_mds.c
arch/powerpc/platforms/83xx/mpc836x_rdk.c
arch/powerpc/platforms/83xx/mpc83xx.h
arch/powerpc/platforms/85xx/corenet_generic.c
arch/powerpc/platforms/85xx/mpc85xx_mds.c
arch/powerpc/platforms/85xx/mpc85xx_rdb.c
arch/powerpc/platforms/85xx/twr_p102x.c
drivers/soc/fsl/qe/qe_ic.c
include/soc/fsl/qe/qe_ic.h

index 273145aed90a1ffae9c329d42289f6c4d590e0a8..5c6227f7bc3785a0cdfa029c26d193f848abe2a3 100644 (file)
@@ -34,7 +34,6 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 #include <soc/fsl/qe/qe.h>
-#include <soc/fsl/qe/qe_ic.h>
 
 #include "mpc83xx.h"
 
index 02e4341fa0d80bbe80a2e1998946583e3c4d83d1..41a9aed9f4ae8f53e54c5a8efe7f54b7db768f84 100644 (file)
@@ -14,7 +14,6 @@
 #include <asm/io.h>
 #include <asm/hw_irq.h>
 #include <asm/ipic.h>
-#include <soc/fsl/qe/qe_ic.h>
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
@@ -92,24 +91,9 @@ void __init mpc83xx_ipic_init_IRQ(void)
 }
 
 #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_mpic, qe_ic_cascade_high_mpic);
-       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 b428835e5919eb69801409b602ae8505e8aabfc0..1c73af104d190614d2818bfdf060e09b52c19ef6 100644 (file)
@@ -33,7 +33,6 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 #include <soc/fsl/qe/qe.h>
-#include <soc/fsl/qe/qe_ic.h>
 
 #include "mpc83xx.h"
 
index 4588ce632484e1f81fabe04dfc9ac0d46e74bbe8..87f68ca0625579683a5ad12a4ef5baadbdb8c414 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/ipic.h>
 #include <asm/udbg.h>
 #include <soc/fsl/qe/qe.h>
-#include <soc/fsl/qe/qe_ic.h>
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
index 240a26d88b07d1d1e65163c9b88d4077e2069f76..1264fac54c30c16ba70a0f588cb08cf11453568c 100644 (file)
@@ -40,7 +40,6 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 #include <soc/fsl/qe/qe.h>
-#include <soc/fsl/qe/qe_ic.h>
 
 #include "mpc83xx.h"
 
index 9923059cb111c2c59451d87164daa44504cb5977..b7119e443920a8028f2bd1c13daf08549ae0b530 100644 (file)
@@ -17,7 +17,6 @@
 #include <asm/ipic.h>
 #include <asm/udbg.h>
 #include <soc/fsl/qe/qe.h>
-#include <soc/fsl/qe/qe_ic.h>
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
index 459145623334256946a244e38f2d2c9d89adaf8d..d343f6ce2599e5206c7debc7341914ba17e09123 100644 (file)
@@ -73,10 +73,8 @@ 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 */
 
index a328a741b45728c7561b564765796a8c9bf50fef..27ac38f7e1a9bc502db0382ab7f415fae87043f6 100644 (file)
@@ -24,7 +24,6 @@
 #include <asm/mpic.h>
 #include <asm/ehv_pic.h>
 #include <asm/swiotlb.h>
-#include <soc/fsl/qe/qe_ic.h>
 
 #include <linux/of_platform.h>
 #include <sysdev/fsl_soc.h>
@@ -38,8 +37,6 @@ void __init corenet_gen_pic_init(void)
        unsigned int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU |
                MPIC_NO_RESET;
 
-       struct device_node *np;
-
        if (ppc_md.get_irq == mpic_get_coreint_irq)
                flags |= MPIC_ENABLE_COREINT;
 
@@ -47,13 +44,6 @@ void __init corenet_gen_pic_init(void)
        BUG_ON(mpic == NULL);
 
        mpic_init(mpic);
-
-       np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
-       if (np) {
-               qe_ic_init(np, 0, qe_ic_cascade_low_mpic,
-                               qe_ic_cascade_high_mpic);
-               of_node_put(np);
-       }
 }
 
 /*
index 381a6ac8cb4bfba1eda2582cb98976e84f389371..7759eca7d535a635b09ec5476b0a6aa8dd8d0fa8 100644 (file)
@@ -44,7 +44,6 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 #include <soc/fsl/qe/qe.h>
-#include <soc/fsl/qe/qe_ic.h>
 #include <asm/mpic.h>
 #include <asm/swiotlb.h>
 #include "smp.h"
@@ -268,33 +267,8 @@ static void __init mpc85xx_mds_qe_init(void)
        }
 }
 
-static void __init mpc85xx_mds_qeic_init(void)
-{
-       struct device_node *np;
-
-       np = of_find_compatible_node(NULL, NULL, "fsl,qe");
-       if (!of_device_is_available(np)) {
-               of_node_put(np);
-               return;
-       }
-
-       np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
-       if (!np) {
-               np = of_find_node_by_type(NULL, "qeic");
-               if (!np)
-                       return;
-       }
-
-       if (machine_is(p1021_mds))
-               qe_ic_init(np, 0, qe_ic_cascade_low_mpic,
-                               qe_ic_cascade_high_mpic);
-       else
-               qe_ic_init(np, 0, qe_ic_cascade_muxed_mpic, NULL);
-       of_node_put(np);
-}
 #else
 static void __init mpc85xx_mds_qe_init(void) { }
-static void __init mpc85xx_mds_qeic_init(void) { }
 #endif /* CONFIG_QUICC_ENGINE */
 
 static void __init mpc85xx_mds_setup_arch(void)
@@ -364,7 +338,6 @@ static void __init mpc85xx_mds_pic_init(void)
        BUG_ON(mpic == NULL);
 
        mpic_init(mpic);
-       mpc85xx_mds_qeic_init();
 }
 
 static int __init mpc85xx_mds_probe(void)
index 7f9a84f857664758c093a1adbc901522a31d7ebf..80a80174768c3ab144db3b1bd6010675465b8b25 100644 (file)
@@ -23,7 +23,6 @@
 #include <asm/udbg.h>
 #include <asm/mpic.h>
 #include <soc/fsl/qe/qe.h>
-#include <soc/fsl/qe/qe_ic.h>
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
@@ -44,10 +43,6 @@ void __init mpc85xx_rdb_pic_init(void)
 {
        struct mpic *mpic;
 
-#ifdef CONFIG_QUICC_ENGINE
-       struct device_node *np;
-#endif
-
        if (of_machine_is_compatible("fsl,MPC85XXRDB-CAMP")) {
                mpic = mpic_alloc(NULL, 0, MPIC_NO_RESET |
                        MPIC_BIG_ENDIAN |
@@ -62,18 +57,6 @@ void __init mpc85xx_rdb_pic_init(void)
 
        BUG_ON(mpic == NULL);
        mpic_init(mpic);
-
-#ifdef CONFIG_QUICC_ENGINE
-       np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
-       if (np) {
-               qe_ic_init(np, 0, qe_ic_cascade_low_mpic,
-                               qe_ic_cascade_high_mpic);
-               of_node_put(np);
-
-       } else
-               pr_err("%s: Could not find qe-ic node\n", __func__);
-#endif
-
 }
 
 /*
index 6c3c0cdaee9ad2706c590d49262f1524a1bc7a85..9abb1e9f73c40fa8235a36f0b6cb72c559aff470 100644 (file)
@@ -19,7 +19,6 @@
 #include <asm/udbg.h>
 #include <asm/mpic.h>
 #include <soc/fsl/qe/qe.h>
-#include <soc/fsl/qe/qe_ic.h>
 
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
@@ -31,26 +30,12 @@ static void __init twr_p1025_pic_init(void)
 {
        struct mpic *mpic;
 
-#ifdef CONFIG_QUICC_ENGINE
-       struct device_node *np;
-#endif
-
        mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
                        MPIC_SINGLE_DEST_CPU,
                        0, 256, " OpenPIC  ");
 
        BUG_ON(mpic == NULL);
        mpic_init(mpic);
-
-#ifdef CONFIG_QUICC_ENGINE
-       np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
-       if (np) {
-               qe_ic_init(np, 0, qe_ic_cascade_low_mpic,
-                               qe_ic_cascade_high_mpic);
-               of_node_put(np);
-       } else
-               pr_err("Could not find qe-ic node\n");
-#endif
 }
 
 /* ************************************************************************
index f170926ce4d16160a20f25d4e0d8e675542b5d49..a062efac398bc12b30aebc9ce80c2f5dd08fdd28 100644 (file)
@@ -314,10 +314,10 @@ unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic)
        return irq_linear_revmap(qe_ic->irqhost, irq);
 }
 
-void __init qe_ic_init(struct device_node *node, unsigned int flags,
-                      void (*low_handler)(struct irq_desc *desc),
-                      void (*high_handler)(struct irq_desc *desc))
+static void __init qe_ic_init(struct device_node *node, unsigned int flags)
 {
+       void (*low_handler)(struct irq_desc *desc);
+       void (*high_handler)(struct irq_desc *desc);
        struct qe_ic *qe_ic;
        struct resource res;
        u32 temp = 0, ret;
@@ -349,6 +349,13 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags,
                kfree(qe_ic);
                return;
        }
+       if (qe_ic->virq_high != qe_ic->virq_low) {
+               low_handler = qe_ic_cascade_low_mpic;
+               high_handler = qe_ic_cascade_high_mpic;
+       } else {
+               low_handler = qe_ic_cascade_muxed_mpic;
+               high_handler = NULL;
+       }
 
        /* default priority scheme is grouped. If spread mode is    */
        /* required, configure cicr accordingly.                    */
@@ -381,6 +388,22 @@ void __init qe_ic_init(struct device_node *node, unsigned int flags,
        }
 }
 
+static int __init qe_ic_of_init(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 -ENODEV;
+       }
+       qe_ic_init(np, 0);
+       of_node_put(np);
+       return 0;
+}
+subsys_initcall(qe_ic_of_init);
+
 void qe_ic_set_highest_priority(unsigned int virq, int high)
 {
        struct qe_ic *qe_ic = qe_ic_from_irq(virq);
index bfaa233d8328019015b7688cf658ec02591f9704..a47a0d26acbd99776c64ec6b311af7ea3ffb3f79 100644 (file)
@@ -54,16 +54,9 @@ enum qe_ic_grp_id {
 };
 
 #ifdef CONFIG_QUICC_ENGINE
-void qe_ic_init(struct device_node *node, unsigned int flags,
-               void (*low_handler)(struct irq_desc *desc),
-               void (*high_handler)(struct irq_desc *desc));
 unsigned int qe_ic_get_low_irq(struct qe_ic *qe_ic);
 unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic);
 #else
-static inline void qe_ic_init(struct device_node *node, unsigned int flags,
-               void (*low_handler)(struct irq_desc *desc),
-               void (*high_handler)(struct irq_desc *desc))
-{}
 static inline unsigned int qe_ic_get_low_irq(struct qe_ic *qe_ic)
 { return 0; }
 static inline unsigned int qe_ic_get_high_irq(struct qe_ic *qe_ic)