]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/platforms/85xx/mpc85xx_cds.c
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux...
[linux-2.6-omap-h63xx.git] / arch / powerpc / platforms / 85xx / mpc85xx_cds.c
index 50c8d6458362276a825df8510144df1b784b34f0..aeb6a5bc55222a26ed4333cb503adf7f0cfc3846 100644 (file)
@@ -24,7 +24,9 @@
 #include <linux/seq_file.h>
 #include <linux/initrd.h>
 #include <linux/module.h>
+#include <linux/interrupt.h>
 #include <linux/fsl_devices.h>
+#include <linux/of_platform.h>
 
 #include <asm/system.h>
 #include <asm/pgtable.h>
@@ -34,9 +36,7 @@
 #include <asm/io.h>
 #include <asm/machdep.h>
 #include <asm/ipic.h>
-#include <asm/bootinfo.h>
 #include <asm/pci-bridge.h>
-#include <asm/mpc85xx.h>
 #include <asm/irq.h>
 #include <mm/mmu_decl.h>
 #include <asm/prom.h>
 #include <asm/i8259.h>
 
 #include <sysdev/fsl_soc.h>
-#include "mpc85xx.h"
+#include <sysdev/fsl_pci.h>
+
+/* CADMUS info */
+/* xxx - galak, move into device tree */
+#define CADMUS_BASE (0xf8004000)
+#define CADMUS_SIZE (256)
+#define CM_VER (0)
+#define CM_CSR (1)
+#define CM_RST (2)
+
 
 static int cds_pci_slot = 2;
 static volatile u8 *cadmus;
@@ -58,8 +67,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;
@@ -69,6 +76,37 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,
                return PCIBIOS_SUCCESSFUL;
 }
 
+static void mpc85xx_cds_restart(char *cmd)
+{
+       struct pci_dev *dev;
+       u_char tmp;
+
+       if ((dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686,
+                                       NULL))) {
+
+               /* Use the VIA Super Southbridge to force a PCI reset */
+               pci_read_config_byte(dev, 0x47, &tmp);
+               pci_write_config_byte(dev, 0x47, tmp | 1);
+
+               /* Flush the outbound PCI write queues */
+               pci_read_config_byte(dev, 0x47, &tmp);
+
+               /*
+                *  At this point, the harware reset should have triggered.
+                *  However, if it doesn't work for some mysterious reason,
+                *  just fall through to the default reset below.
+                */
+
+               pci_dev_put(dev);
+       }
+
+       /*
+        *  If we can't find the VIA chip (maybe the P2P bridge is disabled)
+        *  or the VIA chip reset didn't work, just use the default reset.
+        */
+       fsl_rstcr_restart(NULL);
+}
+
 static void __init mpc85xx_cds_pci_irq_fixup(struct pci_dev *dev)
 {
        u_char c;
@@ -98,7 +136,7 @@ static void __init mpc85xx_cds_pci_irq_fixup(struct pci_dev *dev)
                /* There are two USB controllers.
                 * Identify them by functon number
                 */
-                       if (PCI_FUNC(dev->devfn))
+                       if (PCI_FUNC(dev->devfn) == 3)
                                dev->irq = 11;
                        else
                                dev->irq = 10;
@@ -109,17 +147,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,10 +190,6 @@ static void __init mpc85xx_cds_pic_init(void)
        struct mpic *mpic;
        struct resource r;
        struct device_node *np = NULL;
-#ifdef CONFIG_PPC_I8259
-       struct device_node *cascade_node = NULL;
-       int cascade_irq;
-#endif
 
        np = of_find_node_by_type(np, "open-pic");
 
@@ -155,8 +213,16 @@ static void __init mpc85xx_cds_pic_init(void)
        of_node_put(np);
 
        mpic_init(mpic);
+}
+
+#if defined(CONFIG_PPC_I8259) && defined(CONFIG_PCI)
+static int mpc85xx_cds_8259_attach(void)
+{
+       int ret;
+       struct device_node *np = NULL;
+       struct device_node *cascade_node = NULL;
+       int cascade_irq;
 
-#ifdef CONFIG_PPC_I8259
        /* Initialize the i8259 controller */
        for_each_node_by_type(np, "interrupt-controller")
                if (of_device_is_compatible(np, "chrp,iic")) {
@@ -166,28 +232,43 @@ static void __init mpc85xx_cds_pic_init(void)
 
        if (cascade_node == NULL) {
                printk(KERN_DEBUG "Could not find i8259 PIC\n");
-               return;
+               return -ENODEV;
        }
 
        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;
+               return -ENXIO;
        }
 
        i8259_init(cascade_node, 0);
        of_node_put(cascade_node);
 
-       set_irq_chained_handler(cascade_irq, mpc85xx_8259_cascade);
-#endif /* CONFIG_PPC_I8259 */
+       /*
+        *  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 ((ret = setup_irq(cascade_irq, &mpc85xxcds_8259_irqaction))) {
+               printk(KERN_ERR "Failed to setup cascade interrupt\n");
+               return ret;
+       }
+
+       /* Success. Connect our low-level cascade handler. */
+       set_irq_handler(cascade_irq, mpc85xx_8259_cascade_handler);
+
+       return 0;
 }
