]> err.no Git - linux-2.6/blobdiff - arch/powerpc/kernel/pci-common.c
Merge branches 'release' and 'dock' into release
[linux-2.6] / arch / powerpc / kernel / pci-common.c
index f706b7e83d7ef31915417a50bbbd79c7a3981d4e..89c83ccb85c10e07d5fe29375d26fb624377567d 100644 (file)
@@ -225,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)
@@ -747,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,
@@ -776,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");
@@ -790,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,
@@ -1127,3 +1158,44 @@ 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)
+{
+       u16 cmd, old_cmd;
+       int idx;
+       struct resource *r;
+
+       if (ppc_md.pcibios_enable_device_hook)
+               if (ppc_md.pcibios_enable_device_hook(dev))
+                       return -EINVAL;
+
+       pci_read_config_word(dev, PCI_COMMAND, &cmd);
+       old_cmd = cmd;
+       for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) {
+               /* Only set up the requested stuff */
+               if (!(mask & (1 << idx)))
+                       continue;
+               r = &dev->resource[idx];
+               if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM)))
+                       continue;
+               if ((idx == PCI_ROM_RESOURCE) &&
+                               (!(r->flags & IORESOURCE_ROM_ENABLE)))
+                       continue;
+               if (r->parent == NULL) {
+                       printk(KERN_ERR "PCI: Device %s not available because"
+                              " of resource collisions\n", pci_name(dev));
+                       return -EINVAL;
+               }
+               if (r->flags & IORESOURCE_IO)
+                       cmd |= PCI_COMMAND_IO;
+               if (r->flags & IORESOURCE_MEM)
+                       cmd |= PCI_COMMAND_MEMORY;
+       }
+       if (cmd != old_cmd) {
+               printk("PCI: Enabling device %s (%04x -> %04x)\n",
+                      pci_name(dev), old_cmd, cmd);
+               pci_write_config_word(dev, PCI_COMMAND, cmd);
+       }
+       return 0;
+}
+