blob: 8a59b6e567df7715ad5c821c8589df4d27e97a94 [file] [log] [blame]
Johannes Bergca2e3342021-03-05 13:19:52 +01001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2021 Intel Corporation
4 * Author: johannes@sipsolutions.net
5 */
6#ifndef _LOGIC_IO_H
7#define _LOGIC_IO_H
8#include <linux/types.h>
9
10/* include this file into asm/io.h */
11
12#ifdef CONFIG_INDIRECT_IOMEM
13
14#ifdef CONFIG_INDIRECT_IOMEM_FALLBACK
15/*
16 * If you want emulated IO memory to fall back to 'normal' IO memory
17 * if a region wasn't registered as emulated, then you need to have
18 * all of the real_* functions implemented.
19 */
20#if !defined(real_ioremap) || !defined(real_iounmap) || \
21 !defined(real_raw_readb) || !defined(real_raw_writeb) || \
22 !defined(real_raw_readw) || !defined(real_raw_writew) || \
23 !defined(real_raw_readl) || !defined(real_raw_writel) || \
24 (defined(CONFIG_64BIT) && \
25 (!defined(real_raw_readq) || !defined(real_raw_writeq))) || \
26 !defined(real_memset_io) || \
27 !defined(real_memcpy_fromio) || \
28 !defined(real_memcpy_toio)
29#error "Must provide fallbacks for real IO memory access"
30#endif /* defined ... */
31#endif /* CONFIG_INDIRECT_IOMEM_FALLBACK */
32
33#define ioremap ioremap
34void __iomem *ioremap(phys_addr_t offset, size_t size);
35
36#define iounmap iounmap
Al Viro5f174ec2021-09-20 21:32:49 +000037void iounmap(void volatile __iomem *addr);
Johannes Bergca2e3342021-03-05 13:19:52 +010038
39#define __raw_readb __raw_readb
40u8 __raw_readb(const volatile void __iomem *addr);
41
42#define __raw_readw __raw_readw
43u16 __raw_readw(const volatile void __iomem *addr);
44
45#define __raw_readl __raw_readl
46u32 __raw_readl(const volatile void __iomem *addr);
47
48#ifdef CONFIG_64BIT
49#define __raw_readq __raw_readq
50u64 __raw_readq(const volatile void __iomem *addr);
51#endif /* CONFIG_64BIT */
52
53#define __raw_writeb __raw_writeb
54void __raw_writeb(u8 value, volatile void __iomem *addr);
55
56#define __raw_writew __raw_writew
57void __raw_writew(u16 value, volatile void __iomem *addr);
58
59#define __raw_writel __raw_writel
60void __raw_writel(u32 value, volatile void __iomem *addr);
61
62#ifdef CONFIG_64BIT
63#define __raw_writeq __raw_writeq
64void __raw_writeq(u64 value, volatile void __iomem *addr);
65#endif /* CONFIG_64BIT */
66
67#define memset_io memset_io
68void memset_io(volatile void __iomem *addr, int value, size_t size);
69
70#define memcpy_fromio memcpy_fromio
71void memcpy_fromio(void *buffer, const volatile void __iomem *addr,
72 size_t size);
73
74#define memcpy_toio memcpy_toio
75void memcpy_toio(volatile void __iomem *addr, const void *buffer, size_t size);
76
77#endif /* CONFIG_INDIRECT_IOMEM */
78#endif /* _LOGIC_IO_H */