+machine_device_initcall(mpc85xx_cds, mpc85xx_cds_8259_attach);
+
+#endif /* CONFIG_PPC_I8259 */
 
 /*
  * Setup the architecture
  */
 static void __init mpc85xx_cds_setup_arch(void)
 {
-       struct device_node *cpu;
 #ifdef CONFIG_PCI
        struct device_node *np;
 #endif
@@ -195,18 +276,6 @@ static void __init mpc85xx_cds_setup_arch(void)
        if (ppc_md.progress)
                ppc_md.progress("mpc85xx_cds_setup_arch()", 0);
 
-       cpu = of_find_node_by_type(NULL, "cpu");
-       if (cpu != 0) {
-               const unsigned int *fp;
-
-               fp = of_get_property(cpu, "clock-frequency", NULL);
-               if (fp != 0)
-                       loops_per_jiffy = *fp / HZ;
-               else
-                       loops_per_jiffy = 500000000 / HZ;
-               of_node_put(cpu);
-       }
-
        cadmus = ioremap(CADMUS_BASE, CADMUS_SIZE);
        cds_pci_slot = ((cadmus[CM_CSR] >> 6) & 0x3) + 1;
 
@@ -218,8 +287,17 @@ 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_each_node_by_type(np, "pci") {
+               if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
+                   of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
+                       struct resource rsrc;
+                       of_address_to_resource(np, 0, &rsrc);
+                       if ((rsrc.start & 0xfffff) == 0x8000)
+                               fsl_add_bridge(np, 1);
+                       else
+                               fsl_add_bridge(np, 0);
+               }
+       }
 
        ppc_md.pci_irq_fixup = mpc85xx_cds_pci_irq_fixup;
        ppc_md.pci_exclude_device = mpc85xx_exclude_device;
@@ -229,7 +307,6 @@ static void __init mpc85xx_cds_setup_arch(void)
 static void mpc85xx_cds_show_cpuinfo(struct seq_file *m)
 {
        uint pvid, svid, phid1;
-       uint memsize = total_memory;
 
        pvid = mfspr(SPRN_PVR);
        svid = mfspr(SPRN_SVR);
@@ -242,9 +319,6 @@ static void mpc85xx_cds_show_cpuinfo(struct seq_file *m)
        /* Display cpu Pll setting */
        phid1 = mfspr(SPRN_HID1);
        seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
-
-       /* Display the amount of memory */
-       seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
 }
 
 
@@ -258,6 +332,19 @@ static int __init mpc85xx_cds_probe(void)
         return of_flat_dt_is_compatible(root, "MPC85xxCDS");
 }
 
+static struct of_device_id __initdata of_bus_ids[] = {
+       { .type = "soc", },
+       { .compatible = "soc", },
+       { .compatible = "simple-bus", },
+       {},
+};
+
+static int __init declare_of_platform_devices(void)
+{
+       return of_platform_bus_probe(NULL, of_bus_ids, NULL);
+}
+machine_device_initcall(mpc85xx_cds, declare_of_platform_devices);
+
 define_machine(mpc85xx_cds) {
        .name           = "MPC85xx CDS",
        .probe          = mpc85xx_cds_probe,
@@ -265,7 +352,12 @@ define_machine(mpc85xx_cds) {
        .init_IRQ       = mpc85xx_cds_pic_init,
        .show_cpuinfo   = mpc85xx_cds_show_cpuinfo,
        .get_irq        = mpic_get_irq,
-       .restart        = mpc85xx_restart,
+#ifdef CONFIG_PCI
+       .restart        = mpc85xx_cds_restart,
+       .pcibios_fixup_bus      = fsl_pcibios_fixup_bus,
+#else
+       .restart        = fsl_rstcr_restart,
+#endif
        .calibrate_decr = generic_calibrate_decr,
        .progress       = udbg_progress,
 };