b1a0402972ced38784d34998a166df1ada7d4ff9
[linux-flexiantxendom0-3.2.10.git] / include / asm-ia64 / sn / pio.h
1 /* $Id$
2  *
3  * This file is subject to the terms and conditions of the GNU General Public
4  * License.  See the file "COPYING" in the main directory of this archive
5  * for more details.
6  *
7  * Copyright (C) 1992 - 1997, 2000-2002 Silicon Graphics, Inc. All rights reserved.
8  */
9 #ifndef _ASM_IA64_SN_PIO_H
10 #define _ASM_IA64_SN_PIO_H
11
12 #include <linux/types.h>
13 #include <asm/sn/sgi.h>
14 #include <asm/sn/driver.h>
15
16 /*
17  * pioaddr_t    - The kernel virtual address that a PIO can be done upon.
18  *                Should probably be (volatile void*) but EVEREST would do PIO
19  *                to long mostly, just cast for other sizes.
20  */
21
22 typedef volatile ulong* pioaddr_t;
23
24 /*
25  * iopaddr_t    - the physical io space relative address (e.g. VME A16S 0x0800).
26  * iosapce_t    - specifies the io address space to be mapped/accessed.
27  * piomap_t     - the handle returned by pio_alloc() and used with all the pio
28  *                access functions.
29  */
30
31
32 typedef struct piomap {
33         uint            pio_bus;
34         uint            pio_adap;
35 #ifdef LATER
36         iospace_t       pio_iospace;
37 #endif
38         int             pio_flag;
39         int             pio_reg;
40         char            pio_name[7];    /* to identify the mapped device */
41         struct piomap   *pio_next;      /* dlist to link active piomap's */
42         struct piomap   *pio_prev;      /* for debug and error reporting */
43 #ifdef LATER
44         void            (*pio_errfunc)(); /* Pointer to an error function */
45                                           /* Used only for piomaps allocated
46                                            * in user level vme driver     */
47 #endif
48         iopaddr_t       pio_iopmask;    /* valid iop address bit mask */
49         iobush_t        pio_bushandle;  /* bus-level handle */
50 } piomap_t;
51
52 #define pio_type        pio_iospace.ios_type
53 #define pio_iopaddr     pio_iospace.ios_iopaddr
54 #define pio_size        pio_iospace.ios_size
55 #define pio_vaddr       pio_iospace.ios_vaddr
56
57 /* Macro to get/set PIO error function */
58 #define pio_seterrf(p,f)        (p)->pio_errfunc = (f)
59 #define pio_geterrf(p)          (p)->pio_errfunc
60
61
62 /*
63  * pio_mapalloc() - allocates a handle that specifies a mapping from kernel
64  *                  virtual to io space. The returned handle piomap is used
65  *                  with the access functions to make sure that the mapping
66  *                  to the iospace exists.
67  * pio_mapfree()  - frees the mapping as specified in the piomap handle.
68  * pio_mapaddr()  - returns the kv address that maps to piomap'ed io address.
69  */
70 #ifdef LATER
71 extern piomap_t *pio_mapalloc(uint,uint,iospace_t*,int,char*);
72 extern void      pio_mapfree(piomap_t*);
73 extern caddr_t   pio_mapaddr(piomap_t*,iopaddr_t);
74 extern piomap_t *pio_ioaddr(int, iobush_t, iopaddr_t, piomap_t *);
75
76 /*
77  * PIO access functions.
78  */
79 extern int  pio_badaddr(piomap_t*,iopaddr_t,int);
80 extern int  pio_badaddr_val(piomap_t*,iopaddr_t,int,void*);
81 extern int  pio_wbadaddr(piomap_t*,iopaddr_t,int);
82 extern int  pio_wbadaddr_val(piomap_t*,iopaddr_t,int,int);
83 extern int  pio_bcopyin(piomap_t*,iopaddr_t,void *,int, int, int);
84 extern int  pio_bcopyout(piomap_t*,iopaddr_t,void *,int, int, int);
85
86
87 /*
88  * PIO RMW functions using piomap.
89  */
90 extern void pio_orb_rmw(piomap_t*, iopaddr_t, unsigned char);
91 extern void pio_orh_rmw(piomap_t*, iopaddr_t, unsigned short);
92 extern void pio_orw_rmw(piomap_t*, iopaddr_t, unsigned long);
93 extern void pio_andb_rmw(piomap_t*, iopaddr_t, unsigned char);
94 extern void pio_andh_rmw(piomap_t*, iopaddr_t, unsigned short); 
95 extern void pio_andw_rmw(piomap_t*, iopaddr_t, unsigned long); 
96
97
98 /*
99  * Old RMW function interface
100  */
101 extern void orb_rmw(volatile void*, unsigned int);
102 extern void orh_rmw(volatile void*, unsigned int);
103 extern void orw_rmw(volatile void*, unsigned int);
104 extern void andb_rmw(volatile void*, unsigned int);
105 extern void andh_rmw(volatile void*, unsigned int);
106 extern void andw_rmw(volatile void*, unsigned int);
107 #endif  /* LATER */
108
109
110 /*
111  * piomap_t type defines
112  */
113
114 #define PIOMAP_NTYPES   7
115
116 #define PIOMAP_A16N     VME_A16NP
117 #define PIOMAP_A16S     VME_A16S
118 #define PIOMAP_A24N     VME_A24NP
119 #define PIOMAP_A24S     VME_A24S
120 #define PIOMAP_A32N     VME_A32NP
121 #define PIOMAP_A32S     VME_A32S
122 #define PIOMAP_A64      6
123
124 #define PIOMAP_EISA_IO  0
125 #define PIOMAP_EISA_MEM 1
126
127 #define PIOMAP_PCI_IO   0
128 #define PIOMAP_PCI_MEM  1
129 #define PIOMAP_PCI_CFG  2
130 #define PIOMAP_PCI_ID   3
131
132 /* IBUS piomap types */
133 #define PIOMAP_FCI      0
134
135 /* dang gio piomap types */
136
137 #define PIOMAP_GIO32    0
138 #define PIOMAP_GIO64    1
139
140 #define ET_MEM          0
141 #define ET_IO           1
142 #define LAN_RAM         2
143 #define LAN_IO          3
144
145 #define PIOREG_NULL     (-1)
146
147 /* standard flags values for pio_map routines,
148  * including {xtalk,pciio}_piomap calls.
149  * NOTE: try to keep these in step with DMAMAP flags.
150  */
151 #define PIOMAP_UNFIXED  0x0
152 #define PIOMAP_FIXED    0x1
153 #define PIOMAP_NOSLEEP  0x2
154 #define PIOMAP_INPLACE  0x4
155
156 #define PIOMAP_FLAGS    0x7
157
158 #endif  /* _ASM_IA64_SN_PIO_H */