ide_pci_generic: add quirk for Netcell ATA RAID
[safe/jmp/linux-2.6] / drivers / pci / setup-res.c
index 1a5fc83..3039fcb 100644 (file)
 #include "pci.h"
 
 
-void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
+void pci_update_resource(struct pci_dev *dev, int resno)
 {
        struct pci_bus_region region;
        u32 new, check, mask;
        int reg;
+       enum pci_bar_type type;
+       struct resource *res = dev->resource + resno;
 
        /*
         * Ignore resources for unimplemented BARs and unused resource slots
@@ -49,10 +51,8 @@ void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
 
        pcibios_resource_to_bus(dev, &region, res);
 
-       dev_dbg(&dev->dev, "BAR %d: got res [%#llx-%#llx] bus [%#llx-%#llx] "
-               "flags %#lx\n", resno,
-                (unsigned long long)res->start,
-                (unsigned long long)res->end,
+       dev_dbg(&dev->dev, "BAR %d: got res %pR bus [%#llx-%#llx] "
+               "flags %#lx\n", resno, res,
                 (unsigned long long)region.start,
                 (unsigned long long)region.end,
                 (unsigned long)res->flags);
@@ -63,17 +63,13 @@ void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
        else
                mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
 
-       if (resno < 6) {
-               reg = PCI_BASE_ADDRESS_0 + 4 * resno;
-       } else if (resno == PCI_ROM_RESOURCE) {
+       reg = pci_resource_bar(dev, resno, &type);
+       if (!reg)
+               return;
+       if (type != pci_bar_unknown) {
                if (!(res->flags & IORESOURCE_ROM_ENABLE))
                        return;
                new |= PCI_ROM_ADDRESS_ENABLE;
-               reg = dev->rom_base_reg;
-       } else {
-               /* Hmm, non-standard resource. */
-       
-               return;         /* kill uninitialised var warning */
        }
 
        pci_write_config_dword(dev, reg, new);
@@ -114,18 +110,31 @@ int pci_claim_resource(struct pci_dev *dev, int resource)
                err = insert_resource(root, res);
 
        if (err) {
-               dev_err(&dev->dev, "BAR %d: %s of %s [%#llx-%#llx]\n",
+               dev_err(&dev->dev, "BAR %d: %s of %s %pR\n",
                        resource,
                        root ? "address space collision on" :
                                "no parent found for",
-                       dtype,
-                       (unsigned long long)res->start,
-                       (unsigned long long)res->end);
+                       dtype, res);
        }
 
        return err;
 }
 
+#ifdef CONFIG_PCI_QUIRKS
+void pci_disable_bridge_window(struct pci_dev *dev)
+{
+       dev_dbg(&dev->dev, "Disabling bridge window.\n");
+
+       /* MMIO Base/Limit */
+       pci_write_config_dword(dev, PCI_MEMORY_BASE, 0x0000fff0);
+
+       /* Prefetchable MMIO Base/Limit */
+       pci_write_config_dword(dev, PCI_PREF_LIMIT_UPPER32, 0);
+       pci_write_config_dword(dev, PCI_PREF_MEMORY_BASE, 0x0000fff0);
+       pci_write_config_dword(dev, PCI_PREF_BASE_UPPER32, 0xffffffff);
+}
+#endif /* CONFIG_PCI_QUIRKS */
+
 int pci_assign_resource(struct pci_dev *dev, int resno)
 {
        struct pci_bus *bus = dev->bus;
@@ -133,15 +142,14 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
        resource_size_t size, min, align;
        int ret;
 
-       size = res->end - res->start + 1;
+       size = resource_size(res);
        min = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM;
 
        align = resource_alignment(res);
        if (!align) {
-               dev_err(&dev->dev, "BAR %d: can't allocate resource (bogus "
-                       "alignment) [%#llx-%#llx] flags %#lx\n",
-                       resno, (unsigned long long)res->start,
-                       (unsigned long long)res->end, res->flags);
+               dev_info(&dev->dev, "BAR %d: can't allocate resource (bogus "
+                       "alignment) %pR flags %#lx\n",
+                       resno, res, res->flags);
                return -EINVAL;
        }
 
@@ -162,15 +170,12 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
        }
 
        if (ret) {
-               dev_err(&dev->dev, "BAR %d: can't allocate %s resource "
-                       "[%#llx-%#llx]\n", resno,
-                       res->flags & IORESOURCE_IO ? "I/O" : "mem",
-                       (unsigned long long)res->start,
-                       (unsigned long long)res->end);
+               dev_info(&dev->dev, "BAR %d: can't allocate %s resource %pR\n",
+                       resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res);
        } else {
                res->flags &= ~IORESOURCE_STARTALIGN;
                if (resno < PCI_BRIDGE_RESOURCES)
-                       pci_update_resource(dev, res, resno);
+                       pci_update_resource(dev, resno);
        }
 
        return ret;
@@ -202,13 +207,10 @@ int pci_assign_resource_fixed(struct pci_dev *dev, int resno)
        }
 
        if (ret) {
-               dev_err(&dev->dev, "BAR %d: can't allocate %s resource "
-                       "[%#llx-%#llx\n]", resno,
-                       res->flags & IORESOURCE_IO ? "I/O" : "mem",
-                       (unsigned long long)res->start,
-                       (unsigned long long)res->end);
+               dev_err(&dev->dev, "BAR %d: can't allocate %s resource %pR\n",
+                       resno, res->flags & IORESOURCE_IO ? "I/O" : "mem", res);
        } else if (resno < PCI_BRIDGE_RESOURCES) {
-               pci_update_resource(dev, res, resno);
+               pci_update_resource(dev, resno);
        }
 
        return ret;
@@ -237,9 +239,8 @@ void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
                r_align = resource_alignment(r);
                if (!r_align) {
                        dev_warn(&dev->dev, "BAR %d: bogus alignment "
-                               "[%#llx-%#llx] flags %#lx\n",
-                               i, (unsigned long long)r->start,
-                               (unsigned long long)r->end, r->flags);
+                               "%pR flags %#lx\n",
+                               i, r, r->flags);
                        continue;
                }
                for (list = head; ; list = list->next) {
@@ -287,9 +288,7 @@ int pci_enable_resources(struct pci_dev *dev, int mask)
 
                if (!r->parent) {
                        dev_err(&dev->dev, "device not available because of "
-                               "BAR %d [%#llx-%#llx] collisions\n", i,
-                               (unsigned long long) r->start,
-                               (unsigned long long) r->end);
+                               "BAR %d %pR collisions\n", i, r);
                        return -EINVAL;
                }