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
6 * Copyright (C) 2000-2004 Silicon Graphics, Inc. All rights reserved.
11 #include <linux/compiler.h>
12 #include <asm/intrinsics.h>
14 extern void * sn_io_addr(unsigned long port
) __attribute_const__
; /* Forward definition */
15 extern void __sn_mmiowb(void); /* Forward definition */
17 extern int numionodes
;
19 #define __sn_mf_a() ia64_mfa()
21 extern void sn_dma_flush(unsigned long);
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
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
44 * The routines should be self explainatory.
47 static inline unsigned int
48 ___sn_inb (unsigned long port
)
50 volatile unsigned char *addr
;
51 unsigned char ret
= -1;
53 if ((addr
= sn_io_addr(port
))) {
56 sn_dma_flush((unsigned long)addr
);
61 static inline unsigned int
62 ___sn_inw (unsigned long port
)
64 volatile unsigned short *addr
;
65 unsigned short ret
= -1;
67 if ((addr
= sn_io_addr(port
))) {
70 sn_dma_flush((unsigned long)addr
);
75 static inline unsigned int
76 ___sn_inl (unsigned long port
)
78 volatile unsigned int *addr
;
79 unsigned int ret
= -1;
81 if ((addr
= sn_io_addr(port
))) {
84 sn_dma_flush((unsigned long)addr
);
90 ___sn_outb (unsigned char val
, unsigned long port
)
92 volatile unsigned char *addr
;
94 if ((addr
= sn_io_addr(port
))) {
101 ___sn_outw (unsigned short val
, unsigned long port
)
103 volatile unsigned short *addr
;
105 if ((addr
= sn_io_addr(port
))) {
112 ___sn_outl (unsigned int val
, unsigned long port
)
114 volatile unsigned int *addr
;
116 if ((addr
= sn_io_addr(port
))) {
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
128 * The routines should be self explainatory.
131 static inline unsigned char
132 ___sn_readb (const volatile void __iomem
*addr
)
136 val
= *(volatile unsigned char __force
*)addr
;
138 sn_dma_flush((unsigned long)addr
);
142 static inline unsigned short
143 ___sn_readw (const volatile void __iomem
*addr
)
147 val
= *(volatile unsigned short __force
*)addr
;
149 sn_dma_flush((unsigned long)addr
);
153 static inline unsigned int
154 ___sn_readl (const volatile void __iomem
*addr
)
158 val
= *(volatile unsigned int __force
*)addr
;
160 sn_dma_flush((unsigned long)addr
);
164 static inline unsigned long
165 ___sn_readq (const volatile void __iomem
*addr
)
169 val
= *(volatile unsigned long __force
*)addr
;
171 sn_dma_flush((unsigned long)addr
);
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.
181 * These routines should be self explainatory.
184 static inline unsigned int
185 sn_inb_fast (unsigned long port
)
187 volatile unsigned char *addr
= (unsigned char *)port
;
195 static inline unsigned int
196 sn_inw_fast (unsigned long port
)
198 volatile unsigned short *addr
= (unsigned short *)port
;
206 static inline unsigned int
207 sn_inl_fast (unsigned long port
)
209 volatile unsigned int *addr
= (unsigned int *)port
;
217 static inline unsigned char
218 ___sn_readb_relaxed (const volatile void __iomem
*addr
)
220 return *(volatile unsigned char __force
*)addr
;
223 static inline unsigned short
224 ___sn_readw_relaxed (const volatile void __iomem
*addr
)
226 return *(volatile unsigned short __force
*)addr
;
229 static inline unsigned int
230 ___sn_readl_relaxed (const volatile void __iomem
*addr
)
232 return *(volatile unsigned int __force
*) addr
;
235 static inline unsigned long
236 ___sn_readq_relaxed (const volatile void __iomem
*addr
)
238 return *(volatile unsigned long __force
*) addr
;
244 sn_pci_set_vchan(struct pci_dev
*pci_dev
, unsigned long *addr
, int vchan
)
251 if (!(*addr
>> 32)) /* Using a mask here would be cleaner */
252 return 0; /* but this generates better code */
256 *addr
|= (1UL << 57);
259 *addr
&= ~(1UL << 57);
265 #endif /* _ASM_SN_IO_H */