iomap.c 1.4 KB

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