diff options
Diffstat (limited to 'arch/sparc/lib/iomap.c')
| -rw-r--r-- | arch/sparc/lib/iomap.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/arch/sparc/lib/iomap.c b/arch/sparc/lib/iomap.c new file mode 100644 index 000000000000..54501c1ca785 --- /dev/null +++ b/arch/sparc/lib/iomap.c | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | /* | ||
| 2 | * Implement the sparc iomap interfaces | ||
| 3 | */ | ||
| 4 | #include <linux/pci.h> | ||
| 5 | #include <linux/module.h> | ||
| 6 | #include <asm/io.h> | ||
| 7 | |||
| 8 | /* Create a virtual mapping cookie for an IO port range */ | ||
| 9 | void __iomem *ioport_map(unsigned long port, unsigned int nr) | ||
| 10 | { | ||
| 11 | return (void __iomem *) (unsigned long) port; | ||
| 12 | } | ||
| 13 | |||
| 14 | void ioport_unmap(void __iomem *addr) | ||
| 15 | { | ||
| 16 | /* Nothing to do */ | ||
| 17 | } | ||
| 18 | EXPORT_SYMBOL(ioport_map); | ||
| 19 | EXPORT_SYMBOL(ioport_unmap); | ||
| 20 | |||
| 21 | /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ | ||
| 22 | void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) | ||
| 23 | { | ||
| 24 | unsigned long start = pci_resource_start(dev, bar); | ||
| 25 | unsigned long len = pci_resource_len(dev, bar); | ||
| 26 | unsigned long flags = pci_resource_flags(dev, bar); | ||
| 27 | |||
| 28 | if (!len || !start) | ||
| 29 | return NULL; | ||
| 30 | if (maxlen && len > maxlen) | ||
| 31 | len = maxlen; | ||
| 32 | if (flags & IORESOURCE_IO) | ||
| 33 | return ioport_map(start, len); | ||
| 34 | if (flags & IORESOURCE_MEM) { | ||
| 35 | if (flags & IORESOURCE_CACHEABLE) | ||
| 36 | return ioremap(start, len); | ||
| 37 | return ioremap_nocache(start, len); | ||
| 38 | } | ||
| 39 | /* What? */ | ||
| 40 | return NULL; | ||
| 41 | } | ||
| 42 | |||
| 43 | void pci_iounmap(struct pci_dev *dev, void __iomem * addr) | ||
| 44 | { | ||
| 45 | /* nothing to do */ | ||
| 46 | } | ||
| 47 | EXPORT_SYMBOL(pci_iomap); | ||
| 48 | EXPORT_SYMBOL(pci_iounmap); | ||
