iomap.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef __GENERIC_IO_H
  2. #define __GENERIC_IO_H
  3. #include <linux/linkage.h>
  4. #include <asm/byteorder.h>
  5. /*
  6. * These are the "generic" interfaces for doing new-style
  7. * memory-mapped or PIO accesses. Architectures may do
  8. * their own arch-optimized versions, these just act as
  9. * wrappers around the old-style IO register access functions:
  10. * read[bwl]/write[bwl]/in[bwl]/out[bwl]
  11. *
  12. * Don't include this directly, include it from <asm/io.h>.
  13. */
  14. /*
  15. * Read/write from/to an (offsettable) iomem cookie. It might be a PIO
  16. * access or a MMIO access, these functions don't care. The info is
  17. * encoded in the hardware mapping set up by the mapping functions
  18. * (or the cookie itself, depending on implementation and hw).
  19. *
  20. * The generic routines just encode the PIO/MMIO as part of the
  21. * cookie, and coldly assume that the MMIO IO mappings are not
  22. * in the low address range. Architectures for which this is not
  23. * true can't use this generic implementation.
  24. */
  25. extern unsigned int ioread8(void __iomem *);
  26. extern unsigned int ioread16(void __iomem *);
  27. extern unsigned int ioread16be(void __iomem *);
  28. extern unsigned int ioread32(void __iomem *);
  29. extern unsigned int ioread32be(void __iomem *);
  30. #ifdef CONFIG_64BIT
  31. extern u64 ioread64(void __iomem *);
  32. extern u64 ioread64be(void __iomem *);
  33. #endif
  34. extern void iowrite8(u8, void __iomem *);
  35. extern void iowrite16(u16, void __iomem *);
  36. extern void iowrite16be(u16, void __iomem *);
  37. extern void iowrite32(u32, void __iomem *);
  38. extern void iowrite32be(u32, void __iomem *);
  39. #ifdef CONFIG_64BIT
  40. extern void iowrite64(u64, void __iomem *);
  41. extern void iowrite64be(u64, void __iomem *);
  42. #endif
  43. /*
  44. * "string" versions of the above. Note that they
  45. * use native byte ordering for the accesses (on
  46. * the assumption that IO and memory agree on a
  47. * byte order, and CPU byteorder is irrelevant).
  48. *
  49. * They do _not_ update the port address. If you
  50. * want MMIO that copies stuff laid out in MMIO
  51. * memory across multiple ports, use "memcpy_toio()"
  52. * and friends.
  53. */
  54. extern void ioread8_rep(void __iomem *port, void *buf, unsigned long count);
  55. extern void ioread16_rep(void __iomem *port, void *buf, unsigned long count);
  56. extern void ioread32_rep(void __iomem *port, void *buf, unsigned long count);
  57. extern void iowrite8_rep(void __iomem *port, const void *buf, unsigned long count);
  58. extern void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count);
  59. extern void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count);
  60. #ifdef CONFIG_HAS_IOPORT_MAP
  61. /* Create a virtual mapping cookie for an IO port range */
  62. extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
  63. extern void ioport_unmap(void __iomem *);
  64. #endif
  65. #ifndef ARCH_HAS_IOREMAP_WC
  66. #define ioremap_wc ioremap_nocache
  67. #endif
  68. #ifndef ARCH_HAS_IOREMAP_WT
  69. #define ioremap_wt ioremap_nocache
  70. #endif
  71. #ifdef CONFIG_PCI
  72. /* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */
  73. struct pci_dev;
  74. extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
  75. #elif defined(CONFIG_GENERIC_IOMAP)
  76. struct pci_dev;
  77. static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
  78. { }
  79. #endif
  80. #include <asm-generic/pci_iomap.h>
  81. #endif