]> git.itanic.dy.fi Git - linux-stable/commitdiff
powerpc/85xx: mpc85xx_ds: Move i8259 code into own file
authorPali Rohár <pali@kernel.org>
Sat, 8 Apr 2023 14:01:18 +0000 (16:01 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 20 Apr 2023 02:22:51 +0000 (12:22 +1000)
In order to share mpc85xx i8259 code between DS and P2020.
Prefix i8259 debug and error messages by i8259 word.

Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
[mpe: Fix some coding style warnings in the moved code]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230408140122.25293-10-pali@kernel.org
arch/powerpc/platforms/85xx/Makefile
arch/powerpc/platforms/85xx/mpc85xx.h
arch/powerpc/platforms/85xx/mpc85xx_8259.c [new file with mode: 0644]
arch/powerpc/platforms/85xx/mpc85xx_ds.c

index 93451850ed833950188135d999834142aadbf0c0..0a0011e8c63ce33712773c695c3435db721e8a63 100644 (file)
@@ -16,7 +16,8 @@ obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
 obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
 obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
 obj-$(CONFIG_MPC8536_DS)  += mpc8536_ds.o
-obj-$(CONFIG_MPC85xx_DS)  += mpc85xx_ds.o p2020.o
+obj8259-$(CONFIG_PPC_I8259)   += mpc85xx_8259.o
+obj-$(CONFIG_MPC85xx_DS)  += mpc85xx_ds.o p2020.o $(obj8259-y)
 obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
 obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o p2020.o
 obj-$(CONFIG_P1010_RDB)   += p1010rdb.o
index 8f7b37c1de87a6049906b8dd13ca6c6bfb729037..e792907ee3d5e7c33fa2c1f65bb395137ae0ceb6 100644 (file)
@@ -15,6 +15,12 @@ extern void mpc85xx_qe_par_io_init(void);
 static inline void __init mpc85xx_qe_par_io_init(void) {}
 #endif
 
+#ifdef CONFIG_PPC_I8259
+void __init mpc85xx_8259_init(void);
+#else
+static inline void __init mpc85xx_8259_init(void) {}
+#endif
+
 void __init mpc85xx_ds_pic_init(void);
 void __init mpc85xx_ds_setup_arch(void);
 void __init mpc85xx_rdb_setup_arch(void);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_8259.c b/arch/powerpc/platforms/85xx/mpc85xx_8259.c
new file mode 100644 (file)
index 0000000..cb00d59
--- /dev/null
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * MPC85xx 8259 functions for DS Board Setup
+ *
+ * Author Xianghua Xiao (x.xiao@freescale.com)
+ * Roy Zang <tie-fei.zang@freescale.com>
+ *      - Add PCI/PCI Express support
+ * Copyright 2007 Freescale Semiconductor Inc.
+ */
+
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/of_irq.h>
+#include <linux/of_platform.h>
+
+#include <asm/mpic.h>
+#include <asm/i8259.h>
+
+#include "mpc85xx.h"
+
+static void mpc85xx_8259_cascade(struct irq_desc *desc)
+{
+       struct irq_chip *chip = irq_desc_get_chip(desc);
+       unsigned int cascade_irq = i8259_irq();
+
+       if (cascade_irq)
+               generic_handle_irq(cascade_irq);
+
+       chip->irq_eoi(&desc->irq_data);
+}
+
+void __init mpc85xx_8259_init(void)
+{
+       struct device_node *np;
+       struct device_node *cascade_node = NULL;
+       int cascade_irq;
+
+       /* Initialize the i8259 controller */
+       for_each_node_by_type(np, "interrupt-controller") {
+               if (of_device_is_compatible(np, "chrp,iic")) {
+                       cascade_node = np;
+                       break;
+               }
+       }
+
+       if (cascade_node == NULL) {
+               pr_debug("i8259: Could not find i8259 PIC\n");
+               return;
+       }
+
+       cascade_irq = irq_of_parse_and_map(cascade_node, 0);
+       if (!cascade_irq) {
+               pr_err("i8259: Failed to map cascade interrupt\n");
+               return;
+       }
+
+       pr_debug("i8259: cascade mapped to irq %d\n", cascade_irq);
+
+       i8259_init(cascade_node, 0);
+       of_node_put(cascade_node);
+
+       irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
+}
index af2cafec4f0a4ad47f2c8acfbecc241793db03f9..db4cf76c0fd1a15c3603913d378d7c40e884311a 100644 (file)
 
 #include "mpc85xx.h"
 
-static void mpc85xx_8259_cascade(struct irq_desc *desc)
-{
-       struct irq_chip *chip = irq_desc_get_chip(desc);
-       unsigned int cascade_irq = i8259_irq();
-
-       if (cascade_irq) {
-               generic_handle_irq(cascade_irq);
-       }
-       chip->irq_eoi(&desc->irq_data);
-}
-
-static void __init mpc85xx_8259_init(void)
-{
-       struct device_node *np;
-       struct device_node *cascade_node = NULL;
-       int cascade_irq;
-
-       if (!IS_ENABLED(CONFIG_PPC_I8259))
-               return;
-
-       /* Initialize the i8259 controller */
-       for_each_node_by_type(np, "interrupt-controller")
-           if (of_device_is_compatible(np, "chrp,iic")) {
-               cascade_node = np;
-               break;
-       }
-
-       if (cascade_node == NULL) {
-               pr_debug("Could not find i8259 PIC\n");
-               return;
-       }
-
-       cascade_irq = irq_of_parse_and_map(cascade_node, 0);
-       if (!cascade_irq) {
-               pr_err("Failed to map cascade interrupt\n");
-               return;
-       }
-
-       pr_debug("mpc85xxds: cascade mapped to irq %d\n", cascade_irq);
-
-       i8259_init(cascade_node, 0);
-       of_node_put(cascade_node);
-
-       irq_set_chained_handler(cascade_irq, mpc85xx_8259_cascade);
-}
-
 void __init mpc85xx_ds_pic_init(void)
 {
        struct mpic *mpic;