aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/ppc/kernel/pci.c21
-rw-r--r--arch/ppc64/kernel/pci.c22
2 files changed, 39 insertions, 4 deletions
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c
index 6d7b92d72458..70cfb6ffd877 100644
--- a/arch/ppc/kernel/pci.c
+++ b/arch/ppc/kernel/pci.c
@@ -1495,7 +1495,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev,
1495 *offset += hose->pci_mem_offset; 1495 *offset += hose->pci_mem_offset;
1496 res_bit = IORESOURCE_MEM; 1496 res_bit = IORESOURCE_MEM;
1497 } else { 1497 } else {
1498 io_offset = (unsigned long)hose->io_base_virt; 1498 io_offset = hose->io_base_virt - ___IO_BASE;
1499 *offset += io_offset; 1499 *offset += io_offset;
1500 res_bit = IORESOURCE_IO; 1500 res_bit = IORESOURCE_IO;
1501 } 1501 }
@@ -1522,7 +1522,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev,
1522 1522
1523 /* found it! construct the final physical address */ 1523 /* found it! construct the final physical address */
1524 if (mmap_state == pci_mmap_io) 1524 if (mmap_state == pci_mmap_io)
1525 *offset += hose->io_base_phys - _IO_BASE; 1525 *offset += hose->io_base_phys - io_offset;
1526 return rp; 1526 return rp;
1527 } 1527 }
1528 1528
@@ -1739,6 +1739,23 @@ long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn)
1739 return result; 1739 return result;
1740} 1740}
1741 1741
1742void pci_resource_to_user(const struct pci_dev *dev, int bar,
1743 const struct resource *rsrc,
1744 u64 *start, u64 *end)
1745{
1746 struct pci_controller *hose = pci_bus_to_hose(dev->bus->number);
1747 unsigned long offset = 0;
1748
1749 if (hose == NULL)
1750 return;
1751
1752 if (rsrc->flags & IORESOURCE_IO)
1753 offset = ___IO_BASE - hose->io_base_virt + hose->io_base_phys;
1754
1755 *start = rsrc->start + offset;
1756 *end = rsrc->end + offset;
1757}
1758
1742void __init 1759void __init
1743pci_init_resource(struct resource *res, unsigned long start, unsigned long end, 1760pci_init_resource(struct resource *res, unsigned long start, unsigned long end,
1744 int flags, char *name) 1761 int flags, char *name)
diff --git a/arch/ppc64/kernel/pci.c b/arch/ppc64/kernel/pci.c
index 580676f87d23..ae6f579d3fa0 100644
--- a/arch/ppc64/kernel/pci.c
+++ b/arch/ppc64/kernel/pci.c
@@ -351,7 +351,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev,
351 *offset += hose->pci_mem_offset; 351 *offset += hose->pci_mem_offset;
352 res_bit = IORESOURCE_MEM; 352 res_bit = IORESOURCE_MEM;
353 } else { 353 } else {
354 io_offset = (unsigned long)hose->io_base_virt; 354 io_offset = (unsigned long)hose->io_base_virt - pci_io_base;
355 *offset += io_offset; 355 *offset += io_offset;
356 res_bit = IORESOURCE_IO; 356 res_bit = IORESOURCE_IO;
357 } 357 }
@@ -378,7 +378,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev,
378 378
379 /* found it! construct the final physical address */ 379 /* found it! construct the final physical address */
380 if (mmap_state == pci_mmap_io) 380 if (mmap_state == pci_mmap_io)
381 *offset += hose->io_base_phys - io_offset; 381 *offset += hose->io_base_phys - io_offset;
382 return rp; 382 return rp;
383 } 383 }
384 384
@@ -944,4 +944,22 @@ int pci_read_irq_line(struct pci_dev *pci_dev)
944} 944}
945EXPORT_SYMBOL(pci_read_irq_line); 945EXPORT_SYMBOL(pci_read_irq_line);
946 946
947void pci_resource_to_user(const struct pci_dev *dev, int bar,
948 const struct resource *rsrc,
949 u64 *start, u64 *end)
950{
951 struct pci_controller *hose = pci_bus_to_host(dev->bus);
952 unsigned long offset = 0;
953
954 if (hose == NULL)
955 return;
956
957 if (rsrc->flags & IORESOURCE_IO)
958 offset = pci_io_base - (unsigned long)hose->io_base_virt +
959 hose->io_base_phys;
960
961 *start = rsrc->start + offset;
962 *end = rsrc->end + offset;
963}
964
947#endif /* CONFIG_PPC_MULTIPLATFORM */ 965#endif /* CONFIG_PPC_MULTIPLATFORM */