Automatic merge of rsync://rsync.kernel.org/pub/scm/linux/kernel/git/gregkh/driver...
[linux-2.6/verdex.git] / include / asm-m32r / io.h
blob8e9e481e6996a2b584dc5add75e9f29755163ddf
1 #ifndef _ASM_M32R_IO_H
2 #define _ASM_M32R_IO_H
4 #include <linux/string.h>
5 #include <linux/compiler.h>
6 #include <asm/page.h> /* __va */
8 #ifdef __KERNEL__
10 #define IO_SPACE_LIMIT 0xFFFFFFFF
12 /**
13 * virt_to_phys - map virtual addresses to physical
14 * @address: address to remap
16 * The returned physical address is the physical (CPU) mapping for
17 * the memory address given. It is only valid to use this function on
18 * addresses directly mapped or allocated via kmalloc.
20 * This function does not give bus mappings for DMA transfers. In
21 * almost all conceivable cases a device driver should not be using
22 * this function
25 static inline unsigned long virt_to_phys(volatile void * address)
27 return __pa(address);
30 /**
31 * phys_to_virt - map physical address to virtual
32 * @address: address to remap
34 * The returned virtual address is a current CPU mapping for
35 * the memory address given. It is only valid to use this function on
36 * addresses that have a kernel mapping
38 * This function does not handle bus mappings for DMA transfers. In
39 * almost all conceivable cases a device driver should not be using
40 * this function
43 static inline void *phys_to_virt(unsigned long address)
45 return __va(address);
48 extern void __iomem *
49 __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
51 /**
52 * ioremap - map bus memory into CPU space
53 * @offset: bus address of the memory
54 * @size: size of the resource to map
56 * ioremap performs a platform specific sequence of operations to
57 * make bus memory CPU accessible via the readb/readw/readl/writeb/
58 * writew/writel functions and the other mmio helpers. The returned
59 * address is not guaranteed to be usable directly as a virtual
60 * address.
63 static inline void * ioremap(unsigned long offset, unsigned long size)
65 return __ioremap(offset, size, 0);
68 extern void iounmap(volatile void __iomem *addr);
69 #define ioremap_nocache(off,size) ioremap(off,size)
72 * IO bus memory addresses are also 1:1 with the physical address
74 #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
75 #define page_to_bus page_to_phys
76 #define virt_to_bus virt_to_phys
78 extern unsigned char _inb(unsigned long);
79 extern unsigned short _inw(unsigned long);
80 extern unsigned long _inl(unsigned long);
81 extern unsigned char _inb_p(unsigned long);
82 extern unsigned short _inw_p(unsigned long);
83 extern unsigned long _inl_p(unsigned long);
84 extern void _outb(unsigned char, unsigned long);
85 extern void _outw(unsigned short, unsigned long);
86 extern void _outl(unsigned long, unsigned long);
87 extern void _outb_p(unsigned char, unsigned long);
88 extern void _outw_p(unsigned short, unsigned long);
89 extern void _outl_p(unsigned long, unsigned long);
90 extern void _insb(unsigned int, void *, unsigned long);
91 extern void _insw(unsigned int, void *, unsigned long);
92 extern void _insl(unsigned int, void *, unsigned long);
93 extern void _outsb(unsigned int, const void *, unsigned long);
94 extern void _outsw(unsigned int, const void *, unsigned long);
95 extern void _outsl(unsigned int, const void *, unsigned long);
97 static inline unsigned char _readb(unsigned long addr)
99 return *(volatile unsigned char __force *)addr;
102 static inline unsigned short _readw(unsigned long addr)
104 return *(volatile unsigned short __force *)addr;
107 static inline unsigned long _readl(unsigned long addr)
109 return *(volatile unsigned long __force *)addr;
112 static inline void _writeb(unsigned char b, unsigned long addr)
114 *(volatile unsigned char __force *)addr = b;
117 static inline void _writew(unsigned short w, unsigned long addr)
119 *(volatile unsigned short __force *)addr = w;
122 static inline void _writel(unsigned long l, unsigned long addr)
124 *(volatile unsigned long __force *)addr = l;
127 #define inb _inb
128 #define inw _inw
129 #define inl _inl
130 #define outb _outb
131 #define outw _outw
132 #define outl _outl
134 #define inb_p _inb_p
135 #define inw_p _inw_p
136 #define inl_p _inl_p
137 #define outb_p _outb_p
138 #define outw_p _outw_p
139 #define outl_p _outl_p
141 #define insb _insb
142 #define insw _insw
143 #define insl _insl
144 #define outsb _outsb
145 #define outsw _outsw
146 #define outsl _outsl
148 #define readb(addr) _readb((unsigned long)(addr))
149 #define readw(addr) _readw((unsigned long)(addr))
150 #define readl(addr) _readl((unsigned long)(addr))
151 #define __raw_readb readb
152 #define __raw_readw readw
153 #define __raw_readl readl
154 #define readb_relaxed readb
155 #define readw_relaxed readw
156 #define readl_relaxed readl
158 #define writeb(val, addr) _writeb((val), (unsigned long)(addr))
159 #define writew(val, addr) _writew((val), (unsigned long)(addr))
160 #define writel(val, addr) _writel((val), (unsigned long)(addr))
161 #define __raw_writeb writeb
162 #define __raw_writew writew
163 #define __raw_writel writel
165 #define mmiowb()
167 #define flush_write_buffers() do { } while (0) /* M32R_FIXME */
170 * check_signature - find BIOS signatures
171 * @io_addr: mmio address to check
172 * @signature: signature block
173 * @length: length of signature
175 * Perform a signature comparison with the ISA mmio address io_addr.
176 * Returns 1 on a match.
178 * This function is deprecated. New drivers should use ioremap and
179 * check_signature.
182 static inline int check_signature(void __iomem *io_addr,
183 const unsigned char *signature, int length)
185 int retval = 0;
186 #if 0
187 printk("check_signature\n");
188 do {
189 if (readb(io_addr) != *signature)
190 goto out;
191 io_addr++;
192 signature++;
193 length--;
194 } while (length);
195 retval = 1;
196 out:
197 #endif
198 return retval;
201 static inline void
202 memset_io(volatile void __iomem *addr, unsigned char val, int count)
204 memset((void __force *) addr, val, count);
207 static inline void
208 memcpy_fromio(void *dst, volatile void __iomem *src, int count)
210 memcpy(dst, (void __force *) src, count);
213 static inline void
214 memcpy_toio(volatile void __iomem *dst, const void *src, int count)
216 memcpy((void __force *) dst, src, count);
220 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
221 * access
223 #define xlate_dev_mem_ptr(p) __va(p)
226 * Convert a virtual cached pointer to an uncached pointer
228 #define xlate_dev_kmem_ptr(p) p
230 #endif /* __KERNEL__ */
232 #endif /* _ASM_M32R_IO_H */