]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
powerpc/86xx: Refactor pic init
authorKumar Gala <galak@kernel.crashing.org>
Wed, 2 Jul 2008 16:46:20 +0000 (11:46 -0500)
committerKumar Gala <galak@kernel.crashing.org>
Mon, 14 Jul 2008 12:55:41 +0000 (07:55 -0500)
Moved the pic initialization into its own common file and out of the board
code.  Also fixed the OF reference counting on the mpic node.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/platforms/86xx/Makefile
arch/powerpc/platforms/86xx/mpc8610_hpcd.c
arch/powerpc/platforms/86xx/mpc86xx.h
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
arch/powerpc/platforms/86xx/pic.c [new file with mode: 0644]
arch/powerpc/platforms/86xx/sbc8641d.c

index 1b9b4a9b2525cd3a7bd0ae2117d9fba50c03fb81..8fee37dec79517ffb344f20398e34361df748e34 100644 (file)
@@ -2,6 +2,7 @@
 # Makefile for the PowerPC 86xx linux kernel.
 #
 
+obj-y                          := pic.o
 obj-$(CONFIG_SMP)              += mpc86xx_smp.o
 obj-$(CONFIG_MPC8641_HPCN)     += mpc86xx_hpcn.o
 obj-$(CONFIG_SBC8641D)         += sbc8641d.o
index eb16208b29d99a68280e71be70e46b57b5057bae..30725302884a53cc43e10fc8173057a6e6256839 100644 (file)
@@ -39,6 +39,8 @@
 #include <sysdev/fsl_pci.h>
 #include <sysdev/fsl_soc.h>
 
+#include "mpc86xx.h"
+
 static unsigned char *pixis_bdcfg0, *pixis_arch;
 
 static struct of_device_id __initdata mpc8610_ids[] = {
@@ -56,28 +58,6 @@ static int __init mpc8610_declare_of_platform_devices(void)
 }
 machine_device_initcall(mpc86xx_hpcd, mpc8610_declare_of_platform_devices);
 
