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