aic7xxxvar.h revision 1.33 1 1.1 mycroft /*
2 1.33 fvdl * Core definitions and data structures shareable across OS platforms.
3 1.1 mycroft *
4 1.33 fvdl * Copyright (c) 1994-2001 Justin T. Gibbs.
5 1.33 fvdl * Copyright (c) 2000-2001 Adaptec Inc.
6 1.1 mycroft * All rights reserved.
7 1.1 mycroft *
8 1.1 mycroft * Redistribution and use in source and binary forms, with or without
9 1.1 mycroft * modification, are permitted provided that the following conditions
10 1.1 mycroft * are met:
11 1.1 mycroft * 1. Redistributions of source code must retain the above copyright
12 1.21 fvdl * notice, this list of conditions, and the following disclaimer,
13 1.21 fvdl * without modification.
14 1.33 fvdl * 2. Redistributions in binary form must reproduce at minimum a disclaimer
15 1.33 fvdl * substantially similar to the "NO WARRANTY" disclaimer below
16 1.33 fvdl * ("Disclaimer") and any redistribution must be conditioned upon
17 1.33 fvdl * including a substantially similar Disclaimer requirement for further
18 1.33 fvdl * binary redistribution.
19 1.33 fvdl * 3. Neither the names of the above-listed copyright holders nor the names
20 1.33 fvdl * of any contributors may be used to endorse or promote products derived
21 1.33 fvdl * from this software without specific prior written permission.
22 1.4 mycroft *
23 1.21 fvdl * Alternatively, this software may be distributed under the terms of the
24 1.33 fvdl * GNU General Public License ("GPL") version 2 as published by the Free
25 1.33 fvdl * Software Foundation.
26 1.21 fvdl *
27 1.33 fvdl * NO WARRANTY
28 1.33 fvdl * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 1.33 fvdl * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 1.33 fvdl * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
31 1.33 fvdl * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 1.33 fvdl * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 1.4 mycroft * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 1.4 mycroft * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 1.33 fvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36 1.33 fvdl * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
37 1.33 fvdl * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 1.33 fvdl * POSSIBILITY OF SUCH DAMAGES.
39 1.33 fvdl *
40 1.33 fvdl * $Id: aic7xxxvar.h,v 1.33 2003/04/19 19:33:30 fvdl Exp $
41 1.8 explorer *
42 1.33 fvdl * $FreeBSD: /repoman/r/ncvs/src/sys/dev/aic7xxx/aic7xxx.h,v 1.44 2003/01/20 20:44:55 gibbs Exp $
43 1.1 mycroft */
44 1.33 fvdl /*
45 1.33 fvdl * Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc. - April 2003
46 1.33 fvdl */
47 1.33 fvdl
48 1.33 fvdl #ifndef _AIC7XXXVAR_H_
49 1.33 fvdl #define _AIC7XXXVAR_H_
50 1.33 fvdl
51 1.33 fvdl #define AHC_DEBUG
52 1.33 fvdl
53 1.33 fvdl /* Register Definitions */
54 1.33 fvdl #include <dev/microcode/aic7xxx/aic7xxx_reg.h>
55 1.33 fvdl
56 1.33 fvdl #include <dev/ic/aic7xxx_cam.h>
57 1.33 fvdl
58 1.33 fvdl #define AIC_OP_OR 0x0
59 1.33 fvdl #define AIC_OP_AND 0x1
60 1.33 fvdl #define AIC_OP_XOR 0x2
61 1.33 fvdl #define AIC_OP_ADD 0x3
62 1.33 fvdl #define AIC_OP_ADC 0x4
63 1.33 fvdl #define AIC_OP_ROL 0x5
64 1.33 fvdl #define AIC_OP_BMOV 0x6
65 1.33 fvdl
66 1.33 fvdl #define AIC_OP_JMP 0x8
67 1.33 fvdl #define AIC_OP_JC 0x9
68 1.33 fvdl #define AIC_OP_JNC 0xa
69 1.33 fvdl #define AIC_OP_CALL 0xb
70 1.33 fvdl #define AIC_OP_JNE 0xc
71 1.33 fvdl #define AIC_OP_JNZ 0xd
72 1.33 fvdl #define AIC_OP_JE 0xe
73 1.33 fvdl #define AIC_OP_JZ 0xf
74 1.33 fvdl
75 1.33 fvdl /* Pseudo Ops */
76 1.33 fvdl #define AIC_OP_SHL 0x10
77 1.33 fvdl #define AIC_OP_SHR 0x20
78 1.33 fvdl #define AIC_OP_ROR 0x30
79 1.33 fvdl
80 1.33 fvdl struct ins_format1 {
81 1.33 fvdl #if BYTE_ORDER == LITTLE_ENDIAN
82 1.33 fvdl uint32_t immediate : 8,
83 1.33 fvdl source : 9,
84 1.33 fvdl destination : 9,
85 1.33 fvdl ret : 1,
86 1.33 fvdl opcode : 4,
87 1.33 fvdl parity : 1;
88 1.33 fvdl #else
89 1.33 fvdl uint32_t parity : 1,
90 1.33 fvdl opcode : 4,
91 1.33 fvdl ret : 1,
92 1.33 fvdl destination : 9,
93 1.33 fvdl source : 9,
94 1.33 fvdl immediate : 8;
95 1.33 fvdl #endif
96 1.33 fvdl };
97 1.33 fvdl
98 1.33 fvdl struct ins_format2 {
99 1.33 fvdl #if BYTE_ORDER == LITTLE_ENDIAN
100 1.33 fvdl uint32_t shift_control : 8,
101 1.33 fvdl source : 9,
102 1.33 fvdl destination : 9,
103 1.33 fvdl ret : 1,
104 1.33 fvdl opcode : 4,
105 1.33 fvdl parity : 1;
106 1.33 fvdl #else
107 1.33 fvdl uint32_t parity : 1,
108 1.33 fvdl opcode : 4,
109 1.33 fvdl ret : 1,
110 1.33 fvdl destination : 9,
111 1.33 fvdl source : 9,
112 1.33 fvdl shift_control : 8;
113 1.33 fvdl #endif
114 1.33 fvdl };
115 1.33 fvdl
116 1.33 fvdl struct ins_format3 {
117 1.33 fvdl #if BYTE_ORDER == LITTLE_ENDIAN
118 1.33 fvdl uint32_t immediate : 8,
119 1.33 fvdl source : 9,
120 1.33 fvdl address : 10,
121 1.33 fvdl opcode : 4,
122 1.33 fvdl parity : 1;
123 1.33 fvdl #else
124 1.33 fvdl uint32_t parity : 1,
125 1.33 fvdl opcode : 4,
126 1.33 fvdl address : 10,
127 1.33 fvdl source : 9,
128 1.33 fvdl immediate : 8;
129 1.33 fvdl #endif
130 1.33 fvdl };
131 1.33 fvdl
132 1.33 fvdl union ins_formats {
133 1.33 fvdl struct ins_format1 format1;
134 1.33 fvdl struct ins_format2 format2;
135 1.33 fvdl struct ins_format3 format3;
136 1.33 fvdl uint8_t bytes[4];
137 1.33 fvdl uint32_t integer;
138 1.33 fvdl };
139 1.1 mycroft
140 1.33 fvdl #define AHC_LUN_WILDCARD -1
141 1.33 fvdl
142 1.33 fvdl /************************* Forward Declarations *******************************/
143 1.33 fvdl struct ahc_platform_data;
144 1.33 fvdl struct scb_platform_data;
145 1.33 fvdl struct seeprom_descriptor;
146 1.33 fvdl
147 1.33 fvdl /****************************** Useful Macros *********************************/
148 1.33 fvdl #ifndef MAX
149 1.33 fvdl #define MAX(a,b) (((a) > (b)) ? (a) : (b))
150 1.33 fvdl #endif
151 1.17 sommerfe
152 1.33 fvdl #ifndef MIN
153 1.33 fvdl #define MIN(a,b) (((a) < (b)) ? (a) : (b))
154 1.33 fvdl #endif
155 1.33 fvdl
156 1.33 fvdl #ifndef TRUE
157 1.33 fvdl #define TRUE 1
158 1.33 fvdl #endif
159 1.21 fvdl #ifndef FALSE
160 1.21 fvdl #define FALSE 0
161 1.21 fvdl #endif
162 1.21 fvdl
163 1.33 fvdl #define NUM_ELEMENTS(array) (sizeof(array) / sizeof(*array))
164 1.33 fvdl
165 1.33 fvdl #define ALL_CHANNELS '\0'
166 1.33 fvdl #define ALL_TARGETS_MASK 0xFFFF
167 1.33 fvdl #define INITIATOR_WILDCARD (~0)
168 1.33 fvdl
169 1.33 fvdl #define SCSIID_TARGET(ahc, scsiid) \
170 1.33 fvdl (((scsiid) & ((((ahc)->features & AHC_TWIN) != 0) ? TWIN_TID : TID)) \
171 1.33 fvdl >> TID_SHIFT)
172 1.33 fvdl #define SCSIID_OUR_ID(scsiid) \
173 1.33 fvdl ((scsiid) & OID)
174 1.33 fvdl #define SCSIID_CHANNEL(ahc, scsiid) \
175 1.33 fvdl ((((ahc)->features & AHC_TWIN) != 0) \
176 1.33 fvdl ? ((((scsiid) & TWIN_CHNLB) != 0) ? 'B' : 'A') \
177 1.33 fvdl : 'A')
178 1.33 fvdl #define SCB_IS_SCSIBUS_B(ahc, scb) \
179 1.33 fvdl (SCSIID_CHANNEL(ahc, (scb)->hscb->scsiid) == 'B')
180 1.33 fvdl #define SCB_GET_OUR_ID(scb) \
181 1.33 fvdl SCSIID_OUR_ID((scb)->hscb->scsiid)
182 1.33 fvdl #define SCB_GET_TARGET(ahc, scb) \
183 1.33 fvdl SCSIID_TARGET((ahc), (scb)->hscb->scsiid)
184 1.33 fvdl #define SCB_GET_CHANNEL(ahc, scb) \
185 1.33 fvdl SCSIID_CHANNEL(ahc, (scb)->hscb->scsiid)
186 1.33 fvdl #define SCB_GET_LUN(scb) \
187 1.33 fvdl ((scb)->hscb->lun)
188 1.33 fvdl #define SCB_GET_TARGET_OFFSET(ahc, scb) \
189 1.33 fvdl (SCB_GET_TARGET(ahc, scb))
190 1.33 fvdl #define SCB_GET_TARGET_MASK(ahc, scb) \
191 1.33 fvdl (0x01 << (SCB_GET_TARGET_OFFSET(ahc, scb)))
192 1.33 fvdl #ifdef AHC_DEBUG
193 1.33 fvdl #define SCB_IS_SILENT(scb) \
194 1.33 fvdl ((ahc_debug & AHC_SHOW_MASKED_ERRORS) == 0 \
195 1.33 fvdl && (((scb)->flags & SCB_SILENT) != 0))
196 1.33 fvdl #else
197 1.33 fvdl #define SCB_IS_SILENT(scb) \
198 1.33 fvdl (((scb)->flags & SCB_SILENT) != 0)
199 1.33 fvdl #endif
200 1.33 fvdl #define TCL_TARGET_OFFSET(tcl) \
201 1.33 fvdl ((((tcl) >> 4) & TID) >> 4)
202 1.33 fvdl #define TCL_LUN(tcl) \
203 1.33 fvdl (tcl & (AHC_NUM_LUNS - 1))
204 1.33 fvdl #define BUILD_TCL(scsiid, lun) \
205 1.33 fvdl ((lun) | (((scsiid) & TID) << 4))
206 1.33 fvdl
207 1.33 fvdl #ifndef AHC_TARGET_MODE
208 1.33 fvdl #undef AHC_TMODE_ENABLE
209 1.33 fvdl #define AHC_TMODE_ENABLE 0
210 1.21 fvdl #endif
211 1.17 sommerfe
212 1.33 fvdl /**************************** Driver Constants ********************************/
213 1.33 fvdl /*
214 1.33 fvdl * The maximum number of supported targets.
215 1.33 fvdl */
216 1.33 fvdl #define AHC_NUM_TARGETS 16
217 1.33 fvdl
218 1.33 fvdl /*
219 1.33 fvdl * The maximum number of supported luns.
220 1.33 fvdl * The identify message only supports 64 luns in SPI3.
221 1.33 fvdl * You can have 2^64 luns when information unit transfers are enabled,
222 1.33 fvdl * but it is doubtful this driver will ever support IUTs.
223 1.33 fvdl */
224 1.33 fvdl #define AHC_NUM_LUNS 64
225 1.33 fvdl
226 1.8 explorer /*
227 1.21 fvdl * The maximum transfer per S/G segment.
228 1.8 explorer */
229 1.33 fvdl #define AHC_MAXTRANSFER_SIZE 0x00ffffff /* limited by 24bit counter */
230 1.33 fvdl
231 1.33 fvdl /*
232 1.33 fvdl * The maximum amount of SCB storage in hardware on a controller.
233 1.33 fvdl * This value represents an upper bound. Controllers vary in the number
234 1.33 fvdl * they actually support.
235 1.33 fvdl */
236 1.33 fvdl #define AHC_SCB_MAX 255
237 1.33 fvdl
238 1.33 fvdl /*
239 1.33 fvdl * The maximum number of concurrent transactions supported per driver instance.
240 1.33 fvdl * Sequencer Control Blocks (SCBs) store per-transaction information. Although
241 1.33 fvdl * the space for SCBs on the host adapter varies by model, the driver will
242 1.33 fvdl * page the SCBs between host and controller memory as needed. We are limited
243 1.33 fvdl * to 253 because:
244 1.33 fvdl * 1) The 8bit nature of the RISC engine holds us to an 8bit value.
245 1.33 fvdl * 2) We reserve one value, 255, to represent the invalid element.
246 1.33 fvdl * 3) Our input queue scheme requires one SCB to always be reserved
247 1.33 fvdl * in advance of queuing any SCBs. This takes us down to 254.
248 1.33 fvdl * 4) To handle our output queue correctly on machines that only
249 1.33 fvdl * support 32bit stores, we must clear the array 4 bytes at a
250 1.33 fvdl * time. To avoid colliding with a DMA write from the sequencer,
251 1.33 fvdl * we must be sure that 4 slots are empty when we write to clear
252 1.33 fvdl * the queue. This reduces us to 253 SCBs: 1 that just completed
253 1.33 fvdl * and the known three additional empty slots in the queue that
254 1.33 fvdl * precede it.
255 1.33 fvdl */
256 1.33 fvdl #define AHC_MAX_QUEUE 253
257 1.16 leo
258 1.21 fvdl /*
259 1.33 fvdl * The maximum amount of SCB storage we allocate in host memory. This
260 1.33 fvdl * number should reflect the 1 additional SCB we require to handle our
261 1.33 fvdl * qinfifo mechanism.
262 1.33 fvdl */
263 1.33 fvdl #define AHC_SCB_MAX_ALLOC (AHC_MAX_QUEUE+1)
264 1.1 mycroft
265 1.33 fvdl /*
266 1.33 fvdl * Ring Buffer of incoming target commands.
267 1.33 fvdl * We allocate 256 to simplify the logic in the sequencer
268 1.33 fvdl * by using the natural wrap point of an 8bit counter.
269 1.33 fvdl */
270 1.33 fvdl #define AHC_TMODE_CMDS 256
271 1.1 mycroft
272 1.33 fvdl /* Reset line assertion time in us */
273 1.33 fvdl #define AHC_BUSRESET_DELAY 25
274 1.4 mycroft
275 1.33 fvdl /******************* Chip Characteristics/Operating Settings *****************/
276 1.33 fvdl /*
277 1.33 fvdl * Chip Type
278 1.33 fvdl * The chip order is from least sophisticated to most sophisticated.
279 1.33 fvdl */
280 1.4 mycroft typedef enum {
281 1.21 fvdl AHC_NONE = 0x0000,
282 1.21 fvdl AHC_CHIPID_MASK = 0x00FF,
283 1.21 fvdl AHC_AIC7770 = 0x0001,
284 1.21 fvdl AHC_AIC7850 = 0x0002,
285 1.21 fvdl AHC_AIC7855 = 0x0003,
286 1.21 fvdl AHC_AIC7859 = 0x0004,
287 1.21 fvdl AHC_AIC7860 = 0x0005,
288 1.21 fvdl AHC_AIC7870 = 0x0006,
289 1.21 fvdl AHC_AIC7880 = 0x0007,
290 1.33 fvdl AHC_AIC7895 = 0x0008,
291 1.33 fvdl AHC_AIC7895C = 0x0009,
292 1.33 fvdl AHC_AIC7890 = 0x000a,
293 1.21 fvdl AHC_AIC7896 = 0x000b,
294 1.33 fvdl AHC_AIC7892 = 0x000c,
295 1.33 fvdl AHC_AIC7899 = 0x000d,
296 1.21 fvdl AHC_VL = 0x0100, /* Bus type VL */
297 1.21 fvdl AHC_EISA = 0x0200, /* Bus type EISA */
298 1.21 fvdl AHC_PCI = 0x0400, /* Bus type PCI */
299 1.21 fvdl AHC_BUS_MASK = 0x0F00
300 1.21 fvdl } ahc_chip;
301 1.21 fvdl
302 1.33 fvdl /*
303 1.33 fvdl * Features available in each chip type.
304 1.33 fvdl */
305 1.21 fvdl typedef enum {
306 1.33 fvdl AHC_FENONE = 0x00000,
307 1.33 fvdl AHC_ULTRA = 0x00001, /* Supports 20MHz Transfers */
308 1.33 fvdl AHC_ULTRA2 = 0x00002, /* Supports 40MHz Transfers */
309 1.33 fvdl AHC_WIDE = 0x00004, /* Wide Channel */
310 1.33 fvdl AHC_TWIN = 0x00008, /* Twin Channel */
311 1.33 fvdl AHC_MORE_SRAM = 0x00010, /* 80 bytes instead of 64 */
312 1.33 fvdl AHC_CMD_CHAN = 0x00020, /* Has a Command DMA Channel */
313 1.33 fvdl AHC_QUEUE_REGS = 0x00040, /* Has Queue management registers */
314 1.33 fvdl AHC_SG_PRELOAD = 0x00080, /* Can perform auto-SG preload */
315 1.33 fvdl AHC_SPIOCAP = 0x00100, /* Has a Serial Port I/O Cap Register */
316 1.33 fvdl AHC_MULTI_TID = 0x00200, /* Has bitmask of TIDs for select-in */
317 1.33 fvdl AHC_HS_MAILBOX = 0x00400, /* Has HS_MAILBOX register */
318 1.33 fvdl AHC_DT = 0x00800, /* Double Transition transfers */
319 1.33 fvdl AHC_NEW_TERMCTL = 0x01000, /* Newer termination scheme */
320 1.33 fvdl AHC_MULTI_FUNC = 0x02000, /* Multi-Function Twin Channel Device */
321 1.33 fvdl AHC_LARGE_SCBS = 0x04000, /* 64byte SCBs */
322 1.33 fvdl AHC_AUTORATE = 0x08000, /* Automatic update of SCSIRATE/OFFSET*/
323 1.33 fvdl AHC_AUTOPAUSE = 0x10000, /* Automatic pause on register access */
324 1.33 fvdl AHC_TARGETMODE = 0x20000, /* Has tested target mode support */
325 1.33 fvdl AHC_MULTIROLE = 0x40000, /* Space for two roles at a time */
326 1.33 fvdl AHC_REMOVABLE = 0x80000, /* Hot-Swap supported */
327 1.33 fvdl AHC_AIC7770_FE = AHC_FENONE,
328 1.33 fvdl /*
329 1.33 fvdl * The real 7850 does not support Ultra modes, but there are
330 1.33 fvdl * several cards that use the generic 7850 PCI ID even though
331 1.33 fvdl * they are using an Ultra capable chip (7859/7860). We start
332 1.33 fvdl * out with the AHC_ULTRA feature set and then check the DEVSTATUS
333 1.33 fvdl * register to determine if the capability is really present.
334 1.33 fvdl */
335 1.33 fvdl AHC_AIC7850_FE = AHC_SPIOCAP|AHC_AUTOPAUSE|AHC_TARGETMODE|AHC_ULTRA,
336 1.33 fvdl AHC_AIC7860_FE = AHC_AIC7850_FE,
337 1.33 fvdl AHC_AIC7870_FE = AHC_TARGETMODE,
338 1.33 fvdl AHC_AIC7880_FE = AHC_AIC7870_FE|AHC_ULTRA,
339 1.33 fvdl /*
340 1.33 fvdl * Although we have space for both the initiator and
341 1.33 fvdl * target roles on ULTRA2 chips, we currently disable
342 1.33 fvdl * the initiator role to allow multi-scsi-id target mode
343 1.33 fvdl * configurations. We can only respond on the same SCSI
344 1.33 fvdl * ID as our initiator role if we allow initiator operation.
345 1.33 fvdl * At some point, we should add a configuration knob to
346 1.33 fvdl * allow both roles to be loaded.
347 1.33 fvdl */
348 1.33 fvdl AHC_AIC7890_FE = AHC_MORE_SRAM|AHC_CMD_CHAN|AHC_ULTRA2
349 1.33 fvdl |AHC_QUEUE_REGS|AHC_SG_PRELOAD|AHC_MULTI_TID
350 1.33 fvdl |AHC_HS_MAILBOX|AHC_NEW_TERMCTL|AHC_LARGE_SCBS
351 1.33 fvdl |AHC_TARGETMODE,
352 1.33 fvdl AHC_AIC7892_FE = AHC_AIC7890_FE|AHC_DT|AHC_AUTORATE|AHC_AUTOPAUSE,
353 1.33 fvdl AHC_AIC7895_FE = AHC_AIC7880_FE|AHC_MORE_SRAM|AHC_AUTOPAUSE
354 1.33 fvdl |AHC_CMD_CHAN|AHC_MULTI_FUNC|AHC_LARGE_SCBS,
355 1.21 fvdl AHC_AIC7895C_FE = AHC_AIC7895_FE|AHC_MULTI_TID,
356 1.21 fvdl AHC_AIC7896_FE = AHC_AIC7890_FE|AHC_MULTI_FUNC,
357 1.21 fvdl AHC_AIC7899_FE = AHC_AIC7892_FE|AHC_MULTI_FUNC
358 1.21 fvdl } ahc_feature;
359 1.4 mycroft
360 1.33 fvdl /*
361 1.33 fvdl * Bugs in the silicon that we work around in software.
362 1.33 fvdl */
363 1.33 fvdl typedef enum {
364 1.33 fvdl AHC_BUGNONE = 0x00,
365 1.33 fvdl /*
366 1.33 fvdl * On all chips prior to the U2 product line,
367 1.33 fvdl * the WIDEODD S/G segment feature does not
368 1.33 fvdl * work during scsi->HostBus transfers.
369 1.33 fvdl */
370 1.33 fvdl AHC_TMODE_WIDEODD_BUG = 0x01,
371 1.33 fvdl /*
372 1.33 fvdl * On the aic7890/91 Rev 0 chips, the autoflush
373 1.33 fvdl * feature does not work. A manual flush of
374 1.33 fvdl * the DMA FIFO is required.
375 1.33 fvdl */
376 1.33 fvdl AHC_AUTOFLUSH_BUG = 0x02,
377 1.33 fvdl /*
378 1.33 fvdl * On many chips, cacheline streaming does not work.
379 1.33 fvdl */
380 1.33 fvdl AHC_CACHETHEN_BUG = 0x04,
381 1.33 fvdl /*
382 1.33 fvdl * On the aic7896/97 chips, cacheline
383 1.33 fvdl * streaming must be enabled.
384 1.33 fvdl */
385 1.33 fvdl AHC_CACHETHEN_DIS_BUG = 0x08,
386 1.33 fvdl /*
387 1.33 fvdl * PCI 2.1 Retry failure on non-empty data fifo.
388 1.33 fvdl */
389 1.33 fvdl AHC_PCI_2_1_RETRY_BUG = 0x10,
390 1.33 fvdl /*
391 1.33 fvdl * Controller does not handle cacheline residuals
392 1.33 fvdl * properly on S/G segments if PCI MWI instructions
393 1.33 fvdl * are allowed.
394 1.33 fvdl */
395 1.33 fvdl AHC_PCI_MWI_BUG = 0x20,
396 1.33 fvdl /*
397 1.33 fvdl * An SCB upload using the SCB channel's
398 1.33 fvdl * auto array entry copy feature may
399 1.33 fvdl * corrupt data. This appears to only
400 1.33 fvdl * occur on 66MHz systems.
401 1.33 fvdl */
402 1.33 fvdl AHC_SCBCHAN_UPLOAD_BUG = 0x40
403 1.33 fvdl } ahc_bug;
404 1.33 fvdl
405 1.33 fvdl /*
406 1.33 fvdl * Configuration specific settings.
407 1.33 fvdl * The driver determines these settings by probing the
408 1.33 fvdl * chip/controller's configuration.
409 1.33 fvdl */
410 1.4 mycroft typedef enum {
411 1.33 fvdl AHC_FNONE = 0x000,
412 1.33 fvdl AHC_PRIMARY_CHANNEL = 0x003, /*
413 1.33 fvdl * The channel that should
414 1.33 fvdl * be probed first.
415 1.4 mycroft */
416 1.33 fvdl AHC_USEDEFAULTS = 0x004, /*
417 1.4 mycroft * For cards without an seeprom
418 1.4 mycroft * or a BIOS to initialize the chip's
419 1.4 mycroft * SRAM, we use the default target
420 1.4 mycroft * settings.
421 1.4 mycroft */
422 1.33 fvdl AHC_SEQUENCER_DEBUG = 0x008,
423 1.33 fvdl AHC_SHARED_SRAM = 0x010,
424 1.33 fvdl AHC_LARGE_SEEPROM = 0x020, /* Uses C56_66 not C46 */
425 1.33 fvdl AHC_RESET_BUS_A = 0x040,
426 1.33 fvdl AHC_RESET_BUS_B = 0x080,
427 1.33 fvdl AHC_EXTENDED_TRANS_A = 0x100,
428 1.33 fvdl AHC_EXTENDED_TRANS_B = 0x200,
429 1.33 fvdl AHC_TERM_ENB_A = 0x400,
430 1.33 fvdl AHC_TERM_ENB_B = 0x800,
431 1.33 fvdl AHC_INITIATORROLE = 0x1000, /*
432 1.21 fvdl * Allow initiator operations on
433 1.21 fvdl * this controller.
434 1.21 fvdl */
435 1.33 fvdl AHC_TARGETROLE = 0x2000, /*
436 1.21 fvdl * Allow target operations on this
437 1.21 fvdl * controller.
438 1.21 fvdl */
439 1.33 fvdl AHC_NEWEEPROM_FMT = 0x4000,
440 1.33 fvdl AHC_RESOURCE_SHORTAGE = 0x8000,
441 1.33 fvdl AHC_TQINFIFO_BLOCKED = 0x10000, /* Blocked waiting for ATIOs */
442 1.33 fvdl AHC_INT50_SPEEDFLEX = 0x20000, /*
443 1.21 fvdl * Internal 50pin connector
444 1.21 fvdl * sits behind an aic3860
445 1.21 fvdl */
446 1.33 fvdl AHC_SCB_BTT = 0x40000, /*
447 1.33 fvdl * The busy targets table is
448 1.33 fvdl * stored in SCB space rather
449 1.33 fvdl * than SRAM.
450 1.33 fvdl */
451 1.33 fvdl AHC_BIOS_ENABLED = 0x80000,
452 1.33 fvdl AHC_ALL_INTERRUPTS = 0x100000,
453 1.33 fvdl AHC_PAGESCBS = 0x400000, /* Enable SCB paging */
454 1.33 fvdl AHC_EDGE_INTERRUPT = 0x800000, /* Device uses edge triggered ints */
455 1.33 fvdl AHC_39BIT_ADDRESSING = 0x1000000, /* Use 39 bit addressing scheme. */
456 1.33 fvdl AHC_LSCBS_ENABLED = 0x2000000, /* 64Byte SCBs enabled */
457 1.33 fvdl AHC_SCB_CONFIG_USED = 0x4000000, /* No SEEPROM but SCB2 had info. */
458 1.33 fvdl AHC_NO_BIOS_INIT = 0x8000000, /* No BIOS left over settings. */
459 1.33 fvdl AHC_DISABLE_PCI_PERR = 0x10000000
460 1.21 fvdl } ahc_flag;
461 1.4 mycroft
462 1.33 fvdl /************************* Hardware SCB Definition ***************************/
463 1.33 fvdl
464 1.33 fvdl /*
465 1.33 fvdl * The driver keeps up to MAX_SCB scb structures per card in memory. The SCB
466 1.33 fvdl * consists of a "hardware SCB" mirroring the fields availible on the card
467 1.33 fvdl * and additional information the kernel stores for each transaction.
468 1.33 fvdl *
469 1.33 fvdl * To minimize space utilization, a portion of the hardware scb stores
470 1.33 fvdl * different data during different portions of a SCSI transaction.
471 1.33 fvdl * As initialized by the host driver for the initiator role, this area
472 1.33 fvdl * contains the SCSI cdb (or a pointer to the cdb) to be executed. After
473 1.33 fvdl * the cdb has been presented to the target, this area serves to store
474 1.33 fvdl * residual transfer information and the SCSI status byte.
475 1.33 fvdl * For the target role, the contents of this area do not change, but
476 1.33 fvdl * still serve a different purpose than for the initiator role. See
477 1.33 fvdl * struct target_data for details.
478 1.33 fvdl */
479 1.33 fvdl
480 1.33 fvdl /*
481 1.33 fvdl * Status information embedded in the shared poriton of
482 1.33 fvdl * an SCB after passing the cdb to the target. The kernel
483 1.33 fvdl * driver will only read this data for transactions that
484 1.33 fvdl * complete abnormally (non-zero status byte).
485 1.33 fvdl */
486 1.33 fvdl struct status_pkt {
487 1.33 fvdl uint32_t residual_datacnt; /* Residual in the current S/G seg */
488 1.33 fvdl uint32_t residual_sg_ptr; /* The next S/G for this transfer */
489 1.33 fvdl uint8_t scsi_status; /* Standard SCSI status byte */
490 1.33 fvdl };
491 1.33 fvdl
492 1.33 fvdl /*
493 1.33 fvdl * Target mode version of the shared data SCB segment.
494 1.33 fvdl */
495 1.33 fvdl struct target_data {
496 1.33 fvdl uint32_t residual_datacnt; /* Residual in the current S/G seg */
497 1.33 fvdl uint32_t residual_sg_ptr; /* The next S/G for this transfer */
498 1.33 fvdl uint8_t scsi_status; /* SCSI status to give to initiator */
499 1.33 fvdl uint8_t target_phases; /* Bitmap of phases to execute */
500 1.33 fvdl uint8_t data_phase; /* Data-In or Data-Out */
501 1.33 fvdl uint8_t initiator_tag; /* Initiator's transaction tag */
502 1.33 fvdl };
503 1.33 fvdl
504 1.33 fvdl struct hardware_scb {
505 1.33 fvdl /*0*/ union {
506 1.33 fvdl /*
507 1.33 fvdl * If the cdb is 12 bytes or less, we embed it directly
508 1.33 fvdl * in the SCB. For longer cdbs, we embed the address
509 1.33 fvdl * of the cdb payload as seen by the chip and a DMA
510 1.33 fvdl * is used to pull it in.
511 1.33 fvdl */
512 1.33 fvdl uint8_t cdb[12];
513 1.33 fvdl uint32_t cdb_ptr;
514 1.33 fvdl struct status_pkt status;
515 1.33 fvdl struct target_data tdata;
516 1.33 fvdl } shared_data;
517 1.33 fvdl /*
518 1.33 fvdl * A word about residuals.
519 1.33 fvdl * The scb is presented to the sequencer with the dataptr and datacnt
520 1.33 fvdl * fields initialized to the contents of the first S/G element to
521 1.33 fvdl * transfer. The sgptr field is initialized to the bus address for
522 1.33 fvdl * the S/G element that follows the first in the in core S/G array
523 1.33 fvdl * or'ed with the SG_FULL_RESID flag. Sgptr may point to an invalid
524 1.33 fvdl * S/G entry for this transfer (single S/G element transfer with the
525 1.33 fvdl * first elements address and length preloaded in the dataptr/datacnt
526 1.33 fvdl * fields). If no transfer is to occur, sgptr is set to SG_LIST_NULL.
527 1.33 fvdl * The SG_FULL_RESID flag ensures that the residual will be correctly
528 1.33 fvdl * noted even if no data transfers occur. Once the data phase is entered,
529 1.33 fvdl * the residual sgptr and datacnt are loaded from the sgptr and the
530 1.33 fvdl * datacnt fields. After each S/G element's dataptr and length are
531 1.33 fvdl * loaded into the hardware, the residual sgptr is advanced. After
532 1.33 fvdl * each S/G element is expired, its datacnt field is checked to see
533 1.33 fvdl * if the LAST_SEG flag is set. If so, SG_LIST_NULL is set in the
534 1.33 fvdl * residual sg ptr and the transfer is considered complete. If the
535 1.33 fvdl * sequencer determines that there is a residual in the tranfer, it
536 1.33 fvdl * will set the SG_RESID_VALID flag in sgptr and dma the scb back into
537 1.33 fvdl * host memory. To sumarize:
538 1.33 fvdl *
539 1.33 fvdl * Sequencer:
540 1.33 fvdl * o A residual has occurred if SG_FULL_RESID is set in sgptr,
541 1.33 fvdl * or residual_sgptr does not have SG_LIST_NULL set.
542 1.33 fvdl *
543 1.33 fvdl * o We are transfering the last segment if residual_datacnt has
544 1.33 fvdl * the SG_LAST_SEG flag set.
545 1.33 fvdl *
546 1.33 fvdl * Host:
547 1.33 fvdl * o A residual has occurred if a completed scb has the
548 1.33 fvdl * SG_RESID_VALID flag set.
549 1.33 fvdl *
550 1.33 fvdl * o residual_sgptr and sgptr refer to the "next" sg entry
551 1.33 fvdl * and so may point beyond the last valid sg entry for the
552 1.33 fvdl * transfer.
553 1.33 fvdl */
554 1.33 fvdl /*12*/ uint32_t dataptr;
555 1.33 fvdl /*16*/ uint32_t datacnt; /*
556 1.33 fvdl * Byte 3 (numbered from 0) of
557 1.33 fvdl * the datacnt is really the
558 1.33 fvdl * 4th byte in that data address.
559 1.33 fvdl */
560 1.33 fvdl /*20*/ uint32_t sgptr;
561 1.33 fvdl #define SG_PTR_MASK 0xFFFFFFF8
562 1.33 fvdl /*24*/ uint8_t control; /* See SCB_CONTROL in aic7xxx.reg for details */
563 1.33 fvdl /*25*/ uint8_t scsiid; /* what to load in the SCSIID register */
564 1.33 fvdl /*26*/ uint8_t lun;
565 1.33 fvdl /*27*/ uint8_t tag; /*
566 1.33 fvdl * Index into our kernel SCB array.
567 1.33 fvdl * Also used as the tag for tagged I/O
568 1.33 fvdl */
569 1.33 fvdl /*28*/ uint8_t cdb_len;
570 1.33 fvdl /*29*/ uint8_t scsirate; /* Value for SCSIRATE register */
571 1.33 fvdl /*30*/ uint8_t scsioffset; /* Value for SCSIOFFSET register */
572 1.33 fvdl /*31*/ uint8_t next; /*
573 1.33 fvdl * Used for threading SCBs in the
574 1.33 fvdl * "Waiting for Selection" and
575 1.33 fvdl * "Disconnected SCB" lists down
576 1.33 fvdl * in the sequencer.
577 1.33 fvdl */
578 1.33 fvdl /*32*/ uint8_t cdb32[32]; /*
579 1.33 fvdl * CDB storage for cdbs of size
580 1.33 fvdl * 13->32. We store them here
581 1.33 fvdl * because hardware scbs are
582 1.33 fvdl * allocated from DMA safe
583 1.33 fvdl * memory so we are guaranteed
584 1.33 fvdl * the controller can access
585 1.33 fvdl * this data.
586 1.33 fvdl */
587 1.33 fvdl };
588 1.33 fvdl
589 1.33 fvdl /************************ Kernel SCB Definitions ******************************/
590 1.33 fvdl /*
591 1.33 fvdl * Some fields of the SCB are OS dependent. Here we collect the
592 1.33 fvdl * definitions for elements that all OS platforms need to include
593 1.33 fvdl * in there SCB definition.
594 1.33 fvdl */
595 1.33 fvdl
596 1.33 fvdl /*
597 1.33 fvdl * Definition of a scatter/gather element as transfered to the controller.
598 1.33 fvdl * The aic7xxx chips only support a 24bit length. We use the top byte of
599 1.33 fvdl * the length to store additional address bits and a flag to indicate
600 1.33 fvdl * that a given segment terminates the transfer. This gives us an
601 1.33 fvdl * addressable range of 512GB on machines with 64bit PCI or with chips
602 1.33 fvdl * that can support dual address cycles on 32bit PCI busses.
603 1.33 fvdl */
604 1.33 fvdl struct ahc_dma_seg {
605 1.33 fvdl uint32_t addr;
606 1.33 fvdl uint32_t len;
607 1.33 fvdl #define AHC_DMA_LAST_SEG 0x80000000
608 1.33 fvdl #define AHC_SG_HIGH_ADDR_MASK 0x7F000000
609 1.33 fvdl #define AHC_SG_LEN_MASK 0x00FFFFFF
610 1.33 fvdl };
611 1.33 fvdl
612 1.33 fvdl struct sg_map_node {
613 1.33 fvdl bus_dmamap_t sg_dmamap;
614 1.33 fvdl bus_addr_t sg_physaddr;
615 1.33 fvdl bus_dma_segment_t sg_dmasegs;
616 1.33 fvdl int sg_nseg;
617 1.33 fvdl struct ahc_dma_seg* sg_vaddr;
618 1.33 fvdl SLIST_ENTRY(sg_map_node) links;
619 1.33 fvdl };
620 1.33 fvdl
621 1.33 fvdl struct ahc_pci_busdata {
622 1.33 fvdl pci_chipset_tag_t pc;
623 1.33 fvdl pcitag_t tag;
624 1.33 fvdl u_int dev;
625 1.33 fvdl u_int func;
626 1.33 fvdl pcireg_t class;
627 1.33 fvdl };
628 1.33 fvdl
629 1.33 fvdl /*
630 1.33 fvdl * The current state of this SCB.
631 1.33 fvdl */
632 1.4 mycroft typedef enum {
633 1.9 gibbs SCB_FREE = 0x0000,
634 1.21 fvdl SCB_OTHERTCL_TIMEOUT = 0x0002,/*
635 1.21 fvdl * Another device was active
636 1.21 fvdl * during the first timeout for
637 1.21 fvdl * this SCB so we gave ourselves
638 1.21 fvdl * an additional timeout period
639 1.21 fvdl * in case it was hogging the
640 1.21 fvdl * bus.
641 1.21 fvdl */
642 1.9 gibbs SCB_DEVICE_RESET = 0x0004,
643 1.21 fvdl SCB_SENSE = 0x0008,
644 1.33 fvdl SCB_CDB32_PTR = 0x0010,
645 1.33 fvdl SCB_RECOVERY_SCB = 0x0020,
646 1.33 fvdl SCB_AUTO_NEGOTIATE = 0x0040,/* Negotiate to achieve goal. */
647 1.33 fvdl SCB_NEGOTIATE = 0x0080,/* Negotiation forced for command. */
648 1.33 fvdl SCB_ABORT = 0x0100,
649 1.33 fvdl SCB_UNTAGGEDQ = 0x0200,
650 1.33 fvdl SCB_ACTIVE = 0x0400,
651 1.33 fvdl SCB_TARGET_IMMEDIATE = 0x0800,
652 1.33 fvdl SCB_TRANSMISSION_ERROR = 0x1000,/*
653 1.33 fvdl * We detected a parity or CRC
654 1.33 fvdl * error that has effected the
655 1.33 fvdl * payload of the command. This
656 1.33 fvdl * flag is checked when normal
657 1.33 fvdl * status is returned to catch
658 1.33 fvdl * the case of a target not
659 1.33 fvdl * responding to our attempt
660 1.33 fvdl * to report the error.
661 1.33 fvdl */
662 1.33 fvdl SCB_TARGET_SCB = 0x2000,
663 1.33 fvdl SCB_SILENT = 0x4000,/*
664 1.33 fvdl * Be quiet about transmission type
665 1.33 fvdl * errors. They are expected and we
666 1.33 fvdl * don't want to upset the user. This
667 1.33 fvdl * flag is typically used during DV.
668 1.33 fvdl */
669 1.33 fvdl SCB_FREEZE_QUEUE = 0x8000
670 1.21 fvdl } scb_flag;
671 1.21 fvdl
672 1.33 fvdl struct scb {
673 1.33 fvdl struct hardware_scb *hscb;
674 1.33 fvdl union {
675 1.33 fvdl SLIST_ENTRY(scb) sle;
676 1.33 fvdl TAILQ_ENTRY(scb) tqe;
677 1.33 fvdl } links;
678 1.33 fvdl LIST_ENTRY(scb) pending_links;
679 1.33 fvdl
680 1.33 fvdl struct scsipi_xfer *xs;
681 1.33 fvdl struct ahc_softc *ahc_softc;
682 1.33 fvdl scb_flag flags;
683 1.33 fvdl #ifndef __linux__
684 1.33 fvdl bus_dmamap_t dmamap;
685 1.33 fvdl #endif
686 1.33 fvdl struct scb_platform_data *platform_data;
687 1.33 fvdl struct sg_map_node *sg_map;
688 1.33 fvdl struct ahc_dma_seg *sg_list;
689 1.33 fvdl bus_addr_t sg_list_phys;
690 1.33 fvdl u_int sg_count;/* How full ahc_dma_seg is */
691 1.33 fvdl };
692 1.21 fvdl
693 1.33 fvdl struct scb_data {
694 1.33 fvdl SLIST_HEAD(, scb) free_scbs; /*
695 1.33 fvdl * Pool of SCBs ready to be assigned
696 1.33 fvdl * commands to execute.
697 1.4 mycroft */
698 1.33 fvdl struct scb *scbindex[256]; /*
699 1.33 fvdl * Mapping from tag to SCB.
700 1.33 fvdl * As tag identifiers are an
701 1.33 fvdl * 8bit value, we provide space
702 1.33 fvdl * for all possible tag values.
703 1.33 fvdl * Any lookups to entries at or
704 1.33 fvdl * above AHC_SCB_MAX_ALLOC will
705 1.33 fvdl * always fail.
706 1.4 mycroft */
707 1.33 fvdl struct hardware_scb *hscbs; /* Array of hardware SCBs */
708 1.33 fvdl struct scb *scbarray; /* Array of kernel SCBs */
709 1.33 fvdl struct scsipi_sense_data *sense; /* Per SCB sense data */
710 1.33 fvdl
711 1.33 fvdl /*
712 1.33 fvdl * "Bus" addresses of our data structures.
713 1.33 fvdl */
714 1.33 fvdl bus_dmamap_t hscb_dmamap;
715 1.33 fvdl bus_addr_t hscb_busaddr;
716 1.33 fvdl bus_dma_segment_t hscb_seg;
717 1.33 fvdl int hscb_nseg;
718 1.33 fvdl int hscb_size;
719 1.33 fvdl
720 1.33 fvdl bus_dmamap_t sense_dmamap;
721 1.33 fvdl bus_addr_t sense_busaddr;
722 1.33 fvdl bus_dma_segment_t sense_seg;
723 1.33 fvdl int sense_nseg;
724 1.33 fvdl int sense_size;
725 1.33 fvdl
726 1.33 fvdl SLIST_HEAD(, sg_map_node) sg_maps;
727 1.33 fvdl uint8_t numscbs;
728 1.33 fvdl uint8_t maxhscbs; /* Number of SCBs on the card */
729 1.33 fvdl uint8_t init_level; /*
730 1.33 fvdl * How far we've initialized
731 1.33 fvdl * this structure.
732 1.21 fvdl */
733 1.21 fvdl };
734 1.21 fvdl
735 1.33 fvdl /************************ Target Mode Definitions *****************************/
736 1.21 fvdl
737 1.21 fvdl /*
738 1.21 fvdl * Connection desciptor for select-in requests in target mode.
739 1.21 fvdl */
740 1.21 fvdl struct target_cmd {
741 1.33 fvdl uint8_t scsiid; /* Our ID and the initiator's ID */
742 1.33 fvdl uint8_t identify; /* Identify message */
743 1.33 fvdl uint8_t bytes[22]; /*
744 1.33 fvdl * Bytes contains any additional message
745 1.33 fvdl * bytes terminated by 0xFF. The remainder
746 1.33 fvdl * is the cdb to execute.
747 1.33 fvdl */
748 1.33 fvdl uint8_t cmd_valid; /*
749 1.33 fvdl * When a command is complete, the firmware
750 1.33 fvdl * will set cmd_valid to all bits set.
751 1.33 fvdl * After the host has seen the command,
752 1.33 fvdl * the bits are cleared. This allows us
753 1.33 fvdl * to just peek at host memory to determine
754 1.33 fvdl * if more work is complete. cmd_valid is on
755 1.33 fvdl * an 8 byte boundary to simplify setting
756 1.33 fvdl * it on aic7880 hardware which only has
757 1.33 fvdl * limited direct access to the DMA FIFO.
758 1.33 fvdl */
759 1.33 fvdl uint8_t pad[7];
760 1.21 fvdl };
761 1.21 fvdl
762 1.21 fvdl /*
763 1.21 fvdl * Number of events we can buffer up if we run out
764 1.21 fvdl * of immediate notify ccbs.
765 1.21 fvdl */
766 1.21 fvdl #define AHC_TMODE_EVENT_BUFFER_SIZE 8
767 1.21 fvdl struct ahc_tmode_event {
768 1.33 fvdl uint8_t initiator_id;
769 1.33 fvdl uint8_t event_type; /* MSG type or EVENT_TYPE_BUS_RESET */
770 1.21 fvdl #define EVENT_TYPE_BUS_RESET 0xFF
771 1.33 fvdl uint8_t event_arg;
772 1.21 fvdl };
773 1.21 fvdl
774 1.21 fvdl /*
775 1.33 fvdl * Per enabled lun target mode state.
776 1.33 fvdl * As this state is directly influenced by the host OS'es target mode
777 1.33 fvdl * environment, we let the OS module define it. Forward declare the
778 1.33 fvdl * structure here so we can store arrays of them, etc. in OS neutral
779 1.33 fvdl * data structures.
780 1.21 fvdl */
781 1.33 fvdl #ifdef AHC_TARGET_MODE
782 1.33 fvdl struct ahc_tmode_lstate {
783 1.33 fvdl #if 0
784 1.21 fvdl struct cam_path *path;
785 1.21 fvdl struct ccb_hdr_slist accept_tios;
786 1.21 fvdl struct ccb_hdr_slist immed_notifies;
787 1.33 fvdl #endif
788 1.21 fvdl struct ahc_tmode_event event_buffer[AHC_TMODE_EVENT_BUFFER_SIZE];
789 1.33 fvdl uint8_t event_r_idx;
790 1.33 fvdl uint8_t event_w_idx;
791 1.33 fvdl };
792 1.21 fvdl #else
793 1.33 fvdl struct ahc_tmode_lstate;
794 1.21 fvdl #endif
795 1.21 fvdl
796 1.33 fvdl /******************** Transfer Negotiation Datastructures *********************/
797 1.21 fvdl #define AHC_TRANS_CUR 0x01 /* Modify current neogtiation status */
798 1.33 fvdl #define AHC_TRANS_ACTIVE 0x03 /* Assume this target is on the bus */
799 1.21 fvdl #define AHC_TRANS_GOAL 0x04 /* Modify negotiation goal */
800 1.21 fvdl #define AHC_TRANS_USER 0x08 /* Modify user negotiation settings */
801 1.21 fvdl
802 1.33 fvdl #define AHC_WIDTH_UNKNOWN 0xFF
803 1.33 fvdl #define AHC_PERIOD_UNKNOWN 0xFF
804 1.33 fvdl #define AHC_OFFSET_UNKNOWN 0x0
805 1.33 fvdl #define AHC_PPR_OPTS_UNKNOWN 0xFF
806 1.33 fvdl
807 1.33 fvdl /*
808 1.33 fvdl * Transfer Negotiation Information.
809 1.33 fvdl */
810 1.21 fvdl struct ahc_transinfo {
811 1.33 fvdl uint8_t protocol_version; /* SCSI Revision level */
812 1.33 fvdl uint8_t transport_version; /* SPI Revision level */
813 1.33 fvdl uint8_t width; /* Bus width */
814 1.33 fvdl uint8_t period; /* Sync rate factor */
815 1.33 fvdl uint8_t offset; /* Sync offset */
816 1.33 fvdl uint8_t ppr_options; /* Parallel Protocol Request options */
817 1.21 fvdl };
818 1.21 fvdl
819 1.33 fvdl /*
820 1.33 fvdl * Per-initiator current, goal and user transfer negotiation information. */
821 1.21 fvdl struct ahc_initiator_tinfo {
822 1.33 fvdl uint8_t scsirate; /* Computed value for SCSIRATE reg */
823 1.33 fvdl struct ahc_transinfo curr;
824 1.21 fvdl struct ahc_transinfo goal;
825 1.21 fvdl struct ahc_transinfo user;
826 1.21 fvdl };
827 1.21 fvdl
828 1.21 fvdl /*
829 1.33 fvdl * Per enabled target ID state.
830 1.33 fvdl * Pointers to lun target state as well as sync/wide negotiation information
831 1.33 fvdl * for each initiator<->target mapping. For the initiator role we pretend
832 1.33 fvdl * that we are the target and the targets are the initiators since the
833 1.33 fvdl * negotiation is the same regardless of role.
834 1.21 fvdl */
835 1.33 fvdl struct ahc_tmode_tstate {
836 1.33 fvdl struct ahc_tmode_lstate* enabled_luns[AHC_NUM_LUNS];
837 1.33 fvdl struct ahc_initiator_tinfo transinfo[AHC_NUM_TARGETS];
838 1.15 leo
839 1.15 leo /*
840 1.21 fvdl * Per initiator state bitmasks.
841 1.15 leo */
842 1.33 fvdl uint16_t auto_negotiate;/* Auto Negotiation Required */
843 1.33 fvdl uint16_t ultraenb; /* Using ultra sync rate */
844 1.33 fvdl uint16_t discenable; /* Disconnection allowed */
845 1.33 fvdl uint16_t tagenable; /* Tagged Queuing allowed */
846 1.21 fvdl };
847 1.21 fvdl
848 1.33 fvdl /*
849 1.33 fvdl * Data structure for our table of allowed synchronous transfer rates.
850 1.33 fvdl */
851 1.33 fvdl struct ahc_syncrate {
852 1.33 fvdl u_int sxfr_u2; /* Value of the SXFR parameter for Ultra2+ Chips */
853 1.33 fvdl u_int sxfr; /* Value of the SXFR parameter for <= Ultra Chips */
854 1.33 fvdl #define ULTRA_SXFR 0x100 /* Rate Requires Ultra Mode set */
855 1.33 fvdl #define ST_SXFR 0x010 /* Rate Single Transition Only */
856 1.33 fvdl #define DT_SXFR 0x040 /* Rate Double Transition Only */
857 1.33 fvdl uint8_t period; /* Period to send to SCSI target */
858 1.33 fvdl char *rate;
859 1.33 fvdl };
860 1.33 fvdl
861 1.33 fvdl /* Safe and valid period for async negotiations. */
862 1.33 fvdl #define AHC_ASYNC_XFER_PERIOD 0x45
863 1.33 fvdl #define AHC_ULTRA2_XFER_PERIOD 0x0a
864 1.15 leo
865 1.21 fvdl /*
866 1.33 fvdl * Indexes into our table of syncronous transfer rates.
867 1.21 fvdl */
868 1.33 fvdl #define AHC_SYNCRATE_DT 0
869 1.33 fvdl #define AHC_SYNCRATE_ULTRA2 1
870 1.33 fvdl #define AHC_SYNCRATE_ULTRA 3
871 1.33 fvdl #define AHC_SYNCRATE_FAST 6
872 1.33 fvdl #define AHC_SYNCRATE_MAX AHC_SYNCRATE_DT
873 1.33 fvdl #define AHC_SYNCRATE_MIN 13
874 1.21 fvdl
875 1.33 fvdl /***************************** Lookup Tables **********************************/
876 1.21 fvdl /*
877 1.33 fvdl * Phase -> name and message out response
878 1.33 fvdl * to parity errors in each phase table.
879 1.21 fvdl */
880 1.33 fvdl struct ahc_phase_table_entry {
881 1.33 fvdl uint8_t phase;
882 1.33 fvdl uint8_t mesg_out; /* Message response to parity errors */
883 1.33 fvdl char *phasemsg;
884 1.33 fvdl };
885 1.33 fvdl
886 1.33 fvdl /************************** Serial EEPROM Format ******************************/
887 1.21 fvdl
888 1.21 fvdl struct seeprom_config {
889 1.21 fvdl /*
890 1.33 fvdl * Per SCSI ID Configuration Flags
891 1.21 fvdl */
892 1.33 fvdl uint16_t device_flags[16]; /* words 0-15 */
893 1.21 fvdl #define CFXFER 0x0007 /* synchronous transfer rate */
894 1.21 fvdl #define CFSYNCH 0x0008 /* enable synchronous transfer */
895 1.21 fvdl #define CFDISC 0x0010 /* enable disconnection */
896 1.21 fvdl #define CFWIDEB 0x0020 /* wide bus device */
897 1.21 fvdl #define CFSYNCHISULTRA 0x0040 /* CFSYNCH is an ultra offset (2940AU)*/
898 1.21 fvdl #define CFSYNCSINGLE 0x0080 /* Single-Transition signalling */
899 1.21 fvdl #define CFSTART 0x0100 /* send start unit SCSI command */
900 1.21 fvdl #define CFINCBIOS 0x0200 /* include in BIOS scan */
901 1.21 fvdl #define CFRNFOUND 0x0400 /* report even if not found */
902 1.33 fvdl #define CFMULTILUNDEV 0x0800 /* Probe multiple luns in BIOS scan */
903 1.21 fvdl #define CFWBCACHEENB 0x4000 /* Enable W-Behind Cache on disks */
904 1.21 fvdl #define CFWBCACHENOP 0xc000 /* Don't touch W-Behind Cache */
905 1.21 fvdl
906 1.21 fvdl /*
907 1.21 fvdl * BIOS Control Bits
908 1.21 fvdl */
909 1.33 fvdl uint16_t bios_control; /* word 16 */
910 1.21 fvdl #define CFSUPREM 0x0001 /* support all removeable drives */
911 1.21 fvdl #define CFSUPREMB 0x0002 /* support removeable boot drives */
912 1.21 fvdl #define CFBIOSEN 0x0004 /* BIOS enabled */
913 1.33 fvdl #define CFBIOS_BUSSCAN 0x0008 /* Have the BIOS Scan the Bus */
914 1.21 fvdl #define CFSM2DRV 0x0010 /* support more than two drives */
915 1.33 fvdl #define CFSTPWLEVEL 0x0010 /* Termination level control */
916 1.21 fvdl #define CF284XEXTEND 0x0020 /* extended translation (284x cards) */
917 1.33 fvdl #define CFCTRL_A 0x0020 /* BIOS displays Ctrl-A message */
918 1.33 fvdl #define CFTERM_MENU 0x0040 /* BIOS displays termination menu */
919 1.21 fvdl #define CFEXTEND 0x0080 /* extended translation enabled */
920 1.33 fvdl #define CFSCAMEN 0x0100 /* SCAM enable */
921 1.33 fvdl #define CFMSG_LEVEL 0x0600 /* BIOS Message Level */
922 1.33 fvdl #define CFMSG_VERBOSE 0x0000
923 1.33 fvdl #define CFMSG_SILENT 0x0200
924 1.33 fvdl #define CFMSG_DIAG 0x0400
925 1.33 fvdl #define CFBOOTCD 0x0800 /* Support Bootable CD-ROM */
926 1.21 fvdl /* UNUSED 0xff00 */
927 1.21 fvdl
928 1.21 fvdl /*
929 1.21 fvdl * Host Adapter Control Bits
930 1.21 fvdl */
931 1.33 fvdl uint16_t adapter_control; /* word 17 */
932 1.21 fvdl #define CFAUTOTERM 0x0001 /* Perform Auto termination */
933 1.21 fvdl #define CFULTRAEN 0x0002 /* Ultra SCSI speed enable */
934 1.21 fvdl #define CF284XSELTO 0x0003 /* Selection timeout (284x cards) */
935 1.21 fvdl #define CF284XFIFO 0x000C /* FIFO Threshold (284x cards) */
936 1.21 fvdl #define CFSTERM 0x0004 /* SCSI low byte termination */
937 1.21 fvdl #define CFWSTERM 0x0008 /* SCSI high byte termination */
938 1.21 fvdl #define CFSPARITY 0x0010 /* SCSI parity */
939 1.21 fvdl #define CF284XSTERM 0x0020 /* SCSI low byte term (284x cards) */
940 1.33 fvdl #define CFMULTILUN 0x0020
941 1.21 fvdl #define CFRESETB 0x0040 /* reset SCSI bus at boot */
942 1.33 fvdl #define CFCLUSTERENB 0x0080 /* Cluster Enable */
943 1.33 fvdl #define CFBOOTCHAN 0x0300 /* probe this channel first */
944 1.33 fvdl #define CFBOOTCHANSHIFT 8
945 1.33 fvdl #define CFSEAUTOTERM 0x0400 /* Ultra2 Perform secondary Auto Term*/
946 1.33 fvdl #define CFSELOWTERM 0x0800 /* Ultra2 secondary low term */
947 1.33 fvdl #define CFSEHIGHTERM 0x1000 /* Ultra2 secondary high term */
948 1.33 fvdl #define CFENABLEDV 0x4000 /* Perform Domain Validation*/
949 1.21 fvdl
950 1.21 fvdl /*
951 1.33 fvdl * Bus Release Time, Host Adapter ID
952 1.21 fvdl */
953 1.33 fvdl uint16_t brtime_id; /* word 18 */
954 1.21 fvdl #define CFSCSIID 0x000f /* host adapter SCSI ID */
955 1.21 fvdl /* UNUSED 0x00f0 */
956 1.21 fvdl #define CFBRTIME 0xff00 /* bus release time */
957 1.21 fvdl
958 1.21 fvdl /*
959 1.21 fvdl * Maximum targets
960 1.21 fvdl */
961 1.33 fvdl uint16_t max_targets; /* word 19 */
962 1.21 fvdl #define CFMAXTARG 0x00ff /* maximum targets */
963 1.33 fvdl #define CFBOOTLUN 0x0f00 /* Lun to boot from */
964 1.33 fvdl #define CFBOOTID 0xf000 /* Target to boot from */
965 1.33 fvdl uint16_t res_1[10]; /* words 20-29 */
966 1.33 fvdl uint16_t signature; /* Signature == 0x250 */
967 1.33 fvdl #define CFSIGNATURE 0x250
968 1.33 fvdl #define CFSIGNATURE2 0x300
969 1.33 fvdl uint16_t checksum; /* word 31 */
970 1.21 fvdl };
971 1.21 fvdl
972 1.33 fvdl /**************************** Message Buffer *********************************/
973 1.21 fvdl typedef enum {
974 1.21 fvdl MSG_TYPE_NONE = 0x00,
975 1.21 fvdl MSG_TYPE_INITIATOR_MSGOUT = 0x01,
976 1.21 fvdl MSG_TYPE_INITIATOR_MSGIN = 0x02,
977 1.21 fvdl MSG_TYPE_TARGET_MSGOUT = 0x03,
978 1.21 fvdl MSG_TYPE_TARGET_MSGIN = 0x04
979 1.21 fvdl } ahc_msg_type;
980 1.21 fvdl
981 1.33 fvdl typedef enum {
982 1.33 fvdl MSGLOOP_IN_PROG,
983 1.33 fvdl MSGLOOP_MSGCOMPLETE,
984 1.33 fvdl MSGLOOP_TERMINATED
985 1.33 fvdl } msg_loop_stat;
986 1.21 fvdl
987 1.33 fvdl /*********************** Software Configuration Structure *********************/
988 1.33 fvdl TAILQ_HEAD(scb_tailq, scb);
989 1.21 fvdl
990 1.33 fvdl struct ahc_suspend_channel_state {
991 1.33 fvdl uint8_t scsiseq;
992 1.33 fvdl uint8_t sxfrctl0;
993 1.33 fvdl uint8_t sxfrctl1;
994 1.33 fvdl uint8_t simode0;
995 1.33 fvdl uint8_t simode1;
996 1.33 fvdl uint8_t seltimer;
997 1.33 fvdl uint8_t seqctl;
998 1.33 fvdl };
999 1.21 fvdl
1000 1.33 fvdl struct ahc_suspend_state {
1001 1.33 fvdl struct ahc_suspend_channel_state channel[2];
1002 1.33 fvdl uint8_t optionmode;
1003 1.33 fvdl uint8_t dscommand0;
1004 1.33 fvdl uint8_t dspcistatus;
1005 1.33 fvdl /* hsmailbox */
1006 1.33 fvdl uint8_t crccontrol1;
1007 1.33 fvdl uint8_t scbbaddr;
1008 1.33 fvdl /* Host and sequencer SCB counts */
1009 1.33 fvdl uint8_t dff_thrsh;
1010 1.33 fvdl uint8_t *scratch_ram;
1011 1.33 fvdl uint8_t *btt;
1012 1.1 mycroft };
1013 1.1 mycroft
1014 1.33 fvdl typedef void (*ahc_bus_intr_t)(struct ahc_softc *);
1015 1.33 fvdl typedef void ahc_callback_t (void *);
1016 1.33 fvdl
1017 1.21 fvdl struct ahc_softc {
1018 1.33 fvdl struct device sc_dev;
1019 1.33 fvdl
1020 1.33 fvdl struct scsipi_channel sc_channel;
1021 1.33 fvdl struct scsipi_channel sc_channel_b;
1022 1.33 fvdl struct device * sc_child;
1023 1.33 fvdl struct device * sc_child_b;
1024 1.33 fvdl struct scsipi_adapter sc_adapter;
1025 1.33 fvdl
1026 1.33 fvdl bus_space_tag_t tag;
1027 1.33 fvdl bus_space_handle_t bsh;
1028 1.33 fvdl
1029 1.33 fvdl scsipi_adapter_req_t sc_req;
1030 1.21 fvdl
1031 1.33 fvdl #ifndef __linux__
1032 1.33 fvdl bus_dma_tag_t buffer_dmat; /* dmat for buffer I/O */
1033 1.33 fvdl #endif
1034 1.33 fvdl struct scb_data *scb_data;
1035 1.33 fvdl
1036 1.33 fvdl struct scb *next_queued_scb;
1037 1.33 fvdl
1038 1.33 fvdl /*
1039 1.33 fvdl * SCBs that have been sent to the controller
1040 1.33 fvdl */
1041 1.33 fvdl LIST_HEAD(, scb) pending_scbs;
1042 1.21 fvdl
1043 1.33 fvdl /*
1044 1.33 fvdl * Counting lock for deferring the release of additional
1045 1.33 fvdl * untagged transactions from the untagged_queues. When
1046 1.33 fvdl * the lock is decremented to 0, all queues in the
1047 1.33 fvdl * untagged_queues array are run.
1048 1.33 fvdl */
1049 1.33 fvdl u_int untagged_queue_lock;
1050 1.21 fvdl
1051 1.33 fvdl /*
1052 1.33 fvdl * Per-target queue of untagged-transactions. The
1053 1.33 fvdl * transaction at the head of the queue is the
1054 1.33 fvdl * currently pending untagged transaction for the
1055 1.33 fvdl * target. The driver only allows a single untagged
1056 1.33 fvdl * transaction per target.
1057 1.33 fvdl */
1058 1.33 fvdl struct scb_tailq untagged_queues[AHC_NUM_TARGETS];
1059 1.21 fvdl
1060 1.33 fvdl /*
1061 1.33 fvdl * Platform specific data.
1062 1.33 fvdl */
1063 1.33 fvdl struct ahc_platform_data *platform_data;
1064 1.30 ichiro
1065 1.21 fvdl /*
1066 1.33 fvdl * Platform specific device information.
1067 1.21 fvdl */
1068 1.33 fvdl /* ahc_dev_softc_t dev_softc; */
1069 1.33 fvdl
1070 1.33 fvdl /*
1071 1.33 fvdl * Bus specific device information.
1072 1.33 fvdl */
1073 1.33 fvdl ahc_bus_intr_t bus_intr;
1074 1.21 fvdl
1075 1.21 fvdl /*
1076 1.21 fvdl * Target mode related state kept on a per enabled lun basis.
1077 1.21 fvdl * Targets that are not enabled will have null entries.
1078 1.21 fvdl * As an initiator, we keep one target entry for our initiator
1079 1.21 fvdl * ID to store our sync/wide transfer settings.
1080 1.21 fvdl */
1081 1.33 fvdl struct ahc_tmode_tstate *enabled_targets[AHC_NUM_TARGETS];
1082 1.33 fvdl
1083 1.33 fvdl char inited_target[AHC_NUM_TARGETS];
1084 1.21 fvdl
1085 1.21 fvdl /*
1086 1.21 fvdl * The black hole device responsible for handling requests for
1087 1.21 fvdl * disabled luns on enabled targets.
1088 1.21 fvdl */
1089 1.33 fvdl struct ahc_tmode_lstate *black_hole;
1090 1.21 fvdl
1091 1.21 fvdl /*
1092 1.21 fvdl * Device instance currently on the bus awaiting a continue TIO
1093 1.21 fvdl * for a command that was not given the disconnect priveledge.
1094 1.21 fvdl */
1095 1.33 fvdl struct ahc_tmode_lstate *pending_device;
1096 1.21 fvdl
1097 1.21 fvdl /*
1098 1.21 fvdl * Card characteristics
1099 1.21 fvdl */
1100 1.33 fvdl ahc_chip chip;
1101 1.33 fvdl ahc_feature features;
1102 1.33 fvdl ahc_bug bugs;
1103 1.33 fvdl ahc_flag flags;
1104 1.33 fvdl struct seeprom_config *seep_config;
1105 1.21 fvdl
1106 1.21 fvdl /* Values to store in the SEQCTL register for pause and unpause */
1107 1.33 fvdl uint8_t unpause;
1108 1.33 fvdl uint8_t pause;
1109 1.21 fvdl
1110 1.21 fvdl /* Command Queues */
1111 1.33 fvdl uint8_t qoutfifonext;
1112 1.33 fvdl uint8_t qinfifonext;
1113 1.33 fvdl uint8_t *qoutfifo;
1114 1.33 fvdl uint8_t *qinfifo;
1115 1.33 fvdl
1116 1.33 fvdl /* Critical Section Data */
1117 1.33 fvdl struct cs *critical_sections;
1118 1.33 fvdl u_int num_critical_sections;
1119 1.21 fvdl
1120 1.33 fvdl /* Links for chaining softcs */
1121 1.33 fvdl TAILQ_ENTRY(ahc_softc) links;
1122 1.21 fvdl
1123 1.21 fvdl /* Channel Names ('A', 'B', etc.) */
1124 1.33 fvdl char channel;
1125 1.21 fvdl
1126 1.21 fvdl /* Initiator Bus ID */
1127 1.33 fvdl uint8_t our_id;
1128 1.33 fvdl uint8_t our_id_b;
1129 1.21 fvdl
1130 1.21 fvdl /*
1131 1.33 fvdl * PCI error detection.
1132 1.21 fvdl */
1133 1.33 fvdl int unsolicited_ints;
1134 1.21 fvdl
1135 1.21 fvdl /*
1136 1.21 fvdl * Target incoming command FIFO.
1137 1.21 fvdl */
1138 1.33 fvdl struct target_cmd *targetcmds;
1139 1.33 fvdl uint8_t tqinfifonext;
1140 1.21 fvdl
1141 1.21 fvdl /*
1142 1.21 fvdl * Incoming and outgoing message handling.
1143 1.21 fvdl */
1144 1.33 fvdl uint8_t send_msg_perror;
1145 1.33 fvdl ahc_msg_type msg_type;
1146 1.33 fvdl uint8_t msgout_buf[12];/* Message we are sending */
1147 1.33 fvdl uint8_t msgin_buf[12];/* Message we are receiving */
1148 1.33 fvdl u_int msgout_len; /* Length of message to send */
1149 1.33 fvdl u_int msgout_index; /* Current index in msgout */
1150 1.33 fvdl u_int msgin_index; /* Current index in msgin */
1151 1.33 fvdl
1152 1.33 fvdl /* Interrupt routine */
1153 1.33 fvdl void *ih;
1154 1.33 fvdl
1155 1.33 fvdl /*
1156 1.33 fvdl * Mapping information for data structures shared
1157 1.33 fvdl * between the sequencer and kernel.
1158 1.33 fvdl */
1159 1.33 fvdl bus_dma_tag_t parent_dmat;
1160 1.33 fvdl bus_dmamap_t shared_data_dmamap;
1161 1.33 fvdl bus_addr_t shared_data_busaddr;
1162 1.33 fvdl
1163 1.33 fvdl bus_dma_segment_t shared_data_seg;
1164 1.33 fvdl int shared_data_nseg;
1165 1.33 fvdl int shared_data_size;
1166 1.33 fvdl int sc_dmaflags;
1167 1.33 fvdl
1168 1.33 fvdl /*
1169 1.33 fvdl * Bus address of the one byte buffer used to
1170 1.33 fvdl * work-around a DMA bug for chips <= aic7880
1171 1.33 fvdl * in target mode.
1172 1.33 fvdl */
1173 1.33 fvdl bus_addr_t dma_bug_buf;
1174 1.33 fvdl
1175 1.33 fvdl /* Information saved through suspend/resume cycles */
1176 1.33 fvdl struct ahc_suspend_state suspend_state;
1177 1.21 fvdl
1178 1.21 fvdl /* Number of enabled target mode device on this card */
1179 1.33 fvdl u_int enabled_luns;
1180 1.21 fvdl
1181 1.21 fvdl /* Initialization level of this data structure */
1182 1.33 fvdl u_int init_level;
1183 1.21 fvdl
1184 1.33 fvdl /* PCI cacheline size. */
1185 1.33 fvdl u_int pci_cachesize;
1186 1.21 fvdl
1187 1.33 fvdl u_int stack_size;
1188 1.21 fvdl
1189 1.33 fvdl /* Per-Unit descriptive information */
1190 1.33 fvdl const char *description;
1191 1.33 fvdl char *name;
1192 1.33 fvdl int unit;
1193 1.4 mycroft
1194 1.33 fvdl /* Selection Timer settings */
1195 1.33 fvdl int seltime;
1196 1.33 fvdl int seltime_b;
1197 1.21 fvdl
1198 1.33 fvdl uint16_t user_discenable;/* Disconnection allowed */
1199 1.33 fvdl uint16_t user_tagenable;/* Tagged Queuing allowed */
1200 1.4 mycroft
1201 1.33 fvdl struct ahc_pci_busdata *bd;
1202 1.4 mycroft
1203 1.33 fvdl void *shutdown_hook;
1204 1.33 fvdl };
1205 1.21 fvdl
1206 1.33 fvdl TAILQ_HEAD(ahc_softc_tailq, ahc_softc);
1207 1.33 fvdl extern struct ahc_softc_tailq ahc_tailq;
1208 1.21 fvdl
1209 1.33 fvdl /************************ Active Device Information ***************************/
1210 1.33 fvdl typedef enum {
1211 1.33 fvdl ROLE_UNKNOWN,
1212 1.33 fvdl ROLE_INITIATOR,
1213 1.33 fvdl ROLE_TARGET
1214 1.33 fvdl } role_t;
1215 1.33 fvdl
1216 1.33 fvdl struct ahc_devinfo {
1217 1.33 fvdl int our_scsiid;
1218 1.33 fvdl int target_offset;
1219 1.33 fvdl uint16_t target_mask;
1220 1.33 fvdl u_int target;
1221 1.33 fvdl u_int lun;
1222 1.33 fvdl char channel;
1223 1.33 fvdl role_t role; /*
1224 1.33 fvdl * Only guaranteed to be correct if not
1225 1.33 fvdl * in the busfree state.
1226 1.33 fvdl */
1227 1.33 fvdl };
1228 1.4 mycroft
1229 1.33 fvdl /****************************** PCI Structures ********************************/
1230 1.33 fvdl typedef int (ahc_device_setup_t)(struct ahc_softc *);
1231 1.4 mycroft
1232 1.33 fvdl struct ahc_pci_identity {
1233 1.33 fvdl uint64_t full_id;
1234 1.33 fvdl uint64_t id_mask;
1235 1.33 fvdl char *name;
1236 1.33 fvdl ahc_device_setup_t *setup;
1237 1.33 fvdl };
1238 1.33 fvdl extern struct ahc_pci_identity ahc_pci_ident_table [];
1239 1.33 fvdl extern const u_int ahc_num_pci_devs;
1240 1.4 mycroft
1241 1.33 fvdl /***************************** VL/EISA Declarations ***************************/
1242 1.33 fvdl struct aic7770_identity {
1243 1.33 fvdl uint32_t full_id;
1244 1.33 fvdl uint32_t id_mask;
1245 1.33 fvdl char *name;
1246 1.33 fvdl ahc_device_setup_t *setup;
1247 1.33 fvdl };
1248 1.33 fvdl extern struct aic7770_identity aic7770_ident_table [];
1249 1.33 fvdl extern const int ahc_num_aic7770_devs;
1250 1.33 fvdl
1251 1.33 fvdl #define AHC_EISA_SLOT_OFFSET 0xc00
1252 1.33 fvdl #define AHC_EISA_IOSIZE 0x100
1253 1.4 mycroft
1254 1.33 fvdl /*************************** Function Declarations ****************************/
1255 1.33 fvdl /******************************************************************************/
1256 1.33 fvdl u_int ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl);
1257 1.33 fvdl void ahc_unbusy_tcl(struct ahc_softc *ahc, u_int tcl);
1258 1.33 fvdl void ahc_busy_tcl(struct ahc_softc *ahc,
1259 1.33 fvdl u_int tcl, u_int busyid);
1260 1.33 fvdl
1261 1.33 fvdl /***************************** PCI Front End *********************************/
1262 1.33 fvdl const struct ahc_pci_identity *ahc_find_pci_device(pcireg_t id, pcireg_t subid, u_int func);
1263 1.33 fvdl int ahc_pci_config(struct ahc_softc *,
1264 1.33 fvdl struct ahc_pci_identity *);
1265 1.33 fvdl int ahc_pci_test_register_access(struct ahc_softc *);
1266 1.33 fvdl
1267 1.33 fvdl /*************************** EISA/VL Front End ********************************/
1268 1.33 fvdl struct aic7770_identity *aic7770_find_device(uint32_t);
1269 1.33 fvdl int aic7770_config(struct ahc_softc *ahc,
1270 1.33 fvdl struct aic7770_identity *,
1271 1.33 fvdl u_int port);
1272 1.33 fvdl
1273 1.33 fvdl /************************** SCB and SCB queue management **********************/
1274 1.33 fvdl int ahc_probe_scbs(struct ahc_softc *);
1275 1.33 fvdl void ahc_run_untagged_queues(struct ahc_softc *ahc);
1276 1.33 fvdl void ahc_run_untagged_queue(struct ahc_softc *ahc,
1277 1.33 fvdl struct scb_tailq *queue);
1278 1.33 fvdl void ahc_qinfifo_requeue_tail(struct ahc_softc *ahc,
1279 1.33 fvdl struct scb *scb);
1280 1.33 fvdl int ahc_match_scb(struct ahc_softc *ahc, struct scb *scb,
1281 1.33 fvdl int target, char channel, int lun,
1282 1.33 fvdl u_int tag, role_t role);
1283 1.33 fvdl
1284 1.33 fvdl /****************************** Initialization ********************************/
1285 1.33 fvdl int ahc_softc_init(struct ahc_softc *);
1286 1.33 fvdl void ahc_controller_info(struct ahc_softc *ahc, char *buf);
1287 1.33 fvdl int ahc_init(struct ahc_softc *ahc);
1288 1.33 fvdl void ahc_intr_enable(struct ahc_softc *ahc, int enable);
1289 1.33 fvdl void ahc_pause_and_flushwork(struct ahc_softc *ahc);
1290 1.33 fvdl int ahc_suspend(struct ahc_softc *ahc);
1291 1.33 fvdl int ahc_resume(struct ahc_softc *ahc);
1292 1.33 fvdl void ahc_softc_insert(struct ahc_softc *);
1293 1.33 fvdl struct ahc_softc *ahc_find_softc(struct ahc_softc *ahc);
1294 1.33 fvdl void ahc_set_unit(struct ahc_softc *, int);
1295 1.33 fvdl void ahc_set_name(struct ahc_softc *, char *);
1296 1.33 fvdl void ahc_alloc_scbs(struct ahc_softc *ahc);
1297 1.33 fvdl void ahc_free(struct ahc_softc *ahc);
1298 1.33 fvdl int ahc_reset(struct ahc_softc *ahc);
1299 1.33 fvdl void ahc_shutdown(void *arg);
1300 1.33 fvdl
1301 1.33 fvdl /*************************** Interrupt Services *******************************/
1302 1.33 fvdl void ahc_pci_intr(struct ahc_softc *ahc);
1303 1.33 fvdl void ahc_clear_intstat(struct ahc_softc *ahc);
1304 1.33 fvdl void ahc_run_qoutfifo(struct ahc_softc *ahc);
1305 1.33 fvdl #ifdef AHC_TARGET_MODE
1306 1.33 fvdl void ahc_run_tqinfifo(struct ahc_softc *ahc, int paused);
1307 1.33 fvdl #endif
1308 1.33 fvdl void ahc_handle_brkadrint(struct ahc_softc *ahc);
1309 1.33 fvdl void ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat);
1310 1.33 fvdl void ahc_handle_scsiint(struct ahc_softc *ahc,
1311 1.33 fvdl u_int intstat);
1312 1.33 fvdl void ahc_clear_critical_section(struct ahc_softc *ahc);
1313 1.20 thorpej
1314 1.33 fvdl /***************************** Error Recovery *********************************/
1315 1.33 fvdl typedef enum {
1316 1.33 fvdl SEARCH_COMPLETE,
1317 1.33 fvdl SEARCH_COUNT,
1318 1.33 fvdl SEARCH_REMOVE
1319 1.33 fvdl } ahc_search_action;
1320 1.33 fvdl int ahc_search_qinfifo(struct ahc_softc *ahc, int target,
1321 1.33 fvdl char channel, int lun, u_int tag,
1322 1.33 fvdl role_t role, uint32_t status,
1323 1.33 fvdl ahc_search_action action);
1324 1.33 fvdl int ahc_search_untagged_queues(struct ahc_softc *ahc,
1325 1.33 fvdl struct scsipi_xfer *xs, /*ahc_io_ctx_t ctx*/
1326 1.33 fvdl int target, char channel,
1327 1.33 fvdl int lun, uint32_t status,
1328 1.33 fvdl ahc_search_action action);
1329 1.33 fvdl int ahc_search_disc_list(struct ahc_softc *ahc, int target,
1330 1.33 fvdl char channel, int lun, u_int tag,
1331 1.33 fvdl int stop_on_first, int remove,
1332 1.33 fvdl int save_state);
1333 1.33 fvdl void ahc_freeze_devq(struct ahc_softc *ahc, struct scb *scb);
1334 1.33 fvdl int ahc_reset_channel(struct ahc_softc *ahc, char channel,
1335 1.33 fvdl int initiate_reset);
1336 1.33 fvdl int ahc_abort_scbs(struct ahc_softc *ahc, int target,
1337 1.33 fvdl char channel, int lun, u_int tag,
1338 1.33 fvdl role_t role, uint32_t status);
1339 1.33 fvdl void ahc_restart(struct ahc_softc *ahc);
1340 1.33 fvdl void ahc_calc_residual(struct ahc_softc *ahc,
1341 1.33 fvdl struct scb *scb);
1342 1.33 fvdl /*************************** Utility Functions ********************************/
1343 1.33 fvdl struct ahc_phase_table_entry*
1344 1.33 fvdl ahc_lookup_phase_entry(int phase);
1345 1.33 fvdl void ahc_compile_devinfo(struct ahc_devinfo *devinfo,
1346 1.33 fvdl u_int our_id, u_int target,
1347 1.33 fvdl u_int lun, char channel,
1348 1.33 fvdl role_t role);
1349 1.33 fvdl /************************** Transfer Negotiation ******************************/
1350 1.33 fvdl struct ahc_syncrate* ahc_find_syncrate(struct ahc_softc *ahc, u_int *period,
1351 1.33 fvdl u_int *ppr_options, u_int maxsync);
1352 1.33 fvdl u_int ahc_find_period(struct ahc_softc *ahc,
1353 1.33 fvdl u_int scsirate, u_int maxsync);
1354 1.33 fvdl void ahc_validate_offset(struct ahc_softc *ahc,
1355 1.33 fvdl struct ahc_initiator_tinfo *tinfo,
1356 1.33 fvdl struct ahc_syncrate *syncrate,
1357 1.33 fvdl u_int *offset, int wide,
1358 1.33 fvdl role_t role);
1359 1.33 fvdl void ahc_validate_width(struct ahc_softc *ahc,
1360 1.33 fvdl struct ahc_initiator_tinfo *tinfo,
1361 1.33 fvdl u_int *bus_width,
1362 1.33 fvdl role_t role);
1363 1.33 fvdl /*
1364 1.33 fvdl * Negotiation types. These are used to qualify if we should renegotiate
1365 1.33 fvdl * even if our goal and current transport parameters are identical.
1366 1.33 fvdl */
1367 1.33 fvdl typedef enum {
1368 1.33 fvdl AHC_NEG_TO_GOAL, /* Renegotiate only if goal and curr differ. */
1369 1.33 fvdl AHC_NEG_IF_NON_ASYNC, /* Renegotiate so long as goal is non-async. */
1370 1.33 fvdl AHC_NEG_ALWAYS /* Renegotiat even if goal is async. */
1371 1.33 fvdl } ahc_neg_type;
1372 1.33 fvdl int ahc_update_neg_request(struct ahc_softc*,
1373 1.33 fvdl struct ahc_devinfo*,
1374 1.33 fvdl struct ahc_tmode_tstate*,
1375 1.33 fvdl struct ahc_initiator_tinfo*,
1376 1.33 fvdl ahc_neg_type);
1377 1.33 fvdl void ahc_set_width(struct ahc_softc *ahc,
1378 1.33 fvdl struct ahc_devinfo *devinfo,
1379 1.33 fvdl u_int width, u_int type, int paused);
1380 1.33 fvdl void ahc_set_syncrate(struct ahc_softc *ahc,
1381 1.33 fvdl struct ahc_devinfo *devinfo,
1382 1.33 fvdl struct ahc_syncrate *syncrate,
1383 1.33 fvdl u_int period, u_int offset,
1384 1.33 fvdl u_int ppr_options,
1385 1.33 fvdl u_int type, int paused);
1386 1.33 fvdl typedef enum {
1387 1.33 fvdl AHC_QUEUE_NONE,
1388 1.33 fvdl AHC_QUEUE_BASIC,
1389 1.33 fvdl AHC_QUEUE_TAGGED
1390 1.33 fvdl } ahc_queue_alg;
1391 1.33 fvdl
1392 1.33 fvdl void ahc_set_tags(struct ahc_softc *ahc,
1393 1.33 fvdl struct ahc_devinfo *devinfo,
1394 1.33 fvdl ahc_queue_alg alg);
1395 1.33 fvdl
1396 1.33 fvdl /**************************** Target Mode *************************************/
1397 1.33 fvdl #ifdef AHC_TARGET_MODE
1398 1.33 fvdl void ahc_send_lstate_events(struct ahc_softc *,
1399 1.33 fvdl struct ahc_tmode_lstate *);
1400 1.33 fvdl void ahc_handle_en_lun(struct ahc_softc *ahc,
1401 1.33 fvdl struct scsipi_xfer *xs
1402 1.33 fvdl /*struct cam_sim *sim, union ccb *ccb*/);
1403 1.33 fvdl cam_status ahc_find_tmode_devs(struct ahc_softc *ahc,
1404 1.33 fvdl /*struct cam_sim *sim, union ccb *ccb,*/
1405 1.33 fvdl struct ahc_tmode_tstate **tstate,
1406 1.33 fvdl struct ahc_tmode_lstate **lstate,
1407 1.33 fvdl int notfound_failure);
1408 1.33 fvdl #ifndef AHC_TMODE_ENABLE
1409 1.33 fvdl #define AHC_TMODE_ENABLE 0
1410 1.33 fvdl #endif
1411 1.33 fvdl #endif
1412 1.33 fvdl /******************************* Debug ***************************************/
1413 1.33 fvdl #ifdef AHC_DEBUG
1414 1.33 fvdl extern uint32_t ahc_debug;
1415 1.33 fvdl #define AHC_SHOW_MISC 0x0001
1416 1.33 fvdl #define AHC_SHOW_SENSE 0x0002
1417 1.33 fvdl #define AHC_DUMP_SEEPROM 0x0004
1418 1.33 fvdl #define AHC_SHOW_TERMCTL 0x0008
1419 1.33 fvdl #define AHC_SHOW_MEMORY 0x0010
1420 1.33 fvdl #define AHC_SHOW_MESSAGES 0x0020
1421 1.33 fvdl #define AHC_SHOW_DV 0x0040
1422 1.33 fvdl #define AHC_SHOW_SELTO 0x0080
1423 1.33 fvdl #define AHC_SHOW_QFULL 0x0200
1424 1.33 fvdl #define AHC_SHOW_QUEUE 0x0400
1425 1.33 fvdl #define AHC_SHOW_TQIN 0x0800
1426 1.33 fvdl #define AHC_SHOW_MASKED_ERRORS 0x1000
1427 1.33 fvdl #define AHC_DEBUG_SEQUENCER 0x2000
1428 1.33 fvdl #endif
1429 1.33 fvdl void ahc_print_scb(struct scb *scb);
1430 1.33 fvdl void ahc_print_devinfo(struct ahc_softc *ahc,
1431 1.33 fvdl struct ahc_devinfo *dev);
1432 1.33 fvdl void ahc_dump_card_state(struct ahc_softc *ahc);
1433 1.33 fvdl int ahc_print_register(ahc_reg_parse_entry_t *table,
1434 1.33 fvdl u_int num_entries,
1435 1.33 fvdl const char *name,
1436 1.33 fvdl u_int address,
1437 1.33 fvdl u_int value,
1438 1.33 fvdl u_int *cur_column,
1439 1.33 fvdl u_int wrap_point);
1440 1.33 fvdl /******************************* SEEPROM *************************************/
1441 1.33 fvdl int ahc_acquire_seeprom(struct ahc_softc *ahc,
1442 1.33 fvdl struct seeprom_descriptor *sd);
1443 1.33 fvdl void ahc_release_seeprom(struct seeprom_descriptor *sd);
1444 1.1 mycroft
1445 1.33 fvdl void ahc_check_extport(struct ahc_softc *ahc, u_int *sxfrctl1);
1446 1.33 fvdl #endif /* _AIC7XXXVAR_H_ */
1447