1 /**************************************************************************
2 * Initio 9100 device driver for Linux.
4 * Copyright (c) 1994-1998 Initio Corporation
5 * Copyright (c) 1998 Bas Vermeulen <bvermeul@blackstar.xs4all.nl>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 * --------------------------------------------------------------------------
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
27 * 1. Redistributions of source code must retain the above copyright
28 * notice, this list of conditions, and the following disclaimer,
29 * without modification, immediately at the beginning of the file.
30 * 2. Redistributions in binary form must reproduce the above copyright
31 * notice, this list of conditions and the following disclaimer in the
32 * documentation and/or other materials provided with the distribution.
33 * 3. The name of the author may not be used to endorse or promote products
34 * derived from this software without specific prior written permission.
36 * Where this Software is combined with software released under the terms of
37 * the GNU Public License ("GPL") and the terms of the GPL would require the
38 * combined work to also be released under the terms of the GPL, the terms
39 * and conditions of this License will apply in addition to those of the
40 * GPL with the exception of any terms or conditions of this License that
41 * conflict with, or are expressly prohibited by, the GPL.
43 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
47 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 *************************************************************************
59 * This is the Linux low-level SCSI driver for Initio INI-9X00U/UW SCSI host
62 * 08/06/97 hc - v1.01h
63 * - Support inic-940 and inic-935
64 * 09/26/97 hc - v1.01i
65 * - Make correction from J.W. Schultz suggestion
66 * 10/13/97 hc - Support reset function
67 * 10/21/97 hc - v1.01j
68 * - Support 32 LUN (SCSI 3)
69 * 01/14/98 hc - v1.01k
70 * - Fix memory allocation problem
71 * 03/04/98 hc - v1.01l
72 * - Fix tape rewind which will hang the system problem
73 * - Set can_queue to tul_num_scb
74 * 06/25/98 hc - v1.01m
75 * - Get it work for kernel version >= 2.1.75
76 * - Dynamic assign SCSI bus reset holding time in init_tulip()
77 * 07/02/98 hc - v1.01n
79 * 08/07/98 hc - v1.01o
80 * - Change the tul_abort_srb routine to use scsi_done. <01>
82 * - Change the INI9100U define and proc_dir_entry to
83 * reflect the newer Kernel 2.1.118, but the v1.o1o
84 * should work with Kernel 2.1.118.
85 * 09/20/98 wh - v1.02a
86 * - Support Abort command.
87 * - Handle reset routine.
90 * 12/09/98 bv - v1.03a
91 * - Removed unused code
92 * 12/13/98 bv - v1.03b
93 * - Remove cli() locking for kernels >= 2.1.95. This uses
94 * spinlocks to serialize access to the pSRB_head and
95 * pSRB_tail members of the HCS structure.
96 * 09/01/99 bv - v1.03d
97 * - Fixed a deadlock problem in SMP.
98 * 21/01/99 bv - v1.03e
99 * - Add support for the Domex 3192U PCI SCSI
100 * This is a slightly modified patch by
101 * Brian Macy <bmacy@sunshinecomputing.com>
102 * 22/02/99 bv - v1.03f
103 * - Didn't detect the INIC-950 in 2.0.x correctly.
105 * 05/07/99 bv - v1.03g
106 * - Changed the assumption that HZ = 100
107 **************************************************************************/
109 #define CVT_LINUX_VERSION(V,P,S) (V * 65536 + P * 256 + S)
111 #ifndef LINUX_VERSION_CODE
112 #include <linux/version.h>
116 #include <linux/module.h>
121 #include <linux/errno.h>
122 #include <linux/delay.h>
123 #include <linux/pci.h>
124 #include <linux/init.h>
125 #include <linux/blk.h>
126 #include <linux/spinlock.h>
127 #include <linux/stat.h>
128 #include <linux/config.h>
130 #include <linux/kernel.h>
131 #include <linux/string.h>
132 #include <linux/ioport.h>
133 #include <linux/sched.h>
134 #include <linux/proc_fs.h>
139 #include <linux/malloc.h>
140 #include "ini9100u.h"
143 unsigned int i91u_debug
= DEBUG_DEFAULT
;
146 static Scsi_Host_Template driver_template
= INI9100U
;
147 #include "scsi_module.c"
149 char *i91uCopyright
= "Copyright (C) 1996-98";
150 char *i91uInitioName
= "by Initio Corporation";
151 char *i91uProductName
= "INI-9X00U/UW";
152 char *i91uVersion
= "v1.03g";
154 #define TULSZ(sz) (sizeof(sz) / sizeof(sz[0]))
155 #define TUL_RDWORD(x,y) (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
157 /* set by i91_setup according to the command line */
158 static int setup_called
= 0;
160 static int tul_num_ch
= 4; /* Maximum 4 adapters */
161 static int tul_num_scb
;
162 static int tul_tag_enable
= 1;
166 static int setup_debug
= 0;
169 static char *setup_str
= (char *) NULL
;
171 static void i91u_intr0(int irq
, void *dev_id
, struct pt_regs
*);
172 static void i91u_intr1(int irq
, void *dev_id
, struct pt_regs
*);
173 static void i91u_intr2(int irq
, void *dev_id
, struct pt_regs
*);
174 static void i91u_intr3(int irq
, void *dev_id
, struct pt_regs
*);
175 static void i91u_intr4(int irq
, void *dev_id
, struct pt_regs
*);
176 static void i91u_intr5(int irq
, void *dev_id
, struct pt_regs
*);
177 static void i91u_intr6(int irq
, void *dev_id
, struct pt_regs
*);
178 static void i91u_intr7(int irq
, void *dev_id
, struct pt_regs
*);
180 static void i91u_panic(char *msg
);
182 static void i91uSCBPost(BYTE
* pHcb
, BYTE
* pScb
);
184 /* ---- EXTERNAL FUNCTIONS ---- */
185 /* Get total number of adapters */
186 extern void init_i91uAdapter_table(void);
187 extern int Addi91u_into_Adapter_table(WORD
, WORD
, BYTE
, BYTE
, BYTE
);
188 extern int tul_ReturnNumberOfAdapters(void);
189 extern void get_tulipPCIConfig(HCS
* pHCB
, int iChannel_index
);
190 extern int init_tulip(HCS
* pHCB
, SCB
* pSCB
, int tul_num_scb
, BYTE
* pbBiosAdr
, int reset_time
);
191 extern SCB
*tul_alloc_scb(HCS
* pHCB
);
192 extern int tul_abort_srb(HCS
* pHCB
, Scsi_Cmnd
* pSRB
);
193 extern void tul_exec_scb(HCS
* pHCB
, SCB
* pSCB
);
194 extern void tul_release_scb(HCS
* pHCB
, SCB
* pSCB
);
195 extern void tul_stop_bm(HCS
* pHCB
);
196 extern int tul_reset_scsi(HCS
* pCurHcb
, int seconds
);
197 extern int tul_isr(HCS
* pHCB
);
198 extern int tul_reset(HCS
* pHCB
, Scsi_Cmnd
* pSRB
, unsigned char target
);
199 extern int tul_reset_scsi_bus(HCS
* pCurHcb
);
200 extern int tul_device_reset(HCS
* pCurHcb
, ULONG pSrb
, unsigned int target
, unsigned int ResetFlags
);
201 /* ---- EXTERNAL VARIABLES ---- */
202 extern HCS tul_hcs
[];
204 const PCI_ID i91u_pci_devices
[] = {
205 { INI_VENDOR_ID
, I950_DEVICE_ID
},
206 { INI_VENDOR_ID
, I940_DEVICE_ID
},
207 { INI_VENDOR_ID
, I935_DEVICE_ID
},
208 { INI_VENDOR_ID
, I920_DEVICE_ID
},
209 { DMX_VENDOR_ID
, I920_DEVICE_ID
},
215 /*****************************************************************************
216 Function name : i91uAppendSRBToQueue
217 Description : This function will push current request into save list
218 Input : pSRB - Pointer to SCSI request block.
219 pHCB - Pointer to host adapter structure
222 *****************************************************************************/
223 static void i91uAppendSRBToQueue(HCS
* pHCB
, Scsi_Cmnd
* pSRB
)
226 spin_lock_irqsave(&(pHCB
->pSRB_lock
), flags
);
228 pSRB
->next
= NULL
; /* Pointer to next */
230 if (pHCB
->pSRB_head
== NULL
)
231 pHCB
->pSRB_head
= pSRB
;
233 pHCB
->pSRB_tail
->next
= pSRB
; /* Pointer to next */
234 pHCB
->pSRB_tail
= pSRB
;
236 spin_unlock_irqrestore(&(pHCB
->pSRB_lock
), flags
);
240 /*****************************************************************************
241 Function name : i91uPopSRBFromQueue
242 Description : This function will pop current request from save list
243 Input : pHCB - Pointer to host adapter structure
245 Return : pSRB - Pointer to SCSI request block.
246 *****************************************************************************/
247 static Scsi_Cmnd
*i91uPopSRBFromQueue(HCS
* pHCB
)
252 spin_lock_irqsave(&(pHCB
->pSRB_lock
), flags
);
254 if ((pSRB
= pHCB
->pSRB_head
) != NULL
) {
255 pHCB
->pSRB_head
= pHCB
->pSRB_head
->next
;
258 spin_unlock_irqrestore(&(pHCB
->pSRB_lock
), flags
);
263 /* called from init/main.c */
265 void i91u_setup(char *str
, int *ints
)
268 i91u_panic("i91u: i91u_setup called twice.\n");
270 setup_called
= ints
[0];
274 setup_debug
= ints
[0] >= 1 ? ints
[1] : DEBUG_DEFAULT
;
278 int tul_NewReturnNumberOfAdapters(void)
280 struct pci_dev
*pDev
= NULL
; /* Start from none */
286 init_i91uAdapter_table();
288 for (i
= 0; i
< TULSZ(i91u_pci_devices
); i
++)
290 while ((pDev
= pci_find_device(i91u_pci_devices
[i
].vendor_id
, i91u_pci_devices
[i
].device_id
, pDev
)) != NULL
) {
291 if (pci_enable_device(pDev
))
293 pci_read_config_dword(pDev
, 0x44, (u32
*) & dRegValue
);
294 wBIOS
= (UWORD
) (dRegValue
& 0xFF);
295 if (((dRegValue
& 0xFF00) >> 8) == 0xFF)
297 wBIOS
= (wBIOS
<< 8) + ((UWORD
) ((dRegValue
& 0xFF00) >> 8));
298 if (Addi91u_into_Adapter_table(wBIOS
,
299 (pDev
->resource
[0].start
),
311 int i91u_detect(Scsi_Host_Template
* tpnt
)
315 struct Scsi_Host
*hreg
;
316 unsigned long i
; /* 01/14/98 */
317 int ok
= 0, iAdapters
;
321 tpnt
->proc_name
= "INI9100U";
323 if (setup_called
) { /* Setup by i91u_setup */
324 printk("i91u: processing commandline: ");
327 if (setup_called
> 1) {
328 printk("\ni91u: %s\n", setup_str
);
329 printk("i91u: usage: i91u[=<DEBUG>]\n");
330 i91u_panic("i91u panics in line %d", __LINE__
);
332 i91u_debug
= setup_debug
;
335 /* Get total number of adapters in the motherboard */
337 iAdapters
= tul_NewReturnNumberOfAdapters();
339 iAdapters
= tul_ReturnNumberOfAdapters();
342 if (iAdapters
== 0) /* If no tulip founded, return */
345 tul_num_ch
= (iAdapters
> tul_num_ch
) ? tul_num_ch
: iAdapters
;
346 /* Update actually channel number */
347 if (tul_tag_enable
) { /* 1.01i */
348 tul_num_scb
= MAX_TARGETS
* i91u_MAXQUEUE
;
350 tul_num_scb
= MAX_TARGETS
+ 3; /* 1-tape, 1-CD_ROM, 1- extra */
351 } /* Update actually SCBs per adapter */
353 /* Get total memory needed for HCS */
354 i
= tul_num_ch
* sizeof(HCS
);
355 memset((unsigned char *) &tul_hcs
[0], 0, i
); /* Initialize tul_hcs 0 */
356 /* Get total memory needed for SCB */
358 for (; tul_num_scb
>= MAX_TARGETS
+ 3; tul_num_scb
--) {
359 i
= tul_num_ch
* tul_num_scb
* sizeof(SCB
);
360 if ((tul_scb
= (SCB
*) kmalloc(i
, GFP_ATOMIC
| GFP_DMA
)) != NULL
)
363 if (tul_scb
== NULL
) {
364 printk("i91u: SCB memory allocation error\n");
367 memset((unsigned char *) tul_scb
, 0, i
);
370 for (i
= 0; i
< tul_num_ch
* tul_num_scb
; i
++, pSCB
++) {
371 pSCB
->SCB_SGPAddr
= (U32
) VIRT_TO_BUS(&pSCB
->SCB_SGList
[0]);
374 for (i
= 0, pHCB
= &tul_hcs
[0]; /* Get pointer for control block */
377 pHCB
->pSRB_head
= NULL
; /* Initial SRB save queue */
378 pHCB
->pSRB_tail
= NULL
; /* Initial SRB save queue */
379 pHCB
->pSRB_lock
= SPIN_LOCK_UNLOCKED
; /* SRB save queue lock */
380 get_tulipPCIConfig(pHCB
, i
);
382 dBiosAdr
= pHCB
->HCS_BIOS
;
383 dBiosAdr
= (dBiosAdr
<< 4);
385 pbBiosAdr
= phys_to_virt(dBiosAdr
);
387 init_tulip(pHCB
, tul_scb
+ (i
* tul_num_scb
), tul_num_scb
, pbBiosAdr
, 10);
388 request_region(pHCB
->HCS_Base
, 256, "i91u"); /* Register */
390 pHCB
->HCS_Index
= i
; /* 7/29/98 */
391 hreg
= scsi_register(tpnt
, sizeof(HCS
));
394 release_region(pHCB
->HCS_Base
, 256);
397 hreg
->io_port
= pHCB
->HCS_Base
;
398 hreg
->n_io_port
= 0xff;
399 hreg
->can_queue
= tul_num_scb
; /* 03/05/98 */
400 hreg
->unique_id
= pHCB
->HCS_Base
;
401 hreg
->max_id
= pHCB
->HCS_MaxTar
;
402 hreg
->max_lun
= 32; /* 10/21/97 */
403 hreg
->irq
= pHCB
->HCS_Intr
;
404 hreg
->this_id
= pHCB
->HCS_SCSI_ID
; /* Assign HCS index */
405 hreg
->base
= (unsigned long)pHCB
;
406 hreg
->sg_tablesize
= TOTAL_SG_ENTRY
; /* Maximun support is 32 */
408 /* Initial tulip chip */
411 ok
= request_irq(pHCB
->HCS_Intr
, i91u_intr0
, SA_INTERRUPT
| SA_SHIRQ
, "i91u", hreg
);
414 ok
= request_irq(pHCB
->HCS_Intr
, i91u_intr1
, SA_INTERRUPT
| SA_SHIRQ
, "i91u", hreg
);
417 ok
= request_irq(pHCB
->HCS_Intr
, i91u_intr2
, SA_INTERRUPT
| SA_SHIRQ
, "i91u", hreg
);
420 ok
= request_irq(pHCB
->HCS_Intr
, i91u_intr3
, SA_INTERRUPT
| SA_SHIRQ
, "i91u", hreg
);
423 ok
= request_irq(pHCB
->HCS_Intr
, i91u_intr4
, SA_INTERRUPT
| SA_SHIRQ
, "i91u", hreg
);
426 ok
= request_irq(pHCB
->HCS_Intr
, i91u_intr5
, SA_INTERRUPT
| SA_SHIRQ
, "i91u", hreg
);
429 ok
= request_irq(pHCB
->HCS_Intr
, i91u_intr6
, SA_INTERRUPT
| SA_SHIRQ
, "i91u", hreg
);
432 ok
= request_irq(pHCB
->HCS_Intr
, i91u_intr7
, SA_INTERRUPT
| SA_SHIRQ
, "i91u", hreg
);
435 i91u_panic("i91u: Too many host adapters\n");
440 printk("i91u: bad IRQ %d.\n", pHCB
->HCS_Intr
);
441 printk(" Contact author.\n");
442 } else if (ok
== -EBUSY
)
443 printk("i91u: IRQ %d already in use. Configure another.\n",
446 printk("\ni91u: Unexpected error code on requesting IRQ %d.\n",
448 printk(" Contact author.\n");
450 i91u_panic("i91u: driver needs an IRQ.\n");
460 static void i91uBuildSCB(HCS
* pHCB
, SCB
* pSCB
, Scsi_Cmnd
* SCpnt
)
461 { /* Create corresponding SCB */
462 struct scatterlist
*pSrbSG
;
463 SG
*pSG
; /* Pointer to SG list */
467 pSCB
->SCB_Post
= i91uSCBPost
; /* i91u's callback routine */
468 pSCB
->SCB_Srb
= SCpnt
;
469 pSCB
->SCB_Opcode
= ExecSCSI
;
470 pSCB
->SCB_Flags
= SCF_POST
; /* After SCSI done, call post routine */
471 pSCB
->SCB_Target
= SCpnt
->target
;
472 pSCB
->SCB_Lun
= SCpnt
->lun
;
473 pSCB
->SCB_Ident
= SCpnt
->lun
| DISC_ALLOW
;
474 pSCB
->SCB_Flags
|= SCF_SENSE
; /* Turn on auto request sense */
476 pSCB
->SCB_SensePtr
= (U32
) VIRT_TO_BUS(SCpnt
->sense_buffer
);
478 pSCB
->SCB_SenseLen
= SENSE_SIZE
;
480 pSCB
->SCB_CDBLen
= SCpnt
->cmd_len
;
481 pSCB
->SCB_HaStat
= 0;
482 pSCB
->SCB_TaStat
= 0;
483 memcpy(&pSCB
->SCB_CDB
[0], &SCpnt
->cmnd
, SCpnt
->cmd_len
);
485 if (SCpnt
->device
->tagged_supported
) { /* Tag Support */
486 pSCB
->SCB_TagMsg
= SIMPLE_QUEUE_TAG
; /* Do simple tag only */
488 pSCB
->SCB_TagMsg
= 0; /* No tag support */
492 pSrbSG
= (struct scatterlist
*) SCpnt
->request_buffer
;
493 if (SCpnt
->use_sg
== 1) { /* If only one entry in the list *//* treat it as regular I/O */
494 pSCB
->SCB_BufPtr
= (U32
) VIRT_TO_BUS(pSrbSG
->address
);
495 TotalLen
= pSrbSG
->length
;
497 } else { /* Assign SG physical address */
498 pSCB
->SCB_BufPtr
= pSCB
->SCB_SGPAddr
;
499 pSCB
->SCB_Flags
|= SCF_SG
; /* Turn on SG list flag */
500 for (i
= 0, TotalLen
= 0, pSG
= &pSCB
->SCB_SGList
[0]; /* 1.01g */
502 i
++, pSG
++, pSrbSG
++) {
503 pSG
->SG_Ptr
= (U32
) VIRT_TO_BUS(pSrbSG
->address
);
504 TotalLen
+= pSG
->SG_Len
= pSrbSG
->length
;
508 pSCB
->SCB_BufLen
= (SCpnt
->request_bufflen
> TotalLen
) ?
509 TotalLen
: SCpnt
->request_bufflen
;
510 } else { /* Non SG */
511 pSCB
->SCB_BufPtr
= (U32
) VIRT_TO_BUS(SCpnt
->request_buffer
);
512 pSCB
->SCB_BufLen
= SCpnt
->request_bufflen
;
520 * Queue a command and setup interrupts for a free bus.
522 int i91u_queue(Scsi_Cmnd
* SCpnt
, void (*done
) (Scsi_Cmnd
*))
525 HCS
*pHCB
; /* Point to Host adapter control block */
527 if (SCpnt
->lun
> 16) { /* 07/22/98 */
529 SCpnt
->result
= (DID_TIME_OUT
<< 16);
530 done(SCpnt
); /* Notify system DONE */
533 pHCB
= (HCS
*) SCpnt
->host
->base
;
535 SCpnt
->scsi_done
= done
;
536 /* Get free SCSI control block */
537 if ((pSCB
= tul_alloc_scb(pHCB
)) == NULL
) {
538 i91uAppendSRBToQueue(pHCB
, SCpnt
); /* Buffer this request */
541 i91uBuildSCB(pHCB
, pSCB
, SCpnt
);
542 tul_exec_scb(pHCB
, pSCB
); /* Start execute SCB */
547 * We only support command in interrupt-driven fashion
549 int i91u_command(Scsi_Cmnd
* SCpnt
)
551 printk("i91u: interrupt driven driver; use i91u_queue()\n");
556 * Abort a queued command
557 * (commands that are on the bus can't be aborted easily)
559 int i91u_abort(Scsi_Cmnd
* SCpnt
)
563 pHCB
= (HCS
*) SCpnt
->host
->base
;
564 return tul_abort_srb(pHCB
, SCpnt
);
568 * Reset registers, reset a hanging bus and
569 * kill active and disconnected commands for target w/o soft reset
571 int i91u_reset(Scsi_Cmnd
* SCpnt
, unsigned int reset_flags
)
572 { /* I need Host Control Block Information */
575 pHCB
= (HCS
*) SCpnt
->host
->base
;
577 if (reset_flags
& (SCSI_RESET_SUGGEST_BUS_RESET
| SCSI_RESET_SUGGEST_HOST_RESET
))
578 return tul_reset_scsi_bus(pHCB
);
580 return tul_device_reset(pHCB
, (ULONG
) SCpnt
, SCpnt
->target
, reset_flags
);
584 * Return the "logical geometry"
586 int i91u_biosparam(Scsi_Disk
* disk
, kdev_t dev
, int *info_array
)
588 HCS
*pHcb
; /* Point to Host adapter control block */
591 pHcb
= (HCS
*) disk
->device
->host
->base
;
592 pTcb
= &pHcb
->HCS_Tcs
[disk
->device
->id
];
594 if (pTcb
->TCS_DrvHead
) {
595 info_array
[0] = pTcb
->TCS_DrvHead
;
596 info_array
[1] = pTcb
->TCS_DrvSector
;
597 info_array
[2] = disk
->capacity
/ pTcb
->TCS_DrvHead
/ pTcb
->TCS_DrvSector
;
599 if (pTcb
->TCS_DrvFlags
& TCF_DRV_255_63
) {
602 info_array
[2] = disk
->capacity
/ 255 / 63;
606 info_array
[2] = disk
->capacity
>> 11;
610 #if defined(DEBUG_BIOSPARAM)
611 if (i91u_debug
& debug_biosparam
) {
612 printk("bios geometry: head=%d, sec=%d, cyl=%d\n",
613 info_array
[0], info_array
[1], info_array
[2]);
614 printk("WARNING: check, if the bios geometry is correct.\n");
621 /*****************************************************************************
622 Function name : i91uSCBPost
623 Description : This is callback routine be called when tulip finish one
625 Input : pHCB - Pointer to host adapter control block.
626 pSCB - Pointer to SCSI control block.
629 *****************************************************************************/
630 static void i91uSCBPost(BYTE
* pHcb
, BYTE
* pScb
)
632 Scsi_Cmnd
*pSRB
; /* Pointer to SCSI request block */
638 if ((pSRB
= pSCB
->SCB_Srb
) == 0) {
639 printk("i91uSCBPost: SRB pointer is empty\n");
641 tul_release_scb(pHCB
, pSCB
); /* Release SCB for current channel */
644 switch (pSCB
->SCB_HaStat
) {
646 case 0xa: /* Linked command complete without error and linked normally */
647 case 0xb: /* Linked command complete without error interrupt generated */
648 pSCB
->SCB_HaStat
= 0;
651 case 0x11: /* Selection time out-The initiator selection or target
652 reselection was not complete within the SCSI Time out period */
653 pSCB
->SCB_HaStat
= DID_TIME_OUT
;
656 case 0x14: /* Target bus phase sequence failure-An invalid bus phase or bus
657 phase sequence was requested by the target. The host adapter
658 will generate a SCSI Reset Condition, notifying the host with
660 pSCB
->SCB_HaStat
= DID_RESET
;
663 case 0x1a: /* SCB Aborted. 07/21/98 */
664 pSCB
->SCB_HaStat
= DID_ABORT
;
667 case 0x12: /* Data overrun/underrun-The target attempted to transfer more data
668 than was allocated by the Data Length field or the sum of the
669 Scatter / Gather Data Length fields. */
670 case 0x13: /* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */
671 case 0x16: /* Invalid SCB Operation Code. */
674 printk("ini9100u: %x %x\n", pSCB
->SCB_HaStat
, pSCB
->SCB_TaStat
);
675 pSCB
->SCB_HaStat
= DID_ERROR
; /* Couldn't find any better */
679 pSRB
->result
= pSCB
->SCB_TaStat
| (pSCB
->SCB_HaStat
<< 16);
682 printk("pSRB is NULL\n");
684 pSRB
->scsi_done(pSRB
); /* Notify system DONE */
685 if ((pSRB
= i91uPopSRBFromQueue(pHCB
)) != NULL
)
686 /* Find the next pending SRB */
687 { /* Assume resend will success */
689 i91uBuildSCB(pHCB
, pSCB
, pSRB
); /* Create corresponding SCB */
691 tul_exec_scb(pHCB
, pSCB
); /* Start execute SCB */
692 } else { /* No Pending SRB */
693 tul_release_scb(pHCB
, pSCB
); /* Release SCB for current channel */
699 * Interrupts handler (main routine of the driver)
701 static void i91u_intr0(int irqno
, void *dev_id
, struct pt_regs
*regs
)
705 if (tul_hcs
[0].HCS_Intr
!= irqno
)
708 spin_lock_irqsave(&io_request_lock
, flags
);
710 tul_isr(&tul_hcs
[0]);
712 spin_unlock_irqrestore(&io_request_lock
, flags
);
715 static void i91u_intr1(int irqno
, void *dev_id
, struct pt_regs
*regs
)
719 if (tul_hcs
[1].HCS_Intr
!= irqno
)
722 spin_lock_irqsave(&io_request_lock
, flags
);
724 tul_isr(&tul_hcs
[1]);
726 spin_unlock_irqrestore(&io_request_lock
, flags
);
729 static void i91u_intr2(int irqno
, void *dev_id
, struct pt_regs
*regs
)
733 if (tul_hcs
[2].HCS_Intr
!= irqno
)
736 spin_lock_irqsave(&io_request_lock
, flags
);
738 tul_isr(&tul_hcs
[2]);
740 spin_unlock_irqrestore(&io_request_lock
, flags
);
743 static void i91u_intr3(int irqno
, void *dev_id
, struct pt_regs
*regs
)
747 if (tul_hcs
[3].HCS_Intr
!= irqno
)
750 spin_lock_irqsave(&io_request_lock
, flags
);
752 tul_isr(&tul_hcs
[3]);
754 spin_unlock_irqrestore(&io_request_lock
, flags
);
757 static void i91u_intr4(int irqno
, void *dev_id
, struct pt_regs
*regs
)
761 if (tul_hcs
[4].HCS_Intr
!= irqno
)
764 spin_lock_irqsave(&io_request_lock
, flags
);
766 tul_isr(&tul_hcs
[4]);
768 spin_unlock_irqrestore(&io_request_lock
, flags
);
771 static void i91u_intr5(int irqno
, void *dev_id
, struct pt_regs
*regs
)
775 if (tul_hcs
[5].HCS_Intr
!= irqno
)
778 spin_lock_irqsave(&io_request_lock
, flags
);
780 tul_isr(&tul_hcs
[5]);
782 spin_unlock_irqrestore(&io_request_lock
, flags
);
785 static void i91u_intr6(int irqno
, void *dev_id
, struct pt_regs
*regs
)
789 if (tul_hcs
[6].HCS_Intr
!= irqno
)
792 spin_lock_irqsave(&io_request_lock
, flags
);
794 tul_isr(&tul_hcs
[6]);
796 spin_unlock_irqrestore(&io_request_lock
, flags
);
799 static void i91u_intr7(int irqno
, void *dev_id
, struct pt_regs
*regs
)
803 if (tul_hcs
[7].HCS_Intr
!= irqno
)
806 spin_lock_irqsave(&io_request_lock
, flags
);
808 tul_isr(&tul_hcs
[7]);
810 spin_unlock_irqrestore(&io_request_lock
, flags
);
814 * Dump the current driver status and panic...
816 static void i91u_panic(char *msg
)
818 printk("\ni91u_panic: %s\n", msg
);
825 int i91u_release(struct Scsi_Host
*hreg
)
827 free_irq(hreg
->irq
, hreg
);
828 release_region(hreg
->io_port
, 256);