aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-ia64/sn/io.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/asm-ia64/sn/io.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'include/asm-ia64/sn/io.h')
-rw-r--r--include/asm-ia64/sn/io.h265
1 files changed, 265 insertions, 0 deletions
diff --git a/include/asm-ia64/sn/io.h b/include/asm-ia64/sn/io.h
new file mode 100644
index 000000000000..42209733f6b1
--- /dev/null
+++ b/include/asm-ia64/sn/io.h
@@ -0,0 +1,265 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
7 */
8
9#ifndef _ASM_SN_IO_H
10#define _ASM_SN_IO_H
11#include <linux/compiler.h>
12#include <asm/intrinsics.h>
13
14extern void * sn_io_addr(unsigned long port) __attribute_const__; /* Forward definition */
15extern void __sn_mmiowb(void); /* Forward definition */
16
17extern int numionodes;
18
19#define __sn_mf_a() ia64_mfa()
20
21extern void sn_dma_flush(unsigned long);
22
23#define __sn_inb ___sn_inb
24#define __sn_inw ___sn_inw
25#define __sn_inl ___sn_inl
26#define __sn_outb ___sn_outb
27#define __sn_outw ___sn_outw
28#define __sn_outl ___sn_outl
29#define __sn_readb ___sn_readb
30#define __sn_readw ___sn_readw
31#define __sn_readl ___sn_readl
32#define __sn_readq ___sn_readq
33#define __sn_readb_relaxed ___sn_readb_relaxed
34#define __sn_readw_relaxed ___sn_readw_relaxed
35#define __sn_readl_relaxed ___sn_readl_relaxed
36#define __sn_readq_relaxed ___sn_readq_relaxed
37
38/*
39 * The following routines are SN Platform specific, called when
40 * a reference is made to inX/outX set macros. SN Platform
41 * inX set of macros ensures that Posted DMA writes on the
42 * Bridge is flushed.
43 *
44 * The routines should be self explainatory.
45 */
46
47static inline unsigned int
48___sn_inb (unsigned long port)
49{
50 volatile unsigned char *addr;
51 unsigned char ret = -1;
52
53 if ((addr = sn_io_addr(port))) {
54 ret = *addr;
55 __sn_mf_a();
56 sn_dma_flush((unsigned long)addr);
57 }
58 return ret;
59}
60
61static inline unsigned int
62___sn_inw (unsigned long port)
63{
64 volatile unsigned short *addr;
65 unsigned short ret = -1;
66
67 if ((addr = sn_io_addr(port))) {
68 ret = *addr;
69 __sn_mf_a();
70 sn_dma_flush((unsigned long)addr);
71 }
72 return ret;
73}
74
75static inline unsigned int
76___sn_inl (unsigned long port)
77{
78 volatile unsigned int *addr;
79 unsigned int ret = -1;
80
81 if ((addr = sn_io_addr(port))) {
82 ret = *addr;
83 __sn_mf_a();
84 sn_dma_flush((unsigned long)addr);
85 }
86 return ret;
87}
88
89static inline void
90___sn_outb (unsigned char val, unsigned long port)
91{
92 volatile unsigned char *addr;
93
94 if ((addr = sn_io_addr(port))) {
95 *addr = val;
96 __sn_mmiowb();
97 }
98}
99
100static inline void
101___sn_outw (unsigned short val, unsigned long port)
102{
103 volatile unsigned short *addr;
104
105 if ((addr = sn_io_addr(port))) {
106 *addr = val;
107 __sn_mmiowb();
108 }
109}
110
111static inline void
112___sn_outl (unsigned int val, unsigned long port)
113{
114 volatile unsigned int *addr;
115
116 if ((addr = sn_io_addr(port))) {
117 *addr = val;
118 __sn_mmiowb();
119 }
120}
121
122/*
123 * The following routines are SN Platform specific, called when
124 * a reference is made to readX/writeX set macros. SN Platform
125 * readX set of macros ensures that Posted DMA writes on the
126 * Bridge is flushed.
127 *
128 * The routines should be self explainatory.
129 */
130
131static inline unsigned char
132___sn_readb (const volatile void __iomem *addr)
133{
134 unsigned char val;
135
136 val = *(volatile unsigned char __force *)addr;
137 __sn_mf_a();
138 sn_dma_flush((unsigned long)addr);
139 return val;
140}
141
142static inline unsigned short
143___sn_readw (const volatile void __iomem *addr)
144{
145 unsigned short val;
146
147 val = *(volatile unsigned short __force *)addr;
148 __sn_mf_a();
149 sn_dma_flush((unsigned long)addr);
150 return val;
151}
152
153static inline unsigned int
154___sn_readl (const volatile void __iomem *addr)
155{
156 unsigned int val;
157
158 val = *(volatile unsigned int __force *)addr;
159 __sn_mf_a();
160 sn_dma_flush((unsigned long)addr);
161 return val;
162}
163
164static inline unsigned long
165___sn_readq (const volatile void __iomem *addr)
166{
167 unsigned long val;
168
169 val = *(volatile unsigned long __force *)addr;
170 __sn_mf_a();
171 sn_dma_flush((unsigned long)addr);
172 return val;
173}
174
175/*
176 * For generic and SN2 kernels, we have a set of fast access
177 * PIO macros. These macros are provided on SN Platform
178 * because the normal inX and readX macros perform an
179 * additional task of flushing Post DMA request on the Bridge.
180 *
181 * These routines should be self explainatory.
182 */
183
184static inline unsigned int
185sn_inb_fast (unsigned long port)
186{
187 volatile unsigned char *addr = (unsigned char *)port;
188 unsigned char ret;
189
190 ret = *addr;
191 __sn_mf_a();
192 return ret;
193}
194
195static inline unsigned int
196sn_inw_fast (unsigned long port)
197{
198 volatile unsigned short *addr = (unsigned short *)port;
199 unsigned short ret;
200
201 ret = *addr;
202 __sn_mf_a();
203 return ret;
204}
205
206static inline unsigned int
207sn_inl_fast (unsigned long port)
208{
209 volatile unsigned int *addr = (unsigned int *)port;
210 unsigned int ret;
211
212 ret = *addr;
213 __sn_mf_a();
214 return ret;
215}
216
217static inline unsigned char
218___sn_readb_relaxed (const volatile void __iomem *addr)
219{
220 return *(volatile unsigned char __force *)addr;
221}
222
223static inline unsigned short
224___sn_readw_relaxed (const volatile void __iomem *addr)
225{
226 return *(volatile unsigned short __force *)addr;
227}
228
229static inline unsigned int
230___sn_readl_relaxed (const volatile void __iomem *addr)
231{
232 return *(volatile unsigned int __force *) addr;
233}
234
235static inline unsigned long
236___sn_readq_relaxed (const volatile void __iomem *addr)
237{
238 return *(volatile unsigned long __force *) addr;
239}
240
241struct pci_dev;
242
243static inline int
244sn_pci_set_vchan(struct pci_dev *pci_dev, unsigned long *addr, int vchan)
245{
246
247 if (vchan > 1) {
248 return -1;
249 }
250
251 if (!(*addr >> 32)) /* Using a mask here would be cleaner */
252 return 0; /* but this generates better code */
253
254 if (vchan == 1) {
255 /* Set Bit 57 */
256 *addr |= (1UL << 57);
257 } else {
258 /* Clear Bit 57 */
259 *addr &= ~(1UL << 57);
260 }
261
262 return 0;
263}
264
265#endif /* _ASM_SN_IO_H */