aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2012-02-23 22:19:02 -0500
committerBjorn Helgaas <bhelgaas@google.com>2012-02-23 22:19:02 -0500
commitaa23bdc0a8a29029ac4c89163a4b63a029580720 (patch)
tree14d728b6be3d3266e38d38b73bcb017f3175b31e /arch/microblaze
parent10d1cd2ba8f2f2f19ad20a38e07d91e87c40795c (diff)
microblaze/PCI: get rid of device resource fixups
Tell the PCI core about host bridge address translation so it can take care of bus-to-resource conversion for us. CC: Michal Simek <monstr@monstr.eu> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'arch/microblaze')
-rw-r--r--arch/microblaze/include/asm/pci.h8
-rw-r--r--arch/microblaze/pci/pci-common.c69
2 files changed, 4 insertions, 73 deletions
diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h
index 033137628e8a..8db01f705b3c 100644
--- a/arch/microblaze/include/asm/pci.h
+++ b/arch/microblaze/include/asm/pci.h
@@ -94,13 +94,7 @@ extern int pci_mmap_legacy_page_range(struct pci_bus *bus,
94 */ 94 */
95#define PCI_DMA_BUS_IS_PHYS (1) 95#define PCI_DMA_BUS_IS_PHYS (1)
96 96
97extern void pcibios_resource_to_bus(struct pci_dev *dev, 97#define ARCH_HAS_GENERIC_PCI_OFFSETS
98 struct pci_bus_region *region,
99 struct resource *res);
100
101extern void pcibios_bus_to_resource(struct pci_dev *dev,
102 struct resource *res,
103 struct pci_bus_region *region);
104 98
105static inline struct resource *pcibios_select_root(struct pci_dev *pdev, 99static inline struct resource *pcibios_select_root(struct pci_dev *pdev,
106 struct resource *res) 100 struct resource *res)
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 8a257a7bf713..d10403dadd2b 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -833,59 +833,6 @@ int pci_proc_domain(struct pci_bus *bus)
833 return 0; 833 return 0;
834} 834}
835 835
836void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
837 struct resource *res)
838{
839 resource_size_t offset = 0, mask = (resource_size_t)-1;
840 struct pci_controller *hose = pci_bus_to_host(dev->bus);
841
842 if (!hose)
843 return;
844 if (res->flags & IORESOURCE_IO) {
845 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
846 mask = 0xffffffffu;
847 } else if (res->flags & IORESOURCE_MEM)
848 offset = hose->pci_mem_offset;
849
850 region->start = (res->start - offset) & mask;
851 region->end = (res->end - offset) & mask;
852}
853EXPORT_SYMBOL(pcibios_resource_to_bus);
854
855void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
856 struct pci_bus_region *region)
857{
858 resource_size_t offset = 0, mask = (resource_size_t)-1;
859 struct pci_controller *hose = pci_bus_to_host(dev->bus);
860
861 if (!hose)
862 return;
863 if (res->flags & IORESOURCE_IO) {
864 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
865 mask = 0xffffffffu;
866 } else if (res->flags & IORESOURCE_MEM)
867 offset = hose->pci_mem_offset;
868 res->start = (region->start + offset) & mask;
869 res->end = (region->end + offset) & mask;
870}
871EXPORT_SYMBOL(pcibios_bus_to_resource);
872
873/* Fixup a bus resource into a linux resource */
874static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev)
875{
876 struct pci_controller *hose = pci_bus_to_host(dev->bus);
877 resource_size_t offset = 0, mask = (resource_size_t)-1;
878
879 if (res->flags & IORESOURCE_IO) {
880 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
881 mask = 0xffffffffu;
882 } else if (res->flags & IORESOURCE_MEM)
883 offset = hose->pci_mem_offset;
884
885 res->start = (res->start + offset) & mask;
886 res->end = (res->end + offset) & mask;
887}
888
889/* This header fixup will do the resource fixup for all devices as they are 836/* This header fixup will do the resource fixup for all devices as they are
890 * probed, but not for bridge ranges 837 * probed, but not for bridge ranges
891 */ 838 */
@@ -916,18 +863,11 @@ static void __devinit pcibios_fixup_resources(struct pci_dev *dev)
916 continue; 863 continue;
917 } 864 }
918 865
919 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] fixup...\n", 866 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]\n",
920 pci_name(dev), i, 867 pci_name(dev), i,
921 (unsigned long long)res->start,\ 868 (unsigned long long)res->start,\
922 (unsigned long long)res->end, 869 (unsigned long long)res->end,
923 (unsigned int)res->flags); 870 (unsigned int)res->flags);
924
925 fixup_resource(res, dev);
926
927 pr_debug("PCI:%s %016llx-%016llx\n",
928 pci_name(dev),
929 (unsigned long long)res->start,
930 (unsigned long long)res->end);
931 } 871 }
932} 872}
933DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources); 873DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources);
@@ -1020,9 +960,6 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus)
1020 (unsigned long long)res->end, 960 (unsigned long long)res->end,
1021 (unsigned int)res->flags); 961 (unsigned int)res->flags);
1022 962
1023 /* Perform fixup */
1024 fixup_resource(res, dev);
1025
1026 /* Try to detect uninitialized P2P bridge resources, 963 /* Try to detect uninitialized P2P bridge resources,
1027 * and clear them out so they get re-assigned later 964 * and clear them out so they get re-assigned later
1028 */ 965 */
@@ -1505,7 +1442,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s
1505 res->end = res->start + IO_SPACE_LIMIT; 1442 res->end = res->start + IO_SPACE_LIMIT;
1506 res->flags = IORESOURCE_IO; 1443 res->flags = IORESOURCE_IO;
1507 } 1444 }
1508 pci_add_resource(resources, res); 1445 pci_add_resource_offset(resources, res, hose->io_base_virt - _IO_BASE);
1509 1446
1510 pr_debug("PCI: PHB IO resource = %016llx-%016llx [%lx]\n", 1447 pr_debug("PCI: PHB IO resource = %016llx-%016llx [%lx]\n",
1511 (unsigned long long)res->start, 1448 (unsigned long long)res->start,
@@ -1528,7 +1465,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s
1528 res->flags = IORESOURCE_MEM; 1465 res->flags = IORESOURCE_MEM;
1529 1466
1530 } 1467 }
1531 pci_add_resource(resources, res); 1468 pci_add_resource_offset(resources, res, hose->pci_mem_offset);
1532 1469
1533 pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", 1470 pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n",
1534 i, (unsigned long long)res->start, 1471 i, (unsigned long long)res->start,