summaryrefslogtreecommitdiff
path: root/include/linux/io.h
blob: 79847886be95ddef9cc4cd309b00225a36ba77df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* SPDX-License-Identifier: GPL-2.0+ */

#ifndef _LINUX_IO_H
#define _LINUX_IO_H

#include <linux/compiler.h>
#include <linux/types.h>
#include <asm/io.h>

#ifndef CONFIG_HAVE_ARCH_IOMAP
static inline u8 ioread8(const volatile void __iomem *addr)
{
	return readb(addr);
}

static inline u16 ioread16(const volatile void __iomem *addr)
{
	return readw(addr);
}

static inline u32 ioread32(const volatile void __iomem *addr)
{
	return readl(addr);
}
#endif /* !CONFIG_HAVE_ARCH_IOMAP */

#ifdef CONFIG_64BIT
static inline u64 ioread64(const volatile void __iomem *addr)
{
	return readq(addr);
}
#endif /* CONFIG_64BIT */

#ifndef CONFIG_HAVE_ARCH_IOMAP
static inline void iowrite8(u8 value, volatile void __iomem *addr)
{
	writeb(value, addr);
}

static inline void iowrite16(u16 value, volatile void __iomem *addr)
{
	writew(value, addr);
}

static inline void iowrite32(u32 value, volatile void __iomem *addr)
{
	writel(value, addr);
}
#endif /* !CONFIG_HAVE_ARCH_IOMAP */

#ifdef CONFIG_64BIT
static inline void iowrite64(u64 value, volatile void __iomem *addr)
{
	writeq(value, addr);
}
#endif /* CONFIG_64BIT */

#ifndef CONFIG_HAVE_ARCH_IOREMAP
static inline void __iomem *ioremap(resource_size_t offset,
				    resource_size_t size)
{
	return (void __iomem *)(unsigned long)offset;
}

static inline void iounmap(void __iomem *addr)
{
}
#endif

#define devm_ioremap(dev, offset, size)		ioremap(offset, size)

#endif /* _LINUX_IO_H */