Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | #ifndef __ASM_SH_IO_H #define __ASM_SH_IO_H /* * Convention: * read{b,w,l}/write{b,w,l} are for PCI, * while in{b,w,l}/out{b,w,l} are for ISA * These may (will) be platform specific function. * * In addition, we have * ctrl_in{b,w,l}/ctrl_out{b,w,l} for SuperH specific I/O. * which are processor specific. */ #include <asm/cache.h> #define inb_p inb #define outb_p outb #define inw_p inw #define outw_p outw #define virt_to_bus virt_to_phys #define bus_to_virt phys_to_virt extern __inline__ unsigned long readb(unsigned long addr) { return *(volatile unsigned char*)addr; } extern __inline__ unsigned long readw(unsigned long addr) { return *(volatile unsigned short*)addr; } extern __inline__ unsigned long readl(unsigned long addr) { return *(volatile unsigned long*)addr; } extern __inline__ void writeb(unsigned char b, unsigned long addr) { *(volatile unsigned char*)addr = b; } extern __inline__ void writew(unsigned short b, unsigned long addr) { *(volatile unsigned short*)addr = b; } extern __inline__ void writel(unsigned int b, unsigned long addr) { *(volatile unsigned long*)addr = b; } extern __inline__ unsigned long inb_local(unsigned long addr) { return readb(addr); } extern __inline__ void outb_local(unsigned char b, unsigned long addr) { return writeb(b,addr); } extern __inline__ unsigned long inb(unsigned long addr) { return readb(addr); } extern __inline__ unsigned long inw(unsigned long addr) { return readw(addr); } extern __inline__ unsigned long inl(unsigned long addr) { return readl(addr); } extern __inline__ void insb(unsigned long addr, void *buffer, int count) { unsigned char *buf=buffer; while(count--) *buf++=inb(addr); } extern __inline__ void insw(unsigned long addr, void *buffer, int count) { unsigned short *buf=buffer; while(count--) *buf++=inw(addr); } extern __inline__ void insl(unsigned long addr, void *buffer, int count) { unsigned long *buf=buffer; while(count--) *buf++=inl(addr); } extern __inline__ void outb(unsigned char b, unsigned long addr) { return writeb(b,addr); } extern __inline__ void outw(unsigned short b, unsigned long addr) { return writew(b,addr); } extern __inline__ void outl(unsigned int b, unsigned long addr) { return writel(b,addr); } extern __inline__ void outsb(unsigned long addr, const void *buffer, int count) { const unsigned char *buf=buffer; while(count--) outb(*buf++, addr); } extern __inline__ void outsw(unsigned long addr, const void *buffer, int count) { const unsigned short *buf=buffer; while(count--) outw(*buf++, addr); } extern __inline__ void outsl(unsigned long addr, const void *buffer, int count) { const unsigned long *buf=buffer; while(count--) outl(*buf++, addr); } #define ctrl_in(addr) *(addr) #define ctrl_out(data,addr) *(addr) = (data) extern __inline__ unsigned long ctrl_inb(unsigned long addr) { return *(volatile unsigned char*)addr; } extern __inline__ unsigned long ctrl_inw(unsigned long addr) { return *(volatile unsigned short*)addr; } extern __inline__ unsigned long ctrl_inl(unsigned long addr) { return *(volatile unsigned long*)addr; } extern __inline__ void ctrl_outb(unsigned char b, unsigned long addr) { *(volatile unsigned char*)addr = b; } extern __inline__ void ctrl_outw(unsigned short b, unsigned long addr) { *(volatile unsigned short*)addr = b; } extern __inline__ void ctrl_outl(unsigned int b, unsigned long addr) { *(volatile unsigned long*)addr = b; } #ifdef __KERNEL__ #define IO_SPACE_LIMIT 0xffffffff #include <asm/addrspace.h> /* * Change virtual addresses to physical addresses and vv. * These are trivial on the 1:1 Linux/SuperH mapping */ extern __inline__ unsigned long virt_to_phys(volatile void * address) { return PHYSADDR(address); } extern __inline__ void * phys_to_virt(unsigned long address) { return (void *)P1SEGADDR(address); } extern void * ioremap(unsigned long phys_addr, unsigned long size); extern void iounmap(void *addr); /* * readX/writeX() are used to access memory mapped devices. On some * architectures the memory mapped IO stuff needs to be accessed * differently. On the x86 architecture, we just read/write the * memory location directly. * * On SH, we have the whole physical address space mapped at all times * (as MIPS does), so "ioremap()" and "iounmap()" do not need to do * anything. (This isn't true for all machines but we still handle * these cases with wired TLB entries anyway ...) * * We cheat a bit and always return uncachable areas until we've fixed * the drivers to handle caching properly. */ extern __inline__ void * ioremap(unsigned long offset, unsigned long size) { return (void *) P2SEGADDR(offset); } /* * This one maps high address device memory and turns off caching for that area. * it's useful if some control registers are in such an area and write combining * or read caching is not desirable: */ extern __inline__ void * ioremap_nocache (unsigned long offset, unsigned long size) { return (void *) P2SEGADDR(offset); } extern __inline__ void iounmap(void *addr) { } static __inline__ int check_signature(unsigned long io_addr, const unsigned char *signature, int length) { int retval = 0; do { if (readb(io_addr) != *signature) goto out; io_addr++; signature++; length--; } while (length); retval = 1; out: return retval; } /* * The caches on some architectures aren't dma-coherent and have need to * handle this in software. There are three types of operations that * can be applied to dma buffers. * * - dma_cache_wback_inv(start, size) makes caches and RAM coherent by * writing the content of the caches back to memory, if necessary. * The function also invalidates the affected part of the caches as * necessary before DMA transfers from outside to memory. * - dma_cache_inv(start, size) invalidates the affected parts of the * caches. Dirty lines of the caches may be written back or simply * be discarded. This operation is necessary before dma operations * to the memory. * - dma_cache_wback(start, size) writes back any dirty lines but does * not invalidate the cache. This can be used before DMA reads from * memory, */ #define dma_cache_wback_inv(_start,_size) \ cache_flush_area((unsigned long)(_start),((unsigned long)(_start)+(_size))) #define dma_cache_inv(_start,_size) \ cache_purge_area((unsigned long)(_start),((unsigned long)(_start)+(_size))) #define dma_cache_wback(_start,_size) \ cache_wback_area((unsigned long)(_start),((unsigned long)(_start)+(_size))) #endif /* __KERNEL__ */ #endif /* __ASM_SH_IO_H */ |