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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [asm-armnommu/] [arch-ebsa110/] [io.h] - Blame information for rev 1765

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

Line No. Rev Author Line
1 1633 jcastillo
/*
2
 * linux/include/asm-arm/arch-ebsa/io.h
3
 *
4
 * Copyright (C) 1997 Russell King
5
 *
6
 * Modifications:
7
 *  06-Dec-1997 RMK     Created.
8
 */
9
#ifndef __ASM_ARM_ARCH_IO_H
10
#define __ASM_ARM_ARCH_IO_H
11
 
12
/*
13
 * This architecture does not require any delayed IO, and
14
 * has the constant-optimised IO
15
 */
16
#undef  ARCH_IO_DELAY
17
 
18
/*
19
 * We use two different types of addressing - PC style addresses, and ARM
20
 * addresses.  PC style accesses the PC hardware with the normal PC IO
21
 * addresses, eg 0x3f8 for serial#1.  ARM addresses are 0x80000000+
22
 * and are translated to the start of IO.  Note that all addresses are
23
 * shifted left!
24
 */
25
#define __PORT_PCIO(x)  (!((x) & 0x80000000))
26
 
27
/*
28
 * Dynamic IO functions - let the compiler
29
 * optimize the expressions
30
 */
31
#define DECLARE_DYN_OUT(fnsuffix,instr)                                         \
32
extern __inline__ void __out##fnsuffix (unsigned int value, unsigned int port)  \
33
{                                                                               \
34
        unsigned long temp;                                                     \
35
        __asm__ __volatile__(                                                   \
36
        "tst    %2, #0x80000000\n\t"                                            \
37
        "mov    %0, %4\n\t"                                                     \
38
        "addeq  %0, %0, %3\n\t"                                                 \
39
        "str" ##instr## "       %1, [%0, %2, lsl #2]"                           \
40
        : "=&r" (temp)                                                          \
41
        : "r" (value), "r" (port), "Ir" (PCIO_BASE - IO_BASE), "Ir" (IO_BASE)   \
42
        : "cc");                                                                \
43
}
44
 
45
#define DECLARE_DYN_IN(sz,fnsuffix,instr)                                       \
46
extern __inline__ unsigned sz __in##fnsuffix (unsigned int port)                \
47
{                                                                               \
48
        unsigned long temp, value;                                              \
49
        __asm__ __volatile__(                                                   \
50
        "tst    %2, #0x80000000\n\t"                                            \
51
        "mov    %0, %4\n\t"                                                     \
52
        "addeq  %0, %0, %3\n\t"                                                 \
53
        "ldr" ##instr## "       %1, [%0, %2, lsl #2]"                           \
54
        : "=&r" (temp), "=r" (value)                                            \
55
        : "r" (port), "Ir" (PCIO_BASE - IO_BASE), "Ir" (IO_BASE)                \
56
        : "cc");                                                                \
57
        return (unsigned sz)value;                                              \
58
}
59
 
60
extern __inline__ unsigned int __ioaddr (unsigned int port)                     \
61
{                                                                               \
62
        if (__PORT_PCIO(port))                                                  \
63
                return (unsigned int)(PCIO_BASE + (port << 2));                 \
64
        else                                                                    \
65
                return (unsigned int)(IO_BASE + (port << 2));                   \
66
}
67
 
68
#define DECLARE_IO(sz,fnsuffix,instr)   \
69
        DECLARE_DYN_OUT(fnsuffix,instr) \
70
        DECLARE_DYN_IN(sz,fnsuffix,instr)
71
 
72
DECLARE_IO(char,b,"b")
73
DECLARE_IO(short,w,"")
74
DECLARE_IO(long,l,"")
75
 
76
#undef DECLARE_IO
77
#undef DECLARE_DYN_OUT
78
#undef DECLARE_DYN_IN
79
 
80
/*
81
 * Constant address IO functions
82
 *
83
 * These have to be macros for the 'J' constraint to work -
84
 * +/-4096 immediate operand.
85
 */
