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