aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/drivers/pci/pci-lib.c
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2009-04-20 03:38:00 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-04-20 03:38:00 -0400
commit0bb34a6bf1f71d5ad2abfda582a2c2794957bc7b (patch)
tree2ac5a8400ac65001b78f173b51bd41b0f38d9376 /arch/sh/drivers/pci/pci-lib.c
parent394b6d2fe624246e258a218dac68d44fe9a8411f (diff)
sh: pci: Consolidate pci_iomap() and use the generic I/O base.
This consolidates the pci_iomap() definitions and reworks how the I/O port base is handled. PCI channels can register their own I/O map base, or if none is provided, the system-wide generic I/O base is used instead. Functionally nothing changes, while this allows us to kill off lots of I/O address special casing and lookups. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/drivers/pci/pci-lib.c')
-rw-r--r--arch/sh/drivers/pci/pci-lib.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/arch/sh/drivers/pci/pci-lib.c b/arch/sh/drivers/pci/pci-lib.c
index 8ab1a2d1b48..654ffcc67d0 100644
--- a/arch/sh/drivers/pci/pci-lib.c
+++ b/arch/sh/drivers/pci/pci-lib.c
@@ -60,6 +60,57 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
60 vma->vm_page_prot); 60 vma->vm_page_prot);
61} 61}
62 62
63static void __iomem *ioport_map_pci(struct pci_dev *dev,
64 unsigned long port, unsigned int nr)
65{
66 struct pci_channel *chan = dev->sysdata;
67
68 if (!chan->io_map_base)
69 chan->io_map_base = generic_io_base;
70
71 return (void __iomem *)(chan->io_map_base + port);
72}
73
74void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
75{
76 resource_size_t start = pci_resource_start(dev, bar);
77 resource_size_t len = pci_resource_len(dev, bar);
78 unsigned long flags = pci_resource_flags(dev, bar);
79
80 if (unlikely(!len || !start))
81 return NULL;
82 if (maxlen && len > maxlen)
83 len = maxlen;
84
85 if (flags & IORESOURCE_IO)
86 return ioport_map_pci(dev, start, len);
87
88 /*
89 * Presently the IORESOURCE_MEM case is a bit special, most
90 * SH7751 style PCI controllers have PCI memory at a fixed
91 * location in the address space where no remapping is desired.
92 * With the IORESOURCE_MEM case more care has to be taken
93 * to inhibit page table mapping for legacy cores, but this is
94 * punted off to __ioremap().
95 * -- PFM.
96 */
97 if (flags & IORESOURCE_MEM) {
98 if (flags & IORESOURCE_CACHEABLE)
99 return ioremap(start, len);
100
101 return ioremap_nocache(start, len);
102 }
103
104 return NULL;
105}
106EXPORT_SYMBOL(pci_iomap);
107
108void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
109{
110 iounmap(addr);
111}
112EXPORT_SYMBOL(pci_iounmap);
113
63#ifdef CONFIG_HOTPLUG 114#ifdef CONFIG_HOTPLUG
64EXPORT_SYMBOL(pcibios_resource_to_bus); 115EXPORT_SYMBOL(pcibios_resource_to_bus);
65EXPORT_SYMBOL(pcibios_bus_to_resource); 116EXPORT_SYMBOL(pcibios_bus_to_resource);