blob: 79847886be95ddef9cc4cd309b00225a36ba77df [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Masahiro Yamadaffde0cc2015-05-15 22:05:18 +09002
3#ifndef _LINUX_IO_H
4#define _LINUX_IO_H
5
Masahiro Yamada332b8292016-06-28 10:48:42 +09006#include <linux/compiler.h>
7#include <linux/types.h>
Masahiro Yamadaffde0cc2015-05-15 22:05:18 +09008#include <asm/io.h>
9
Bin Mengb95e9db2018-10-15 02:21:15 -070010#ifndef CONFIG_HAVE_ARCH_IOMAP
Masahiro Yamadae632f5e2017-08-26 01:02:39 +090011static inline u8 ioread8(const volatile void __iomem *addr)
12{
13 return readb(addr);
14}
15
16static inline u16 ioread16(const volatile void __iomem *addr)
17{
18 return readw(addr);
19}
20
21static inline u32 ioread32(const volatile void __iomem *addr)
22{
23 return readl(addr);
24}
Bin Mengb95e9db2018-10-15 02:21:15 -070025#endif /* !CONFIG_HAVE_ARCH_IOMAP */
Masahiro Yamadae632f5e2017-08-26 01:02:39 +090026
27#ifdef CONFIG_64BIT
28static inline u64 ioread64(const volatile void __iomem *addr)
29{
30 return readq(addr);
31}
32#endif /* CONFIG_64BIT */
33
Bin Mengb95e9db2018-10-15 02:21:15 -070034#ifndef CONFIG_HAVE_ARCH_IOMAP
Masahiro Yamadae632f5e2017-08-26 01:02:39 +090035static inline void iowrite8(u8 value, volatile void __iomem *addr)
36{
37 writeb(value, addr);
38}
39
40static inline void iowrite16(u16 value, volatile void __iomem *addr)
41{
42 writew(value, addr);
43}
44
45static inline void iowrite32(u32 value, volatile void __iomem *addr)
46{
47 writel(value, addr);
48}
Bin Mengb95e9db2018-10-15 02:21:15 -070049#endif /* !CONFIG_HAVE_ARCH_IOMAP */
Masahiro Yamadae632f5e2017-08-26 01:02:39 +090050
51#ifdef CONFIG_64BIT
52static inline void iowrite64(u64 value, volatile void __iomem *addr)
53{
54 writeq(value, addr);
55}
56#endif /* CONFIG_64BIT */
57
Masahiro Yamada332b8292016-06-28 10:48:42 +090058#ifndef CONFIG_HAVE_ARCH_IOREMAP
59static inline void __iomem *ioremap(resource_size_t offset,
60 resource_size_t size)
61{
62 return (void __iomem *)(unsigned long)offset;
63}
64
65static inline void iounmap(void __iomem *addr)
66{
67}
Philippe Reynes98f50432019-03-15 15:14:34 +010068#endif
Masahiro Yamada332b8292016-06-28 10:48:42 +090069
70#define devm_ioremap(dev, offset, size) ioremap(offset, size)
Masahiro Yamada332b8292016-06-28 10:48:42 +090071
Masahiro Yamadaffde0cc2015-05-15 22:05:18 +090072#endif /* _LINUX_IO_H */