[PATCH] some more av7110 dvb-driver updates
[linux-2.6/history.git] / include / asm-m68knommu / io.h
blobf42645e4a2d29bd939b1745a6b457edd2e1fa279
1 #ifndef _M68KNOMMU_IO_H
2 #define _M68KNOMMU_IO_H
4 #ifdef __KERNEL__
6 #include <linux/config.h>
8 /*
9 * These are for ISA/PCI shared memory _only_ and should never be used
10 * on any other type of memory, including Zorro memory. They are meant to
11 * access the bus in the bus byte order which is little-endian!.
13 * readX/writeX() are used to access memory mapped devices. On some
14 * architectures the memory mapped IO stuff needs to be accessed
15 * differently. On the m68k architecture, we just read/write the
16 * memory location directly.
18 /* ++roman: The assignments to temp. vars avoid that gcc sometimes generates
19 * two accesses to memory, which may be undesireable for some devices.
23 * swap functions are sometimes needed to interface little-endian hardware
25 static inline unsigned short _swapw(volatile unsigned short v)
27 return ((v << 8) | (v >> 8));
30 static inline unsigned int _swapl(volatile unsigned long v)
32 return ((v << 24) | ((v & 0xff00) << 8) | ((v & 0xff0000) >> 8) | (v >> 24));
35 #define readb(addr) \
36 ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
37 #define readw(addr) \
38 ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
39 #define readl(addr) \
40 ({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })
42 #define writeb(b,addr) (void)((*(volatile unsigned char *) (addr)) = (b))
43 #define writew(b,addr) (void)((*(volatile unsigned short *) (addr)) = (b))
44 #define writel(b,addr) (void)((*(volatile unsigned int *) (addr)) = (b))
46 #define __raw_readb readb
47 #define __raw_readw readw
48 #define __raw_readl readl
49 #define __raw_writeb writeb
50 #define __raw_writew writew
51 #define __raw_writel writel
53 static inline void io_outsb(unsigned int addr, void *buf, int len)
55 volatile unsigned char *ap = (volatile unsigned char *) addr;
56 unsigned char *bp = (unsigned char *) buf;
57 while (len--)
58 *ap = *bp++;
61 static inline void io_outsw(unsigned int addr, void *buf, int len)
63 volatile unsigned short *ap = (volatile unsigned short *) addr;
64 unsigned short *bp = (unsigned short *) buf;
65 while (len--)
66 *ap = _swapw(*bp++);
69 static inline void io_outsl(unsigned int addr, void *buf, int len)
71 volatile unsigned int *ap = (volatile unsigned int *) addr;
72 unsigned int *bp = (unsigned int *) buf;
73 while (len--)
74 *ap = _swapl(*bp++);
77 static inline void io_insb(unsigned int addr, void *buf, int len)
79 volatile unsigned char *ap = (volatile unsigned char *) addr;
80 unsigned char *bp = (unsigned char *) buf;
81 while (len--)
82 *bp++ = *ap;
85 static inline void io_insw(unsigned int addr, void *buf, int len)
87 volatile unsigned short *ap = (volatile unsigned short *) addr;
88 unsigned short *bp = (unsigned short *) buf;
89 while (len--)
90 *bp++ = _swapw(*ap);
93 static inline void io_insl(unsigned int addr, void *buf, int len)
95 volatile unsigned int *ap = (volatile unsigned int *) addr;
96 unsigned int *bp = (unsigned int *) buf;
97 while (len--)
98 *bp++ = _swapl(*ap);
102 * make the short names macros so specific devices
103 * can override them as required
106 #define memset_io(a,b,c) memset((void *)(a),(b),(c))
107 #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
108 #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
110 #define inb(addr) readb(addr)
111 #define inw(addr) readw(addr)
112 #define inl(addr) readl(addr)
113 #define outb(x,addr) ((void) writeb(x,addr))
114 #define outw(x,addr) ((void) writew(x,addr))
115 #define outl(x,addr) ((void) writel(x,addr))
117 #define inb_p(addr) inb(addr)
118 #define inw_p(addr) inw(addr)
119 #define inl_p(addr) inl(addr)
120 #define outb_p(x,addr) outb(x,addr)
121 #define outw_p(x,addr) outw(x,addr)
122 #define outl_p(x,addr) outl(x,addr)
124 #define outsb(a,b,l) io_outsb(a,b,l)
125 #define outsw(a,b,l) io_outsw(a,b,l)
126 #define outsl(a,b,l) io_outsl(a,b,l)
128 #define insb(a,b,l) io_insb(a,b,l)
129 #define insw(a,b,l) io_insw(a,b,l)
130 #define insl(a,b,l) io_insl(a,b,l)
132 #define IO_SPACE_LIMIT 0xffff
135 /* Values for nocacheflag and cmode */
136 #define IOMAP_FULL_CACHING 0
137 #define IOMAP_NOCACHE_SER 1
138 #define IOMAP_NOCACHE_NONSER 2
139 #define IOMAP_WRITETHROUGH 3
141 extern void *__ioremap(unsigned long physaddr, unsigned long size, int cacheflag);
142 extern void __iounmap(void *addr, unsigned long size);
144 extern inline void *ioremap(unsigned long physaddr, unsigned long size)
146 return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
148 extern inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
150 return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
152 extern inline void *ioremap_writethrough(unsigned long physaddr, unsigned long size)
154 return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
156 extern inline void *ioremap_fullcache(unsigned long physaddr, unsigned long size)
158 return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
161 extern void iounmap(void *addr);
163 /* Nothing to do */
165 #define dma_cache_inv(_start,_size) do { } while (0)
166 #define dma_cache_wback(_start,_size) do { } while (0)
167 #define dma_cache_wback_inv(_start,_size) do { } while (0)
169 /* Pages to physical address... */
170 #define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
171 #define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT)
174 * Macros used for converting between virtual and physical mappings.
176 #define mm_ptov(vaddr) ((void *) (vaddr))
177 #define mm_vtop(vaddr) ((unsigned long) (vaddr))
178 #define phys_to_virt(vaddr) ((void *) (vaddr))
179 #define virt_to_phys(vaddr) ((unsigned long) (vaddr))
181 #define virt_to_bus virt_to_phys
182 #define bus_to_virt phys_to_virt
184 #endif /* __KERNEL__ */
186 #endif /* _M68KNOMMU_IO_H */