]> err.no Git - linux-2.6/blobdiff - arch/powerpc/kernel/pci-common.c
Merge branch 'powerpc-next' of master.kernel.org:/pub/scm/linux/kernel/git/galak...
[linux-2.6] / arch / powerpc / kernel / pci-common.c
index d804c8d0be00f9463a97b9696ff46dc8cbb4279d..063cdd4130497173eca006e49e310393e9b9df0b 100644 (file)
@@ -190,6 +190,20 @@ int pci_read_irq_line(struct pci_dev *pci_dev)
        struct of_irq oirq;
        unsigned int virq;
 
+       /* The current device-tree that iSeries generates from the HV
+        * PCI informations doesn't contain proper interrupt routing,
+        * and all the fallback would do is print out crap, so we
+        * don't attempt to resolve the interrupts here at all, some
+        * iSeries specific fixup does it.
+        *
+        * In the long run, we will hopefully fix the generated device-tree
+        * instead.
+        */
+#ifdef CONFIG_PPC_ISERIES
+       if (firmware_has_feature(FW_FEATURE_ISERIES))
+               return -1;
+#endif
+
        DBG("Try to map irq for %s...\n", pci_name(pci_dev));
 
 #ifdef DEBUG
@@ -211,10 +225,11 @@ int pci_read_irq_line(struct pci_dev *pci_dev)
                if (pin == 0)
                        return -1;
                if (pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &line) ||
-                   line == 0xff) {
+                   line == 0xff || line == 0) {
                        return -1;
                }
-               DBG(" -> no map ! Using irq line %d from PCI config\n", line);
+               DBG(" -> no map ! Using line %d (pin %d) from PCI config\n",
+                   line, pin);
 
                virq = irq_create_mapping(NULL, line);
                if (virq != NO_IRQ)
@@ -733,7 +748,13 @@ static void __devinit pcibios_fixup_resources(struct pci_dev *dev)
                struct resource *res = dev->resource + i;
                if (!res->flags)
                        continue;
-               if (res->end == 0xffffffff) {
+               /* On platforms that have PPC_PCI_PROBE_ONLY set, we don't
+                * consider 0 as an unassigned BAR value. It's technically
+                * a valid value, but linux doesn't like it... so when we can
+                * re-assign things, we do so, but if we can't, we keep it
+                * around and hope for the best...
+                */
+               if (res->start == 0 && !(ppc_pci_flags & PPC_PCI_PROBE_ONLY)) {
                        pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] is unassigned\n",
                                 pci_name(dev), i,
                                 (unsigned long long)res->start,
@@ -762,6 +783,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources);
 
 static void __devinit __pcibios_fixup_bus(struct pci_bus *bus)
 {
+       struct pci_controller *hose = pci_bus_to_host(bus);
        struct pci_dev *dev = bus->self;
 
        pr_debug("PCI: Fixup bus %d (%s)\n", bus->number, dev ? pci_name(dev) : "PHB");
@@ -776,8 +798,31 @@ static void __devinit __pcibios_fixup_bus(struct pci_bus *bus)
                for (i = 0; i < PCI_BUS_NUM_RESOURCES; ++i) {
                        if ((res = bus->resource[i]) == NULL)
                                continue;
-                       if (!res->flags || bus->self->transparent)
+                       if (!res->flags)
+                               continue;
+                       if (i >= 3 && bus->self->transparent)
                                continue;
+                       /* On PowerMac, Apple leaves bridge windows open over
+                        * an inaccessible region of memory space (0...fffff)
+                        * which is somewhat bogus, but that's what they think
+                        * means disabled...
+                        *
+                        * We clear those to force them to be reallocated later
+                        *
+                        * We detect such regions by the fact that the base is
+                        * equal to the pci_mem_offset of the host bridge and
+                        * their size is smaller than 1M.
+                        */
+                       if (res->flags & IORESOURCE_MEM &&
+                           res->start == hose->pci_mem_offset &&
+                           res->end < 0x100000) {
+                               printk(KERN_INFO
+                                      "PCI: Closing bogus Apple Firmware"
+                                      " region %d on bus 0x%02x\n",
+                                      i, bus->number);
+                               res->flags = 0;
+                               continue;
+                       }
 
                        pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x] fixup...\n",
                                 pci_name(dev), i,
@@ -946,7 +991,7 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
                            || res->start > res->end)
                                continue;
                        if (bus->parent == NULL)
-                               pr = (res->flags & IORESOURCE_IO)?
+                               pr = (res->flags & IORESOURCE_IO) ?
                                        &ioport_resource : &iomem_resource;
                        else {
                                /* Don't bother with non-root busses when
@@ -1113,3 +1158,12 @@ void __devinit pcibios_claim_one_bus(struct pci_bus *bus)
 }
 EXPORT_SYMBOL_GPL(pcibios_claim_one_bus);
 #endif /* CONFIG_HOTPLUG */
+
+int pcibios_enable_device(struct pci_dev *dev, int mask)
+{
+       if (ppc_md.pcibios_enable_device_hook)
+               if (ppc_md.pcibios_enable_device_hook(dev))
+                       return -EINVAL;
+
+       return pci_enable_resources(dev, mask);
+}