[S390] kernel: Add z/VM LGR detection
[linux/fpc-iii.git] / arch / mn10300 / include / asm / io.h
blob139df8c53de83374a86189a8278d91a184d3e26c
1 /* MN10300 I/O port emulation and memory-mapped I/O
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
11 #ifndef _ASM_IO_H
12 #define _ASM_IO_H
14 #include <asm/page.h> /* I/O is all done through memory accesses */
15 #include <asm/cpu-regs.h>
16 #include <asm/cacheflush.h>
18 #define mmiowb() do {} while (0)
20 /*****************************************************************************/
22 * readX/writeX() are used to access memory mapped devices. On some
23 * architectures the memory mapped IO stuff needs to be accessed
24 * differently. On the x86 architecture, we just read/write the
25 * memory location directly.
27 static inline u8 readb(const volatile void __iomem *addr)
29 return *(const volatile u8 *) addr;
32 static inline u16 readw(const volatile void __iomem *addr)
34 return *(const volatile u16 *) addr;
37 static inline u32 readl(const volatile void __iomem *addr)
39 return *(const volatile u32 *) addr;
42 #define __raw_readb readb
43 #define __raw_readw readw
44 #define __raw_readl readl
46 #define readb_relaxed readb
47 #define readw_relaxed readw
48 #define readl_relaxed readl
50 static inline void writeb(u8 b, volatile void __iomem *addr)
52 *(volatile u8 *) addr = b;
55 static inline void writew(u16 b, volatile void __iomem *addr)
57 *(volatile u16 *) addr = b;
60 static inline void writel(u32 b, volatile void __iomem *addr)
62 *(volatile u32 *) addr = b;
65 #define __raw_writeb writeb
66 #define __raw_writew writew
67 #define __raw_writel writel
69 /*****************************************************************************/
71 * traditional input/output functions
73 static inline u8 inb_local(unsigned long addr)
75 return readb((volatile void __iomem *) addr);
78 static inline void outb_local(u8 b, unsigned long addr)
80 return writeb(b, (volatile void __iomem *) addr);
83 static inline u8 inb(unsigned long addr)
85 return readb((volatile void __iomem *) addr);
88 static inline u16 inw(unsigned long addr)
90 return readw((volatile void __iomem *) addr);
93 static inline u32 inl(unsigned long addr)
95 return readl((volatile void __iomem *) addr);
98 static inline void outb(u8 b, unsigned long addr)
100 return writeb(b, (volatile void __iomem *) addr);
103 static inline void outw(u16 b, unsigned long addr)
105 return writew(b, (volatile void __iomem *) addr);
108 static inline void outl(u32 b, unsigned long addr)
110 return writel(b, (volatile void __iomem *) addr);
113 #define inb_p(addr) inb(addr)
114 #define inw_p(addr) inw(addr)
115 #define inl_p(addr) inl(addr)
116 #define outb_p(x, addr) outb((x), (addr))
117 #define outw_p(x, addr) outw((x), (addr))
118 #define outl_p(x, addr) outl((x), (addr))
120 static inline void insb(unsigned long addr, void *buffer, int count)
122 if (count) {
123 u8 *buf = buffer;
124 do {
125 u8 x = inb(addr);
126 *buf++ = x;
127 } while (--count);
131 static inline void insw(unsigned long addr, void *buffer, int count)
133 if (count) {
134 u16 *buf = buffer;
135 do {
136 u16 x = inw(addr);
137 *buf++ = x;
138 } while (--count);
142 static inline void insl(unsigned long addr, void *buffer, int count)
144 if (count) {
145 u32 *buf = buffer;
146 do {
147 u32 x = inl(addr);
148 *buf++ = x;
149 } while (--count);
153 static inline void outsb(unsigned long addr, const void *buffer, int count)
155 if (count) {
156 const u8 *buf = buffer;
157 do {
158 outb(*buf++, addr);
159 } while (--count);
163 static inline void outsw(unsigned long addr, const void *buffer, int count)
165 if (count) {
166 const u16 *buf = buffer;
167 do {
168 outw(*buf++, addr);
169 } while (--count);
173 extern void __outsl(unsigned long addr, const void *buffer, int count);
174 static inline void outsl(unsigned long addr, const void *buffer, int count)
176 if ((unsigned long) buffer & 0x3)
177 return __outsl(addr, buffer, count);
179 if (count) {
180 const u32 *buf = buffer;
181 do {
182 outl(*buf++, addr);
183 } while (--count);
187 #define ioread8(addr) readb(addr)
188 #define ioread16(addr) readw(addr)
189 #define ioread32(addr) readl(addr)
191 #define iowrite8(v, addr) writeb((v), (addr))
192 #define iowrite16(v, addr) writew((v), (addr))
193 #define iowrite32(v, addr) writel((v), (addr))
195 #define ioread8_rep(p, dst, count) \
196 insb((unsigned long) (p), (dst), (count))
197 #define ioread16_rep(p, dst, count) \
198 insw((unsigned long) (p), (dst), (count))
199 #define ioread32_rep(p, dst, count) \
200 insl((unsigned long) (p), (dst), (count))
202 #define iowrite8_rep(p, src, count) \
203 outsb((unsigned long) (p), (src), (count))
204 #define iowrite16_rep(p, src, count) \
205 outsw((unsigned long) (p), (src), (count))
206 #define iowrite32_rep(p, src, count) \
207 outsl((unsigned long) (p), (src), (count))
209 #define readsb(p, dst, count) \
210 insb((unsigned long) (p), (dst), (count))
211 #define readsw(p, dst, count) \
212 insw((unsigned long) (p), (dst), (count))
213 #define readsl(p, dst, count) \
214 insl((unsigned long) (p), (dst), (count))
216 #define writesb(p, src, count) \
217 outsb((unsigned long) (p), (src), (count))
218 #define writesw(p, src, count) \
219 outsw((unsigned long) (p), (src), (count))
220 #define writesl(p, src, count) \
221 outsl((unsigned long) (p), (src), (count))
223 #define IO_SPACE_LIMIT 0xffffffff
225 #ifdef __KERNEL__
227 #include <linux/vmalloc.h>
228 #define __io_virt(x) ((void *) (x))
230 /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
231 struct pci_dev;
232 static inline void pci_iounmap(struct pci_dev *dev, void __iomem *p)
237 * Change virtual addresses to physical addresses and vv.
238 * These are pretty trivial
240 static inline unsigned long virt_to_phys(volatile void *address)
242 return __pa(address);
245 static inline void *phys_to_virt(unsigned long address)
247 return __va(address);
251 * Change "struct page" to physical address.
253 static inline void __iomem *__ioremap(unsigned long offset, unsigned long size,
254 unsigned long flags)
256 return (void __iomem *) offset;
259 static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
261 return (void __iomem *) offset;
265 * This one maps high address device memory and turns off caching for that
266 * area. it's useful if some control registers are in such an area and write
267 * combining or read caching is not desirable:
269 static inline void __iomem *ioremap_nocache(unsigned long offset, unsigned long size)
271 return (void __iomem *) (offset | 0x20000000);
274 #define ioremap_wc ioremap_nocache
276 static inline void iounmap(void __iomem *addr)
280 static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
282 return (void __iomem *) port;
285 static inline void ioport_unmap(void __iomem *p)
289 #define xlate_dev_kmem_ptr(p) ((void *) (p))
290 #define xlate_dev_mem_ptr(p) ((void *) (p))
293 * PCI bus iomem addresses must be in the region 0x80000000-0x9fffffff
295 static inline unsigned long virt_to_bus(volatile void *address)
297 return ((unsigned long) address) & ~0x20000000;
300 static inline void *bus_to_virt(unsigned long address)
302 return (void *) address;
305 #define page_to_bus page_to_phys
307 #define memset_io(a, b, c) memset(__io_virt(a), (b), (c))
308 #define memcpy_fromio(a, b, c) memcpy((a), __io_virt(b), (c))
309 #define memcpy_toio(a, b, c) memcpy(__io_virt(a), (b), (c))
311 #endif /* __KERNEL__ */
313 #endif /* _ASM_IO_H */