iomap.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. unsigned long vga_base;
  12. EXPORT_SYMBOL(vga_base);
  13. #ifdef __io
  14. void __iomem *ioport_map(unsigned long port, unsigned int nr)
  15. {
  16. return __io(port);
  17. }
  18. EXPORT_SYMBOL(ioport_map);
  19. void ioport_unmap(void __iomem *addr)
  20. {
  21. }
  22. EXPORT_SYMBOL(ioport_unmap);
  23. #endif
  24. #ifdef CONFIG_PCI
  25. unsigned long pcibios_min_io = 0x1000;
  26. EXPORT_SYMBOL(pcibios_min_io);
  27. unsigned long pcibios_min_mem = 0x01000000;
  28. EXPORT_SYMBOL(pcibios_min_mem);
  29. unsigned int pci_flags = PCI_REASSIGN_ALL_RSRC;
  30. EXPORT_SYMBOL(pci_flags);
  31. void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
  32. {
  33. resource_size_t start = pci_resource_start(dev, bar);
  34. resource_size_t len = pci_resource_len(dev, bar);
  35. unsigned long flags = pci_resource_flags(dev, bar);
  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. }
  49. EXPORT_SYMBOL(pci_iomap);
  50. void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
  51. {
  52. if ((unsigned long)addr >= VMALLOC_START &&
  53. (unsigned long)addr < VMALLOC_END)
  54. iounmap(addr);
  55. }
  56. EXPORT_SYMBOL(pci_iounmap);
  57. #endif