fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / alpha / kernel / pci.c
index 1e3abbb..3c10b9a 100644 (file)
@@ -12,7 +12,6 @@
  * Nov 2000, Ivan Kokshaysky <ink@jurassic.park.msu.ru>
  *          PCI-PCI bridges cleanup
  */
-#include <linux/config.h>
 #include <linux/string.h>
 #include <linux/pci.h>
 #include <linux/init.h>
@@ -67,6 +66,7 @@ quirk_isa_bridge(struct pci_dev *dev)
 {
        dev->class = PCI_CLASS_BRIDGE_ISA << 8;
 }
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82378, quirk_isa_bridge);
 
 static void __init
 quirk_cypress(struct pci_dev *dev)
@@ -100,6 +100,7 @@ quirk_cypress(struct pci_dev *dev)
                }
        }
 }
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693, quirk_cypress);
 
 /* Called for each device after PCI setup is done. */
 static void __init
@@ -112,29 +113,22 @@ pcibios_fixup_final(struct pci_dev *dev)
                isa_bridge = dev;
        }
 }
+DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_final);
 
-struct pci_fixup pcibios_fixups[] __initdata = {
-       { PCI_FIXUP_HEADER, PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82378,
-         quirk_isa_bridge },
-       { PCI_FIXUP_HEADER, PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693,
-         quirk_cypress },
-       { PCI_FIXUP_FINAL,  PCI_ANY_ID, PCI_ANY_ID,
-         pcibios_fixup_final },
-       { 0 }
-};
-
+/* Just declaring that the power-of-ten prefixes are actually the
+   power-of-two ones doesn't make it true :) */
 #define KB                     1024
 #define MB                     (1024*KB)
 #define GB                     (1024*MB)
 
 void
 pcibios_align_resource(void *data, struct resource *res,
-                      unsigned long size, unsigned long align)
+                      resource_size_t size, resource_size_t align)
 {
        struct pci_dev *dev = data;
        struct pci_controller *hose = dev->sysdata;
        unsigned long alignto;
-       unsigned long start = res->start;
+       resource_size_t start = res->start;
 
        if (res->flags & IORESOURCE_IO) {
                /* Make sure we start at our min on all hoses */
@@ -232,7 +226,7 @@ pdev_save_srm_config(struct pci_dev *dev)
        tmp->next = srm_saved_configs;
        tmp->dev = dev;
 
-       pci_save_state(dev, tmp->regs);
+       pci_save_state(dev);
 
        srm_saved_configs = tmp;
 }
@@ -248,7 +242,7 @@ pci_restore_srm_config(void)
 
        /* Restore SRM config. */
        for (tmp = srm_saved_configs; tmp; tmp = tmp->next) {
-               pci_restore_state(tmp->dev, tmp->regs);
+               pci_restore_state(tmp->dev);
        }
 }
 #endif
@@ -285,7 +279,6 @@ pcibios_fixup_bus(struct pci_bus *bus)
        /* Propagate hose info into the subordinate devices.  */
 
        struct pci_controller *hose = bus->sysdata;
-       struct list_head *ln;
        struct pci_dev *dev = bus->self;
 
        if (!dev) {
@@ -309,9 +302,7 @@ pcibios_fixup_bus(struct pci_bus *bus)
                pcibios_fixup_device_resources(dev, bus);
        } 
 
-       for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
-               struct pci_dev *dev = pci_dev_b(ln);
-
+       list_for_each_entry(dev, &bus->devices, bus_list) {
                pdev_save_srm_config(dev);
                if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
                        pcibios_fixup_device_resources(dev, bus);
@@ -358,8 +349,24 @@ pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
        region->end = res->end - offset;
 }
 
+void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
+                            struct pci_bus_region *region)
+{
+       struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
+       unsigned long offset = 0;
+
+       if (res->flags & IORESOURCE_IO)
+               offset = hose->io_space->start;
+       else if (res->flags & IORESOURCE_MEM)
+               offset = hose->mem_space->start;
+
+       res->start = region->start + offset;
+       res->end = region->end + offset;
+}
+
 #ifdef CONFIG_HOTPLUG
 EXPORT_SYMBOL(pcibios_resource_to_bus);
+EXPORT_SYMBOL(pcibios_bus_to_resource);
 #endif
 
 int
@@ -408,11 +415,10 @@ pcibios_set_master(struct pci_dev *dev)
 static void __init
 pcibios_claim_one_bus(struct pci_bus *b)
 {
-       struct list_head *ld;
+       struct pci_dev *dev;
        struct pci_bus *child_bus;
 
-       for (ld = b->devices.next; ld != &b->devices; ld = ld->next) {
-               struct pci_dev *dev = pci_dev_b(ld);
+       list_for_each_entry(dev, &b->devices, bus_list) {
                int i;
 
                for (i = 0; i < PCI_NUM_RESOURCES; i++) {
@@ -431,12 +437,10 @@ pcibios_claim_one_bus(struct pci_bus *b)
 static void __init
 pcibios_claim_console_setup(void)
 {
-       struct list_head *lb;
+       struct pci_bus *b;
 
-       for(lb = pci_root_buses.next; lb != &pci_root_buses; lb = lb->next) {
-               struct pci_bus *b = pci_bus_b(lb);
+       list_for_each_entry(b, &pci_root_buses, node)
                pcibios_claim_one_bus(b);
-       }
 }
 
 void __init
@@ -512,10 +516,11 @@ sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
                if (bus == 0 && dfn == 0) {
                        hose = pci_isa_hose;
                } else {
-                       dev = pci_find_slot(bus, dfn);
+                       dev = pci_get_bus_and_slot(bus, dfn);
                        if (!dev)
                                return -ENODEV;
                        hose = dev->sysdata;
+                       pci_dev_put(dev);
                }
        }
 
@@ -536,3 +541,37 @@ sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
 
        return -EOPNOTSUPP;
 }
+
+/* Create an __iomem token from a PCI BAR.  Copied from lib/iomap.c with
+   no changes, since we don't want the other things in that object file.  */
+
+void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
+{
+       unsigned long start = pci_resource_start(dev, bar);
+       unsigned long len = pci_resource_len(dev, bar);
+       unsigned long flags = pci_resource_flags(dev, bar);
+
+       if (!len || !start)
+               return NULL;
+       if (maxlen && len > maxlen)
+               len = maxlen;
+       if (flags & IORESOURCE_IO)
+               return ioport_map(start, len);
+       if (flags & IORESOURCE_MEM) {
+               /* Not checking IORESOURCE_CACHEABLE because alpha does
+                  not distinguish between ioremap and ioremap_nocache.  */
+               return ioremap(start, len);
+       }
+       return NULL;
+}
+
+/* Destroy that token.  Not copied from lib/iomap.c.  */
+
+void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
+{
+       if (__is_mmio(addr))
+               iounmap(addr);
+}
+
+EXPORT_SYMBOL(pci_iomap);
+EXPORT_SYMBOL(pci_iounmap);