blob: ad41414c02803b83af94b061967cd841e94e4016 [file] [log] [blame]
Russell King59244862006-06-22 15:05:36 +01001/*
2 * linux/arch/arm/mm/iomap.c
3 *
4 * Map IO port and PCI memory spaces so that {read,write}[bwl] can
5 * be used to access this memory.
6 */
7#include <linux/module.h>
8#include <linux/pci.h>
9#include <linux/ioport.h>
Russell Kingfced80c2008-09-06 12:10:45 +010010#include <linux/io.h>
Rob Herringdc8d9662011-06-29 10:59:45 -050011#include <asm/pci.h>
Russell King59244862006-06-22 15:05:36 +010012
13#ifdef __io
14void __iomem *ioport_map(unsigned long port, unsigned int nr)
15{
16 return __io(port);
17}
18EXPORT_SYMBOL(ioport_map);
19
20void ioport_unmap(void __iomem *addr)
21{
22}
23EXPORT_SYMBOL(ioport_unmap);
24#endif
25
26#ifdef CONFIG_PCI
Rob Herringdc8d9662011-06-29 10:59:45 -050027unsigned int pci_flags = PCI_REASSIGN_ALL_RSRC;
28EXPORT_SYMBOL(pci_flags);
29
Russell King59244862006-06-22 15:05:36 +010030void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
31{
Benjamin Herrenschmidtb70d3a22008-04-29 00:59:11 -070032 resource_size_t start = pci_resource_start(dev, bar);
33 resource_size_t len = pci_resource_len(dev, bar);
Russell King59244862006-06-22 15:05:36 +010034 unsigned long flags = pci_resource_flags(dev, bar);
35
36 if (!len || !start)
37 return NULL;
38 if (maxlen && len > maxlen)
39 len = maxlen;
40 if (flags & IORESOURCE_IO)
41 return ioport_map(start, len);
42 if (flags & IORESOURCE_MEM) {
43 if (flags & IORESOURCE_CACHEABLE)
44 return ioremap(start, len);
45 return ioremap_nocache(start, len);
46 }
47 return NULL;
48}
49EXPORT_SYMBOL(pci_iomap);
50
51void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
52{
53 if ((unsigned long)addr >= VMALLOC_START &&
54 (unsigned long)addr < VMALLOC_END)
55 iounmap(addr);
56}
57EXPORT_SYMBOL(pci_iounmap);
58#endif