]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
arm/PCI: get rid of device resource fixups
authorBjorn Helgaas <bhelgaas@google.com>
Fri, 24 Feb 2012 03:19:01 +0000 (20:19 -0700)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 24 Feb 2012 03:19:01 +0000 (20:19 -0700)
Tell the PCI core about host bridge address translation so it can take
care of bus-to-resource conversion for us.

CC: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
19 files changed:
arch/arm/common/it8152.c
arch/arm/include/asm/pci.h
arch/arm/kernel/bios32.c
arch/arm/mach-cns3xxx/pcie.c
arch/arm/mach-dove/pcie.c
arch/arm/mach-footbridge/dc21285.c
arch/arm/mach-integrator/pci_v3.c
arch/arm/mach-iop13xx/pci.c
arch/arm/mach-ixp2000/pci.c
arch/arm/mach-ixp23xx/pci.c
arch/arm/mach-ixp4xx/common-pci.c
arch/arm/mach-kirkwood/pcie.c
arch/arm/mach-ks8695/pci.c
arch/arm/mach-mv78xx0/pcie.c
arch/arm/mach-orion5x/pci.c
arch/arm/mach-sa1100/pci-nanoengine.c
arch/arm/mach-tegra/pcie.c
arch/arm/mach-versatile/pci.c
arch/arm/plat-iop/pci.c

index d1bcd7b13ebc963c195fc88064fed9191984b4fe..9384c2d02baaa5249c0218a0c781f7e17f887cb0 100644 (file)
@@ -299,8 +299,8 @@ int __init it8152_pci_setup(int nr, struct pci_sys_data *sys)
                goto err1;
        }
 
-       pci_add_resource(&sys->resources, &it8152_io);
-       pci_add_resource(&sys->resources, &it8152_mem);
+       pci_add_resource_offset(&sys->resources, &it8152_io, sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &it8152_mem, sys->mem_offset);
 
        if (platform_notify || platform_notify_remove) {
                printk(KERN_ERR "PCI: Can't use platform_notify\n");
index da337ba57ffd786ebcdd20efd60d98d22976357c..4748a75ed112ee9ccc380e26c0ccc8e94a708ec0 100644 (file)
@@ -57,13 +57,7 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
                                enum pci_mmap_state mmap_state, int write_combine);
 
