]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/asm-nios2/io.h
Merge git://www.denx.de/git/u-boot
[karo-tx-uboot.git] / include / asm-nios2 / io.h
1 /*
2  * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
3  * Scott McNutt <smcnutt@psyent.com>
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23
24 #ifndef __ASM_NIOS2_IO_H_
25 #define __ASM_NIOS2_IO_H_
26
27 static inline void sync(void)
28 {
29         __asm__ __volatile__ ("sync" : : : "memory");
30 }
31
32 /*
33  * Given a physical address and a length, return a virtual address
34  * that can be used to access the memory range with the caching
35  * properties specified by "flags".
36  */
37 typedef unsigned long phys_addr_t;
38
39 #define MAP_NOCACHE     (0)
40 #define MAP_WRCOMBINE   (0)
41 #define MAP_WRBACK      (0)
42 #define MAP_WRTHROUGH   (0)
43
44 static inline void *
45 map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
46 {
47         return (void *)paddr;
48 }
49
50 /*
51  * Take down a mapping set up by map_physmem().
52  */
53 static inline void unmap_physmem(void *vaddr, unsigned long flags)
54 {
55
56 }
57
58 extern unsigned char inb (unsigned char *port);
59 extern unsigned short inw (unsigned short *port);
60 extern unsigned inl (unsigned port);
61
62 #define __raw_writeb(v,a)       (*(volatile unsigned char  *)(a) = (v))
63 #define __raw_writew(v,a)       (*(volatile unsigned short *)(a) = (v))
64 #define __raw_writel(v,a)       (*(volatile unsigned int   *)(a) = (v))
65
66 #define __raw_readb(a)          (*(volatile unsigned char  *)(a))
67 #define __raw_readw(a)          (*(volatile unsigned short *)(a))
68 #define __raw_readl(a)          (*(volatile unsigned int   *)(a))
69
70 #define readb(addr)\
71         ({unsigned char val;\
72          asm volatile( "ldbio %0, 0(%1)" :"=r"(val) : "r" (addr)); val;})
73 #define readw(addr)\
74         ({unsigned short val;\
75          asm volatile( "ldhio %0, 0(%1)" :"=r"(val) : "r" (addr)); val;})
76 #define readl(addr)\
77         ({unsigned long val;\
78          asm volatile( "ldwio %0, 0(%1)" :"=r"(val) : "r" (addr)); val;})
79
80 #define writeb(addr,val)\
81         asm volatile ("stbio %1, 0(%0)" : : "r" (addr), "r" (val))
82 #define writew(addr,val)\
83         asm volatile ("sthio %1, 0(%0)" : : "r" (addr), "r" (val))
84 #define writel(addr,val)\
85         asm volatile ("stwio %1, 0(%0)" : : "r" (addr), "r" (val))
86
87 #define inb(addr)       readb(addr)
88 #define inw(addr)       readw(addr)
89 #define inl(addr)       readl(addr)
90 #define outb(addr,val)  writeb(addr,val)
91 #define outw(addr,val)  writew(addr,val)
92 #define outl(addr,val)  writel(addr,val)
93
94 static inline void insb (unsigned long port, void *dst, unsigned long count)
95 {
96         unsigned char *p = dst;
97         while (count--) *p++ = inb (port);
98 }
99 static inline void insw (unsigned long port, void *dst, unsigned long count)
100 {
101         unsigned short *p = dst;
102         while (count--) *p++ = inw (port);
103 }
104 static inline void insl (unsigned long port, void *dst, unsigned long count)
105 {
106         unsigned long *p = dst;
107         while (count--) *p++ = inl (port);
108 }
109
110 static inline void outsb (unsigned long port, const void *src, unsigned long count)
111 {
112         const unsigned char *p = src;
113         while (count--) outb (*p++, port);
114 }
115
116 static inline void outsw (unsigned long port, const void *src, unsigned long count)
117 {
118         const unsigned short *p = src;
119         while (count--) outw (*p++, port);
120 }
121 static inline void outsl (unsigned long port, const void *src, unsigned long count)
122 {
123         const unsigned long *p = src;
124         while (count--) outl (*p++, port);
125 }
126
127 #endif /* __ASM_NIOS2_IO_H_ */