Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Masahiro Yamada | ffde0cc | 2015-05-15 22:05:18 +0900 | [diff] [blame] | 2 | |
| 3 | #ifndef _LINUX_IO_H |
| 4 | #define _LINUX_IO_H |
| 5 | |
Masahiro Yamada | 332b829 | 2016-06-28 10:48:42 +0900 | [diff] [blame] | 6 | #include <linux/compiler.h> |
| 7 | #include <linux/types.h> |
Masahiro Yamada | ffde0cc | 2015-05-15 22:05:18 +0900 | [diff] [blame] | 8 | #include <asm/io.h> |
| 9 | |
Bin Meng | b95e9db | 2018-10-15 02:21:15 -0700 | [diff] [blame] | 10 | #ifndef CONFIG_HAVE_ARCH_IOMAP |
Masahiro Yamada | e632f5e | 2017-08-26 01:02:39 +0900 | [diff] [blame] | 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 | } |
Bin Meng | b95e9db | 2018-10-15 02:21:15 -0700 | [diff] [blame] | 25 | #endif /* !CONFIG_HAVE_ARCH_IOMAP */ |
Masahiro Yamada | e632f5e | 2017-08-26 01:02:39 +0900 | [diff] [blame] | 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 | |
Bin Meng | b95e9db | 2018-10-15 02:21:15 -0700 | [diff] [blame] | 34 | #ifndef CONFIG_HAVE_ARCH_IOMAP |
Masahiro Yamada | e632f5e | 2017-08-26 01:02:39 +0900 | [diff] [blame] | 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 | } |
Bin Meng | b95e9db | 2018-10-15 02:21:15 -0700 | [diff] [blame] | 49 | #endif /* !CONFIG_HAVE_ARCH_IOMAP */ |
Masahiro Yamada | e632f5e | 2017-08-26 01:02:39 +0900 | [diff] [blame] | 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 | |
Masahiro Yamada | 332b829 | 2016-06-28 10:48:42 +0900 | [diff] [blame] | 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 | } |
Philippe Reynes | 98f5043 | 2019-03-15 15:14:34 +0100 | [diff] [blame] | 68 | #endif |
Masahiro Yamada | 332b829 | 2016-06-28 10:48:42 +0900 | [diff] [blame] | 69 | |
| 70 | #define devm_ioremap(dev, offset, size) ioremap(offset, size) |
Masahiro Yamada | 332b829 | 2016-06-28 10:48:42 +0900 | [diff] [blame] | 71 | |
Masahiro Yamada | ffde0cc | 2015-05-15 22:05:18 +0900 | [diff] [blame] | 72 | #endif /* _LINUX_IO_H */ |