wdenk | 507bbe3 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 1 | /* |
| 2 | * include/asm-microblaze/io.h -- Misc I/O operations |
| 3 | * |
| 4 | * Copyright (C) 2003 John Williams <jwilliams@itee.uq.edu.au> |
| 5 | * Copyright (C) 2001,02 NEC Corporation |
| 6 | * Copyright (C) 2001,02 Miles Bader <miles@gnu.org> |
| 7 | * |
| 8 | * This file is subject to the terms and conditions of the GNU General |
| 9 | * Public License. See the file COPYING in the main directory of this |
| 10 | * archive for more details. |
| 11 | * |
| 12 | * Written by Miles Bader <miles@gnu.org> |
| 13 | * Microblaze port by John Williams |
| 14 | */ |
| 15 | |
| 16 | #ifndef __MICROBLAZE_IO_H__ |
| 17 | #define __MICROBLAZE_IO_H__ |
| 18 | |
| 19 | #define IO_SPACE_LIMIT 0xFFFFFFFF |
| 20 | |
| 21 | #define readb(addr) \ |
| 22 | ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; }) |
| 23 | #define readw(addr) \ |
| 24 | ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; }) |
| 25 | #define readl(addr) \ |
| 26 | ({ unsigned long __v = (*(volatile unsigned long *) (addr)); __v; }) |
| 27 | |
| 28 | #define writeb(b, addr) \ |
| 29 | (void)((*(volatile unsigned char *) (addr)) = (b)) |
| 30 | #define writew(b, addr) \ |
| 31 | (void)((*(volatile unsigned short *) (addr)) = (b)) |
| 32 | #define writel(b, addr) \ |
| 33 | (void)((*(volatile unsigned int *) (addr)) = (b)) |
| 34 | |
| 35 | #define memset_io(a,b,c) memset((void *)(a),(b),(c)) |
| 36 | #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c)) |
| 37 | #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c)) |
| 38 | |
| 39 | #define inb(addr) readb (addr) |
| 40 | #define inw(addr) readw (addr) |
| 41 | #define inl(addr) readl (addr) |
| 42 | #define outb(x, addr) ((void) writeb (x, addr)) |
| 43 | #define outw(x, addr) ((void) writew (x, addr)) |
| 44 | #define outl(x, addr) ((void) writel (x, addr)) |
| 45 | |
| 46 | /* Some #definitions to keep strange Xilinx code happy */ |
| 47 | #define in_8(addr) readb (addr) |
| 48 | #define in_be16(addr) readw (addr) |
| 49 | #define in_be32(addr) readl (addr) |
| 50 | |
| 51 | #define out_8(addr,x ) outb (x,addr) |
| 52 | #define out_be16(addr,x ) outw (x,addr) |
| 53 | #define out_be32(addr,x ) outl (x,addr) |
| 54 | |
| 55 | |
| 56 | #define inb_p(port) inb((port)) |
| 57 | #define outb_p(val, port) outb((val), (port)) |
| 58 | #define inw_p(port) inw((port)) |
| 59 | #define outw_p(val, port) outw((val), (port)) |
| 60 | #define inl_p(port) inl((port)) |
| 61 | #define outl_p(val, port) outl((val), (port)) |
| 62 | |
| 63 | /* Some defines to keep the MTD flash drivers happy */ |
| 64 | |
| 65 | #define __raw_readb readb |
| 66 | #define __raw_readw readw |
| 67 | #define __raw_readl readl |
| 68 | #define __raw_writeb writeb |
| 69 | #define __raw_writew writew |
| 70 | #define __raw_writel writel |
| 71 | |
| 72 | static inline void io_insb (unsigned long port, void *dst, unsigned long count) |
| 73 | { |
| 74 | unsigned char *p = dst; |
| 75 | while (count--) |
| 76 | *p++ = inb (port); |
| 77 | } |
| 78 | static inline void io_insw (unsigned long port, void *dst, unsigned long count) |
| 79 | { |
| 80 | unsigned short *p = dst; |
| 81 | while (count--) |
| 82 | *p++ = inw (port); |
| 83 | } |
| 84 | static inline void io_insl (unsigned long port, void *dst, unsigned long count) |
| 85 | { |
| 86 | unsigned long *p = dst; |
| 87 | while (count--) |
| 88 | *p++ = inl (port); |
| 89 | } |
| 90 | |
| 91 | static inline void |
| 92 | io_outsb (unsigned long port, const void *src, unsigned long count) |
| 93 | { |
| 94 | const unsigned char *p = src; |
| 95 | while (count--) |
| 96 | outb (*p++, port); |
| 97 | } |
| 98 | static inline void |
| 99 | io_outsw (unsigned long port, const void *src, unsigned long count) |
| 100 | { |
| 101 | const unsigned short *p = src; |
| 102 | while (count--) |
| 103 | outw (*p++, port); |
| 104 | } |
| 105 | static inline void |
| 106 | io_outsl (unsigned long port, const void *src, unsigned long count) |
| 107 | { |
| 108 | const unsigned long *p = src; |
| 109 | while (count--) |
| 110 | outl (*p++, port); |
| 111 | } |
| 112 | |
| 113 | #define outsb(a,b,l) io_outsb(a,b,l) |
| 114 | #define outsw(a,b,l) io_outsw(a,b,l) |
| 115 | #define outsl(a,b,l) io_outsl(a,b,l) |
| 116 | |
| 117 | #define insb(a,b,l) io_insb(a,b,l) |
| 118 | #define insw(a,b,l) io_insw(a,b,l) |
| 119 | #define insl(a,b,l) io_insl(a,b,l) |
| 120 | |
| 121 | |
| 122 | #define iounmap(addr) ((void)0) |
| 123 | #define ioremap(physaddr, size) (physaddr) |
| 124 | #define ioremap_nocache(physaddr, size) (physaddr) |
| 125 | #define ioremap_writethrough(physaddr, size) (physaddr) |
| 126 | #define ioremap_fullcache(physaddr, size) (physaddr) |
| 127 | |
| 128 | #endif /* __MICROBLAZE_IO_H__ */ |