]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/ia64/pci/pci.c
[IA64] pci_acpi_scan_root cleanup
[linux-2.6-omap-h63xx.git] / arch / ia64 / pci / pci.c
index 488e48a5deeaefd75d390df505a59288ccb828f4..7545037a86254f1f5da925f9b96f80fafcfc1a33 100644 (file)
@@ -43,8 +43,7 @@
 #define PCI_SAL_EXT_ADDRESS(seg, bus, devfn, reg)      \
        (((u64) seg << 28) | (bus << 20) | (devfn << 12) | (reg))
 
-static int
-pci_sal_read (unsigned int seg, unsigned int bus, unsigned int devfn,
+int raw_pci_read(unsigned int seg, unsigned int bus, unsigned int devfn,
              int reg, int len, u32 *value)
 {
        u64 addr, data = 0;
@@ -68,8 +67,7 @@ pci_sal_read (unsigned int seg, unsigned int bus, unsigned int devfn,
        return 0;
 }
 
-static int
-pci_sal_write (unsigned int seg, unsigned int bus, unsigned int devfn,
+int raw_pci_write(unsigned int seg, unsigned int bus, unsigned int devfn,
               int reg, int len, u32 value)
 {
        u64 addr;
@@ -91,24 +89,17 @@ pci_sal_write (unsigned int seg, unsigned int bus, unsigned int devfn,
        return 0;
 }
 
-static struct pci_raw_ops pci_sal_ops = {
-       .read =         pci_sal_read,
-       .write =        pci_sal_write
-};
-
-struct pci_raw_ops *raw_pci_ops = &pci_sal_ops;
-
-static int
-pci_read (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
+static int pci_read(struct pci_bus *bus, unsigned int devfn, int where,
+                                                       int size, u32 *value)
 {
-       return raw_pci_ops->read(pci_domain_nr(bus), bus->number,
+       return raw_pci_read(pci_domain_nr(bus), bus->number,
                                 devfn, where, size, value);
 }
 
-static int
-pci_write (struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
+static int pci_write(struct pci_bus *bus, unsigned int devfn, int where,
+                                                       int size, u32 value)
 {
-       return raw_pci_ops->write(pci_domain_nr(bus), bus->number,
+       return raw_pci_write(pci_domain_nr(bus), bus->number,
                                  devfn, where, size, value);
 }
 
@@ -333,7 +324,6 @@ pcibios_setup_root_windows(struct pci_bus *bus, struct pci_controller *ctrl)
 struct pci_bus * __devinit
 pci_acpi_scan_root(struct acpi_device *device, int domain, int bus)
 {
-       struct pci_root_info info;
        struct pci_controller *controller;
        unsigned int windows = 0;
        struct pci_bus *pbus;
@@ -355,23 +345,30 @@ pci_acpi_scan_root(struct acpi_device *device, int domain, int bus)
        acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window,
                        &windows);
        if (windows) {
+               struct pci_root_info info;
+
                controller->window =
                        kmalloc_node(sizeof(*controller->window) * windows,
                                     GFP_KERNEL, controller->node);
                if (!controller->window)
                        goto out2;
-       }
-
-       name = kmalloc(16, GFP_KERNEL);
-       if (!name)
-               goto out3;
 
-       sprintf(name, "PCI Bus %04x:%02x", domain, bus);
-       info.controller = controller;
-       info.name = name;
-       acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window,
-                       &info);
+               name = kmalloc(16, GFP_KERNEL);
+               if (!name)
+                       goto out3;
 
+               sprintf(name, "PCI Bus %04x:%02x", domain, bus);
+               info.controller = controller;
+               info.name = name;
+               acpi_walk_resources(device->handle, METHOD_NAME__CRS,
+                       add_window, &info);
+       }
+       /*
+        * See arch/x86/pci/acpi.c.
+        * The desired pci bus might already be scanned in a quirk. We
+        * should handle the case here, but it appears that IA64 hasn't
+        * such quirk. So we just ignore the case now.
+        */
        pbus = pci_scan_bus_parented(NULL, bus, &pci_root_ops, controller);
        if (pbus)
                pcibios_setup_root_windows(pbus, controller);
@@ -508,54 +505,12 @@ pcibios_update_irq (struct pci_dev *dev, int irq)
        /* ??? FIXME -- record old value for shutdown.  */
 }
 
-static inline int
-pcibios_enable_resources (struct pci_dev *dev, int mask)
-{
-       u16 cmd, old_cmd;
-       int idx;
-       struct resource *r;
-       unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
-
-       if (!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 desired resources.  */
-               if (!(mask & (1 << idx)))
-                       continue;
-
-               r = &dev->resource[idx];
-               if (!(r->flags & type_mask))
-                       continue;
-               if ((idx == PCI_ROM_RESOURCE) &&
-                               (!(r->flags & IORESOURCE_ROM_ENABLE)))
-                       continue;
-               if (!r->start && r->end) {
-                       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;
-}
-
 int
 pcibios_enable_device (struct pci_dev *dev, int mask)
 {
        int ret;
 
-       ret = pcibios_enable_resources(dev, mask);
+       ret = pci_enable_resources(dev, mask);
        if (ret < 0)
                return ret;
 
@@ -774,7 +729,7 @@ static void __init set_pci_cacheline_size(void)
        status = ia64_pal_cache_summary(&levels, &unique_caches);
        if (status != 0) {
                printk(KERN_ERR "%s: ia64_pal_cache_summary() failed "
-                       "(status=%ld)\n", __FUNCTION__, status);
+                       "(status=%ld)\n", __func__, status);
                return;
        }
 
@@ -782,7 +737,7 @@ static void __init set_pci_cacheline_size(void)
                                /* cache_type (data_or_unified)= */ 2, &cci);
        if (status != 0) {
                printk(KERN_ERR "%s: ia64_pal_cache_config_info() failed "
-                       "(status=%ld)\n", __FUNCTION__, status);
+                       "(status=%ld)\n", __func__, status);
                return;
        }
        pci_cache_line_size = (1 << cci.pcci_line_size) / 4;