aic7xxxvar.h revision 1.19.10.5 1 1.19.10.5 bouyer /* $NetBSD: aic7xxxvar.h,v 1.19.10.5 2001/04/02 16:22:57 bouyer Exp $ */
2 1.7 thorpej
3 1.1 mycroft /*
4 1.4 mycroft * Interface to the generic driver for the aic7xxx based adaptec
5 1.4 mycroft * SCSI controllers. This is used to implement product specific
6 1.1 mycroft * probe and attach routines.
7 1.1 mycroft *
8 1.19.10.2 bouyer * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000 Justin T. Gibbs.
9 1.1 mycroft * All rights reserved.
10 1.1 mycroft *
11 1.1 mycroft * Redistribution and use in source and binary forms, with or without
12 1.1 mycroft * modification, are permitted provided that the following conditions
13 1.1 mycroft * are met:
14 1.1 mycroft * 1. Redistributions of source code must retain the above copyright
15 1.19.10.2 bouyer * notice, this list of conditions, and the following disclaimer,
16 1.19.10.2 bouyer * without modification.
17 1.19.10.2 bouyer * 2. The name of the author may not be used to endorse or promote products
18 1.4 mycroft * derived from this software without specific prior written permission.
19 1.4 mycroft *
20 1.19.10.2 bouyer * Alternatively, this software may be distributed under the terms of the
21 1.19.10.2 bouyer * the GNU Public License ("GPL").
22 1.19.10.2 bouyer *
23 1.4 mycroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 1.4 mycroft * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.4 mycroft * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.4 mycroft * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
27 1.4 mycroft * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.4 mycroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.4 mycroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.4 mycroft * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.4 mycroft * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.4 mycroft * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.4 mycroft * SUCH DAMAGE.
34 1.8 explorer *
35 1.19.10.2 bouyer * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.h,v 1.16 2000/02/09 21:24:59 gibbs Exp $
36 1.1 mycroft */
37 1.1 mycroft
38 1.1 mycroft #ifndef _AIC7XXX_H_
39 1.1 mycroft #define _AIC7XXX_H_
40 1.1 mycroft
41 1.19.10.2 bouyer #ifndef FALSE
42 1.19.10.2 bouyer #define FALSE 0
43 1.16 leo #endif
44 1.16 leo
45 1.19.10.2 bouyer #ifndef TRUE
46 1.19.10.2 bouyer #define TRUE 1
47 1.4 mycroft #endif
48 1.4 mycroft
49 1.19.10.2 bouyer /*
50 1.19.10.2 bouyer * The maximum transfer per S/G segment.
51 1.19.10.2 bouyer */
52 1.19.10.2 bouyer #define AHC_MAXTRANSFER_SIZE ctob(AHC_NSEG - 1)
53 1.19.10.2 bouyer
54 1.19.10.2 bouyer /*
55 1.19.10.2 bouyer * Convert FreeBSD queue macro
56 1.19.10.2 bouyer */
57 1.19.10.2 bouyer #define STAILQ_ENTRY SIMPLEQ_ENTRY
58 1.19.10.2 bouyer
59 1.19.10.2 bouyer /*
60 1.19.10.2 bouyer * The number of dma segments supported. The current implementation limits
61 1.19.10.2 bouyer * us to 255 S/G entries (this may change to be unlimited at some point).
62 1.19.10.2 bouyer * To reduce the driver's memory consumption, we further limit the number
63 1.19.10.2 bouyer * supported to be sufficient to handle the largest mapping supported by
64 1.19.10.2 bouyer * the kernel, MAXPHYS. Assuming the transfer is as fragmented as possible
65 1.19.10.2 bouyer * and unaligned, this turns out to be the number of paged sized transfers
66 1.19.10.2 bouyer * in MAXPHYS plus an extra element to handle any unaligned residual.
67 1.19.10.2 bouyer */
68 1.19.10.2 bouyer #define AHC_NSEG (MIN(btoc(MAXPHYS) + 1, 255))
69 1.1 mycroft
70 1.4 mycroft #define AHC_SCB_MAX 255 /*
71 1.4 mycroft * Up to 255 SCBs on some types of aic7xxx
72 1.4 mycroft * based boards. The aic7870 have 16 internal
73 1.4 mycroft * SCBs, but external SRAM bumps this to 255.
74 1.4 mycroft * The aic7770 family have only 4, and the
75 1.4 mycroft * aic7850 has only 3.
76 1.1 mycroft */
77 1.1 mycroft
78 1.19.10.2 bouyer #define AHC_TMODE_CMDS 256 /*
79 1.19.10.2 bouyer * Ring Buffer of incoming target commands.
80 1.19.10.2 bouyer * We allocate 256 to simplify the logic
81 1.19.10.2 bouyer * in the sequencer by using the natural
82 1.19.10.2 bouyer * wrap point of an 8bit counter.
83 1.19.10.2 bouyer */
84 1.1 mycroft
85 1.1 mycroft struct ahc_dma_seg {
86 1.19.10.2 bouyer u_int32_t addr;
87 1.9 gibbs u_int32_t len;
88 1.1 mycroft };
89 1.4 mycroft
90 1.4 mycroft typedef enum {
91 1.19.10.2 bouyer AHC_NONE = 0x0000,
92 1.19.10.2 bouyer AHC_CHIPID_MASK = 0x00FF,
93 1.19.10.2 bouyer AHC_AIC7770 = 0x0001,
94 1.19.10.2 bouyer AHC_AIC7850 = 0x0002,
95 1.19.10.2 bouyer AHC_AIC7855 = 0x0003,
96 1.19.10.2 bouyer AHC_AIC7859 = 0x0004,
97 1.19.10.2 bouyer AHC_AIC7860 = 0x0005,
98 1.19.10.2 bouyer AHC_AIC7870 = 0x0006,
99 1.19.10.2 bouyer AHC_AIC7880 = 0x0007,
100 1.19.10.2 bouyer AHC_AIC7890 = 0x0008,
101 1.19.10.2 bouyer AHC_AIC7892 = 0x0009,
102 1.19.10.2 bouyer AHC_AIC7895 = 0x000a,
103 1.19.10.2 bouyer AHC_AIC7896 = 0x000b,
104 1.19.10.2 bouyer AHC_AIC7899 = 0x000c,
105 1.19.10.2 bouyer AHC_VL = 0x0100, /* Bus type VL */
106 1.19.10.2 bouyer AHC_EISA = 0x0200, /* Bus type EISA */
107 1.19.10.2 bouyer AHC_PCI = 0x0400, /* Bus type PCI */
108 1.19.10.2 bouyer AHC_BUS_MASK = 0x0F00
109 1.19.10.2 bouyer } ahc_chip;
110 1.19.10.2 bouyer
111 1.19.10.3 bouyer extern const char * const ahc_chip_names[];
112 1.19.10.2 bouyer
113 1.19.10.2 bouyer typedef enum {
114 1.19.10.2 bouyer AHC_FENONE = 0x0000,
115 1.19.10.2 bouyer AHC_ULTRA = 0x0001, /* Supports 20MHz Transfers */
116 1.19.10.2 bouyer AHC_ULTRA2 = 0x0002, /* Supports 40MHz Transfers */
117 1.19.10.2 bouyer AHC_WIDE = 0x0004, /* Wide Channel */
118 1.19.10.2 bouyer AHC_TWIN = 0x0008, /* Twin Channel */
119 1.19.10.2 bouyer AHC_MORE_SRAM = 0x0010, /* 80 bytes instead of 64 */
120 1.19.10.2 bouyer AHC_CMD_CHAN = 0x0020, /* Has a Command DMA Channel */
121 1.19.10.2 bouyer AHC_QUEUE_REGS = 0x0040, /* Has Queue management registers */
122 1.19.10.2 bouyer AHC_SG_PRELOAD = 0x0080, /* Can perform auto-SG preload */
123 1.19.10.2 bouyer AHC_SPIOCAP = 0x0100, /* Has a Serial Port I/O Cap Register */
124 1.19.10.2 bouyer AHC_MULTI_TID = 0x0200, /* Has bitmask of TIDs for select-in */
125 1.19.10.2 bouyer AHC_HS_MAILBOX = 0x0400, /* Has HS_MAILBOX register */
126 1.19.10.2 bouyer AHC_DT = 0x0800, /* Double Transition transfers */
127 1.19.10.2 bouyer AHC_NEW_TERMCTL = 0x1000,
128 1.19.10.2 bouyer AHC_MULTI_FUNC = 0x2000, /* Multi-Function Twin Channel Device */
129 1.19.10.2 bouyer AHC_TARG_DMABUG = 0x4000, /* WideOdd Data-In bug in TMODE */
130 1.19.10.2 bouyer AHC_AIC7770_FE = AHC_TARG_DMABUG,
131 1.19.10.2 bouyer AHC_AIC7850_FE = AHC_TARG_DMABUG|AHC_SPIOCAP,
132 1.19.10.2 bouyer AHC_AIC7855_FE = AHC_AIC7850_FE,
133 1.19.10.2 bouyer AHC_AIC7859_FE = AHC_AIC7850_FE|AHC_ULTRA,
134 1.19.10.2 bouyer AHC_AIC7860_FE = AHC_AIC7859_FE,
135 1.19.10.2 bouyer AHC_AIC7870_FE = AHC_TARG_DMABUG,
136 1.19.10.2 bouyer AHC_AIC7880_FE = AHC_TARG_DMABUG|AHC_ULTRA,
137 1.19.10.2 bouyer AHC_AIC7890_FE = AHC_MORE_SRAM|AHC_CMD_CHAN|AHC_ULTRA2|AHC_QUEUE_REGS
138 1.19.10.2 bouyer |AHC_SG_PRELOAD|AHC_MULTI_TID|AHC_HS_MAILBOX
139 1.19.10.2 bouyer |AHC_NEW_TERMCTL,
140 1.19.10.2 bouyer AHC_AIC7892_FE = AHC_AIC7890_FE|AHC_DT,
141 1.19.10.2 bouyer AHC_AIC7895_FE = AHC_AIC7880_FE|AHC_MORE_SRAM
142 1.19.10.2 bouyer |AHC_CMD_CHAN|AHC_MULTI_FUNC,
143 1.19.10.2 bouyer AHC_AIC7895C_FE = AHC_AIC7895_FE|AHC_MULTI_TID,
144 1.19.10.2 bouyer AHC_AIC7896_FE = AHC_AIC7890_FE|AHC_MULTI_FUNC,
145 1.19.10.2 bouyer AHC_AIC7899_FE = AHC_AIC7892_FE|AHC_MULTI_FUNC
146 1.19.10.2 bouyer } ahc_feature;
147 1.4 mycroft
148 1.4 mycroft typedef enum {
149 1.19.10.2 bouyer AHC_FNONE = 0x000,
150 1.19.10.2 bouyer AHC_PAGESCBS = 0x001,/* Enable SCB paging */
151 1.19.10.2 bouyer AHC_CHANNEL_B_PRIMARY = 0x002,/*
152 1.4 mycroft * On twin channel adapters, probe
153 1.4 mycroft * channel B first since it is the
154 1.4 mycroft * primary bus.
155 1.4 mycroft */
156 1.19.10.2 bouyer AHC_USEDEFAULTS = 0x004,/*
157 1.4 mycroft * For cards without an seeprom
158 1.4 mycroft * or a BIOS to initialize the chip's
159 1.4 mycroft * SRAM, we use the default target
160 1.4 mycroft * settings.
161 1.4 mycroft */
162 1.19.10.2 bouyer AHC_SHARED_SRAM = 0x010,
163 1.19.10.2 bouyer AHC_LARGE_SEEPROM = 0x020,/* Uses C56_66 not C46 */
164 1.19.10.2 bouyer AHC_RESET_BUS_A = 0x040,
165 1.19.10.2 bouyer AHC_RESET_BUS_B = 0x080,
166 1.19.10.2 bouyer AHC_EXTENDED_TRANS_A = 0x100,
167 1.19.10.2 bouyer AHC_EXTENDED_TRANS_B = 0x200,
168 1.19.10.2 bouyer AHC_TERM_ENB_A = 0x400,
169 1.19.10.2 bouyer AHC_TERM_ENB_B = 0x800,
170 1.19.10.2 bouyer AHC_INITIATORMODE = 0x1000,/*
171 1.19.10.2 bouyer * Allow initiator operations on
172 1.19.10.2 bouyer * this controller.
173 1.19.10.2 bouyer */
174 1.19.10.2 bouyer AHC_TARGETMODE = 0x2000,/*
175 1.19.10.2 bouyer * Allow target operations on this
176 1.19.10.2 bouyer * controller.
177 1.19.10.2 bouyer */
178 1.19.10.2 bouyer AHC_NEWEEPROM_FMT = 0x4000,
179 1.19.10.2 bouyer AHC_RESOURCE_SHORTAGE = 0x8000,
180 1.19.10.2 bouyer AHC_TQINFIFO_BLOCKED = 0x10000,/* Blocked waiting for ATIOs */
181 1.19.10.2 bouyer AHC_INT50_SPEEDFLEX = 0x20000,/*
182 1.19.10.2 bouyer * Internal 50pin connector
183 1.19.10.2 bouyer * sits behind an aic3860
184 1.19.10.2 bouyer */
185 1.19.10.2 bouyer } ahc_flag;
186 1.4 mycroft
187 1.4 mycroft typedef enum {
188 1.9 gibbs SCB_FREE = 0x0000,
189 1.19.10.2 bouyer SCB_OTHERTCL_TIMEOUT = 0x0002,/*
190 1.19.10.2 bouyer * Another device was active
191 1.19.10.2 bouyer * during the first timeout for
192 1.19.10.2 bouyer * this SCB so we gave ourselves
193 1.19.10.2 bouyer * an additional timeout period
194 1.19.10.2 bouyer * in case it was hogging the
195 1.19.10.2 bouyer * bus.
196 1.19.10.2 bouyer */
197 1.9 gibbs SCB_DEVICE_RESET = 0x0004,
198 1.19.10.2 bouyer SCB_SENSE = 0x0008,
199 1.19.10.2 bouyer SCB_FREEZE_QUEUE = 0x0010,
200 1.19.10.2 bouyer SCB_REQUEUE = 0x0020,
201 1.19.10.2 bouyer SCB_RECOVERY_SCB = 0x0040,
202 1.19.10.2 bouyer SCB_ABORT = 0x1000,
203 1.19.10.2 bouyer SCB_QUEUED_MSG = 0x2000,
204 1.19.10.2 bouyer SCB_ACTIVE = 0x4000,
205 1.19.10.2 bouyer SCB_TARGET_IMMEDIATE = 0x8000
206 1.19.10.2 bouyer } scb_flag;
207 1.19.10.2 bouyer
208 1.19.10.2 bouyer typedef enum {
209 1.19.10.2 bouyer MSGLOOP_IN_PROG,
210 1.19.10.2 bouyer MSGLOOP_MSGCOMPLETE,
211 1.19.10.2 bouyer MSGLOOP_TERMINATED
212 1.19.10.2 bouyer } msg_loop_stat;
213 1.19.10.2 bouyer
214 1.19.10.2 bouyer /*
215 1.19.10.2 bouyer * The driver keeps up to MAX_SCB scb structures per card in memory. The SCB
216 1.19.10.2 bouyer * consists of a "hardware SCB" mirroring the fields availible on the card
217 1.19.10.2 bouyer * and additional information the kernel stores for each transaction.
218 1.1 mycroft */
219 1.19.10.2 bouyer struct hardware_scb {
220 1.19.10.2 bouyer /*0*/ u_int8_t control;
221 1.19.10.2 bouyer /*1*/ u_int8_t tcl; /* 4/1/3 bits */
222 1.19.10.2 bouyer /*2*/ u_int8_t status;
223 1.19.10.2 bouyer /*3*/ u_int8_t SG_count;
224 1.19.10.2 bouyer /*4*/ u_int32_t SG_pointer;
225 1.19.10.2 bouyer /*8*/ u_int8_t residual_SG_count;
226 1.19.10.2 bouyer /*9*/ u_int8_t residual_data_count[3];
227 1.19.10.2 bouyer /*12*/ u_int32_t data;
228 1.19.10.2 bouyer /*16*/ u_int32_t datalen; /* Really only three bytes, but its
229 1.4 mycroft * faster to treat it as a long on
230 1.4 mycroft * a quad boundary.
231 1.4 mycroft */
232 1.19.10.2 bouyer /*20*/ u_int32_t cmdpointer;
233 1.19.10.2 bouyer /*24*/ u_int8_t cmdlen;
234 1.19.10.2 bouyer /*25*/ u_int8_t tag; /* Index into our kernel SCB array.
235 1.4 mycroft * Also used as the tag for tagged I/O
236 1.4 mycroft */
237 1.19.10.2 bouyer /*26*/ u_int8_t next; /* Used for threading SCBs in the
238 1.4 mycroft * "Waiting for Selection" and
239 1.4 mycroft * "Disconnected SCB" lists down
240 1.4 mycroft * in the sequencer.
241 1.4 mycroft */
242 1.19.10.2 bouyer /*27*/ u_int8_t scsirate; /* Value for SCSIRATE register */
243 1.19.10.2 bouyer /*28*/ u_int8_t scsioffset; /* Value for SCSIOFFSET register */
244 1.19.10.2 bouyer /*29*/ u_int8_t spare[3]; /*
245 1.19.10.2 bouyer * Spare space available on
246 1.19.10.2 bouyer * all controller types.
247 1.19.10.2 bouyer */
248 1.19.10.2 bouyer /*32*/ u_int8_t cmdstore[16]; /*
249 1.19.10.2 bouyer * CDB storage for controllers
250 1.19.10.2 bouyer * supporting 64 byte SCBs.
251 1.19.10.2 bouyer */
252 1.19.10.2 bouyer /*48*/ u_int32_t cmdstore_busaddr; /*
253 1.19.10.2 bouyer * Address of command store for
254 1.19.10.2 bouyer * 32byte SCB adapters
255 1.19.10.2 bouyer */
256 1.19.10.2 bouyer /*48*/ u_int8_t spare_64[12]; /*
257 1.19.10.2 bouyer * Pad to 64 bytes.
258 1.19.10.2 bouyer */
259 1.19.10.2 bouyer };
260 1.15 leo
261 1.19.10.2 bouyer struct scb {
262 1.19.10.2 bouyer struct hardware_scb *hscb;
263 1.19.10.2 bouyer SLIST_ENTRY(scb) links; /* for chaining */
264 1.19.10.2 bouyer LIST_ENTRY(scb) plinks; /* pending chain */
265 1.19.10.2 bouyer struct scsipi_xfer *xs;
266 1.19.10.2 bouyer scb_flag flags;
267 1.19.10.2 bouyer bus_dmamap_t dmamap;
268 1.19.10.2 bouyer struct ahc_dma_seg *sg_list;
269 1.19.10.2 bouyer bus_addr_t sg_list_phys;
270 1.19.10.2 bouyer u_int sg_count;/* How full ahc_dma_seg is */
271 1.19.10.2 bouyer };
272 1.15 leo
273 1.19.10.2 bouyer /*
274 1.19.10.2 bouyer * Connection desciptor for select-in requests in target mode.
275 1.19.10.2 bouyer * The first byte is the connecting target, followed by identify
276 1.19.10.2 bouyer * message and optional tag information, terminated by 0xFF. The
277 1.19.10.2 bouyer * remainder is the command to execute. The cmd_valid byte is on
278 1.19.10.2 bouyer * an 8 byte boundary to simplify setting it on aic7880 hardware
279 1.19.10.2 bouyer * which only has limited direct access to the DMA FIFO.
280 1.19.10.2 bouyer */
281 1.19.10.2 bouyer struct target_cmd {
282 1.19.10.2 bouyer u_int8_t initiator_channel;
283 1.19.10.2 bouyer u_int8_t targ_id; /* Target ID we were selected at */
284 1.19.10.2 bouyer u_int8_t identify; /* Identify message */
285 1.19.10.2 bouyer u_int8_t bytes[21];
286 1.19.10.2 bouyer u_int8_t cmd_valid;
287 1.19.10.2 bouyer u_int8_t pad[7];
288 1.1 mycroft };
289 1.1 mycroft
290 1.19.10.2 bouyer /*
291 1.19.10.2 bouyer * Number of events we can buffer up if we run out
292 1.19.10.2 bouyer * of immediate notify ccbs.
293 1.19.10.2 bouyer */
294 1.19.10.2 bouyer #define AHC_TMODE_EVENT_BUFFER_SIZE 8
295 1.19.10.2 bouyer struct ahc_tmode_event {
296 1.19.10.2 bouyer u_int8_t initiator_id;
297 1.19.10.2 bouyer u_int8_t event_type; /* MSG type or EVENT_TYPE_BUS_RESET */
298 1.19.10.2 bouyer #define EVENT_TYPE_BUS_RESET 0xFF
299 1.19.10.2 bouyer u_int8_t event_arg;
300 1.19.10.2 bouyer };
301 1.15 leo
302 1.19.10.2 bouyer /*
303 1.19.10.2 bouyer * Per lun target mode state including accept TIO CCB
304 1.19.10.2 bouyer * and immediate notify CCB pools.
305 1.19.10.2 bouyer */
306 1.19.10.2 bouyer struct tmode_lstate {
307 1.19.10.2 bouyer #ifdef maybe_later
308 1.19.10.2 bouyer struct cam_path *path;
309 1.19.10.2 bouyer struct ccb_hdr_slist accept_tios;
310 1.19.10.2 bouyer struct ccb_hdr_slist immed_notifies;
311 1.19.10.2 bouyer struct ahc_tmode_event event_buffer[AHC_TMODE_EVENT_BUFFER_SIZE];
312 1.19.10.2 bouyer u_int8_t event_r_idx;
313 1.19.10.2 bouyer u_int8_t event_w_idx;
314 1.19.10.2 bouyer #else
315 1.19.10.2 bouyer u_int8_t dummy;
316 1.1 mycroft #endif
317 1.19.10.2 bouyer };
318 1.19.10.2 bouyer
319 1.19.10.2 bouyer #define AHC_TRANS_CUR 0x01 /* Modify current neogtiation status */
320 1.19.10.2 bouyer #define AHC_TRANS_ACTIVE 0x03 /* Assume this is the active target */
321 1.19.10.2 bouyer #define AHC_TRANS_GOAL 0x04 /* Modify negotiation goal */
322 1.19.10.2 bouyer #define AHC_TRANS_USER 0x08 /* Modify user negotiation settings */
323 1.19.10.2 bouyer
324 1.19.10.2 bouyer struct ahc_transinfo {
325 1.19.10.2 bouyer u_int8_t width;
326 1.19.10.2 bouyer u_int8_t period;
327 1.19.10.2 bouyer u_int8_t offset;
328 1.19.10.2 bouyer u_int8_t ppr_flags;
329 1.19.10.2 bouyer };
330 1.19.10.2 bouyer
331 1.19.10.2 bouyer struct ahc_initiator_tinfo {
332 1.19.10.2 bouyer u_int8_t scsirate;
333 1.19.10.2 bouyer struct ahc_transinfo current;
334 1.19.10.2 bouyer struct ahc_transinfo goal;
335 1.19.10.2 bouyer struct ahc_transinfo user;
336 1.19.10.2 bouyer };
337 1.19.10.2 bouyer
338 1.19.10.2 bouyer /*
339 1.19.10.2 bouyer * Per target mode enabled target state. Esentially just an array of
340 1.19.10.2 bouyer * pointers to lun target state as well as sync/wide negotiation information
341 1.19.10.2 bouyer * for each initiator<->target mapping (including the mapping for when we
342 1.19.10.2 bouyer * are the initiator).
343 1.19.10.2 bouyer */
344 1.19.10.2 bouyer struct tmode_tstate {
345 1.19.10.2 bouyer #if 0
346 1.19.10.2 bouyer struct tmode_lstate* enabled_luns[8];
347 1.1 mycroft #endif
348 1.19.10.2 bouyer struct ahc_initiator_tinfo transinfo[16];
349 1.19.10.2 bouyer
350 1.19.10.2 bouyer /*
351 1.19.10.2 bouyer * Per initiator state bitmasks.
352 1.19.10.2 bouyer */
353 1.19.10.2 bouyer u_int16_t ultraenb; /* Using ultra sync rate */
354 1.19.10.2 bouyer u_int16_t discenable; /* Disconnection allowed */
355 1.19.10.2 bouyer u_int16_t tagenable; /* Tagged Queuing allowed */
356 1.19.10.2 bouyer u_int16_t tagdisable; /* TQ explicity disallowed */
357 1.1 mycroft };
358 1.4 mycroft
359 1.19.10.2 bouyer #define AHC_TARGET_WILDCARD -1
360 1.19.10.2 bouyer #define AHC_LUN_WILDCARD -1
361 1.19.10.2 bouyer
362 1.19.10.2 bouyer /*
363 1.19.10.2 bouyer * XXX translate FreeBSD SCSI status byte values to NetBSD, and define
364 1.19.10.2 bouyer * a few more.
365 1.19.10.2 bouyer */
366 1.19.10.2 bouyer #define SCSI_STATUS_OK SCSI_OK
367 1.19.10.2 bouyer #define SCSI_STATUS_CHECK_COND SCSI_CHECK
368 1.19.10.2 bouyer #define SCSI_STATUS_COND_MET 0x04
369 1.19.10.2 bouyer #define SCSI_STATUS_BUSY SCSI_BUSY
370 1.19.10.2 bouyer #define SCSI_STATUS_INTERMED SCSI_INTERM
371 1.19.10.2 bouyer #define SCSI_STATUS_INTERMED_COND_MET 0x14
372 1.19.10.2 bouyer #define SCSI_STATUS_RESERV_CONFLICT 0x18
373 1.19.10.2 bouyer #define SCSI_STATUS_CMD_TERMINATED 0x22
374 1.19.10.2 bouyer #define SCSI_STATUS_QUEUE_FULL SCSI_QUEUE_FULL
375 1.19.10.2 bouyer
376 1.19.10.2 bouyer /*
377 1.19.10.2 bouyer * Define the format of the aic7XXX SEEPROM registers (16 bits).
378 1.19.10.2 bouyer */
379 1.19.10.2 bouyer
380 1.19.10.2 bouyer struct seeprom_config {
381 1.19.10.2 bouyer /*
382 1.19.10.2 bouyer * SCSI ID Configuration Flags
383 1.19.10.2 bouyer */
384 1.19.10.2 bouyer u_int16_t device_flags[16]; /* words 0-15 */
385 1.19.10.2 bouyer #define CFXFER 0x0007 /* synchronous transfer rate */
386 1.19.10.2 bouyer #define CFSYNCH 0x0008 /* enable synchronous transfer */
387 1.19.10.2 bouyer #define CFDISC 0x0010 /* enable disconnection */
388 1.19.10.2 bouyer #define CFWIDEB 0x0020 /* wide bus device */
389 1.19.10.2 bouyer #define CFSYNCHISULTRA 0x0040 /* CFSYNCH is an ultra offset (2940AU)*/
390 1.19.10.2 bouyer #define CFSYNCSINGLE 0x0080 /* Single-Transition signalling */
391 1.19.10.2 bouyer #define CFSTART 0x0100 /* send start unit SCSI command */
392 1.19.10.2 bouyer #define CFINCBIOS 0x0200 /* include in BIOS scan */
393 1.19.10.2 bouyer #define CFRNFOUND 0x0400 /* report even if not found */
394 1.19.10.2 bouyer #define CFMULTILUN 0x0800 /* Probe multiple luns in BIOS scan */
395 1.19.10.2 bouyer #define CFWBCACHEENB 0x4000 /* Enable W-Behind Cache on disks */
396 1.19.10.2 bouyer #define CFWBCACHENOP 0xc000 /* Don't touch W-Behind Cache */
397 1.19.10.2 bouyer
398 1.19.10.2 bouyer /*
399 1.19.10.2 bouyer * BIOS Control Bits
400 1.19.10.2 bouyer */
401 1.19.10.2 bouyer u_int16_t bios_control; /* word 16 */
402 1.19.10.2 bouyer #define CFSUPREM 0x0001 /* support all removeable drives */
403 1.19.10.2 bouyer #define CFSUPREMB 0x0002 /* support removeable boot drives */
404 1.19.10.2 bouyer #define CFBIOSEN 0x0004 /* BIOS enabled */
405 1.19.10.2 bouyer /* UNUSED 0x0008 */
406 1.19.10.2 bouyer #define CFSM2DRV 0x0010 /* support more than two drives */
407 1.19.10.2 bouyer #define CF284XEXTEND 0x0020 /* extended translation (284x cards) */
408 1.19.10.2 bouyer /* UNUSED 0x0040 */
409 1.19.10.2 bouyer #define CFEXTEND 0x0080 /* extended translation enabled */
410 1.19.10.2 bouyer /* UNUSED 0xff00 */
411 1.19.10.2 bouyer
412 1.19.10.2 bouyer /*
413 1.19.10.2 bouyer * Host Adapter Control Bits
414 1.19.10.2 bouyer */
415 1.19.10.2 bouyer u_int16_t adapter_control; /* word 17 */
416 1.19.10.2 bouyer #define CFAUTOTERM 0x0001 /* Perform Auto termination */
417 1.19.10.2 bouyer #define CFULTRAEN 0x0002 /* Ultra SCSI speed enable */
418 1.19.10.2 bouyer #define CF284XSELTO 0x0003 /* Selection timeout (284x cards) */
419 1.19.10.2 bouyer #define CF284XFIFO 0x000C /* FIFO Threshold (284x cards) */
420 1.19.10.2 bouyer #define CFSTERM 0x0004 /* SCSI low byte termination */
421 1.19.10.2 bouyer #define CFWSTERM 0x0008 /* SCSI high byte termination */
422 1.19.10.2 bouyer #define CFSPARITY 0x0010 /* SCSI parity */
423 1.19.10.2 bouyer #define CF284XSTERM 0x0020 /* SCSI low byte term (284x cards) */
424 1.19.10.2 bouyer #define CFRESETB 0x0040 /* reset SCSI bus at boot */
425 1.19.10.2 bouyer #define CFCHNLBPRIMARY 0x0100 /* aic7895 probe B channel first */
426 1.19.10.2 bouyer #define CFSEAUTOTERM 0x0400 /* aic7890 Perform SE Auto Termination*/
427 1.19.10.2 bouyer #define CFLVDSTERM 0x0800 /* aic7890 LVD Termination */
428 1.19.10.2 bouyer /* UNUSED 0xf280 */
429 1.19.10.2 bouyer
430 1.19.10.2 bouyer /*
431 1.19.10.2 bouyer * Bus Release, Host Adapter ID
432 1.19.10.2 bouyer */
433 1.19.10.2 bouyer u_int16_t brtime_id; /* word 18 */
434 1.19.10.2 bouyer #define CFSCSIID 0x000f /* host adapter SCSI ID */
435 1.19.10.2 bouyer /* UNUSED 0x00f0 */
436 1.19.10.2 bouyer #define CFBRTIME 0xff00 /* bus release time */
437 1.19.10.2 bouyer
438 1.19.10.2 bouyer /*
439 1.19.10.2 bouyer * Maximum targets
440 1.19.10.2 bouyer */
441 1.19.10.2 bouyer u_int16_t max_targets; /* word 19 */
442 1.19.10.2 bouyer #define CFMAXTARG 0x00ff /* maximum targets */
443 1.19.10.2 bouyer /* UNUSED 0xff00 */
444 1.19.10.2 bouyer u_int16_t res_1[11]; /* words 20-30 */
445 1.19.10.2 bouyer u_int16_t checksum; /* word 31 */
446 1.19.10.2 bouyer };
447 1.19.10.2 bouyer
448 1.19.10.2 bouyer struct ahc_syncrate {
449 1.19.10.2 bouyer int sxfr_u2;
450 1.19.10.2 bouyer int sxfr;
451 1.19.10.2 bouyer /* Rates in Ultra mode have bit 8 of sxfr set */
452 1.19.10.2 bouyer #define ULTRA_SXFR 0x100
453 1.19.10.2 bouyer #define ST_SXFR 0x010
454 1.19.10.2 bouyer u_int8_t period; /* Period to send to SCSI target */
455 1.19.10.2 bouyer char *rate;
456 1.19.10.2 bouyer };
457 1.19.10.2 bouyer
458 1.19.10.2 bouyer typedef enum {
459 1.19.10.2 bouyer MSG_TYPE_NONE = 0x00,
460 1.19.10.2 bouyer MSG_TYPE_INITIATOR_MSGOUT = 0x01,
461 1.19.10.2 bouyer MSG_TYPE_INITIATOR_MSGIN = 0x02,
462 1.19.10.2 bouyer MSG_TYPE_TARGET_MSGOUT = 0x03,
463 1.19.10.2 bouyer MSG_TYPE_TARGET_MSGIN = 0x04
464 1.19.10.2 bouyer } ahc_msg_type;
465 1.19.10.2 bouyer
466 1.19.10.2 bouyer struct sg_map_node {
467 1.19.10.2 bouyer bus_dmamap_t sg_dmamap;
468 1.19.10.2 bouyer bus_addr_t sg_physaddr;
469 1.19.10.2 bouyer bus_dma_segment_t sg_dmasegs;
470 1.19.10.2 bouyer int sg_nseg;
471 1.19.10.2 bouyer struct ahc_dma_seg* sg_vaddr;
472 1.19.10.2 bouyer SLIST_ENTRY(sg_map_node) links;
473 1.19.10.2 bouyer };
474 1.19.10.2 bouyer
475 1.19.10.2 bouyer struct scb_data {
476 1.19.10.2 bouyer struct hardware_scb *hscbs; /* Array of hardware SCBs */
477 1.19.10.2 bouyer struct scb *scbarray; /* Array of kernel SCBs */
478 1.19.10.2 bouyer SLIST_HEAD(, scb) free_scbs; /*
479 1.19.10.2 bouyer * Pool of SCBs ready to be assigned
480 1.19.10.2 bouyer * commands to execute.
481 1.19.10.2 bouyer */
482 1.19.10.2 bouyer struct scsipi_sense_data *sense; /* Per SCB sense data */
483 1.19.10.2 bouyer
484 1.19.10.2 bouyer /*
485 1.19.10.2 bouyer * "Bus" addresses of our data structures.
486 1.19.10.2 bouyer */
487 1.19.10.2 bouyer bus_dmamap_t hscb_dmamap;
488 1.19.10.2 bouyer bus_addr_t hscb_busaddr;
489 1.19.10.2 bouyer bus_dma_segment_t hscb_seg;
490 1.19.10.2 bouyer int hscb_nseg;
491 1.19.10.2 bouyer int hscb_size;
492 1.19.10.2 bouyer
493 1.19.10.2 bouyer bus_dmamap_t sense_dmamap;
494 1.19.10.2 bouyer bus_addr_t sense_busaddr;
495 1.19.10.2 bouyer bus_dma_segment_t sense_seg;
496 1.19.10.2 bouyer int sense_nseg;
497 1.19.10.2 bouyer int sense_size;
498 1.19.10.2 bouyer
499 1.19.10.2 bouyer SLIST_HEAD(, sg_map_node) sg_maps;
500 1.19.10.2 bouyer u_int8_t numscbs;
501 1.19.10.2 bouyer u_int8_t maxhscbs; /* Number of SCBs on the card */
502 1.19.10.2 bouyer u_int8_t init_level; /*
503 1.19.10.2 bouyer * How far we've initialized
504 1.19.10.2 bouyer * this structure.
505 1.19.10.2 bouyer */
506 1.19.10.2 bouyer };
507 1.19.10.2 bouyer
508 1.19.10.2 bouyer struct ahc_softc {
509 1.19.10.2 bouyer struct device sc_dev;
510 1.19.10.2 bouyer
511 1.19.10.4 bouyer struct scsipi_channel sc_channel;
512 1.19.10.4 bouyer struct scsipi_channel sc_channel_b;
513 1.19.10.2 bouyer struct scsipi_adapter sc_adapter;
514 1.19.10.2 bouyer
515 1.19.10.2 bouyer bus_space_tag_t tag;
516 1.19.10.2 bouyer bus_space_handle_t bsh;
517 1.19.10.2 bouyer struct scb_data *scb_data;
518 1.19.10.2 bouyer
519 1.19.10.2 bouyer #define AHC_NEG_PENDING 0x01
520 1.19.10.2 bouyer #define AHC_NEG_SDTRDONE 0x02
521 1.19.10.2 bouyer #define AHC_NEG_WDTRDONE 0x04
522 1.19.10.2 bouyer u_int8_t inited_channels[2];
523 1.19.10.2 bouyer
524 1.19.10.2 bouyer /*
525 1.19.10.2 bouyer * SCBs that have been send to the controller
526 1.19.10.2 bouyer */
527 1.19.10.2 bouyer LIST_HEAD(, scb) pending_ccbs;
528 1.19.10.2 bouyer
529 1.19.10.2 bouyer /*
530 1.19.10.2 bouyer * Target mode related state kept on a per enabled lun basis.
531 1.19.10.2 bouyer * Targets that are not enabled will have null entries.
532 1.19.10.2 bouyer * As an initiator, we keep one target entry for our initiator
533 1.19.10.2 bouyer * ID to store our sync/wide transfer settings.
534 1.19.10.2 bouyer */
535 1.19.10.2 bouyer struct tmode_tstate* enabled_targets[16];
536 1.19.10.2 bouyer
537 1.19.10.2 bouyer /*
538 1.19.10.2 bouyer * The black hole device responsible for handling requests for
539 1.19.10.2 bouyer * disabled luns on enabled targets.
540 1.19.10.2 bouyer */
541 1.19.10.2 bouyer struct tmode_lstate* black_hole;
542 1.19.10.2 bouyer
543 1.19.10.2 bouyer /*
544 1.19.10.2 bouyer * Device instance currently on the bus awaiting a continue TIO
545 1.19.10.2 bouyer * for a command that was not given the disconnect priveledge.
546 1.19.10.2 bouyer */
547 1.19.10.2 bouyer struct tmode_lstate* pending_device;
548 1.19.10.2 bouyer
549 1.19.10.2 bouyer /*
550 1.19.10.2 bouyer * Card characteristics
551 1.19.10.2 bouyer */
552 1.19.10.2 bouyer ahc_chip chip;
553 1.19.10.2 bouyer ahc_feature features;
554 1.19.10.2 bouyer ahc_flag flags;
555 1.19.10.2 bouyer
556 1.19.10.2 bouyer /* Values to store in the SEQCTL register for pause and unpause */
557 1.19.10.2 bouyer u_int8_t unpause;
558 1.19.10.2 bouyer u_int8_t pause;
559 1.19.10.2 bouyer
560 1.19.10.2 bouyer /* Command Queues */
561 1.19.10.2 bouyer u_int8_t qoutfifonext;
562 1.19.10.2 bouyer u_int8_t qinfifonext;
563 1.19.10.2 bouyer u_int8_t *qoutfifo;
564 1.19.10.2 bouyer u_int8_t *qinfifo;
565 1.19.10.2 bouyer
566 1.19.10.2 bouyer /*
567 1.19.10.2 bouyer * 256 byte array storing the SCBID of outstanding
568 1.19.10.2 bouyer * untagged SCBs indexed by TCL.
569 1.19.10.2 bouyer */
570 1.19.10.2 bouyer u_int8_t *untagged_scbs;
571 1.19.10.2 bouyer
572 1.19.10.2 bouyer /* Channel Names ('A', 'B', etc.) */
573 1.19.10.2 bouyer char channel;
574 1.19.10.2 bouyer char channel_b;
575 1.19.10.2 bouyer
576 1.19.10.2 bouyer /* Initiator Bus ID */
577 1.19.10.2 bouyer u_int8_t our_id;
578 1.19.10.2 bouyer u_int8_t our_id_b;
579 1.19.10.2 bouyer
580 1.19.10.2 bouyer /* Targets that need negotiation messages */
581 1.19.10.2 bouyer u_int16_t targ_msg_req;
582 1.19.10.2 bouyer
583 1.19.10.2 bouyer /*
584 1.19.10.2 bouyer * PCI error detection and data for running the
585 1.19.10.2 bouyer * PCI error interrupt handler.
586 1.19.10.2 bouyer */
587 1.19.10.2 bouyer int unsolicited_ints;
588 1.19.10.2 bouyer
589 1.19.10.2 bouyer /*
590 1.19.10.2 bouyer * Target incoming command FIFO.
591 1.19.10.2 bouyer */
592 1.19.10.2 bouyer struct target_cmd *targetcmds;
593 1.19.10.2 bouyer u_int8_t tqinfifonext;
594 1.19.10.2 bouyer
595 1.19.10.2 bouyer /*
596 1.19.10.2 bouyer * Incoming and outgoing message handling.
597 1.19.10.2 bouyer */
598 1.19.10.2 bouyer u_int8_t send_msg_perror;
599 1.19.10.2 bouyer ahc_msg_type msg_type;
600 1.19.10.2 bouyer u_int8_t msgout_buf[8]; /* Message we are sending */
601 1.19.10.2 bouyer u_int8_t msgin_buf[8]; /* Message we are receiving */
602 1.19.10.2 bouyer u_int msgout_len; /* Length of message to send */
603 1.19.10.2 bouyer u_int msgout_index; /* Current index in msgout */
604 1.19.10.2 bouyer u_int msgin_index; /* Current index in msgin */
605 1.19.10.2 bouyer
606 1.19.10.2 bouyer void *ih;
607 1.19.10.2 bouyer bus_dma_tag_t parent_dmat;
608 1.19.10.2 bouyer int sc_dmaflags;
609 1.19.10.2 bouyer bus_dmamap_t shared_data_dmamap;
610 1.19.10.2 bouyer bus_addr_t shared_data_busaddr;
611 1.19.10.2 bouyer bus_dma_segment_t shared_data_seg;
612 1.19.10.2 bouyer int shared_data_nseg;
613 1.19.10.2 bouyer int shared_data_size;
614 1.19.10.2 bouyer bus_addr_t dma_bug_buf;
615 1.19.10.2 bouyer
616 1.19.10.2 bouyer /* Number of enabled target mode device on this card */
617 1.19.10.2 bouyer u_int enabled_luns;
618 1.19.10.2 bouyer
619 1.19.10.2 bouyer /* Initialization level of this data structure */
620 1.19.10.2 bouyer u_int init_level;
621 1.19.10.2 bouyer
622 1.19.10.2 bouyer u_int16_t user_discenable;/* Disconnection allowed */
623 1.19.10.2 bouyer u_int16_t user_tagenable;/* Tagged Queuing allowed */
624 1.19.10.2 bouyer
625 1.19.10.2 bouyer void *bus_data;
626 1.19.10.2 bouyer int (*bus_intr)(struct ahc_softc *);
627 1.19.10.2 bouyer };
628 1.19.10.2 bouyer
629 1.19.10.2 bouyer struct full_ahc_softc {
630 1.19.10.2 bouyer struct ahc_softc softc;
631 1.19.10.2 bouyer struct scb_data scb_data_storage;
632 1.19.10.2 bouyer };
633 1.19.10.2 bouyer
634 1.19.10.2 bouyer /* #define AHC_DEBUG 0x019f */
635 1.19.10.2 bouyer
636 1.4 mycroft #ifdef AHC_DEBUG
637 1.4 mycroft /* Different debugging levels used when AHC_DEBUG is defined */
638 1.19.10.2 bouyer #define AHC_SHOWMISC 0x0001
639 1.19.10.2 bouyer #define AHC_SHOWCMDS 0x0002
640 1.19.10.2 bouyer #define AHC_SHOWSCBS 0x0004
641 1.19.10.2 bouyer #define AHC_SHOWABORTS 0x0008
642 1.19.10.2 bouyer #define AHC_SHOWSENSE 0x0010
643 1.19.10.2 bouyer #define AHC_SHOWSCBCNT 0x0020
644 1.19.10.2 bouyer #define AHC_SHOWSCBALLOC 0x0040
645 1.19.10.2 bouyer #define AHC_SHOWINTR 0x0080
646 1.19.10.2 bouyer #define AHC_SHOWMSG 0x0100
647 1.4 mycroft
648 1.4 mycroft extern int ahc_debug; /* Initialized in i386/scsi/aic7xxx.c */
649 1.4 mycroft #endif
650 1.4 mycroft
651 1.19.10.2 bouyer char *ahc_name(struct ahc_softc *ahc);
652 1.4 mycroft
653 1.19.10.2 bouyer int ahc_alloc(struct ahc_softc *ahc, bus_space_handle_t sh,
654 1.19.10.2 bouyer bus_space_tag_t st, bus_dma_tag_t parent_dmat,
655 1.19.10.2 bouyer ahc_chip chip, ahc_feature features, ahc_flag flags);
656 1.19.10.2 bouyer int ahc_reset(struct ahc_softc *ahc);
657 1.19.10.2 bouyer void ahc_free(struct ahc_softc *);
658 1.19.10.2 bouyer int ahc_probe_scbs(struct ahc_softc *);
659 1.19.10.2 bouyer int ahc_init(struct ahc_softc *);
660 1.19.10.2 bouyer int ahc_attach(struct ahc_softc *);
661 1.19.10.2 bouyer int ahc_intr(void *arg);
662 1.4 mycroft
663 1.19.10.2 bouyer /*
664 1.19.10.2 bouyer * SEEPROM related functions.
665 1.19.10.2 bouyer */
666 1.19.10.2 bouyer void check_extport(struct ahc_softc *ahc, u_int *sxfrctl1);
667 1.4 mycroft
668 1.4 mycroft
669 1.19.10.2 bouyer #define ahc_inb(ahc, port) \
670 1.19.10.2 bouyer bus_space_read_1((ahc)->tag, (ahc)->bsh, port)
671 1.19.10.2 bouyer
672 1.19.10.2 bouyer #define ahc_outb(ahc, port, value) \
673 1.19.10.2 bouyer bus_space_write_1((ahc)->tag, (ahc)->bsh, port, value)
674 1.19.10.2 bouyer
675 1.19.10.2 bouyer #define ahc_outsb(ahc, port, valp, count) \
676 1.19.10.2 bouyer bus_space_write_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count)
677 1.19.10.2 bouyer
678 1.19.10.2 bouyer #define ahc_insb(ahc, port, valp, count) \
679 1.19.10.2 bouyer bus_space_read_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count)
680 1.1 mycroft
681 1.1 mycroft #endif /* _AIC7XXX_H_ */
682