hpibvar.h revision 1.18 1 1.18 christos /* $NetBSD: hpibvar.h,v 1.18 2007/03/04 05:59:48 christos Exp $ */
2 1.13 thorpej
3 1.13 thorpej /*-
4 1.13 thorpej * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
5 1.13 thorpej * All rights reserved.
6 1.13 thorpej *
7 1.13 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.13 thorpej * by Jason R. Thorpe.
9 1.13 thorpej *
10 1.13 thorpej * Redistribution and use in source and binary forms, with or without
11 1.13 thorpej * modification, are permitted provided that the following conditions
12 1.13 thorpej * are met:
13 1.13 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.13 thorpej * notice, this list of conditions and the following disclaimer.
15 1.13 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.13 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.13 thorpej * documentation and/or other materials provided with the distribution.
18 1.13 thorpej * 3. All advertising materials mentioning features or use of this software
19 1.13 thorpej * must display the following acknowledgement:
20 1.13 thorpej * This product includes software developed by the NetBSD
21 1.13 thorpej * Foundation, Inc. and its contributors.
22 1.13 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.13 thorpej * contributors may be used to endorse or promote products derived
24 1.13 thorpej * from this software without specific prior written permission.
25 1.13 thorpej *
26 1.13 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.13 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.13 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.13 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.13 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.13 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.13 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.13 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.13 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.13 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.13 thorpej * POSSIBILITY OF SUCH DAMAGE.
37 1.13 thorpej */
38 1.4 cgd
39 1.1 cgd /*
40 1.3 mycroft * Copyright (c) 1982, 1990, 1993
41 1.3 mycroft * The Regents of the University of California. All rights reserved.
42 1.1 cgd *
43 1.1 cgd * Redistribution and use in source and binary forms, with or without
44 1.1 cgd * modification, are permitted provided that the following conditions
45 1.1 cgd * are met:
46 1.1 cgd * 1. Redistributions of source code must retain the above copyright
47 1.1 cgd * notice, this list of conditions and the following disclaimer.
48 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
49 1.1 cgd * notice, this list of conditions and the following disclaimer in the
50 1.1 cgd * documentation and/or other materials provided with the distribution.
51 1.14 agc * 3. Neither the name of the University nor the names of its contributors
52 1.1 cgd * may be used to endorse or promote products derived from this software
53 1.1 cgd * without specific prior written permission.
54 1.1 cgd *
55 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
56 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
59 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 1.1 cgd * SUCH DAMAGE.
66 1.1 cgd *
67 1.4 cgd * @(#)hpibvar.h 8.1 (Berkeley) 6/10/93
68 1.1 cgd */
69 1.1 cgd
70 1.9 thorpej #include <sys/queue.h>
71 1.9 thorpej
72 1.1 cgd #define HPIB_IPL(x) ((((x) >> 4) & 0x3) + 3)
73 1.1 cgd
74 1.1 cgd #define HPIBA 32
75 1.1 cgd #define HPIBB 1
76 1.1 cgd #define HPIBC 8
77 1.1 cgd #define HPIBA_BA 21
78 1.1 cgd #define HPIBC_BA 30
79 1.1 cgd #define HPIBA_IPL 3
80 1.1 cgd
81 1.1 cgd #define CSA_BA 0x1F
82 1.1 cgd
83 1.1 cgd #define IDS_WDMA 0x04
84 1.1 cgd #define IDS_WRITE 0x08
85 1.1 cgd #define IDS_IR 0x40
86 1.1 cgd #define IDS_IE 0x80
87 1.1 cgd #define IDS_DMA(x) (1 << (x))
88 1.1 cgd
89 1.5 mycroft #define C_SDC 0x04 /* Selected device clear */
90 1.5 mycroft #define C_SDC_P 0x04 /* with odd parity */
91 1.5 mycroft #define C_DCL 0x14 /* Universal device clear */
92 1.5 mycroft #define C_DCL_P 0x94 /* with odd parity */
93 1.5 mycroft #define C_LAG 0x20 /* Listener address group commands */
94 1.5 mycroft #define C_UNL 0x3f /* Universal unlisten */
95 1.5 mycroft #define C_UNL_P 0xbf /* with odd parity */
96 1.5 mycroft #define C_TAG 0x40 /* Talker address group commands */
97 1.5 mycroft #define C_UNA 0x5e /* Unaddress (master talk address?) */
98 1.5 mycroft #define C_UNA_P 0x5e /* with odd parity */
99 1.5 mycroft #define C_UNT 0x5f /* Universal untalk */
100 1.5 mycroft #define C_UNT_P 0xdf /* with odd parity */
101 1.5 mycroft #define C_SCG 0x60 /* Secondary group commands */
102 1.1 cgd
103 1.9 thorpej struct hpibbus_softc;
104 1.8 thorpej
105 1.7 thorpej /*
106 1.7 thorpej * Each of the HP-IB controller drivers fills in this structure, which
107 1.7 thorpej * is used by the indirect driver to call controller-specific functions.
108 1.7 thorpej */
109 1.7 thorpej struct hpib_controller {
110 1.15 thorpej void (*hpib_reset)(struct hpibbus_softc *);
111 1.15 thorpej int (*hpib_send)(struct hpibbus_softc *,
112 1.15 thorpej int, int, void *, int);
113 1.15 thorpej int (*hpib_recv)(struct hpibbus_softc *,
114 1.15 thorpej int, int, void *, int);
115 1.15 thorpej int (*hpib_ppoll)(struct hpibbus_softc *);
116 1.15 thorpej void (*hpib_ppwatch)(void *);
117 1.15 thorpej void (*hpib_go)(struct hpibbus_softc *,
118 1.15 thorpej int, int, void *, int, int, int);
119 1.15 thorpej void (*hpib_done)(struct hpibbus_softc *);
120 1.15 thorpej int (*hpib_intr)(void *);
121 1.1 cgd };
122 1.1 cgd
123 1.9 thorpej /*
124 1.9 thorpej * Attach an HP-IB bus to an HP-IB controller.
125 1.9 thorpej */
126 1.9 thorpej struct hpibdev_attach_args {
127 1.9 thorpej struct hpib_controller *ha_ops; /* controller ops vector */
128 1.9 thorpej int ha_type; /* XXX */
129 1.9 thorpej int ha_ba;
130 1.9 thorpej struct hpibbus_softc **ha_softcpp; /* XXX */
131 1.9 thorpej };
132 1.9 thorpej
133 1.9 thorpej /*
134 1.9 thorpej * Attach an HP-IB device to an HP-IB bus.
135 1.9 thorpej */
136 1.9 thorpej struct hpibbus_attach_args {
137 1.16 tsutsui uint16_t ha_id; /* device id */
138 1.9 thorpej int ha_slave; /* HP-IB bus slave */
139 1.9 thorpej int ha_punit; /* physical unit on slave */
140 1.9 thorpej };
141 1.9 thorpej
142 1.9 thorpej /* Locator short-hand */
143 1.11 jtk #include "locators.h"
144 1.9 thorpej
145 1.11 jtk #define hpibbuscf_slave cf_loc[HPIBBUSCF_SLAVE]
146 1.11 jtk #define hpibbuscf_punit cf_loc[HPIBBUSCF_PUNIT]
147 1.9 thorpej
148 1.9 thorpej #define HPIB_NSLAVES 8 /* number of slaves on a bus */
149 1.9 thorpej #define HPIB_NPUNITS 2 /* number of punits per slave */
150 1.9 thorpej
151 1.9 thorpej /*
152 1.9 thorpej * An HP-IB job queue entry. Slave drivers have one of these used
153 1.9 thorpej * to queue requests with the controller.
154 1.9 thorpej */
155 1.9 thorpej struct hpibqueue {
156 1.9 thorpej TAILQ_ENTRY(hpibqueue) hq_list; /* entry on queue */
157 1.9 thorpej void *hq_softc; /* slave's softc */
158 1.9 thorpej int hq_slave; /* slave on bus */
159 1.9 thorpej
160 1.9 thorpej /*
161 1.9 thorpej * Callbacks used to start and stop the slave driver.
162 1.9 thorpej */
163 1.15 thorpej void (*hq_start)(void *);
164 1.15 thorpej void (*hq_go)(void *);
165 1.15 thorpej void (*hq_intr)(void *);
166 1.9 thorpej };
167 1.9 thorpej
168 1.9 thorpej struct dmaqueue;
169 1.9 thorpej
170 1.9 thorpej /*
171 1.9 thorpej * Software state per HP-IB bus.
172 1.9 thorpej */
173 1.9 thorpej struct hpibbus_softc {
174 1.9 thorpej struct device sc_dev; /* generic device glue */
175 1.9 thorpej struct hpib_controller *sc_ops; /* controller ops vector */
176 1.9 thorpej volatile int sc_flags; /* misc flags */
177 1.9 thorpej struct dmaqueue *sc_dq;
178 1.9 thorpej TAILQ_HEAD(, hpibqueue) sc_queue;
179 1.9 thorpej int sc_ba;
180 1.9 thorpej int sc_type;
181 1.9 thorpej char *sc_addr;
182 1.9 thorpej int sc_count;
183 1.9 thorpej int sc_curcnt;
184 1.9 thorpej
185 1.9 thorpej /*
186 1.9 thorpej * HP-IB is an indirect bus; this cheezy resource map
187 1.9 thorpej * keeps track of slave/punit allocations.
188 1.9 thorpej */
189 1.9 thorpej char sc_rmap[HPIB_NSLAVES][HPIB_NPUNITS];
190 1.9 thorpej };
191 1.9 thorpej
192 1.1 cgd /* sc_flags */
193 1.1 cgd #define HPIBF_IO 0x1
194 1.1 cgd #define HPIBF_DONE 0x2
195 1.1 cgd #define HPIBF_PPOLL 0x4
196 1.1 cgd #define HPIBF_READ 0x8
197 1.5 mycroft #define HPIBF_TIMO 0x10
198 1.1 cgd #define HPIBF_DMA16 0x8000
199 1.1 cgd
200 1.6 jtc #ifdef _KERNEL
201 1.18 christos extern void *internalhpib;
202 1.1 cgd extern int hpibtimeout;
203 1.1 cgd extern int hpibdmathresh;
204 1.7 thorpej
205 1.15 thorpej void hpibreset(int);
206 1.15 thorpej int hpibsend(int, int, int, void *, int);
207 1.15 thorpej int hpibrecv(int, int, int, void *, int);
208 1.15 thorpej int hpibustart(int);
209 1.15 thorpej void hpibgo(int, int, int, void *, int, int, int);
210 1.15 thorpej int hpibpptest(int, int);
211 1.15 thorpej void hpibppclear(int);
212 1.15 thorpej void hpibawait(int);
213 1.15 thorpej int hpibswait(int, int);
214 1.15 thorpej int hpibid(int, int);
215 1.9 thorpej
216 1.15 thorpej int hpibreq(struct device *, struct hpibqueue *);
217 1.15 thorpej void hpibfree(struct device *, struct hpibqueue *);
218 1.15 thorpej
219 1.15 thorpej int hpibintr(void *);
220 1.15 thorpej int hpibdevprint(void *, const char *);
221 1.1 cgd #endif
222