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 10 #ifndef CONFIG_HAVE_ARCH_IOMAP 11 static inline u8 ioread8(const volatile void __iomem *addr) 12 { 13 return readb(addr); 14 } 15 16 static inline u16 ioread16(const volatile void __iomem *addr) 17 { 18 return readw(addr); 19 } 20 21 static inline u32 ioread32(const volatile void __iomem *addr) 22 { 23 return readl(addr); 24 } 25 #endif /* !CONFIG_HAVE_ARCH_IOMAP */ 26 27 #ifdef CONFIG_64BIT 28 static inline u64 ioread64(const volatile void __iomem *addr) 29 { 30 return readq(addr); 31 } 32 #endif /* CONFIG_64BIT */ 33 34 #ifndef CONFIG_HAVE_ARCH_IOMAP 35 static inline void iowrite8(u8 value, volatile void __iomem *addr) 36 { 37 writeb(value, addr); 38 } 39 40 static inline void iowrite16(u16 value, volatile void __iomem *addr) 41 { 42 writew(value, addr); 43 } 44 45 static inline void iowrite32(u32 value, volatile void __iomem *addr) 46 { 47 writel(value, addr); 48 } 49 #endif /* !CONFIG_HAVE_ARCH_IOMAP */ 50 51 #ifdef CONFIG_64BIT 52 static inline void iowrite64(u64 value, volatile void __iomem *addr) 53 { 54 writeq(value, addr); 55 } 56 #endif /* CONFIG_64BIT */ 57 58 #ifndef CONFIG_HAVE_ARCH_IOREMAP 59 static inline void __iomem *ioremap(resource_size_t offset, 60 resource_size_t size) 61 { 62 return (void __iomem *)(unsigned long)offset; 63 } 64 65 static inline void iounmap(void __iomem *addr) 66 { 67 } 68 69 #define devm_ioremap(dev, offset, size) ioremap(offset, size) 70 #endif 71 72 #endif /* _LINUX_IO_H */ 73