-extern void
-pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
-                        struct resource *res);
-
-extern void
-pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
-                       struct pci_bus_region *region);
+#define ARCH_HAS_GENERIC_PCI_OFFSETS
 
 /*
  * Dummy implementation; always return 0.
index 8d7c22d7dff89a04f7e41b98591021eef8ea891a..be5d3b23284d5d8d68b041301339da25b6132097 100644 (file)
@@ -293,28 +293,6 @@ static inline int pdev_bad_for_parity(struct pci_dev *dev)
 
 }
 
-/*
- * Adjust the device resources from bus-centric to Linux-centric.
- */
-static void __devinit
-pdev_fixup_device_resources(struct pci_sys_data *root, struct pci_dev *dev)
-{
-       resource_size_t offset;
-       int i;
-
-       for (i = 0; i < PCI_NUM_RESOURCES; i++) {
-               if (dev->resource[i].start == 0)
-                       continue;
-               if (dev->resource[i].flags & IORESOURCE_MEM)
-                       offset = root->mem_offset;
-               else
-                       offset = root->io_offset;
-
-               dev->resource[i].start += offset;
-               dev->resource[i].end   += offset;
-       }
-}
-
 /*
  * pcibios_fixup_bus - Called after each bus is probed,
  * but before its children are examined.
@@ -332,8 +310,6 @@ void pcibios_fixup_bus(struct pci_bus *bus)
        list_for_each_entry(dev, &bus->devices, bus_list) {
                u16 status;
 
-               pdev_fixup_device_resources(root, dev);
-
                pci_read_config_word(dev, PCI_STATUS, &status);
 
                /*
@@ -398,43 +374,6 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 EXPORT_SYMBOL(pcibios_fixup_bus);
 #endif
 
-/*
- * Convert from Linux-centric to bus-centric addresses for bridge devices.
- */
-void
-pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
-                        struct resource *res)
-{
-       struct pci_sys_data *root = dev->sysdata;
-       unsigned long offset = 0;
-
-       if (res->flags & IORESOURCE_IO)
-               offset = root->io_offset;
-       if (res->flags & IORESOURCE_MEM)
-               offset = root->mem_offset;
-
-       region->start = res->start - offset;
-       region->end   = res->end - offset;
-}
-EXPORT_SYMBOL(pcibios_resource_to_bus);
-
-void __devinit
-pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
-                       struct pci_bus_region *region)
-{
-       struct pci_sys_data *root = dev->sysdata;
-       unsigned long offset = 0;
-
-       if (res->flags & IORESOURCE_IO)
-               offset = root->io_offset;
-       if (res->flags & IORESOURCE_MEM)
-               offset = root->mem_offset;
-
-       res->start = region->start + offset;
-       res->end   = region->end + offset;
-}
-EXPORT_SYMBOL(pcibios_bus_to_resource);
-
 /*
  * Swizzle the device pin each time we cross a bridge.
  * This might update pin and returns the slot number.
@@ -496,10 +435,10 @@ static void __init pcibios_init_hw(struct hw_pci *hw)
 
                if (ret > 0) {
                        if (list_empty(&sys->resources)) {
-                               pci_add_resource(&sys->resources,
-                                                &ioport_resource);
-                               pci_add_resource(&sys->resources,
-                                                &iomem_resource);
+                               pci_add_resource_offset(&sys->resources,
+                                        &ioport_resource, sys->io_offset);
+                               pci_add_resource_offset(&sys->resources,
+                                        &iomem_resource, sys->mem_offset);
                        }
 
                        sys->bus = hw->scan(nr, sys);
index e159d69967c91b562ff6590d59141198447c534f..79d001f831e056046acb1780d8ba9ccf64830ad4 100644 (file)
@@ -155,8 +155,8 @@ static int cns3xxx_pci_setup(int nr, struct pci_sys_data *sys)
        BUG_ON(request_resource(&iomem_resource, res_io) ||
               request_resource(&iomem_resource, res_mem));
 
-       pci_add_resource(&sys->resources, res_io);
-       pci_add_resource(&sys->resources, res_mem);
+       pci_add_resource_offset(&sys->resources, res_io, sys->io_offset);
+       pci_add_resource_offset(&sys->resources, res_mem, sys->mem_offset);
 
        return 1;
 }
index 52e96d397ba8cfffe68b1085f3cdbf5eee2bc463..48a032005ea36c04e55c368f8bfe813ab45ec404 100644 (file)
@@ -69,7 +69,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
        pp->res[0].flags = IORESOURCE_IO;
        if (request_resource(&ioport_resource, &pp->res[0]))
                panic("Request PCIe IO resource failed\n");
-       pci_add_resource(&sys->resources, &pp->res[0]);
+       pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
 
        /*
         * IORESOURCE_MEM
@@ -88,7 +88,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
        pp->res[1].flags = IORESOURCE_MEM;
        if (request_resource(&iomem_resource, &pp->res[1]))
                panic("Request PCIe Memory resource failed\n");
-       pci_add_resource(&sys->resources, &pp->res[1]);
+       pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
 
        return 1;
 }
index f685650c25d7b00be7ca14939c41ce0cde81d812..3194d3f73503fe32efaf86cdecd46442e6afbcf9 100644 (file)
@@ -275,11 +275,13 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
        allocate_resource(&iomem_resource, &res[0], 0x40000000,
                          0x80000000, 0xffffffff, 0x40000000, NULL, NULL);
 
-       pci_add_resource(&sys->resources, &ioport_resource);
-       pci_add_resource(&sys->resources, &res[0]);
-       pci_add_resource(&sys->resources, &res[1]);
        sys->mem_offset  = DC21285_PCI_MEM;
 
+       pci_add_resource_offset(&sys->resources,
+                               &ioport_resource, sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->mem_offset);
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
+
        return 1;
 }
 
index 3c82566acece2d8296d343eceddc8dad389a93c3..015be770c1d87e04261e0d62ebec3a07ec548b40 100644 (file)
@@ -378,9 +378,10 @@ static int __init pci_v3_setup_resources(struct pci_sys_data *sys)
         * the mem resource for this bus
         * the prefetch mem resource for this bus
         */
