1 /* 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
34 void __iomem *ioremap(phys_addr_t offset, size_t size);
35 
36 #define iounmap iounmap
37 void iounmap(void __iomem *addr);
38 
39 #define __raw_readb __raw_readb
40 u8 __raw_readb(const volatile void __iomem *addr);
41 
42 #define __raw_readw __raw_readw
43 u16 __raw_readw(const volatile void __iomem *addr);
44 
45 #define __raw_readl __raw_readl
46 u32 __raw_readl(const volatile void __iomem *addr);
47 
48 #ifdef CONFIG_64BIT
49 #define __raw_readq __raw_readq
50 u64 __raw_readq(const volatile void __iomem *addr);
51 #endif /* CONFIG_64BIT */
52 
53 #define __raw_writeb __raw_writeb
54 void __raw_writeb(u8 value, volatile void __iomem *addr);
55 
56 #define __raw_writew __raw_writew
57 void __raw_writew(u16 value, volatile void __iomem *addr);
58 
59 #define __raw_writel __raw_writel
60 void __raw_writel(u32 value, volatile void __iomem *addr);
61 
62 #ifdef CONFIG_64BIT
63 #define __raw_writeq __raw_writeq
64 void __raw_writeq(u64 value, volatile void __iomem *addr);
65 #endif /* CONFIG_64BIT */
66 
67 #define memset_io memset_io
68 void memset_io(volatile void __iomem *addr, int value, size_t size);
69 
70 #define memcpy_fromio memcpy_fromio
71 void memcpy_fromio(void *buffer, const volatile void __iomem *addr,
72 		   size_t size);
73 
74 #define memcpy_toio memcpy_toio
75 void memcpy_toio(volatile void __iomem *addr, const void *buffer, size_t size);
76 
77 #endif /* CONFIG_INDIRECT_IOMEM */
78 #endif /* _LOGIC_IO_H */
79