Import 2.3.17
[davej-history.git] / include / asm-sh / io.h
blobe13c80dbee427465c13537f0e2be52cf6b02f736
1 #ifndef __ASM_SH_IO_H
2 #define __ASM_SH_IO_H
3 /* XXXXXXXXXXXXXXXXX */
5 #define virt_to_bus virt_to_phys
6 #define bus_to_virt phys_to_virt
8 extern __inline__ unsigned long readb(unsigned long addr)
10 return *(volatile unsigned char*)addr;
13 extern __inline__ unsigned long readw(unsigned long addr)
15 return *(volatile unsigned short*)addr;
18 extern __inline__ unsigned long readl(unsigned long addr)
20 return *(volatile unsigned long*)addr;
23 extern __inline__ void writeb(unsigned short b, unsigned long addr)
25 *(volatile unsigned char*)addr = b;
28 extern __inline__ void writew(unsigned short b, unsigned long addr)
30 *(volatile unsigned short*)addr = b;
33 extern __inline__ void writel(unsigned int b, unsigned long addr)
35 *(volatile unsigned long*)addr = b;
38 extern __inline__ unsigned long inb_local(unsigned long addr)
40 return readb(addr);
43 extern __inline__ void outb_local(unsigned char b, unsigned long addr)
45 return writeb(b,addr);
48 extern __inline__ unsigned long inb(unsigned long addr)
50 return readb(addr);
53 extern __inline__ unsigned long inw(unsigned long addr)
55 return readw(addr);
58 extern __inline__ unsigned long inl(unsigned long addr)
60 return readl(addr);
63 extern __inline__ void outb(unsigned char b, unsigned long addr)
65 return writeb(b,addr);
68 extern __inline__ void outw(unsigned short b, unsigned long addr)
70 return writew(b,addr);
73 extern __inline__ void outl(unsigned int b, unsigned long addr)
75 return writel(b,addr);
78 #define inb_p inb
79 #define outb_p outb
81 #ifdef __KERNEL__
83 #include <asm/addrspace.h>
86 * Change virtual addresses to physical addresses and vv.
87 * These are trivial on the 1:1 Linux/SuperH mapping
89 extern __inline__ unsigned long virt_to_phys(volatile void * address)
91 return PHYSADDR(address);
94 extern __inline__ void * phys_to_virt(unsigned long address)
96 return (void *)KSEG0ADDR(address);
99 extern void * ioremap(unsigned long phys_addr, unsigned long size);
100 extern void iounmap(void *addr);
103 * readX/writeX() are used to access memory mapped devices. On some
104 * architectures the memory mapped IO stuff needs to be accessed
105 * differently. On the x86 architecture, we just read/write the
106 * memory location directly.
108 * On SH, we have the whole physical address space mapped at all times
109 * (as MIPS does), so "ioremap()" and "iounmap()" do not need to do
110 * anything. (This isn't true for all machines but we still handle
111 * these cases with wired TLB entries anyway ...)
113 * We cheat a bit and always return uncachable areas until we've fixed
114 * the drivers to handle caching properly.
116 extern __inline__ void * ioremap(unsigned long offset, unsigned long size)
118 return (void *) KSEG1ADDR(offset);
122 * This one maps high address device memory and turns off caching for that area.
123 * it's useful if some control registers are in such an area and write combining
124 * or read caching is not desirable:
126 extern __inline__ void * ioremap_nocache (unsigned long offset, unsigned long size)
128 return (void *) KSEG1ADDR(offset);
131 extern __inline__ void iounmap(void *addr)
135 static __inline__ int check_signature(unsigned long io_addr,
136 const unsigned char *signature, int length)
138 int retval = 0;
139 do {
140 if (readb(io_addr) != *signature)
141 goto out;
142 io_addr++;
143 signature++;
144 length--;
145 } while (length);
146 retval = 1;
147 out:
148 return retval;
151 /* Nothing to do */
153 #define dma_cache_inv(_start,_size) do { } while (0)
154 #define dma_cache_wback(_start,_size) do { } while (0)
155 #define dma_cache_wback_inv(_start,_size) do { } while (0)
157 #endif /* __KERNEL__ */
158 #endif /* __ASM_SH_IO_H */