-       pci_add_resource(&sys->resources, &ioport_resource);
-       pci_add_resource(&sys->resources, &non_mem);
-       pci_add_resource(&sys->resources, &pre_mem);
+       pci_add_resource_offset(&sys->resources,
+                               &ioport_resource, sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &non_mem, sys->mem_offset);
+       pci_add_resource_offset(&sys->resources, &pre_mem, sys->mem_offset);
 
        return 1;
 }
index b8f5a87365112d0622b017dcbd2c7507e1e2934c..861cb12ef4363b69e78e83c34b4bc0b3c1c5ccbd 100644 (file)
@@ -1084,8 +1084,8 @@ int iop13xx_pci_setup(int nr, struct pci_sys_data *sys)
        request_resource(&ioport_resource, &res[0]);
        request_resource(&iomem_resource, &res[1]);
 
-       pci_add_resource(&sys->resources, &res[0]);
-       pci_add_resource(&sys->resources, &res[1]);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
 
        return 1;
 }
index 626fda435aa921b8ecaa91d4e7e25da9abc31a01..49c36f3cd602c551be909d48a1b3f78a11616dfa 100644 (file)
@@ -243,8 +243,10 @@ int ixp2000_pci_setup(int nr, struct pci_sys_data *sys)
        if (nr >= 1)
                return 0;
 
-       pci_add_resource(&sys->resources, &ixp2000_pci_io_space);
-       pci_add_resource(&sys->resources, &ixp2000_pci_mem_space);
+       pci_add_resource_offset(&sys->resources,
+                               &ixp2000_pci_io_space, sys->io_offset);
+       pci_add_resource_offset(&sys->resources,
+                               &ixp2000_pci_mem_space, sys->mem_offset);
 
        return 1;
 }
index 25b5c462cea2015703924bf74bf591d3ababb2c5..3cbbd3208fa8994dafc8c5247d49924921aa36a7 100644 (file)
@@ -281,8 +281,10 @@ int ixp23xx_pci_setup(int nr, struct pci_sys_data *sys)
        if (nr >= 1)
                return 0;
 
-       pci_add_resource(&sys->resources, &ixp23xx_pci_io_space);
-       pci_add_resource(&sys->resources, &ixp23xx_pci_mem_space);
+       pci_add_resource_offset(&sys->resources,
+                               &ixp23xx_pci_io_space, sys->io_offset);
+       pci_add_resource_offset(&sys->resources,
+                               &ixp23xx_pci_mem_space, sys->mem_offset);
 
        return 1;
 }
index 5eff15f24bc27e5a4f12dd56dab5eaea8cf4c118..8508882b13f0303c36d2f39edf043097c05c1961 100644 (file)
@@ -472,8 +472,8 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
        request_resource(&ioport_resource, &res[0]);
        request_resource(&iomem_resource, &res[1]);
 
-       pci_add_resource(&sys->resources, &res[0]);
-       pci_add_resource(&sys->resources, &res[1]);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
 
        platform_notify = ixp4xx_pci_platform_notify;
        platform_notify_remove = ixp4xx_pci_platform_notify_remove;
