xref: /openbmc/linux/arch/sh/include/asm/io_trapped.h (revision 588b48ca)
1 #ifndef __ASM_SH_IO_TRAPPED_H
2 #define __ASM_SH_IO_TRAPPED_H
3 
4 #include <linux/list.h>
5 #include <linux/ioport.h>
6 #include <asm/page.h>
7 
8 #define IO_TRAPPED_MAGIC 0xfeedbeef
9 
10 struct trapped_io {
11 	unsigned int magic;
12 	struct resource *resource;
13 	unsigned int num_resources;
14 	unsigned int minimum_bus_width;
15 	struct list_head list;
16 	void __iomem *virt_base;
17 } __aligned(PAGE_SIZE);
18 
19 #ifdef CONFIG_IO_TRAPPED
20 int register_trapped_io(struct trapped_io *tiop);
21 int handle_trapped_io(struct pt_regs *regs, unsigned long address);
22 
23 void __iomem *match_trapped_io_handler(struct list_head *list,
24 				       unsigned long offset,
25 				       unsigned long size);
26 
27 #ifdef CONFIG_HAS_IOMEM
28 extern struct list_head trapped_mem;
29 
30 static inline void __iomem *
31 __ioremap_trapped(unsigned long offset, unsigned long size)
32 {
33 	return match_trapped_io_handler(&trapped_mem, offset, size);
34 }
35 #else
36 #define __ioremap_trapped(offset, size) NULL
37 #endif
38 
39 #ifdef CONFIG_HAS_IOPORT_MAP
40 extern struct list_head trapped_io;
41 
42 static inline void __iomem *
43 __ioport_map_trapped(unsigned long offset, unsigned long size)
44 {
45 	return match_trapped_io_handler(&trapped_io, offset, size);
46 }
47 #else
48 #define __ioport_map_trapped(offset, size) NULL
49 #endif
50 
51 #else
52 #define register_trapped_io(tiop) (-1)
53 #define handle_trapped_io(tiop, address) 0
54 #define __ioremap_trapped(offset, size) NULL
55 #define __ioport_map_trapped(offset, size) NULL
56 #endif
57 
58 #endif /* __ASM_SH_IO_TRAPPED_H */
59