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