OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-armnommu/] [io.h] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1633 jcastillo
/*
2
 * linux/include/asm-arm/io.h
3
 *
4
 * Copyright (C) 1996 Russell King
5
 *
6
 * Modifications:
7
 *  16-Sep-1996 RMK     Inlined the inx/outx functions & optimised for both
8
 *                      constant addresses and variable addresses.
9
 *  04-Dec-1997 RMK     Moved a lot of this stuff to the new architecture
10
 *                      specific IO header files.
11
 */
12
#ifndef __ASM_ARM_IO_H
13
#define __ASM_ARM_IO_H
14
 
15
#include <asm/hardware.h>
16
#include <asm/arch/mmu.h>
17
#include <asm/arch/io.h>
18
 
19
/* unsigned long virt_to_phys(void *x) */
20
#define virt_to_phys(x) (__virt_to_phys((unsigned long)(x)))
21
 
22
/* void *phys_to_virt(unsigned long x) */
23
#define phys_to_virt(x) ((void *)(__phys_to_virt((unsigned long)(x))))
24
 
25
/*
26
 * Virtual view <-> DMA view memory address translations
27
 * virt_to_bus: Used to translate the virtual address to an
28
 *              address suitable to be passed to set_dma_addr
29
 * bus_to_virt: Used to convert an address for DMA operations
30
 *              to an address that the kernel can use.
31
 */
32
#define virt_to_bus(x)  (__virt_to_bus((unsigned long)(x)))
33
#define bus_to_virt(x)  ((void *)(__bus_to_virt(x)))
34
 
35
/*
36
 * These macros actually build the multi-value IO function prototypes
37
 */
38
#define __OUTS(s,i,x)   extern void outs##s(unsigned int port, const void *from, int len);
39
#define __INS(s,i,x)    extern void ins##s(unsigned int port, void *to, int len);
40
 
41
#define __IO(s,i,x) \
42
  __OUTS(s,i,x) \
43
  __INS(s,i,x)
44
 
45
__IO(b,"b",char)
46
__IO(w,"h",short)
47
__IO(l,"",long)
48
 
49
/*
50
 * Note that due to the way __builtin_constant_t() works, you
51
 *  - can't use it inside an inline function (it will never be true)
52
 *  - you don't have to worry about side effects withing the __builtin..
53
 */
54
#ifdef __outbc
55
#define outb(val,port)  \
56
  (__builtin_constant_p((port)) ? __outbc((val),(port)) : __outb((val),(port)))
57
#else
58
#define outb(val,port) __outb((val),(port))
59
#endif
60
 
61
#ifdef __outwc
62
#define outw(val,port)  \
63
  (__builtin_constant_p((port)) ? __outwc((val),(port)) : __outw((val),(port)))
64
#else
65
#define outw(val,port) __outw((val),(port))
66
#endif
67
 
68
#ifdef __outlc
69
#define outl(val,port)  \
70
  (__builtin_constant_p((port)) ? __outlc((val),(port)) : __outl((val),(port)))
71
#else
72
#define outl(val,port) __outl((val),(port))
73
#endif
74
 
75
#ifdef __inbc
76
#define inb(port)       \
77
  (__builtin_constant_p((port)) ? __inbc((port)) : __inb((port)))
78
#else
79
#define inb(port) __inb((port))
80
#endif
81
 
82
#ifdef __inwc
83
#define inw(port)       \
84
  (__builtin_constant_p((port)) ? __inwc((port)) : __inw((port)))
85
#else
86
#define inw(port) __inw((port))
87
#endif
88
 
89
#ifdef __inlc
90
#define inl(port)       \
91
  (__builtin_constant_p((port)) ? __inlc((port)) : __inl((port)))
92
#else
93
#define inl(port) __inl((port))
94
#endif
95
 
96
/*
97
 * This macro will give you the translated IO address for this particular
98
 * architecture, which can be used with the out_t... functions.
99
 */
100
#define ioaddr(port)    \
101
  (__builtin_constant_p((port)) ? __ioaddrc((port)) : __ioaddr((port)))
102
 
103
#ifndef ARCH_IO_DELAY
104
/*
105
 * This architecture does not require any delayed IO.
106
 * It is handled in the hardware.
107
 */
