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
7 * Copyright (C) 1992 - 1997, 2000-2002 Silicon Graphics, Inc. All rights reserved.
9 #ifndef _ASM_IA64_SN_PIO_H
10 #define _ASM_IA64_SN_PIO_H
12 #include <linux/types.h>
13 #include <asm/sn/sgi.h>
14 #include <asm/sn/driver.h>
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.
22 typedef volatile ulong* pioaddr_t;
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
32 typedef struct piomap {
36 iospace_t pio_iospace;
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 */
44 void (*pio_errfunc)(); /* Pointer to an error function */
45 /* Used only for piomaps allocated
46 * in user level vme driver */
48 iopaddr_t pio_iopmask; /* valid iop address bit mask */
49 iobush_t pio_bushandle; /* bus-level handle */
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
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
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.
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 *);
77 * PIO access functions.
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);
88 * PIO RMW functions using piomap.
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);
99 * Old RMW function interface
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);
111 * piomap_t type defines
114 #define PIOMAP_NTYPES 7
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
124 #define PIOMAP_EISA_IO 0
125 #define PIOMAP_EISA_MEM 1
127 #define PIOMAP_PCI_IO 0
128 #define PIOMAP_PCI_MEM 1
129 #define PIOMAP_PCI_CFG 2
130 #define PIOMAP_PCI_ID 3
132 /* IBUS piomap types */
135 /* dang gio piomap types */
137 #define PIOMAP_GIO32 0
138 #define PIOMAP_GIO64 1
145 #define PIOREG_NULL (-1)
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.
151 #define PIOMAP_UNFIXED 0x0
152 #define PIOMAP_FIXED 0x1
153 #define PIOMAP_NOSLEEP 0x2
154 #define PIOMAP_INPLACE 0x4
156 #define PIOMAP_FLAGS 0x7
158 #endif /* _ASM_IA64_SN_PIO_H */