2 * include/asm-s390/io.h
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
8 * Derived from "include/asm-i386/io.h"
16 #include <linux/vmalloc.h>
19 #define IO_SPACE_LIMIT 0xffffffff
21 #define __io_virt(x) ((void *)(PAGE_OFFSET | (unsigned long)(x)))
24 * Change virtual addresses to physical addresses and vv.
25 * These are pretty trivial
27 static inline unsigned long virt_to_phys(volatile void * address)
29 unsigned long real_address;
35 #endif /* __s390x__ */
39 : "=a" (real_address) : "a" (address) : "cc");
43 static inline void * phys_to_virt(unsigned long address)
45 return __io_virt(address);
49 * Change "struct page" to physical address.
51 #define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
53 extern void * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
55 static inline void * ioremap (unsigned long offset, unsigned long size)
57 return __ioremap(offset, size, 0);
61 * This one maps high address device memory and turns off caching for that area.
62 * it's useful if some control registers are in such an area and write combining
63 * or read caching is not desirable:
65 static inline void * ioremap_nocache (unsigned long offset, unsigned long size)
67 return __ioremap(offset, size, 0);
70 extern void iounmap(void *addr);
73 * IO bus memory addresses are also 1:1 with the physical address
75 #define virt_to_bus virt_to_phys
76 #define bus_to_virt phys_to_virt
79 * readX/writeX() are used to access memory mapped devices. On some
80 * architectures the memory mapped IO stuff needs to be accessed
84 #define readb(addr) (*(volatile unsigned char *) __io_virt(addr))
85 #define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
86 #define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
87 #define readq(addr) (*(volatile unsigned long long *) __io_virt(addr))
89 #define readb_relaxed(addr) readb(addr)
90 #define readw_relaxed(addr) readw(addr)
91 #define readl_relaxed(addr) readl(addr)
92 #define readq_relaxed(addr) readq(addr)
93 #define __raw_readb readb
94 #define __raw_readw readw
95 #define __raw_readl readl
96 #define __raw_readq readq
98 #define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
99 #define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
100 #define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
101 #define writeq(b,addr) (*(volatile unsigned long long *) __io_virt(addr) = (b))
102 #define __raw_writeb writeb
103 #define __raw_writew writew
104 #define __raw_writel writel
105 #define __raw_writeq writeq
107 #define memset_io(a,b,c) memset(__io_virt(a),(b),(c))
108 #define memcpy_fromio(a,b,c) memcpy((a),__io_virt(b),(c))
109 #define memcpy_toio(a,b,c) memcpy(__io_virt(a),(b),(c))
111 #define inb_p(addr) readb(addr)
112 #define inb(addr) readb(addr)
114 #define outb(x,addr) ((void) writeb(x,addr))
115 #define outb_p(x,addr) outb(x,addr)
117 #define mmiowb() do { } while (0)
120 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
123 #define xlate_dev_mem_ptr(p) __va(p)
126 * Convert a virtual cached pointer to an uncached pointer
128 #define xlate_dev_kmem_ptr(p) p
130 #endif /* __KERNEL__ */