iomap.h 3.3 KB

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