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