aacvar.h revision 1.1.6.2 1 1.1.6.2 nathanw /* $NetBSD: aacvar.h,v 1.1.6.2 2002/06/20 03:44:26 nathanw Exp $ */
2 1.1.6.2 nathanw
3 1.1.6.2 nathanw /*-
4 1.1.6.2 nathanw * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 1.1.6.2 nathanw * All rights reserved.
6 1.1.6.2 nathanw *
7 1.1.6.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.1.6.2 nathanw * by Andrew Doran.
9 1.1.6.2 nathanw *
10 1.1.6.2 nathanw * Redistribution and use in source and binary forms, with or without
11 1.1.6.2 nathanw * modification, are permitted provided that the following conditions
12 1.1.6.2 nathanw * are met:
13 1.1.6.2 nathanw * 1. Redistributions of source code must retain the above copyright
14 1.1.6.2 nathanw * notice, this list of conditions and the following disclaimer.
15 1.1.6.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.6.2 nathanw * notice, this list of conditions and the following disclaimer in the
17 1.1.6.2 nathanw * documentation and/or other materials provided with the distribution.
18 1.1.6.2 nathanw * 3. All advertising materials mentioning features or use of this software
19 1.1.6.2 nathanw * must display the following acknowledgement:
20 1.1.6.2 nathanw * This product includes software developed by the NetBSD
21 1.1.6.2 nathanw * Foundation, Inc. and its contributors.
22 1.1.6.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.6.2 nathanw * contributors may be used to endorse or promote products derived
24 1.1.6.2 nathanw * from this software without specific prior written permission.
25 1.1.6.2 nathanw *
26 1.1.6.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.6.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.6.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.6.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.6.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.6.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.6.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.6.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.6.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.6.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.6.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
37 1.1.6.2 nathanw */
38 1.1.6.2 nathanw
39 1.1.6.2 nathanw /*-
40 1.1.6.2 nathanw * Copyright (c) 2000 Michael Smith
41 1.1.6.2 nathanw * Copyright (c) 2000 BSDi
42 1.1.6.2 nathanw * Copyright (c) 2000 Niklas Hallqvist
43 1.1.6.2 nathanw * All rights reserved.
44 1.1.6.2 nathanw *
45 1.1.6.2 nathanw * Redistribution and use in source and binary forms, with or without
46 1.1.6.2 nathanw * modification, are permitted provided that the following conditions
47 1.1.6.2 nathanw * are met:
48 1.1.6.2 nathanw * 1. Redistributions of source code must retain the above copyright
49 1.1.6.2 nathanw * notice, this list of conditions and the following disclaimer.
50 1.1.6.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
51 1.1.6.2 nathanw * notice, this list of conditions and the following disclaimer in the
52 1.1.6.2 nathanw * documentation and/or other materials provided with the distribution.
53 1.1.6.2 nathanw *
54 1.1.6.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
55 1.1.6.2 nathanw * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56 1.1.6.2 nathanw * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57 1.1.6.2 nathanw * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
58 1.1.6.2 nathanw * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 1.1.6.2 nathanw * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 1.1.6.2 nathanw * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 1.1.6.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 1.1.6.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 1.1.6.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 1.1.6.2 nathanw * SUCH DAMAGE.
65 1.1.6.2 nathanw *
66 1.1.6.2 nathanw * from FreeBSD: aacvar.h,v 1.1 2000/09/13 03:20:34 msmith Exp
67 1.1.6.2 nathanw * via OpenBSD: aacvar.h,v 1.2 2002/03/14 01:26:53 millert Exp
68 1.1.6.2 nathanw */
69 1.1.6.2 nathanw
70 1.1.6.2 nathanw #ifndef _PCI_AACVAR_H_
71 1.1.6.2 nathanw #define _PCI_AACVAR_H_
72 1.1.6.2 nathanw
73 1.1.6.2 nathanw /* Debugging */
74 1.1.6.2 nathanw #ifdef AAC_DEBUG
75 1.1.6.2 nathanw #define AAC_DPRINTF(mask, args) if ((aac_debug & (mask)) != 0) printf args
76 1.1.6.2 nathanw #define AAC_D_INTR 0x01
77 1.1.6.2 nathanw #define AAC_D_MISC 0x02
78 1.1.6.2 nathanw #define AAC_D_CMD 0x04
79 1.1.6.2 nathanw #define AAC_D_QUEUE 0x08
80 1.1.6.2 nathanw #define AAC_D_IO 0x10
81 1.1.6.2 nathanw extern int aac_debug;
82 1.1.6.2 nathanw
83 1.1.6.2 nathanw #define AAC_PRINT_FIB(sc, fib) aac_print_fib((sc), (fib), __FUNCTION__)
84 1.1.6.2 nathanw #else
85 1.1.6.2 nathanw #define AAC_DPRINTF(mask, args)
86 1.1.6.2 nathanw #define AAC_PRINT_FIB(sc, fib)
87 1.1.6.2 nathanw #endif
88 1.1.6.2 nathanw
89 1.1.6.2 nathanw struct aac_code_lookup {
90 1.1.6.2 nathanw char *string;
91 1.1.6.2 nathanw u_int32_t code;
92 1.1.6.2 nathanw };
93 1.1.6.2 nathanw
94 1.1.6.2 nathanw extern const struct aac_code_lookup aac_command_status_table[];
95 1.1.6.2 nathanw extern const struct aac_code_lookup aac_cpu_variant[];
96 1.1.6.2 nathanw extern const struct aac_code_lookup aac_battery_platform[];
97 1.1.6.2 nathanw extern const struct aac_code_lookup aac_container_types[];
98 1.1.6.2 nathanw
99 1.1.6.2 nathanw struct aac_softc;
100 1.1.6.2 nathanw
101 1.1.6.2 nathanw /*
102 1.1.6.2 nathanw * We allocate a small set of FIBs for the adapter to use to send us messages.
103 1.1.6.2 nathanw */
104 1.1.6.2 nathanw #define AAC_ADAPTER_FIBS 8
105 1.1.6.2 nathanw
106 1.1.6.2 nathanw /*
107 1.1.6.2 nathanw * Firmware messages are passed in the printf buffer.
108 1.1.6.2 nathanw */
109 1.1.6.2 nathanw #define AAC_PRINTF_BUFSIZE 256
110 1.1.6.2 nathanw
111 1.1.6.2 nathanw /*
112 1.1.6.2 nathanw * We wait this many seconds for the adapter to come ready if it is still
113 1.1.6.2 nathanw * booting.
114 1.1.6.2 nathanw */
115 1.1.6.2 nathanw #define AAC_BOOT_TIMEOUT (3 * 60)
116 1.1.6.2 nathanw
117 1.1.6.2 nathanw /*
118 1.1.6.2 nathanw * Wait this long for a lost interrupt to get detected.
119 1.1.6.2 nathanw */
120 1.1.6.2 nathanw #define AAC_WATCH_TIMEOUT 10000 /* 10000 * 1ms = 10s */
121 1.1.6.2 nathanw
122 1.1.6.2 nathanw /*
123 1.1.6.2 nathanw * Timeout for immediate commands.
124 1.1.6.2 nathanw */
125 1.1.6.2 nathanw #define AAC_IMMEDIATE_TIMEOUT 30
126 1.1.6.2 nathanw
127 1.1.6.2 nathanw /*
128 1.1.6.2 nathanw * Delay 20ms after the qnotify in sync operations. Experimentally deduced.
129 1.1.6.2 nathanw */
130 1.1.6.2 nathanw #define AAC_SYNC_DELAY 20000
131 1.1.6.2 nathanw
132 1.1.6.2 nathanw /*
133 1.1.6.2 nathanw * The firmware interface allows for a 16-bit s/g list length. We limit
134 1.1.6.2 nathanw * ourselves to a reasonable maximum and ensure alignment.
135 1.1.6.2 nathanw */
136 1.1.6.2 nathanw #define AAC_MAX_SGENTRIES 17 /* max S/G entries, limit 65535 */
137 1.1.6.2 nathanw #define AAC_MAX_XFER ((AAC_MAX_SGENTRIES - 1) * PAGE_SIZE)
138 1.1.6.2 nathanw
139 1.1.6.2 nathanw /*
140 1.1.6.2 nathanw * Fixed sector size.
141 1.1.6.2 nathanw */
142 1.1.6.2 nathanw #define AAC_SECTOR_SIZE 512
143 1.1.6.2 nathanw
144 1.1.6.2 nathanw /*
145 1.1.6.2 nathanw * Number of CCBs to allocate, and to reserve for control operations.
146 1.1.6.2 nathanw */
147 1.1.6.2 nathanw #define AAC_NCCBS 256
148 1.1.6.2 nathanw #define AAC_NCCBS_RESERVE 4
149 1.1.6.2 nathanw
150 1.1.6.2 nathanw /*
151 1.1.6.2 nathanw * Quirk listings.
152 1.1.6.2 nathanw */
153 1.1.6.2 nathanw #define AAC_QUIRK_PERC2QC 0x0001
154 1.1.6.2 nathanw
155 1.1.6.2 nathanw /*
156 1.1.6.2 nathanw * We gather a number of adapter-visible items into a single structure.
157 1.1.6.2 nathanw *
158 1.1.6.2 nathanw * The ordering of this strucure may be important; we copy the Linux driver:
159 1.1.6.2 nathanw *
160 1.1.6.2 nathanw * Adapter FIBs
161 1.1.6.2 nathanw * Init struct
162 1.1.6.2 nathanw * Queue headers (Comm Area)
163 1.1.6.2 nathanw * Printf buffer
164 1.1.6.2 nathanw *
165 1.1.6.2 nathanw * In addition, we add:
166 1.1.6.2 nathanw * Sync Fib
167 1.1.6.2 nathanw */
168 1.1.6.2 nathanw struct aac_common {
169 1.1.6.2 nathanw /* fibs for the controller to send us messages */
170 1.1.6.2 nathanw struct aac_fib ac_fibs[AAC_ADAPTER_FIBS];
171 1.1.6.2 nathanw
172 1.1.6.2 nathanw /* the init structure */
173 1.1.6.2 nathanw struct aac_adapter_init ac_init;
174 1.1.6.2 nathanw
175 1.1.6.2 nathanw /* arena within which the queue structures are kept */
176 1.1.6.2 nathanw u_int8_t ac_qbuf[sizeof(struct aac_queue_table) + AAC_QUEUE_ALIGN];
177 1.1.6.2 nathanw
178 1.1.6.2 nathanw /* buffer for text messages from the controller */
179 1.1.6.2 nathanw char ac_printf[AAC_PRINTF_BUFSIZE];
180 1.1.6.2 nathanw
181 1.1.6.2 nathanw /* fib for synchronous commands */
182 1.1.6.2 nathanw struct aac_fib ac_sync_fib;
183 1.1.6.2 nathanw };
184 1.1.6.2 nathanw
185 1.1.6.2 nathanw /*
186 1.1.6.2 nathanw * Interface operations
187 1.1.6.2 nathanw */
188 1.1.6.2 nathanw struct aac_interface {
189 1.1.6.2 nathanw int (*aif_get_fwstatus)(struct aac_softc *);
190 1.1.6.2 nathanw void (*aif_qnotify)(struct aac_softc *, int);
191 1.1.6.2 nathanw int (*aif_get_istatus)(struct aac_softc *);
192 1.1.6.2 nathanw void (*aif_set_istatus)(struct aac_softc *, int);
193 1.1.6.2 nathanw void (*aif_set_mailbox)(struct aac_softc *, u_int32_t,
194 1.1.6.2 nathanw u_int32_t, u_int32_t, u_int32_t, u_int32_t);
195 1.1.6.2 nathanw int (*aif_get_mailboxstatus)(struct aac_softc *);
196 1.1.6.2 nathanw void (*aif_set_interrupts)(struct aac_softc *, int);
197 1.1.6.2 nathanw };
198 1.1.6.2 nathanw
199 1.1.6.2 nathanw #define AAC_GET_FWSTATUS(sc) ((sc)->sc_if.aif_get_fwstatus(sc))
200 1.1.6.2 nathanw #define AAC_QNOTIFY(sc, qbit) \
201 1.1.6.2 nathanw ((sc)->sc_if.aif_qnotify((sc), (qbit)))
202 1.1.6.2 nathanw #define AAC_GET_ISTATUS(sc) ((sc)->sc_if.aif_get_istatus(sc))
203 1.1.6.2 nathanw #define AAC_CLEAR_ISTATUS(sc, mask) \
204 1.1.6.2 nathanw ((sc)->sc_if.aif_set_istatus((sc), (mask)))
205 1.1.6.2 nathanw #define AAC_SET_MAILBOX(sc, command, arg0, arg1, arg2, arg3) \
206 1.1.6.2 nathanw do { \
207 1.1.6.2 nathanw ((sc)->sc_if.aif_set_mailbox((sc), (command), (arg0), \
208 1.1.6.2 nathanw (arg1), (arg2), (arg3))); \
209 1.1.6.2 nathanw } while(0)
210 1.1.6.2 nathanw #define AAC_GET_MAILBOXSTATUS(sc) \
211 1.1.6.2 nathanw ((sc)->sc_if.aif_get_mailboxstatus(sc))
212 1.1.6.2 nathanw #define AAC_MASK_INTERRUPTS(sc) \
213 1.1.6.2 nathanw ((sc)->sc_if.aif_set_interrupts((sc), 0))
214 1.1.6.2 nathanw #define AAC_UNMASK_INTERRUPTS(sc) \
215 1.1.6.2 nathanw ((sc)->sc_if.aif_set_interrupts((sc), 1))
216 1.1.6.2 nathanw
217 1.1.6.2 nathanw #define AAC_SETREG4(sc, reg, val) \
218 1.1.6.2 nathanw bus_space_write_4((sc)->sc_memt, (sc)->sc_memh, (reg), (val))
219 1.1.6.2 nathanw #define AAC_GETREG4(sc, reg) \
220 1.1.6.2 nathanw bus_space_read_4((sc)->sc_memt, (sc)->sc_memh, (reg))
221 1.1.6.2 nathanw #define AAC_SETREG2(sc, reg, val) \
222 1.1.6.2 nathanw bus_space_write_2((sc)->sc_memt, (sc)->sc_memh, (reg), (val))
223 1.1.6.2 nathanw #define AAC_GETREG2(sc, reg) \
224 1.1.6.2 nathanw bus_space_read_2((sc)->sc_memt, (sc)->sc_memh, (reg))
225 1.1.6.2 nathanw #define AAC_SETREG1(sc, reg, val) \
226 1.1.6.2 nathanw bus_space_write_1((sc)->sc_memt, (sc)->sc_memh, (reg), (val))
227 1.1.6.2 nathanw #define AAC_GETREG1(sc, reg) \
228 1.1.6.2 nathanw bus_space_read_1((sc)->sc_memt, (sc)->sc_memh, (reg))
229 1.1.6.2 nathanw
230 1.1.6.2 nathanw
231 1.1.6.2 nathanw /*
232 1.1.6.2 nathanw * A command contol block, one for each corresponding command index of the
233 1.1.6.2 nathanw * controller.
234 1.1.6.2 nathanw */
235 1.1.6.2 nathanw struct aac_ccb {
236 1.1.6.2 nathanw SIMPLEQ_ENTRY(aac_ccb) ac_chain;
237 1.1.6.2 nathanw
238 1.1.6.2 nathanw struct aac_fib *ac_fib;
239 1.1.6.2 nathanw bus_addr_t ac_fibphys;
240 1.1.6.2 nathanw bus_dmamap_t ac_dmamap_xfer;
241 1.1.6.2 nathanw
242 1.1.6.2 nathanw void *ac_data;
243 1.1.6.2 nathanw size_t ac_datalen;
244 1.1.6.2 nathanw u_int ac_flags;
245 1.1.6.2 nathanw
246 1.1.6.2 nathanw void (*ac_intr)(struct aac_ccb *);
247 1.1.6.2 nathanw struct device *ac_device;
248 1.1.6.2 nathanw void *ac_context;
249 1.1.6.2 nathanw };
250 1.1.6.2 nathanw #define AAC_CCB_MAPPED 0x01
251 1.1.6.2 nathanw #define AAC_CCB_COMPLETED 0x02
252 1.1.6.2 nathanw #define AAC_CCB_DATA_IN 0x04
253 1.1.6.2 nathanw #define AAC_CCB_DATA_OUT 0x08
254 1.1.6.2 nathanw
255 1.1.6.2 nathanw struct aac_drive {
256 1.1.6.2 nathanw u_int hd_present;
257 1.1.6.2 nathanw u_int hd_devtype;
258 1.1.6.2 nathanw u_int hd_size;
259 1.1.6.2 nathanw };
260 1.1.6.2 nathanw
261 1.1.6.2 nathanw /*
262 1.1.6.2 nathanw * Per-controller structure.
263 1.1.6.2 nathanw */
264 1.1.6.2 nathanw struct aac_softc {
265 1.1.6.2 nathanw struct device sc_dv;
266 1.1.6.2 nathanw void *sc_ih;
267 1.1.6.2 nathanw bus_space_tag_t sc_memt;
268 1.1.6.2 nathanw bus_space_handle_t sc_memh;
269 1.1.6.2 nathanw bus_dma_tag_t sc_dmat;
270 1.1.6.2 nathanw
271 1.1.6.2 nathanw struct FsaRevision sc_revision;
272 1.1.6.2 nathanw int sc_hwif;
273 1.1.6.2 nathanw int sc_quirks;
274 1.1.6.2 nathanw struct aac_interface sc_if;
275 1.1.6.2 nathanw
276 1.1.6.2 nathanw struct aac_common *sc_common;
277 1.1.6.2 nathanw bus_dma_segment_t sc_common_seg;
278 1.1.6.2 nathanw bus_dmamap_t sc_common_dmamap;
279 1.1.6.2 nathanw struct aac_fib *sc_fibs;
280 1.1.6.2 nathanw bus_dma_segment_t sc_fibs_seg;
281 1.1.6.2 nathanw bus_dmamap_t sc_fibs_dmamap;
282 1.1.6.2 nathanw
283 1.1.6.2 nathanw struct aac_ccb *sc_ccbs;
284 1.1.6.2 nathanw SIMPLEQ_HEAD(, aac_ccb) sc_ccb_free;
285 1.1.6.2 nathanw SIMPLEQ_HEAD(, aac_ccb) sc_ccb_queue;
286 1.1.6.2 nathanw SIMPLEQ_HEAD(, aac_ccb) sc_ccb_complete;
287 1.1.6.2 nathanw
288 1.1.6.2 nathanw struct aac_queue_table *sc_queues;
289 1.1.6.2 nathanw struct aac_queue_entry *sc_qentries[AAC_QUEUE_COUNT];
290 1.1.6.2 nathanw struct aac_drive sc_hdr[AAC_MAX_CONTAINERS];
291 1.1.6.2 nathanw int sc_nunits;
292 1.1.6.2 nathanw int sc_flags;
293 1.1.6.2 nathanw };
294 1.1.6.2 nathanw #define AAC_HWIF_I960RX 0
295 1.1.6.2 nathanw #define AAC_HWIF_STRONGARM 1
296 1.1.6.2 nathanw
297 1.1.6.2 nathanw #define AAC_ONLINE 2
298 1.1.6.2 nathanw
299 1.1.6.2 nathanw struct aac_attach_args {
300 1.1.6.2 nathanw int aaca_unit;
301 1.1.6.2 nathanw };
302 1.1.6.2 nathanw
303 1.1.6.2 nathanw #define aaccf_unit cf_loc[AACCF_UNIT]
304 1.1.6.2 nathanw
305 1.1.6.2 nathanw int aac_attach(struct aac_softc *);
306 1.1.6.2 nathanw void aac_ccb_enqueue(struct aac_softc *, struct aac_ccb *);
307 1.1.6.2 nathanw void aac_ccb_free(struct aac_softc *, struct aac_ccb *);
308 1.1.6.2 nathanw struct aac_ccb *aac_ccb_alloc(struct aac_softc *, int);
309 1.1.6.2 nathanw int aac_ccb_map(struct aac_softc *, struct aac_ccb *);
310 1.1.6.2 nathanw int aac_ccb_poll(struct aac_softc *, struct aac_ccb *, int);
311 1.1.6.2 nathanw int aac_ccb_submit(struct aac_softc *, struct aac_ccb *);
312 1.1.6.2 nathanw void aac_ccb_unmap(struct aac_softc *, struct aac_ccb *);
313 1.1.6.2 nathanw const char *aac_describe_code(const struct aac_code_lookup *, u_int32_t);
314 1.1.6.2 nathanw int aac_intr(void *);
315 1.1.6.2 nathanw
316 1.1.6.2 nathanw #endif /* !_PCI_AACVAR_H_ */
317