86
#define __outbc(value,port)                                                     \
87
({                                                                              \
88
        if (__PORT_PCIO((port)))                                                \
89
                __asm__ __volatile__(                                           \
90
                "strb   %0, [%1, %2]"                                           \
91
                : : "r" (value), "r" (PCIO_BASE), "Jr" ((port) << 2));          \
92
        else                                                                    \
93
                __asm__ __volatile__(                                           \
94
                "strb   %0, [%1, %2]"                                           \
95
                : : "r" (value), "r" (IO_BASE), "r" ((port) << 2));             \
96
})
97
 
98
#define __inbc(port)                                                            \
99
({                                                                              \
100
        unsigned char result;                                                   \
101
        if (__PORT_PCIO((port)))                                                \
102
                __asm__ __volatile__(                                           \
103
                "ldrb   %0, [%1, %2]"                                           \
104
                : "=r" (result) : "r" (PCIO_BASE), "Jr" ((port) << 2));         \
105
        else                                                                    \
106
                __asm__ __volatile__(                                           \
107
                "ldrb   %0, [%1, %2]"                                           \
108
                : "=r" (result) : "r" (IO_BASE), "r" ((port) << 2));            \
109
        result;                                                                 \
110
})
111
 
112
#define __outwc(value,port)                                                     \
113
({                                                                              \
114
        unsigned long v = value;                                                \
115
        if (__PORT_PCIO((port)))                                                \
116
                __asm__ __volatile__(                                           \
117
                "str    %0, [%1, %2]"                                           \
118
                : : "r" (v|v<<16), "r" (PCIO_BASE), "Jr" ((port) << 2));        \
119
        else                                                                    \
120
                __asm__ __volatile__(                                           \
121
                "str    %0, [%1, %2]"                                           \
122
                : : "r" (v|v<<16), "r" (IO_BASE), "r" ((port) << 2));           \
123
})
124
 
125
#define __inwc(port)                                                            \
126
({                                                                              \
127
        unsigned short result;                                                  \
128
        if (__PORT_PCIO((port)))                                                \
129
                __asm__ __volatile__(                                           \
130
                "ldr    %0, [%1, %2]"                                           \
131
                : "=r" (result) : "r" (PCIO_BASE), "Jr" ((port) << 2));         \
132
        else                                                                    \
133
                __asm__ __volatile__(                                           \
134
                "ldr    %0, [%1, %2]"                                           \
135
                : "=r" (result) : "r" (IO_BASE), "r" ((port) << 2));            \
136
        result & 0xffff;                                                        \
137
})
138
 
139
#define __outlc(v,p) __outwc((v),(p))
140
 
141
#define __inlc(port)                                                            \
142
({                                                                              \
143
        unsigned long result;                                                   \
144
        if (__PORT_PCIO((port)))                                                \
145
                __asm__ __volatile__(                                           \
146
                "ldr    %0, [%1, %2]"                                           \
147
                : "=r" (result) : "r" (PCIO_BASE), "Jr" ((port) << 2));         \
148
        else                                                                    \
149
                __asm__ __volatile__(                                           \
150
                "ldr    %0, [%1, %2]"                                           \
151
                : "=r" (result) : "r" (IO_BASE), "r" ((port) << 2));            \
152
        result;                                                                 \
153
})
154
 
155
#define __ioaddrc(port)                                                         \
156
({                                                                              \
157
        unsigned long addr;                                                     \
158
        if (__PORT_PCIO((port)))                                                \
159
                addr = PCIO_BASE + ((port) << 2);                               \
160
        else                                                                    \
161
                addr = IO_BASE + ((port) << 2);                                 \
162
        addr;                                                                   \
163
})
164
 
165
/*
166
 * Translated address IO functions
167
 *
168
 * IO address has already been translated to a virtual address
169
 */
170
#define outb_t(v,p)                                                             \
171
        (*(volatile unsigned char *)(p) = (v))
172
 
173
#define inb_t(p)                                                                \
174
        (*(volatile unsigned char *)(p))
175
 
176
#define outl_t(v,p)                                                             \
177
        (*(volatile unsigned long *)(p) = (v))
178
 
179
#define inl_t(p)                                                                \
180
        (*(volatile unsigned long *)(p))
181
 
182
#endif

powered by: WebSVN 2.1.0

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