0001
0002
0003
0004
0005
0006 #ifndef _LINUX_IO_H
0007 #define _LINUX_IO_H
0008
0009 #include <linux/types.h>
0010 #include <linux/init.h>
0011 #include <linux/bug.h>
0012 #include <linux/err.h>
0013 #include <asm/io.h>
0014 #include <asm/page.h>
0015
0016 struct device;
0017 struct resource;
0018
0019 __visible void __iowrite32_copy(void __iomem *to, const void *from, size_t count);
0020 void __ioread32_copy(void *to, const void __iomem *from, size_t count);
0021 void __iowrite64_copy(void __iomem *to, const void *from, size_t count);
0022
0023 #ifdef CONFIG_MMU
0024 int ioremap_page_range(unsigned long addr, unsigned long end,
0025 phys_addr_t phys_addr, pgprot_t prot);
0026 #else
0027 static inline int ioremap_page_range(unsigned long addr, unsigned long end,
0028 phys_addr_t phys_addr, pgprot_t prot)
0029 {
0030 return 0;
0031 }
0032 #endif
0033
0034
0035
0036
0037 #ifdef CONFIG_HAS_IOPORT_MAP
0038 void __iomem * devm_ioport_map(struct device *dev, unsigned long port,
0039 unsigned int nr);
0040 void devm_ioport_unmap(struct device *dev, void __iomem *addr);
0041 #else
0042 static inline void __iomem *devm_ioport_map(struct device *dev,
0043 unsigned long port,
0044 unsigned int nr)
0045 {
0046 return NULL;
0047 }
0048
0049 static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr)
0050 {
0051 }
0052 #endif
0053
0054 #define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)
0055
0056 void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
0057 resource_size_t size);
0058 void __iomem *devm_ioremap_uc(struct device *dev, resource_size_t offset,
0059 resource_size_t size);
0060 void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
0061 resource_size_t size);
0062 void __iomem *devm_ioremap_np(struct device *dev, resource_size_t offset,
0063 resource_size_t size);
0064 void devm_iounmap(struct device *dev, void __iomem *addr);
0065 int check_signature(const volatile void __iomem *io_addr,
0066 const unsigned char *signature, int length);
0067 void devm_ioremap_release(struct device *dev, void *res);
0068
0069 void *devm_memremap(struct device *dev, resource_size_t offset,
0070 size_t size, unsigned long flags);
0071 void devm_memunmap(struct device *dev, void *addr);
0072
0073 #ifdef CONFIG_PCI
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 #ifndef pci_remap_cfgspace
0085 #define pci_remap_cfgspace pci_remap_cfgspace
0086 static inline void __iomem *pci_remap_cfgspace(phys_addr_t offset,
0087 size_t size)
0088 {
0089 return ioremap_np(offset, size) ?: ioremap(offset, size);
0090 }
0091 #endif
0092 #endif
0093
0094
0095
0096
0097
0098
0099 #ifndef arch_has_dev_port
0100 #define arch_has_dev_port() (1)
0101 #endif
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114 #ifndef arch_phys_wc_add
0115 static inline int __must_check arch_phys_wc_add(unsigned long base,
0116 unsigned long size)
0117 {
0118 return 0;
0119 }
0120
0121 static inline void arch_phys_wc_del(int handle)
0122 {
0123 }
0124
0125 #define arch_phys_wc_add arch_phys_wc_add
0126 #ifndef arch_phys_wc_index
0127 static inline int arch_phys_wc_index(int handle)
0128 {
0129 return -1;
0130 }
0131 #define arch_phys_wc_index arch_phys_wc_index
0132 #endif
0133 #endif
0134
0135 int devm_arch_phys_wc_add(struct device *dev, unsigned long base, unsigned long size);
0136
0137 enum {
0138
0139 MEMREMAP_WB = 1 << 0,
0140 MEMREMAP_WT = 1 << 1,
0141 MEMREMAP_WC = 1 << 2,
0142 MEMREMAP_ENC = 1 << 3,
0143 MEMREMAP_DEC = 1 << 4,
0144 };
0145
0146 void *memremap(resource_size_t offset, size_t size, unsigned long flags);
0147 void memunmap(void *addr);
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158 #ifndef arch_io_reserve_memtype_wc
0159 static inline int arch_io_reserve_memtype_wc(resource_size_t base,
0160 resource_size_t size)
0161 {
0162 return 0;
0163 }
0164
0165 static inline void arch_io_free_memtype_wc(resource_size_t base,
0166 resource_size_t size)
0167 {
0168 }
0169 #endif
0170
0171 int devm_arch_io_reserve_memtype_wc(struct device *dev, resource_size_t start,
0172 resource_size_t size);
0173
0174 #endif