io.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright 2006 PathScale, Inc. All Rights Reserved.
  3. *
  4. * This file is free software; you can redistribute it and/or modify
  5. * it under the terms of version 2 of the GNU General Public License
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software Foundation,
  15. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  16. */
  17. #ifndef _LINUX_IO_H
  18. #define _LINUX_IO_H
  19. #include <linux/types.h>
  20. #include <linux/init.h>
  21. #include <asm/io.h>
  22. #include <asm/page.h>
  23. struct device;
  24. __visible void __iowrite32_copy(void __iomem *to, const void *from, size_t count);
  25. void __iowrite64_copy(void __iomem *to, const void *from, size_t count);
  26. #ifdef CONFIG_MMU
  27. int ioremap_page_range(unsigned long addr, unsigned long end,
  28. phys_addr_t phys_addr, pgprot_t prot);
  29. #else
  30. static inline int ioremap_page_range(unsigned long addr, unsigned long end,
  31. phys_addr_t phys_addr, pgprot_t prot)
  32. {
  33. return 0;
  34. }
  35. #endif
  36. #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
  37. void __init ioremap_huge_init(void);
  38. int arch_ioremap_pud_supported(void);
  39. int arch_ioremap_pmd_supported(void);
  40. #else
  41. static inline void ioremap_huge_init(void) { }
  42. #endif
  43. /*
  44. * Managed iomap interface
  45. */
  46. #ifdef CONFIG_HAS_IOPORT_MAP
  47. void __iomem * devm_ioport_map(struct device *dev, unsigned long port,
  48. unsigned int nr);
  49. void devm_ioport_unmap(struct device *dev, void __iomem *addr);
  50. #else
  51. static inline void __iomem *devm_ioport_map(struct device *dev,
  52. unsigned long port,
  53. unsigned int nr)
  54. {
  55. return NULL;
  56. }
  57. static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr)
  58. {
  59. }
  60. #endif
  61. #define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)
  62. void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
  63. resource_size_t size);
  64. void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
  65. resource_size_t size);
  66. void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
  67. resource_size_t size);
  68. void devm_iounmap(struct device *dev, void __iomem *addr);
  69. int check_signature(const volatile void __iomem *io_addr,
  70. const unsigned char *signature, int length);
  71. void devm_ioremap_release(struct device *dev, void *res);
  72. void *devm_memremap(struct device *dev, resource_size_t offset,
  73. size_t size, unsigned long flags);
  74. void devm_memunmap(struct device *dev, void *addr);
  75. /*
  76. * Some systems do not have legacy ISA devices.
  77. * /dev/port is not a valid interface on these systems.
  78. * So for those archs, <asm/io.h> should define the following symbol.
  79. */
  80. #ifndef arch_has_dev_port
  81. #define arch_has_dev_port() (1)
  82. #endif
  83. /*
  84. * Some systems (x86 without PAT) have a somewhat reliable way to mark a
  85. * physical address range such that uncached mappings will actually
  86. * end up write-combining. This facility should be used in conjunction
  87. * with pgprot_writecombine, ioremap-wc, or set_memory_wc, since it has
  88. * no effect if the per-page mechanisms are functional.
  89. * (On x86 without PAT, these functions manipulate MTRRs.)
  90. *
  91. * arch_phys_del_wc(0) or arch_phys_del_wc(any error code) is guaranteed
  92. * to have no effect.
  93. */
  94. #ifndef arch_phys_wc_add
  95. static inline int __must_check arch_phys_wc_add(unsigned long base,
  96. unsigned long size)
  97. {
  98. return 0; /* It worked (i.e. did nothing). */
  99. }
  100. static inline void arch_phys_wc_del(int handle)
  101. {
  102. }
  103. #define arch_phys_wc_add arch_phys_wc_add
  104. #ifndef arch_phys_wc_index
  105. static inline int arch_phys_wc_index(int handle)
  106. {
  107. return -1;
  108. }
  109. #define arch_phys_wc_index arch_phys_wc_index
  110. #endif
  111. #endif
  112. enum {
  113. /* See memremap() kernel-doc for usage description... */
  114. MEMREMAP_WB = 1 << 0,
  115. MEMREMAP_WT = 1 << 1,
  116. };
  117. void *memremap(resource_size_t offset, size_t size, unsigned long flags);
  118. void memunmap(void *addr);
  119. #endif /* _LINUX_IO_H */