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-2003 Silicon Graphics, Inc. All rights reserved.
9 #ifndef _ASM_SN_SN2_IO_H
10 #define _ASM_SN_SN2_IO_H
12 extern void * sn_io_addr(unsigned long port); /* Forward definition */
13 extern void sn_mmiob(void); /* Forward definition */
14 #include <asm/intrinsics.h>
16 #define __sn_mf_a() ia64_mfa()
18 extern void sn_dma_flush(unsigned long);
20 #define __sn_inb ___sn_inb
21 #define __sn_inw ___sn_inw
22 #define __sn_inl ___sn_inl
23 #define __sn_outb ___sn_outb
24 #define __sn_outw ___sn_outw
25 #define __sn_outl ___sn_outl
26 #define __sn_readb ___sn_readb
27 #define __sn_readw ___sn_readw
28 #define __sn_readl ___sn_readl
29 #define __sn_readq ___sn_readq
30 #define __sn_readb_relaxed ___sn_readb_relaxed
31 #define __sn_readw_relaxed ___sn_readw_relaxed
32 #define __sn_readl_relaxed ___sn_readl_relaxed
33 #define __sn_readq_relaxed ___sn_readq_relaxed
36 * The following routines are SN Platform specific, called when
37 * a reference is made to inX/outX set macros. SN Platform
38 * inX set of macros ensures that Posted DMA writes on the
41 * The routines should be self explainatory.
44 static inline unsigned int
45 ___sn_inb (unsigned long port)
47 volatile unsigned char *addr;
48 unsigned char ret = -1;
50 if ((addr = sn_io_addr(port))) {
53 sn_dma_flush((unsigned long)addr);
58 static inline unsigned int
59 ___sn_inw (unsigned long port)
61 volatile unsigned short *addr;
62 unsigned short ret = -1;
64 if ((addr = sn_io_addr(port))) {
67 sn_dma_flush((unsigned long)addr);
72 static inline unsigned int
73 ___sn_inl (unsigned long port)
75 volatile unsigned int *addr;
76 unsigned int ret = -1;
78 if ((addr = sn_io_addr(port))) {
81 sn_dma_flush((unsigned long)addr);
87 ___sn_outb (unsigned char val, unsigned long port)
89 volatile unsigned char *addr;
91 if ((addr = sn_io_addr(port))) {
98 ___sn_outw (unsigned short val, unsigned long port)
100 volatile unsigned short *addr;
102 if ((addr = sn_io_addr(port))) {
109 ___sn_outl (unsigned int val, unsigned long port)
111 volatile unsigned int *addr;
113 if ((addr = sn_io_addr(port))) {
120 * The following routines are SN Platform specific, called when
121 * a reference is made to readX/writeX set macros. SN Platform
122 * readX set of macros ensures that Posted DMA writes on the
125 * The routines should be self explainatory.
128 static inline unsigned char
129 ___sn_readb (void *addr)
133 val = *(volatile unsigned char *)addr;
135 sn_dma_flush((unsigned long)addr);
139 static inline unsigned short
140 ___sn_readw (void *addr)
144 val = *(volatile unsigned short *)addr;
146 sn_dma_flush((unsigned long)addr);
150 static inline unsigned int
151 ___sn_readl (void *addr)
155 val = *(volatile unsigned int *) addr;
157 sn_dma_flush((unsigned long)addr);
161 static inline unsigned long
162 ___sn_readq (void *addr)
166 val = *(volatile unsigned long *) addr;
168 sn_dma_flush((unsigned long)addr);
173 * For generic and SN2 kernels, we have a set of fast access
174 * PIO macros. These macros are provided on SN Platform
175 * because the normal inX and readX macros perform an
176 * additional task of flushing Post DMA request on the Bridge.
178 * These routines should be self explainatory.
181 static inline unsigned int
182 sn_inb_fast (unsigned long port)
184 volatile unsigned char *addr = (unsigned char *)port;
192 static inline unsigned int
193 sn_inw_fast (unsigned long port)
195 volatile unsigned short *addr = (unsigned short *)port;
203 static inline unsigned int
204 sn_inl_fast (unsigned long port)
206 volatile unsigned int *addr = (unsigned int *)port;
214 static inline unsigned char
215 ___sn_readb_relaxed (void *addr)
217 return *(volatile unsigned char *)addr;
220 static inline unsigned short
221 ___sn_readw_relaxed (void *addr)
223 return *(volatile unsigned short *)addr;
226 static inline unsigned int
227 ___sn_readl_relaxed (void *addr)
229 return *(volatile unsigned int *) addr;
232 static inline unsigned long
233 ___sn_readq_relaxed (void *addr)
235 return *(volatile unsigned long *) addr;