Russell King | 5924486 | 2006-06-22 15:05:36 +0100 | [diff] [blame] | 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> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 10 | #include <linux/io.h> |
Russell King | 5924486 | 2006-06-22 15:05:36 +0100 | [diff] [blame] | 11 | |
| 12 | #ifdef __io |
| 13 | void __iomem *ioport_map(unsigned long port, unsigned int nr) |
| 14 | { |
| 15 | return __io(port); |
| 16 | } |
| 17 | EXPORT_SYMBOL(ioport_map); |
| 18 | |
| 19 | void ioport_unmap(void __iomem *addr) |
| 20 | { |
| 21 | } |
| 22 | EXPORT_SYMBOL(ioport_unmap); |
| 23 | #endif |
| 24 | |
| 25 | #ifdef CONFIG_PCI |
Rob Herring | c9d95fb | 2011-06-28 21:16:13 -0500 | [diff] [blame^] | 26 | unsigned long pcibios_min_io = 0x1000; |
| 27 | EXPORT_SYMBOL(pcibios_min_io); |
| 28 | |
| 29 | unsigned long pcibios_min_mem = 0x01000000; |
| 30 | EXPORT_SYMBOL(pcibios_min_mem); |
| 31 | |
Rob Herring | dc8d966 | 2011-06-29 10:59:45 -0500 | [diff] [blame] | 32 | unsigned int pci_flags = PCI_REASSIGN_ALL_RSRC; |
| 33 | EXPORT_SYMBOL(pci_flags); |
| 34 | |
Russell King | 5924486 | 2006-06-22 15:05:36 +0100 | [diff] [blame] | 35 | void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) |
| 36 | { |
Benjamin Herrenschmidt | b70d3a2 | 2008-04-29 00:59:11 -0700 | [diff] [blame] | 37 | resource_size_t start = pci_resource_start(dev, bar); |
| 38 | resource_size_t len = pci_resource_len(dev, bar); |
Russell King | 5924486 | 2006-06-22 15:05:36 +0100 | [diff] [blame] | 39 | unsigned long flags = pci_resource_flags(dev, bar); |
| 40 | |
| 41 | if (!len || !start) |
| 42 | return NULL; |
| 43 | if (maxlen && len > maxlen) |
| 44 | len = maxlen; |
| 45 | if (flags & IORESOURCE_IO) |
| 46 | return ioport_map(start, len); |
| 47 | if (flags & IORESOURCE_MEM) { |
| 48 | if (flags & IORESOURCE_CACHEABLE) |
| 49 | return ioremap(start, len); |
| 50 | return ioremap_nocache(start, len); |
| 51 | } |
| 52 | return NULL; |
| 53 | } |
| 54 | EXPORT_SYMBOL(pci_iomap); |
| 55 | |
| 56 | void pci_iounmap(struct pci_dev *dev, void __iomem *addr) |
| 57 | { |
| 58 | if ((unsigned long)addr >= VMALLOC_START && |
| 59 | (unsigned long)addr < VMALLOC_END) |
| 60 | iounmap(addr); |
| 61 | } |
| 62 | EXPORT_SYMBOL(pci_iounmap); |
| 63 | #endif |