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