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
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_mmiob(void); /* Forward definition */
17 #define __sn_mf_a() ia64_mfa()
19 extern void sn_dma_flush(unsigned long);
21 #define __sn_inb ___sn_inb
22 #define __sn_inw ___sn_inw
23 #define __sn_inl ___sn_inl
24 #define __sn_outb ___sn_outb
25 #define __sn_outw ___sn_outw
26 #define __sn_outl ___sn_outl
27 #define __sn_readb ___sn_readb
28 #define __sn_readw ___sn_readw
29 #define __sn_readl ___sn_readl
30 #define __sn_readq ___sn_readq
31 #define __sn_readb_relaxed ___sn_readb_relaxed
32 #define __sn_readw_relaxed ___sn_readw_relaxed
33 #define __sn_readl_relaxed ___sn_readl_relaxed
34 #define __sn_readq_relaxed ___sn_readq_relaxed
37 * The following routines are SN Platform specific, called when
38 * a reference is made to inX/outX set macros. SN Platform
39 * inX set of macros ensures that Posted DMA writes on the
42 * The routines should be self explainatory.
45 static inline unsigned int
46 ___sn_inb (unsigned long port)
48 volatile unsigned char *addr;
49 unsigned char ret = -1;
51 if ((addr = sn_io_addr(port))) {
54 sn_dma_flush((unsigned long)addr);
59 static inline unsigned int
60 ___sn_inw (unsigned long port)
62 volatile unsigned short *addr;
63 unsigned short ret = -1;
65 if ((addr = sn_io_addr(port))) {
68 sn_dma_flush((unsigned long)addr);
73 static inline unsigned int
74 ___sn_inl (unsigned long port)
76 volatile unsigned int *addr;
77 unsigned int ret = -1;
79 if ((addr = sn_io_addr(port))) {
82 sn_dma_flush((unsigned long)addr);
88 ___sn_outb (unsigned char val, unsigned long port)
90 volatile unsigned char *addr;
92 if ((addr = sn_io_addr(port))) {
99 ___sn_outw (unsigned short val, unsigned long port)
101 volatile unsigned short *addr;
103 if ((addr = sn_io_addr(port))) {
110 ___sn_outl (unsigned int val, unsigned long port)
112 volatile unsigned int *addr;
114 if ((addr = sn_io_addr(port))) {
121 * The following routines are SN Platform specific, called when
122 * a reference is made to readX/writeX set macros. SN Platform
123 * readX set of macros ensures that Posted DMA writes on the
126 * The routines should be self explainatory.
129 static inline unsigned char
130 ___sn_readb (void *addr)
134 val = *(volatile unsigned char *)addr;
136 sn_dma_flush((unsigned long)addr);
140 static inline unsigned short
141 ___sn_readw (void *addr)
145 val = *(volatile unsigned short *)addr;
147 sn_dma_flush((unsigned long)addr);
151 static inline unsigned int
152 ___sn_readl (void *addr)
156 val = *(volatile unsigned int *) addr;
158 sn_dma_flush((unsigned long)addr);
162 static inline unsigned long
163 ___sn_readq (void *addr)
167 val = *(volatile unsigned long *) addr;
169 sn_dma_flush((unsigned long)addr);
174 * For generic and SN2 kernels, we have a set of fast access
175 * PIO macros. These macros are provided on SN Platform
176 * because the normal inX and readX macros perform an
177 * additional task of flushing Post DMA request on the Bridge.
179 * These routines should be self explainatory.
182 static inline unsigned int
183 sn_inb_fast (unsigned long port)
185 volatile unsigned char *addr = (unsigned char *)port;
193 static inline unsigned int
194 sn_inw_fast (unsigned long port)
196 volatile unsigned short *addr = (unsigned short *)port;
204 static inline unsigned int
205 sn_inl_fast (unsigned long port)
207 volatile unsigned int *addr = (unsigned int *)port;
215 static inline unsigned char
216 ___sn_readb_relaxed (void *addr)
218 return *(volatile unsigned char *)addr;
221 static inline unsigned short
222 ___sn_readw_relaxed (void *addr)
224 return *(volatile unsigned short *)addr;
227 static inline unsigned int
228 ___sn_readl_relaxed (void *addr)
230 return *(volatile unsigned int *) addr;
233 static inline unsigned long
234 ___sn_readq_relaxed (void *addr)
236 return *(volatile unsigned long *) addr;