index a066a6d8d9d2126bc577401b8710e16a1b40d133..f56a0118c1bb1f2fc42b09f19917706e6b1182d2 100644 (file)
@@ -198,9 +198,9 @@ static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys)
        if (request_resource(&iomem_resource, &pp->res[1]))
                panic("Request PCIe%d Memory resource failed\n", index);
 
-       pci_add_resource(&sys->resources, &pp->res[0]);
-       pci_add_resource(&sys->resources, &pp->res[1]);
        sys->io_offset = 0;
+       pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
 
        /*
         * Generic PCIe unit setup.
index b26f992071df4553df94bf2da1d8356af03cc56f..acc7014358172dc5987b7aff9c52518b9346f311 100644 (file)
@@ -169,8 +169,8 @@ static int __init ks8695_pci_setup(int nr, struct pci_sys_data *sys)
        request_resource(&iomem_resource, &pci_mem);
        request_resource(&ioport_resource, &pci_io);
 
-       pci_add_resource(&sys->resources, &pci_io);
-       pci_add_resource(&sys->resources, &pci_mem);
+       pci_add_resource_offset(&sys->resources, &pci_io, sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &pci_mem, sys->mem_offset);
 
        /* Assign and enable processor bridge */
        ks8695_local_writeconfig(PCI_BASE_ADDRESS_0, KS8695_PCIMEM_PA);
index 8459f6d7d8caff6091fe05d2862895ba94460626..df3e38055a246380a6e631de74e5aff3d3d887d8 100644 (file)
@@ -155,8 +155,8 @@ static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys)
        orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
        orion_pcie_setup(pp->base);
 
-       pci_add_resource(&sys->resources, &pp->res[0]);
-       pci_add_resource(&sys->resources, &pp->res[1]);
+       pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
 
        return 1;
 }
index 09a045f0c406c50b64275f450993874b1af18f02..d6a91948e4dc58bea1124691eb336ddfd543e4ac 100644 (file)
@@ -171,13 +171,14 @@ static int __init pcie_setup(struct pci_sys_data *sys)
        /*
         * IORESOURCE_IO
         */
+       sys->io_offset = 0;
        res[0].name = "PCIe I/O Space";
        res[0].flags = IORESOURCE_IO;
        res[0].start = ORION5X_PCIE_IO_BUS_BASE;
        res[0].end = res[0].start + ORION5X_PCIE_IO_SIZE - 1;
        if (request_resource(&ioport_resource, &res[0]))
                panic("Request PCIe IO resource failed\n");
-       pci_add_resource(&sys->resources, &res[0]);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
 
        /*
         * IORESOURCE_MEM
@@ -188,9 +189,7 @@ static int __init pcie_setup(struct pci_sys_data *sys)
        res[1].end = res[1].start + ORION5X_PCIE_MEM_SIZE - 1;
        if (request_resource(&iomem_resource, &res[1]))
                panic("Request PCIe Memory resource failed\n");
-       pci_add_resource(&sys->resources, &res[1]);
-
-       sys->io_offset = 0;
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
 
        return 1;
 }
@@ -499,13 +498,14 @@ static int __init pci_setup(struct pci_sys_data *sys)
        /*
         * IORESOURCE_IO
         */
+       sys->io_offset = 0;
        res[0].name = "PCI I/O Space";
        res[0].flags = IORESOURCE_IO;
        res[0].start = ORION5X_PCI_IO_BUS_BASE;
        res[0].end = res[0].start + ORION5X_PCI_IO_SIZE - 1;
        if (request_resource(&ioport_resource, &res[0]))
                panic("Request PCI IO resource failed\n");
