1 /*
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>
10 #include <linux/io.h>
11
12 #ifdef __io
ioport_map(unsigned long port,unsigned int nr)13 void __iomem *ioport_map(unsigned long port, unsigned int nr)
14 {
15 return __io(port);
16 }
17 EXPORT_SYMBOL(ioport_map);
18
ioport_unmap(void __iomem * addr)19 void ioport_unmap(void __iomem *addr)
20 {
21 }
22 EXPORT_SYMBOL(ioport_unmap);
23 #endif
24
25 #ifdef CONFIG_PCI
pci_iomap(struct pci_dev * dev,int bar,unsigned long maxlen)26 void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
27 {
28 resource_size_t start = pci_resource_start(dev, bar);
29 resource_size_t len = pci_resource_len(dev, bar);
30 unsigned long flags = pci_resource_flags(dev, bar);
31
32 if (!len || !start)
33 return NULL;
34 if (maxlen && len > maxlen)
35 len = maxlen;
36 if (flags & IORESOURCE_IO)
37 return ioport_map(start, len);
38 if (flags & IORESOURCE_MEM) {
39 if (flags & IORESOURCE_CACHEABLE)
40 return ioremap(start, len);
41 return ioremap_nocache(start, len);
42 }
43 return NULL;
44 }
45 EXPORT_SYMBOL(pci_iomap);
46
pci_iounmap(struct pci_dev * dev,void __iomem * addr)47 void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
48 {
49 if ((unsigned long)addr >= VMALLOC_START &&
50 (unsigned long)addr < VMALLOC_END)
51 iounmap(addr);
52 }
53 EXPORT_SYMBOL(pci_iounmap);
54 #endif
55