1 |
1626 |
jcastillo |
/**************************************************************************
|
2 |
|
|
* Initio 9100 device driver for Linux.
|
3 |
|
|
*
|
4 |
|
|
* Copyright (c) 1994-1998 Initio Corporation
|
5 |
|
|
* All rights reserved.
|
6 |
|
|
*
|
7 |
|
|
* This program is free software; you can redistribute it and/or modify
|
8 |
|
|
* it under the terms of the GNU General Public License as published by
|
9 |
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
10 |
|
|
* any later version.
|
11 |
|
|
*
|
12 |
|
|
* This program is distributed in the hope that it will be useful,
|
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
* GNU General Public License for more details.
|
16 |
|
|
*
|
17 |
|
|
* You should have received a copy of the GNU General Public License
|
18 |
|
|
* along with this program; see the file COPYING. If not, write to
|
19 |
|
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
20 |
|
|
*
|
21 |
|
|
* --------------------------------------------------------------------------
|
22 |
|
|
*
|
23 |
|
|
* Redistribution and use in source and binary forms, with or without
|
24 |
|
|
* modification, are permitted provided that the following conditions
|
25 |
|
|
* are met:
|
26 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
27 |
|
|
* notice, this list of conditions, and the following disclaimer,
|
28 |
|
|
* without modification, immediately at the beginning of the file.
|
29 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
30 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
31 |
|
|
* documentation and/or other materials provided with the distribution.
|
32 |
|
|
* 3. The name of the author may not be used to endorse or promote products
|
33 |
|
|
* derived from this software without specific prior written permission.
|
34 |
|
|
*
|
35 |
|
|
* Where this Software is combined with software released under the terms of
|
36 |
|
|
* the GNU Public License ("GPL") and the terms of the GPL would require the
|
37 |
|
|
* combined work to also be released under the terms of the GPL, the terms
|
38 |
|
|
* and conditions of this License will apply in addition to those of the
|
39 |
|
|
* GPL with the exception of any terms or conditions of this License that
|
40 |
|
|
* conflict with, or are expressly prohibited by, the GPL.
|
41 |
|
|
*
|
42 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
43 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
44 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
45 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
46 |
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
47 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
48 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
49 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
50 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
51 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
52 |
|
|
* SUCH DAMAGE.
|
53 |
|
|
*
|
54 |
|
|
*************************************************************************
|
55 |
|
|
*
|
56 |
|
|
* Module: ini9100u.h
|
57 |
|
|
* Description: INI-9100U/UW LINUX device driver header
|
58 |
|
|
* Revision History:
|
59 |
|
|
* 06/18/96 Harry Chen, Initial Version 1.00A (Beta)
|
60 |
|
|
* 06/23/98 hc - v1.01k
|
61 |
|
|
* - Get it work for kernel version >= 2.1.75
|
62 |
|
|
* 12/09/98 bv - v1.03a
|
63 |
|
|
* - Removed unused code
|
64 |
|
|
* 12/13/98 bv - v1.03b
|
65 |
|
|
* - Add spinlocks to HCS structure.
|
66 |
|
|
* 21/01/99 bv - v1.03e
|
67 |
|
|
* - Added PCI_ID structure
|
68 |
|
|
**************************************************************************/
|
69 |
|
|
|
70 |
|
|
#ifndef CVT_LINUX_VERSION
|
71 |
|
|
#define CVT_LINUX_VERSION(V,P,S) (((V) * 65536) + ((P) * 256) + (S))
|
72 |
|
|
#endif
|
73 |
|
|
|
74 |
|
|
#ifndef LINUX_VERSION_CODE
|
75 |
|
|
#include <linux/version.h>
|
76 |
|
|
#endif
|
77 |
|
|
|
78 |
|
|
#include "sd.h"
|
79 |
|
|
|
80 |
|
|
extern int i91u_detect(Scsi_Host_Template *);
|
81 |
|
|
extern int i91u_command(Scsi_Cmnd *);
|
82 |
|
|
extern int i91u_queue(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
|
83 |
|
|
extern int i91u_abort(Scsi_Cmnd *);
|
84 |
|
|
extern int i91u_reset(Scsi_Cmnd *, unsigned int);
|
85 |
|
|
|
86 |
|
|
#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(1, 3, 0)
|
87 |
|
|
extern int i91u_biosparam(Scsi_Disk *, kdev_t, int *); /*for linux v2.0 */
|
88 |
|
|
extern struct proc_dir_entry proc_scsi_ini9100u;
|
89 |
|
|
#else
|
90 |
|
|
extern int i91u_biosparam(Disk *, int, int *); /*for linux v1.13 */
|
91 |
|
|
#endif
|
92 |
|
|
|
93 |
|
|
#define i91u_REVID "Initio INI-9X00U/UW SCSI device driver; Revision: 1.03f"
|
94 |
|
|
|
95 |
|
|
#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(1, 3, 0)
|
96 |
|
|
#define INI9100U { \
|
97 |
|
|
NULL, \
|
98 |
|
|
NULL, \
|
99 |
|
|
i91u_REVID, \
|
100 |
|
|
i91u_detect, \
|
101 |
|
|
NULL, \
|
102 |
|
|
NULL, \
|
103 |
|
|
i91u_command, \
|
104 |
|
|
i91u_queue, \
|
105 |
|
|
i91u_abort, \
|
106 |
|
|
i91u_reset, \
|
107 |
|
|
NULL, \
|
108 |
|
|
i91u_biosparam, \
|
109 |
|
|
1, \
|
110 |
|
|
7, \
|
111 |
|
|
SG_ALL, \
|
112 |
|
|
1, \
|
113 |
|
|
0, \
|
114 |
|
|
0, \
|
115 |
|
|
ENABLE_CLUSTERING \
|
116 |
|
|
}
|
117 |
|
|
#else
|
118 |
|
|
|
119 |
|
|
#if LINUX_VERSION_CODE < CVT_LINUX_VERSION(2, 1, 75)
|
120 |
|
|
#define INI9100U { \
|
121 |
|
|
NULL, \
|
122 |
|
|
NULL, \
|
123 |
|
|
&proc_scsi_ini9100u, \
|
124 |
|
|
NULL, \
|
125 |
|
|
i91u_REVID, \
|
126 |
|
|
i91u_detect, \
|
127 |
|
|
NULL, \
|
128 |
|
|
NULL, \
|
129 |
|
|
i91u_command, \
|
130 |
|
|
i91u_queue, \
|
131 |
|
|
i91u_abort, \
|
132 |
|
|
i91u_reset, \
|
133 |
|
|
NULL, \
|
134 |
|
|
i91u_biosparam, \
|
135 |
|
|
1, \
|
136 |
|
|
7, \
|
137 |
|
|
SG_ALL, \
|
138 |
|
|
1, \
|
139 |
|
|
0, \
|
140 |
|
|
0, \
|
141 |
|
|
ENABLE_CLUSTERING \
|
142 |
|
|
}
|
143 |
|
|
#else /* Version >= 2.1.75 */
|
144 |
|
|
#define INI9100U { \
|
145 |
|
|
next: NULL, \
|
146 |
|
|
module: NULL, \
|
147 |
|
|
proc_dir: &proc_scsi_ini9100u, \
|
148 |
|
|
proc_info: NULL, \
|
149 |
|
|
name: i91u_REVID, \
|
150 |
|
|
detect: i91u_detect, \
|
151 |
|
|
release: NULL, \
|
152 |
|
|
info: NULL, \
|
153 |
|
|
command: i91u_command, \
|
154 |
|
|
queuecommand: i91u_queue, \
|
155 |
|
|
eh_strategy_handler: NULL, \
|
156 |
|
|
eh_abort_handler: NULL, \
|
157 |
|
|
eh_device_reset_handler: NULL, \
|
158 |
|
|
eh_bus_reset_handler: NULL, \
|
159 |
|
|
eh_host_reset_handler: NULL, \
|
160 |
|
|
abort: i91u_abort, \
|
161 |
|
|
reset: i91u_reset, \
|
162 |
|
|
slave_attach: NULL, \
|
163 |
|
|
bios_param: i91u_biosparam, \
|
164 |
|
|
can_queue: 1, \
|
165 |
|
|
this_id: 1, \
|
166 |
|
|
sg_tablesize: SG_ALL, \
|
167 |
|
|
cmd_per_lun: 1, \
|
168 |
|
|
present: 0, \
|
169 |
|
|
unchecked_isa_dma: 0, \
|
170 |
|
|
use_clustering: ENABLE_CLUSTERING, \
|
171 |
|
|
use_new_eh_code: 0 \
|
172 |
|
|
}
|
173 |
|
|
#endif
|
174 |
|
|
#endif
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
#define VIRT_TO_BUS(i) (unsigned int) virt_to_bus((void *)(i))
|
178 |
|
|
#define ULONG unsigned long
|
179 |
|
|
#define USHORT unsigned short
|
180 |
|
|
#define UCHAR unsigned char
|
181 |
|
|
#define BYTE unsigned char
|
182 |
|
|
#define WORD unsigned short
|
183 |
|
|
#define DWORD unsigned long
|
184 |
|
|
#define UBYTE unsigned char
|
185 |
|
|
#define UWORD unsigned short
|
186 |
|
|
#define UDWORD unsigned long
|
187 |
|
|
#ifdef ALPHA
|
188 |
|
|
#define U32 unsigned int
|
189 |
|
|
#else
|
190 |
|
|
#define U32 unsigned long
|
191 |
|
|
#endif
|
192 |
|
|
|
193 |
|
|
#ifndef NULL
|
194 |
|
|
#define NULL 0 /* zero */
|
195 |
|
|
#endif
|
196 |
|
|
#ifndef TRUE
|
197 |
|
|
#define TRUE (1) /* boolean true */
|
198 |
|
|
#endif
|
199 |
|
|
#ifndef FALSE
|
200 |
|
|
#define FALSE (0) /* boolean false */
|
201 |
|
|
#endif
|
202 |
|
|
#ifndef FAILURE
|
203 |
|
|
#define FAILURE (-1)
|
204 |
|
|
#endif
|
205 |
|
|
|
206 |
|
|
#define i91u_MAXQUEUE 2
|
207 |
|
|
#define TOTAL_SG_ENTRY 32
|
208 |
|
|
#define MAX_TARGETS 16
|
209 |
|
|
#define SENSE_SIZE 14
|
210 |
|
|
|
211 |
|
|
#define INI_VENDOR_ID 0x1101 /* Initio's PCI vendor ID */
|
212 |
|
|
#define DMX_VENDOR_ID 0x134a /* Domex's PCI vendor ID */
|
213 |
|
|
#define I950_DEVICE_ID 0x9500 /* Initio's inic-950 product ID */
|
214 |
|
|
#define I940_DEVICE_ID 0x9400 /* Initio's inic-940 product ID */
|
215 |
|
|
#define I935_DEVICE_ID 0x9401 /* Initio's inic-935 product ID */
|
216 |
|
|
#define I920_DEVICE_ID 0x0002 /* Initio's other product ID */
|
217 |
|
|
|
218 |
|
|
/************************************************************************/
|
219 |
|
|
/* Vendor ID/Device ID Pair Structure */
|
220 |
|
|
/************************************************************************/
|
221 |
|
|
typedef struct PCI_ID_Struc {
|
222 |
|
|
unsigned short vendor_id;
|
223 |
|
|
unsigned short device_id;
|
224 |
|
|
} PCI_ID;
|
225 |
|
|
|
226 |
|
|
/************************************************************************/
|
227 |
|
|
/* Scatter-Gather Element Structure */
|
228 |
|
|
/************************************************************************/
|
229 |
|
|
typedef struct SG_Struc {
|
230 |
|
|
U32 SG_Ptr; /* Data Pointer */
|
231 |
|
|
U32 SG_Len; /* Data Length */
|
232 |
|
|
} SG;
|
233 |
|
|
|
234 |
|
|
/***********************************************************************
|
235 |
|
|
SCSI Control Block
|
236 |
|
|
************************************************************************/
|
237 |
|
|
typedef struct Scsi_Ctrl_Blk {
|
238 |
|
|
U32 SCB_InitioReserved[9]; /* 0 */
|
239 |
|
|
|
240 |
|
|
UBYTE SCB_Opcode; /*24 SCB command code */
|
241 |
|
|
UBYTE SCB_Flags; /*25 SCB Flags */
|
242 |
|
|
UBYTE SCB_Target; /*26 Target Id */
|
243 |
|
|
UBYTE SCB_Lun; /*27 Lun */
|
244 |
|
|
U32 SCB_BufPtr; /*28 Data Buffer Pointer */
|
245 |
|
|
U32 SCB_BufLen; /*2C Data Allocation Length */
|
246 |
|
|
UBYTE SCB_SGLen; /*30 SG list # */
|
247 |
|
|
UBYTE SCB_SenseLen; /*31 Sense Allocation Length */
|
248 |
|
|
UBYTE SCB_HaStat; /*32 */
|
249 |
|
|
UBYTE SCB_TaStat; /*33 */
|
250 |
|
|
UBYTE SCB_CDBLen; /*34 CDB Length */
|
251 |
|
|
UBYTE SCB_Ident; /*35 Identify */
|
252 |
|
|
UBYTE SCB_TagMsg; /*36 Tag Message */
|
253 |
|
|
UBYTE SCB_TagId; /*37 Queue Tag */
|
254 |
|
|
UBYTE SCB_CDB[12]; /*38 */
|
255 |
|
|
U32 SCB_SGPAddr; /*44 SG List/Sense Buf phy. Addr. */
|
256 |
|
|
U32 SCB_SensePtr; /*48 Sense data pointer */
|
257 |
|
|
void (*SCB_Post) (BYTE *, BYTE *); /*4C POST routine */
|
258 |
|
|
Scsi_Cmnd *SCB_Srb; /*50 SRB Pointer */
|
259 |
|
|
SG SCB_SGList[TOTAL_SG_ENTRY]; /*54 Start of SG list */
|
260 |
|
|
} SCB;
|
261 |
|
|
|
262 |
|
|
/* Opcodes of SCB_Opcode */
|
263 |
|
|
#define ExecSCSI 0x1
|
264 |
|
|
#define BusDevRst 0x2
|
265 |
|
|
#define AbortCmd 0x3
|
266 |
|
|
|
267 |
|
|
/* Bit Definition for SCB_Flags */
|
268 |
|
|
#define SCF_DONE 0x01
|
269 |
|
|
#define SCF_POST 0x02
|
270 |
|
|
#define SCF_SENSE 0x04
|
271 |
|
|
#define SCF_DIR 0x18
|
272 |
|
|
#define SCF_NO_DCHK 0x00
|
273 |
|
|
#define SCF_DIN 0x08
|
274 |
|
|
#define SCF_DOUT 0x10
|
275 |
|
|
#define SCF_NO_XF 0x18
|
276 |
|
|
#define SCF_POLL 0x40
|
277 |
|
|
#define SCF_SG 0x80
|
278 |
|
|
|
279 |
|
|
/* Error Codes for SCB_HaStat */
|
280 |
|
|
#define HOST_SEL_TOUT 0x11
|
281 |
|
|
#define HOST_DO_DU 0x12
|
282 |
|
|
#define HOST_BUS_FREE 0x13
|
283 |
|
|
#define HOST_BAD_PHAS 0x14
|
284 |
|
|
#define HOST_INV_CMD 0x16
|
285 |
|
|
#define HOST_SCSI_RST 0x1B
|
286 |
|
|
#define HOST_DEV_RST 0x1C
|
287 |
|
|
|
288 |
|
|
/* Error Codes for SCB_TaStat */
|
289 |
|
|
#define TARGET_CHKCOND 0x02
|
290 |
|
|
#define TARGET_BUSY 0x08
|
291 |
|
|
|
292 |
|
|
/* Queue tag msg: Simple_quque_tag, Head_of_queue_tag, Ordered_queue_tag */
|
293 |
|
|
#define MSG_STAG 0x20
|
294 |
|
|
#define MSG_HTAG 0x21
|
295 |
|
|
#define MSG_OTAG 0x22
|
296 |
|
|
|
297 |
|
|
/***********************************************************************
|
298 |
|
|
Target Device Control Structure
|
299 |
|
|
**********************************************************************/
|
300 |
|
|
|
301 |
|
|
typedef struct Tar_Ctrl_Struc {
|
302 |
|
|
ULONG TCS_InitioReserved; /* 0 */
|
303 |
|
|
|
304 |
|
|
UWORD TCS_DrvFlags; /* 4 */
|
305 |
|
|
UBYTE TCS_DrvHead; /* 6 */
|
306 |
|
|
UBYTE TCS_DrvSector; /* 7 */
|
307 |
|
|
} TCS;
|
308 |
|
|
|
309 |
|
|
/***********************************************************************
|
310 |
|
|
Target Device Control Structure
|
311 |
|
|
**********************************************************************/
|
312 |
|
|
/* Bit Definition for TCF_DrvFlags */
|
313 |
|
|
#define TCF_DRV_255_63 0x0400
|
314 |
|
|
|
315 |
|
|
/***********************************************************************
|
316 |
|
|
Host Adapter Control Structure
|
317 |
|
|
************************************************************************/
|
318 |
|
|
typedef struct Ha_Ctrl_Struc {
|
319 |
|
|
UWORD HCS_Base; /* 00 */
|
320 |
|
|
UWORD HCS_BIOS; /* 02 */
|
321 |
|
|
UBYTE HCS_Intr; /* 04 */
|
322 |
|
|
UBYTE HCS_SCSI_ID; /* 05 */
|
323 |
|
|
UBYTE HCS_MaxTar; /* 06 */
|
324 |
|
|
UBYTE HCS_NumScbs; /* 07 */
|
325 |
|
|
|
326 |
|
|
UBYTE HCS_Flags; /* 08 */
|
327 |
|
|
UBYTE HCS_Index; /* 09 */
|
328 |
|
|
UBYTE HCS_Reserved[2]; /* 0a */
|
329 |
|
|
ULONG HCS_InitioReserved[27]; /* 0C */
|
330 |
|
|
TCS HCS_Tcs[16]; /* 78 -> 16 Targets */
|
331 |
|
|
Scsi_Cmnd *pSRB_head; /* SRB save queue header */
|
332 |
|
|
Scsi_Cmnd *pSRB_tail; /* SRB save queue tail */
|
333 |
|
|
#if LINUX_VERSION_CODE >= CVT_LINUX_VERSION(2,1,95)
|
334 |
|
|
spinlock_t HCS_AvailLock;
|
335 |
|
|
spinlock_t HCS_SemaphLock;
|
336 |
|
|
spinlock_t pSRB_lock;
|
337 |
|
|
#endif
|
338 |
|
|
} HCS;
|
339 |
|
|
|
340 |
|
|
/* Bit Definition for HCB_Flags */
|
341 |
|
|
#define HCF_EXPECT_RESET 0x10
|
342 |
|
|
|
343 |
|
|
/* SCSI related definition */
|
344 |
|
|
#define DISC_NOT_ALLOW 0x80 /* Disconnect is not allowed */
|
345 |
|
|
#define DISC_ALLOW 0xC0 /* Disconnect is allowed */
|