-       pci_add_resource(&sys->resources, &res[0]);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
 
        /*
         * IORESOURCE_MEM
@@ -516,9 +516,7 @@ static int __init pci_setup(struct pci_sys_data *sys)
        res[1].end = res[1].start + ORION5X_PCI_MEM_SIZE - 1;
        if (request_resource(&iomem_resource, &res[1]))
                panic("Request PCI Memory resource failed\n");
-       pci_add_resource(&sys->resources, &res[1]);
-
-       sys->io_offset = 0;
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
 
        return 1;
 }
index 0d01ca788922931f854846c03203089b8ae33648..b466bca9c651a1dfed4d5ddb20850bba6bf5ae8b 100644 (file)
@@ -244,9 +244,11 @@ static int __init pci_nanoengine_setup_resources(struct pci_sys_data *sys)
                printk(KERN_ERR "PCI: unable to allocate prefetchable\n");
                return -EBUSY;
        }
-       pci_add_resource(&sys->resources, &pci_io_ports);
-       pci_add_resource(&sys->resources, &pci_non_prefetchable_memory);
-       pci_add_resource(&sys->resources, &pci_prefetchable_memory);
+       pci_add_resource_offset(&sys->resources, &pci_io_ports, sys->io_offset);
+       pci_add_resource_offset(&sys->resources,
+                               &pci_non_prefetchable_memory, sys->mem_offset);
+       pci_add_resource_offset(&sys->resources,
+                               &pci_prefetchable_memory, sys->mem_offset);
 
        return 1;
 }
index af8b634357278b5682955d7eca3f4a3f946e0895..14b29ab5d8f0d006ae4230088d9071b9ad41d234 100644 (file)
@@ -408,7 +408,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
        pp->res[0].flags = IORESOURCE_IO;
        if (request_resource(&ioport_resource, &pp->res[0]))
                panic("Request PCIe IO resource failed\n");
-       pci_add_resource(&sys->resources, &pp->res[0]);
+       pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
 
        /*
         * IORESOURCE_MEM
@@ -427,7 +427,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
        pp->res[1].flags = IORESOURCE_MEM;
        if (request_resource(&iomem_resource, &pp->res[1]))
                panic("Request PCIe Memory resource failed\n");
-       pci_add_resource(&sys->resources, &pp->res[1]);
+       pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
 
        /*
         * IORESOURCE_MEM | IORESOURCE_PREFETCH
@@ -446,7 +446,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
        pp->res[2].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
        if (request_resource(&iomem_resource, &pp->res[2]))
                panic("Request PCIe Prefetch Memory resource failed\n");
-       pci_add_resource(&sys->resources, &pp->res[2]);
+       pci_add_resource_offset(&sys->resources, &pp->res[2], sys->mem_offset);
 
        return 1;
 }
index 90069bce23bc3c4b2b1d88096e0eca5e8dde9841..51733b022d0433b2f1704f720fd93ed3a6a9af03 100644 (file)
@@ -219,9 +219,9 @@ static int __init pci_versatile_setup_resources(struct list_head *resources)
         * the mem resource for this bus
         * the prefetch mem resource for this bus
         */
-       pci_add_resource(resources, &io_mem);
-       pci_add_resource(resources, &non_mem);
-       pci_add_resource(resources, &pre_mem);
+       pci_add_resource_offset(resources, &io_mem, sys->io_offset);
+       pci_add_resource_offset(resources, &non_mem, sys->mem_offset);
+       pci_add_resource_offset(resources, &pre_mem, sys->mem_offset);
 
        goto out;
 
index f4d40a27111e57328739f9ac3111564dbcda8395..72768356447ae9b8b3aa6b56314cc172708d998d 100644 (file)
@@ -215,8 +215,8 @@ int iop3xx_pci_setup(int nr, struct pci_sys_data *sys)
        sys->mem_offset = IOP3XX_PCI_LOWER_MEM_PA - *IOP3XX_OMWTVR0;
        sys->io_offset  = IOP3XX_PCI_LOWER_IO_PA - *IOP3XX_OIOWTVR;
 
-       pci_add_resource(&sys->resources, &res[0]);
-       pci_add_resource(&sys->resources, &res[1]);
+       pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
+       pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
 
        return 1;
 }