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