fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / mips / pci / pci.c
index eacfcda..5ace368 100644 (file)
@@ -4,9 +4,8 @@
  * Free Software Foundation;  either version 2 of the  License, or (at your
  * option) any later version.
  *
- * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org)
+ * Copyright (C) 2003, 04 Ralf Baechle (ralf@linux-mips.org)
  */
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/bootmem.h>
@@ -14,8 +13,6 @@
 #include <linux/types.h>
 #include <linux/pci.h>
 
-#include <asm/pci_channel.h>
-
 /*
  * Indicate whether we respect the PCI setup left by the firmware.
  *
@@ -53,15 +50,15 @@ unsigned long PCIBIOS_MIN_MEM       = 0;
  */
 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 start = res->start;
+       resource_size_t start = res->start;
 
        if (res->flags & IORESOURCE_IO) {
                /* Make sure we start at our min on all hoses */
-               if (start - hose->io_resource->start < PCIBIOS_MIN_IO)
+               if (start < PCIBIOS_MIN_IO + hose->io_resource->start)
                        start = PCIBIOS_MIN_IO + hose->io_resource->start;
 
                /*
@@ -71,18 +68,13 @@ pcibios_align_resource(void *data, struct resource *res,
                        start = (start + 0x3ff) & ~0x3ff;
        } else if (res->flags & IORESOURCE_MEM) {
                /* Make sure we start at our min on all hoses */
-               if (start - hose->mem_resource->start < PCIBIOS_MIN_MEM)
+               if (start < PCIBIOS_MIN_MEM + hose->mem_resource->start)
                        start = PCIBIOS_MIN_MEM + hose->mem_resource->start;
        }
 
        res->start = start;
 }
 
-struct pci_controller * __init alloc_pci_controller(void)
-{
-       return alloc_bootmem(sizeof(struct pci_controller));
-}
-
 void __init register_pci_controller(struct pci_controller *hose)
 {
        *hose_tail = hose;
@@ -129,15 +121,20 @@ static int __init pcibios_init(void)
                if (!hose->iommu)
                        PCI_DMA_BUS_IS_PHYS = 1;
 
+               if (hose->get_busno && pci_probe_only)
+                       next_busno = (*hose->get_busno)();
+
                bus = pci_scan_bus(next_busno, hose->pci_ops, hose);
                hose->bus = bus;
                hose->need_domain_info = need_domain_info;
-               next_busno = bus->subordinate + 1;
-               /* Don't allow 8-bit bus number overflow inside the hose -
-                  reserve some space for bridges. */ 
-               if (next_busno > 224) {
-                       next_busno = 0;
-                       need_domain_info = 1;
+               if (bus) {
+                       next_busno = bus->subordinate + 1;
+                       /* Don't allow 8-bit bus number overflow inside the hose -
+                          reserve some space for bridges. */
+                       if (next_busno > 224) {
+                               next_busno = 0;
+                               need_domain_info = 1;
+                       }
                }
                continue;
 
@@ -166,7 +163,7 @@ static int pcibios_enable_resources(struct pci_dev *dev, int mask)
 
        pci_read_config_word(dev, PCI_COMMAND, &cmd);
        old_cmd = cmd;
-       for(idx=0; idx<6; idx++) {
+       for (idx=0; idx < PCI_NUM_RESOURCES; idx++) {
                /* Only set up the requested stuff */
                if (!(mask & (1<<idx)))
                        continue;
@@ -223,7 +220,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
        if ((err = pcibios_enable_resources(dev, mask)) < 0)
                return err;
 
-       return 0;
+       return pcibios_plat_dev_init(dev);
 }
 
 static void __init pcibios_fixup_device_resources(struct pci_dev *dev,
@@ -231,7 +228,7 @@ static void __init pcibios_fixup_device_resources(struct pci_dev *dev,
 {
        /* Update device resources.  */
        struct pci_controller *hose = (struct pci_controller *)bus->sysdata;
-       unsigned long offset;
+       unsigned long offset = 0;
        int i;
 
        for (i = 0; i < PCI_NUM_RESOURCES; i++) {
@@ -262,7 +259,7 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
                   (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
                pci_read_bridge_bases(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);
@@ -294,8 +291,27 @@ pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
        region->end = res->end - offset;
 }
 
+void __devinit
+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_offset;
+       else if (res->flags & IORESOURCE_MEM)
+               offset = hose->mem_offset;
+
+       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);
+EXPORT_SYMBOL(PCIBIOS_MIN_IO);
+EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
 #endif
 
 char *pcibios_setup(char *str)