wdenk | 1249065 | 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 | |
Michal Simek | 403d619 | 2008-07-11 10:10:31 +0200 | [diff] [blame] | 19 | #include <asm/types.h> |
| 20 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 21 | #define IO_SPACE_LIMIT 0xFFFFFFFF |
| 22 | |
| 23 | #define readb(addr) \ |
| 24 | ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; }) |
| 25 | #define readw(addr) \ |
| 26 | ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; }) |
| 27 | #define readl(addr) \ |
Michal Simek | 75a081e | 2011-10-18 11:33:07 +0200 | [diff] [blame] | 28 | ({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; }) |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 29 | |
| 30 | #define writeb(b, addr) \ |
| 31 | (void)((*(volatile unsigned char *) (addr)) = (b)) |
| 32 | #define writew(b, addr) \ |
| 33 | (void)((*(volatile unsigned short *) (addr)) = (b)) |
| 34 | #define writel(b, addr) \ |
| 35 | (void)((*(volatile unsigned int *) (addr)) = (b)) |
| 36 | |
| 37 | #define memset_io(a,b,c) memset((void *)(a),(b),(c)) |
| 38 | #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c)) |
| 39 | #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c)) |
| 40 | |
| 41 | #define inb(addr) readb (addr) |
| 42 | #define inw(addr) readw (addr) |
| 43 | #define inl(addr) readl (addr) |
| 44 | #define outb(x, addr) ((void) writeb (x, addr)) |
| 45 | #define outw(x, addr) ((void) writew (x, addr)) |
| 46 | #define outl(x, addr) ((void) writel (x, addr)) |
| 47 | |
| 48 | /* Some #definitions to keep strange Xilinx code happy */ |
| 49 | #define in_8(addr) readb (addr) |
| 50 | #define in_be16(addr) readw (addr) |
| 51 | #define in_be32(addr) readl (addr) |
| 52 | |
| 53 | #define out_8(addr,x ) outb (x,addr) |
| 54 | #define out_be16(addr,x ) outw (x,addr) |
| 55 | #define out_be32(addr,x ) outl (x,addr) |
| 56 | |
| 57 | |
| 58 | #define inb_p(port) inb((port)) |
| 59 | #define outb_p(val, port) outb((val), (port)) |
| 60 | #define inw_p(port) inw((port)) |
| 61 | #define outw_p(val, port) outw((val), (port)) |
| 62 | #define inl_p(port) inl((port)) |
| 63 | #define outl_p(val, port) outl((val), (port)) |
| 64 | |
| 65 | /* Some defines to keep the MTD flash drivers happy */ |
| 66 | |
| 67 | #define __raw_readb readb |
| 68 | #define __raw_readw readw |
| 69 | #define __raw_readl readl |
| 70 | #define __raw_writeb writeb |
| 71 | #define __raw_writew writew |
| 72 | #define __raw_writel writel |
| 73 | |
| 74 | static inline void io_insb (unsigned long port, void *dst, unsigned long count) |
| 75 | { |
| 76 | unsigned char *p = dst; |
| 77 | while (count--) |
| 78 | *p++ = inb (port); |
| 79 | } |
| 80 | static inline void io_insw (unsigned long port, void *dst, unsigned long count) |
| 81 | { |
| 82 | unsigned short *p = dst; |
| 83 | while (count--) |
| 84 | *p++ = inw (port); |
| 85 | } |
| 86 | static inline void io_insl (unsigned long port, void *dst, unsigned long count) |
| 87 | { |
| 88 | unsigned long *p = dst; |
| 89 | while (count--) |
| 90 | *p++ = inl (port); |
| 91 | } |
| 92 | |
| 93 | static inline void |
| 94 | io_outsb (unsigned long port, const void *src, unsigned long count) |
| 95 | { |
| 96 | const unsigned char *p = src; |
| 97 | while (count--) |
| 98 | outb (*p++, port); |
| 99 | } |
| 100 | static inline void |
| 101 | io_outsw (unsigned long port, const void *src, unsigned long count) |
| 102 | { |
| 103 | const unsigned short *p = src; |
| 104 | while (count--) |
| 105 | outw (*p++, port); |
| 106 | } |
| 107 | static inline void |
| 108 | io_outsl (unsigned long port, const void *src, unsigned long count) |
| 109 | { |
| 110 | const unsigned long *p = src; |
| 111 | while (count--) |
| 112 | outl (*p++, port); |
| 113 | } |
| 114 | |
| 115 | #define outsb(a,b,l) io_outsb(a,b,l) |
| 116 | #define outsw(a,b,l) io_outsw(a,b,l) |
| 117 | #define outsl(a,b,l) io_outsl(a,b,l) |
| 118 | |
| 119 | #define insb(a,b,l) io_insb(a,b,l) |
| 120 | #define insw(a,b,l) io_insw(a,b,l) |
| 121 | #define insl(a,b,l) io_insl(a,b,l) |
| 122 | |
| 123 | |
| 124 | #define iounmap(addr) ((void)0) |
| 125 | #define ioremap(physaddr, size) (physaddr) |
| 126 | #define ioremap_nocache(physaddr, size) (physaddr) |
| 127 | #define ioremap_writethrough(physaddr, size) (physaddr) |
| 128 | #define ioremap_fullcache(physaddr, size) (physaddr) |
| 129 | |
Haiying Wang | c123a38 | 2007-02-21 16:52:31 +0100 | [diff] [blame] | 130 | static inline void sync(void) |
| 131 | { |
| 132 | } |
| 133 | |
Haavard Skinnemoen | f985551 | 2007-12-13 12:56:33 +0100 | [diff] [blame] | 134 | /* |
| 135 | * Given a physical address and a length, return a virtual address |
| 136 | * that can be used to access the memory range with the caching |
| 137 | * properties specified by "flags". |
| 138 | */ |
Haavard Skinnemoen | f985551 | 2007-12-13 12:56:33 +0100 | [diff] [blame] | 139 | #define MAP_NOCACHE (0) |
| 140 | #define MAP_WRCOMBINE (0) |
| 141 | #define MAP_WRBACK (0) |
| 142 | #define MAP_WRTHROUGH (0) |
| 143 | |
| 144 | static inline void * |
| 145 | map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) |
| 146 | { |
| 147 | return (void *)paddr; |
| 148 | } |
| 149 | |
| 150 | /* |
| 151 | * Take down a mapping set up by map_physmem(). |
| 152 | */ |
| 153 | static inline void unmap_physmem(void *vaddr, unsigned long flags) |
| 154 | { |
| 155 | |
| 156 | } |
| 157 | |
Kumar Gala | 9364a67 | 2008-12-13 17:20:27 -0600 | [diff] [blame] | 158 | static inline phys_addr_t virt_to_phys(void * vaddr) |
| 159 | { |
| 160 | return (phys_addr_t)(vaddr); |
| 161 | } |
| 162 | |
wdenk | 1249065 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 163 | #endif /* __MICROBLAZE_IO_H__ */ |