-static void __init mpc86xx_hpcd_init_irq(void)
-{
-       struct mpic *mpic1;
-       struct device_node *np;
-       struct resource res;
-
-       /* Determine PIC address. */
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (np == NULL)
-               return;
-       of_address_to_resource(np, 0, &res);
-
-       /* Alloc mpic structure and per isu has 16 INT entries. */
-       mpic1 = mpic_alloc(np, res.start,
-                       MPIC_PRIMARY | MPIC_WANTS_RESET |
-                       MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
-                       0, 256, " MPIC     ");
-       BUG_ON(mpic1 == NULL);
-
-       mpic_init(mpic1);
-}
-
 #ifdef CONFIG_PCI
 static void __devinit quirk_uli1575(struct pci_dev *dev)
 {
@@ -405,7 +385,7 @@ define_machine(mpc86xx_hpcd) {
        .name                   = "MPC86xx HPCD",
        .probe                  = mpc86xx_hpcd_probe,
        .setup_arch             = mpc86xx_hpcd_setup_arch,
-       .init_IRQ               = mpc86xx_hpcd_init_irq,
+       .init_IRQ               = mpc86xx_init_irq,
        .get_irq                = mpic_get_irq,
        .restart                = fsl_rstcr_restart,
        .time_init              = mpc86xx_time_init,
index 525ffa1904f939bd6582c3d85b9f935c67257183..08efb57559d1ceaa7c230e7eddaf10c31dcfc23b 100644 (file)
@@ -15,6 +15,7 @@
  * mpc86xx_* files. Mostly for use by mpc86xx_setup().
  */
 
-extern void __init mpc86xx_smp_init(void);
+extern void mpc86xx_smp_init(void);
+extern void mpc86xx_init_irq(void);
 
 #endif /* __MPC86XX_H__ */
index f13704aabbea401fdd177b753f816961f0d1cffb..7916599c9126c4a26f46900ba6434b96422727c6 100644 (file)
@@ -28,7 +28,6 @@
 #include <asm/prom.h>
 #include <mm/mmu_decl.h>
 #include <asm/udbg.h>
-#include <asm/i8259.h>
 
 #include <asm/mpic.h>
 
 #define DBG(fmt...) do { } while(0)
 #endif
 
-#ifdef CONFIG_PCI
-static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
-{
-       unsigned int cascade_irq = i8259_irq();
-       if (cascade_irq != NO_IRQ)
-               generic_handle_irq(cascade_irq);
-       desc->chip->eoi(irq);
-}
-#endif /* CONFIG_PCI */
-
-static void __init
-mpc86xx_hpcn_init_irq(void)
-{
-       struct mpic *mpic1;
-       struct device_node *np;
-       struct resource res;
-#ifdef CONFIG_PCI
-       struct device_node *cascade_node = NULL;
-       int cascade_irq;
-#endif
-
-       /* Determine PIC address. */
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (np == NULL)
-               return;
-       of_address_to_resource(np, 0, &res);
-
-       /* Alloc mpic structure and per isu has 16 INT entries. */
-       mpic1 = mpic_alloc(np, res.start,
-                       MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
-                       0, 256, " MPIC     ");
-       BUG_ON(mpic1 == NULL);
-
-       mpic_init(mpic1);
-
-#ifdef CONFIG_PCI
-       /* Initialize 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) {
-               printk(KERN_DEBUG "mpc86xxhpcn: no ISA interrupt controller\n");
-               return;
-       }
-
-       cascade_irq = irq_of_parse_and_map(cascade_node, 0);
-       if (cascade_irq == NO_IRQ) {
-               printk(KERN_ERR "mpc86xxhpcn: failed to map cascade interrupt");
-               return;
-       }
-       DBG("mpc86xxhpcn: cascade mapped to irq %d\n", cascade_irq);
-
-       i8259_init(cascade_node, 0);
-       of_node_put(cascade_node);
-
-       set_irq_chained_handler(cascade_irq, mpc86xx_8259_cascade);
-#endif
-}
-
 #ifdef CONFIG_PCI
 extern int uses_fsl_uli_m1575;
 extern int uli_exclude_device(struct pci_controller *hose,
@@ -237,7 +175,7 @@ define_machine(mpc86xx_hpcn) {
        .name                   = "MPC86xx HPCN",
        .probe                  = mpc86xx_hpcn_probe,
        .setup_arch             = mpc86xx_hpcn_setup_arch,
-       .init_IRQ               = mpc86xx_hpcn_init_irq,
+       .init_IRQ               = mpc86xx_init_irq,
        .show_cpuinfo           = mpc86xx_hpcn_show_cpuinfo,
        .get_irq                = mpic_get_irq,
        .restart                = fsl_rstcr_restart,
diff --git a/arch/powerpc/platforms/86xx/pic.c b/arch/powerpc/platforms/86xx/pic.c
new file mode 100644 (file)
index 0000000..8881c5d
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2008 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/of_platform.h>
+
+#include <asm/system.h>
+#include <asm/mpic.h>
+#include <asm/i8259.h>
+
+#ifdef CONFIG_PPC_I8259
+static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
+{
+       unsigned int cascade_irq = i8259_irq();
+       if (cascade_irq != NO_IRQ)
+               generic_handle_irq(cascade_irq);
+       desc->chip->eoi(irq);
+}
+#endif /* CONFIG_PPC_I8259 */
+
+void __init mpc86xx_init_irq(void)
+{
+       struct mpic *mpic;
+       struct device_node *np;
+       struct resource res;
+#ifdef CONFIG_PPC_I8259
+       struct device_node *cascade_node = NULL;
+       int cascade_irq;
+#endif
+
+       /* Determine PIC address. */
+       np = of_find_node_by_type(NULL, "open-pic");
+       if (np == NULL)
+               return;
+       of_address_to_resource(np, 0, &res);
+
+       mpic = mpic_alloc(np, res.start,
+                       MPIC_PRIMARY | MPIC_WANTS_RESET |
+                       MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
+                       0, 256, " MPIC     ");
+       of_node_put(np);
+       BUG_ON(mpic == NULL);
+
+       mpic_init(mpic);
+
+#ifdef CONFIG_PPC_I8259
+       /* Initialize 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) {
+               printk(KERN_DEBUG "Could not find i8259 PIC\n");
+               return;
+       }
+
+       cascade_irq = irq_of_parse_and_map(cascade_node, 0);
+       if (cascade_irq == NO_IRQ) {
+               printk(KERN_ERR "Failed to map cascade interrupt\n");
+               return;
+       }
+
+       i8259_init(cascade_node, 0);
+       of_node_put(cascade_node);
+
+       set_irq_chained_handler(cascade_irq, mpc86xx_8259_cascade);
+#endif
+}
index 510a06ef0b55cd6b4420b1dd7be208ed421153df..00e6fad3b3ca99f155350617d8838f33abe1069a 100644 (file)
 
 #include "mpc86xx.h"
 
-static void __init
-sbc8641_init_irq(void)
-{
-       struct mpic *mpic1;
-       struct device_node *np;
-       struct resource res;
-
-       /* Determine PIC address. */
-       np = of_find_node_by_type(NULL, "open-pic");
-       if (np == NULL)
-               return;
-       of_address_to_resource(np, 0, &res);
-
-       /* Alloc mpic structure and per isu has 16 INT entries. */
-       mpic1 = mpic_alloc(np, res.start,
-                       MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
-                       0, 256, " MPIC     ");
-       of_node_put(np);
-       BUG_ON(mpic1 == NULL);
-
-       mpic_init(mpic1);
-}
-
 static void __init
 sbc8641_setup_arch(void)
 {
@@ -151,7 +128,7 @@ define_machine(sbc8641) {
        .name                   = "SBC8641D",
        .probe                  = sbc8641_probe,
        .setup_arch             = sbc8641_setup_arch,
-       .init_IRQ               = sbc8641_init_irq,
+       .init_IRQ               = mpc86xx_init_irq,
        .show_cpuinfo           = sbc8641_show_cpuinfo,
        .get_irq                = mpic_get_irq,
        .restart                = fsl_rstcr_restart,