]> err.no Git - linux-2.6/blobdiff - arch/powerpc/platforms/85xx/mpc85xx_cds.c
[POWERPC] 85xxCDS: Allow 8259 cascade to share an MPIC interrupt line.
[linux-2.6] / arch / powerpc / platforms / 85xx / mpc85xx_cds.c
index 50c8d6458362276a825df8510144df1b784b34f0..81b70628df75c8c287689c67d093058e8619f34b 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/seq_file.h>
 #include <linux/initrd.h>
 #include <linux/module.h>
+#include <linux/interrupt.h>
 #include <linux/fsl_devices.h>
 
 #include <asm/system.h>
@@ -45,6 +46,7 @@
 #include <asm/i8259.h>
 
 #include <sysdev/fsl_soc.h>
+#include <sysdev/fsl_pci.h>
 #include "mpc85xx.h"
 
 static int cds_pci_slot = 2;
@@ -58,8 +60,6 @@ static volatile u8 *cadmus;
 static int mpc85xx_exclude_device(struct pci_controller *hose,
                                  u_char bus, u_char devfn)
 {
-       if ((bus == hose->first_busno) && PCI_SLOT(devfn) == 0)
-               return PCIBIOS_DEVICE_NOT_FOUND;
        /* We explicitly do not go past the Tundra 320 Bridge */
        if ((bus == 1) && (PCI_SLOT(devfn) == ARCADIA_2ND_BRIDGE_IDSEL))
                return PCIBIOS_DEVICE_NOT_FOUND;
@@ -109,17 +109,41 @@ static void __init mpc85xx_cds_pci_irq_fixup(struct pci_dev *dev)
        }
 }
 
+static void __devinit skip_fake_bridge(struct pci_dev *dev)
+{
+       /* Make it an error to skip the fake bridge
+        * in pci_setup_device() in probe.c */
+       dev->hdr_type = 0x7f;
+}
+DECLARE_PCI_FIXUP_EARLY(0x1957, 0x3fff, skip_fake_bridge);
+DECLARE_PCI_FIXUP_EARLY(0x3fff, 0x1957, skip_fake_bridge);
+DECLARE_PCI_FIXUP_EARLY(0xff3f, 0x5719, skip_fake_bridge);
+
 #ifdef CONFIG_PPC_I8259
-#warning The i8259 PIC support is currently broken
-static void mpc85xx_8259_cascade(unsigned int irq, struct irq_desc *desc)
+static void mpc85xx_8259_cascade_handler(unsigned int irq,
+                                        struct irq_desc *desc)
 {
        unsigned int cascade_irq = i8259_irq();
 
        if (cascade_irq != NO_IRQ)
+               /* handle an interrupt from the 8259 */
                generic_handle_irq(cascade_irq);
 
-       desc->chip->eoi(irq);
+       /* check for any interrupts from the shared IRQ line */
+       handle_fasteoi_irq(irq, desc);
 }
+
+static irqreturn_t mpc85xx_8259_cascade_action(int irq, void *dev_id)
+{
+       return IRQ_HANDLED;
+}
+
+static struct irqaction mpc85xxcds_8259_irqaction = {
+       .handler = mpc85xx_8259_cascade_action,
+       .flags = IRQF_SHARED,
+       .mask = CPU_MASK_NONE,
+       .name = "8259 cascade",
+};
 #endif /* PPC_I8259 */
 #endif /* CONFIG_PCI */
 
@@ -128,7 +152,7 @@ static void __init mpc85xx_cds_pic_init(void)
        struct mpic *mpic;
        struct resource r;
        struct device_node *np = NULL;
-#ifdef CONFIG_PPC_I8259
+#if defined(CONFIG_PPC_I8259) && defined(CONFIG_PCI)
        struct device_node *cascade_node = NULL;
        int cascade_irq;
 #endif
@@ -156,7 +180,7 @@ static void __init mpc85xx_cds_pic_init(void)
 
        mpic_init(mpic);
 
-#ifdef CONFIG_PPC_I8259
+#if defined(CONFIG_PPC_I8259) && defined(CONFIG_PCI)
        /* Initialize the i8259 controller */
        for_each_node_by_type(np, "interrupt-controller")
                if (of_device_is_compatible(np, "chrp,iic")) {
@@ -178,7 +202,17 @@ static void __init mpc85xx_cds_pic_init(void)
        i8259_init(cascade_node, 0);
        of_node_put(cascade_node);
 
-       set_irq_chained_handler(cascade_irq, mpc85xx_8259_cascade);
+       /*
+        *  Hook the interrupt to make sure desc->action is never NULL.
+        *  This is required to ensure that the interrupt does not get
+        *  disabled when the last user of the shared IRQ line frees their
+        *  interrupt.
+        */
+       if (setup_irq(cascade_irq, &mpc85xxcds_8259_irqaction))
+               printk(KERN_ERR "Failed to setup cascade interrupt\n");
+       else
+               /* Success. Connect our low-level cascade handler. */
+               set_irq_handler(cascade_irq, mpc85xx_8259_cascade_handler);
 #endif /* CONFIG_PPC_I8259 */
 }
 
@@ -218,9 +252,14 @@ static void __init mpc85xx_cds_setup_arch(void)
        }
 
 #ifdef CONFIG_PCI
-       for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
-               mpc85xx_add_bridge(np);
-
+       for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) {
+               struct resource rsrc;
+               of_address_to_resource(np, 0, &rsrc);
+               if ((rsrc.start & 0xfffff) == 0x9000)
+                       fsl_add_bridge(np, 0);
+               else
+                       fsl_add_bridge(np, 1);
+       }
        ppc_md.pci_irq_fixup = mpc85xx_cds_pci_irq_fixup;
        ppc_md.pci_exclude_device = mpc85xx_exclude_device;
 #endif
@@ -268,4 +307,5 @@ define_machine(mpc85xx_cds) {
        .restart        = mpc85xx_restart,
        .calibrate_decr = generic_calibrate_decr,
        .progress       = udbg_progress,
+       .pcibios_fixup_bus      = fsl_pcibios_fixup_bus,
 };