1 /* SPDX-License-Identifier: GPL-2.0+ */
2
3 #ifndef _LINUX_IO_H
4 #define _LINUX_IO_H
5
6 #include <linux/compiler.h>
7 #include <linux/types.h>
8 #include <asm/io.h>
9
ioread8(const volatile void __iomem * addr)10 static inline u8 ioread8(const volatile void __iomem *addr)
11 {
12 return readb(addr);
13 }
14
ioread16(const volatile void __iomem * addr)15 static inline u16 ioread16(const volatile void __iomem *addr)
16 {
17 return readw(addr);
18 }
19
ioread32(const volatile void __iomem * addr)20 static inline u32 ioread32(const volatile void __iomem *addr)
21 {
22 return readl(addr);
23 }
24
25 #ifdef CONFIG_64BIT
ioread64(const volatile void __iomem * addr)26 static inline u64 ioread64(const volatile void __iomem *addr)
27 {
28 return readq(addr);
29 }
30 #endif /* CONFIG_64BIT */
31
iowrite8(u8 value,volatile void __iomem * addr)32 static inline void iowrite8(u8 value, volatile void __iomem *addr)
33 {
34 writeb(value, addr);
35 }
36
iowrite16(u16 value,volatile void __iomem * addr)37 static inline void iowrite16(u16 value, volatile void __iomem *addr)
38 {
39 writew(value, addr);
40 }
41
iowrite32(u32 value,volatile void __iomem * addr)42 static inline void iowrite32(u32 value, volatile void __iomem *addr)
43 {
44 writel(value, addr);
45 }
46
47 #ifdef CONFIG_64BIT
iowrite64(u64 value,volatile void __iomem * addr)48 static inline void iowrite64(u64 value, volatile void __iomem *addr)
49 {
50 writeq(value, addr);
51 }
52 #endif /* CONFIG_64BIT */
53
54 #ifndef CONFIG_HAVE_ARCH_IOREMAP
ioremap(resource_size_t offset,resource_size_t size)55 static inline void __iomem *ioremap(resource_size_t offset,
56 resource_size_t size)
57 {
58 return (void __iomem *)(unsigned long)offset;
59 }
60
iounmap(void __iomem * addr)61 static inline void iounmap(void __iomem *addr)
62 {
63 }
64
65 #define devm_ioremap(dev, offset, size) ioremap(offset, size)
66 #endif
67
68 #endif /* _LINUX_IO_H */
69