108
#define outb_p(val,port)        outb((val),(port))
109
#define outw_p(val,port)        outw((val),(port))
110
#define outl_p(val,port)        outl((val),(port))
111
#define inb_p(port)             inb((port))
112
#define inw_p(port)             inw((port))
113
#define inl_p(port)             inl((port))
114
#define outsb_p(port,from,len)  outsb(port,from,len)
115
#define outsw_p(port,from,len)  outsw(port,from,len)
116
#define outsl_p(port,from,len)  outsl(port,from,len)
117
#define insb_p(port,to,len)     insb(port,to,len)
118
#define insw_p(port,to,len)     insw(port,to,len)
119
#define insl_p(port,to,len)     insl(port,to,len)
120
 
121
#else
122
 
123
/*
124
 * We have to delay the IO...
125
 */
126
#ifdef __outbc_p
127
#define outb_p(val,port)        \
128
  (__builtin_constant_p((port)) ? __outbc_p((val),(port)) : __outb_p((val),(port)))
129
#else
130
#define outb_p(val,port) __outb_p((val),(port))
131
#endif
132
 
133
#ifdef __outwc_p
134
#define outw_p(val,port)        \
135
  (__builtin_constant_p((port)) ? __outwc_p((val),(port)) : __outw_p((val),(port)))
136
#else
137
#define outw_p(val,port) __outw_p((val),(port))
138
#endif
139
 
140
#ifdef __outlc_p
141
#define outl_p(val,port)        \
142
  (__builtin_constant_p((port)) ? __outlc_p((val),(port)) : __outl_p((val),(port)))
143
#else
144
#define outl_p(val,port) __outl_p((val),(port))
145
#endif
146
 
147
#ifdef __inbc_p
148
#define inb_p(port)     \
149
  (__builtin_constant_p((port)) ? __inbc_p((port)) : __inb_p((port)))
150
#else
151
#define inb_p(port) __inb_p((port))
152
#endif
153
 
154
#ifdef __inwc_p
155
#define inw_p(port)     \
156
  (__builtin_constant_p((port)) ? __inwc_p((port)) : __inw_p((port)))
157
#else
158
#define inw_p(port) __inw_p((port))
159
#endif
160
 
161
#ifdef __inlc_p
162
#define inl_p(port)     \
163
  (__builtin_constant_p((port)) ? __inlc_p((port)) : __inl_p((port)))
164
#else
165
#define inl_p(port) __inl_p((port))
166
#endif
167
 
168
#endif
169
 
170
#undef ARCH_IO_DELAY
171
#undef ARCH_IO_CONSTANT
172
 
173
/*
174
 * Leftovers...
175
 */
176
#if 0
177
#define __outwc(value,port)                                             \
178
({                                                                      \
179
        if (port < 256)                                                 \
180
                __asm__ __volatile__(                                   \
181
                "strh   %0, [%1, %2]"                                   \
182
                : : "r" (value), "r" (PCIO_BASE), "J" (port << 2));     \
183
        else if (__PORT_PCIO(port))                                     \
184
                __asm__ __volatile__(                                   \
185
                "strh   %0, [%1, %2]"                                   \
186
                : : "r" (value), "r" (PCIO_BASE), "r" (port << 2));     \
187
        else                                                            \
188
                __asm__ __volatile__(                                   \
189
                "strh   %0, [%1, %2]"                                   \
190
                : : "r" (value), "r" (IO_BASE), "r" (port << 2));       \
191
})
192
 
193
#define __inwc(port)                                                    \
194
({                                                                      \
195
        unsigned short result;                                          \
196
        if (port < 256)                                                 \
197
                __asm__ __volatile__(                                   \
198
                "ldrh   %0, [%1, %2]"                                   \
199
                : "=r" (result) : "r" (PCIO_BASE), "J" (port << 2));    \
200
        else                                                            \
201
        if (__PORT_PCIO(port))                                          \
202
                __asm__ __volatile__(                                   \
203
                "ldrh   %0, [%1, %2]"                                   \
204
                : "=r" (result) : "r" (PCIO_BASE), "r" (port << 2));    \
205
        else                                                            \
206
                __asm__ __volatile__(                                   \
207
                "ldrh   %0, [%1, %2]"                                   \
208
                : "=r" (result) : "r" (IO_BASE), "r" (port << 2));      \
209
        result;                                                         \
210
})
211
#endif
212
#endif
213
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.