2 * include/asm-microblaze/io.h -- Misc I/O operations
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>
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.
12 * Written by Miles Bader <miles@gnu.org>
13 * Microblaze port by John Williams
16 #ifndef __MICROBLAZE_IO_H__
17 #define __MICROBLAZE_IO_H__
19 #include <asm/types.h>
21 #define IO_SPACE_LIMIT 0xFFFFFFFF
24 ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; })
26 ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; })
28 ({ unsigned long __v = (*(volatile unsigned long *) (addr)); __v; })
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))
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))
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))
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)
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)
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))
65 /* Some defines to keep the MTD flash drivers happy */
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
74 static inline void io_insb (unsigned long port, void *dst, unsigned long count)
76 unsigned char *p = dst;
80 static inline void io_insw (unsigned long port, void *dst, unsigned long count)
82 unsigned short *p = dst;
86 static inline void io_insl (unsigned long port, void *dst, unsigned long count)
88 unsigned long *p = dst;
94 io_outsb (unsigned long port, const void *src, unsigned long count)
96 const unsigned char *p = src;
101 io_outsw (unsigned long port, const void *src, unsigned long count)
103 const unsigned short *p = src;
108 io_outsl (unsigned long port, const void *src, unsigned long count)
110 const unsigned long *p = src;
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)
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)
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)
130 static inline void sync(void)
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".
139 #define MAP_NOCACHE (0)
140 #define MAP_WRCOMBINE (0)
141 #define MAP_WRBACK (0)
142 #define MAP_WRTHROUGH (0)
145 map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
147 return (void *)paddr;
151 * Take down a mapping set up by map_physmem().
153 static inline void unmap_physmem(void *vaddr, unsigned long flags)
158 static inline phys_addr_t virt_to_phys(void * vaddr)
160 return (phys_addr_t)(vaddr);
163 #endif /* __MICROBLAZE_IO_H__ */