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 General 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>
115 #include <linux/module.h>
119 #include <linux/errno.h>
120 #include <linux/delay.h>
121 #include <linux/pci.h>
122 #include <linux/init.h>
123 #include <linux/blk.h>
124 #include <linux/spinlock.h>
125 #include <linux/stat.h>
126 #include <linux/config.h>
128 #include <linux/kernel.h>
129 #include <linux/string.h>
130 #include <linux/ioport.h>
131 #include <linux/sched.h>
132 #include <linux/proc_fs.h>
137 #include <linux/slab.h>
138 #include "ini9100u.h"
141 unsigned int i91u_debug = DEBUG_DEFAULT;
144 static Scsi_Host_Template driver_template = INI9100U;
145 #include "scsi_module.c"
147 char *i91uCopyright = "Copyright (C) 1996-98";
148 char *i91uInitioName = "by Initio Corporation";
149 char *i91uProductName = "INI-9X00U/UW";
150 char *i91uVersion = "v1.03g";
152 #define TULSZ(sz) (sizeof(sz) / sizeof(sz[0]))
153 #define TUL_RDWORD(x,y) (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
155 /* set by i91_setup according to the command line */
156 static int setup_called = 0;
158 static int tul_num_ch = 4; /* Maximum 4 adapters */
159 static int tul_num_scb;
160 static int tul_tag_enable = 1;
164 static int setup_debug = 0;
167 static char *setup_str = (char *) NULL;
169 static void i91u_intr0(int irq, void *dev_id, struct pt_regs *);
170 static void i91u_intr1(int irq, void *dev_id, struct pt_regs *);
171 static void i91u_intr2(int irq, void *dev_id, struct pt_regs *);
172 static void i91u_intr3(int irq, void *dev_id, struct pt_regs *);
173 static void i91u_intr4(int irq, void *dev_id, struct pt_regs *);
174 static void i91u_intr5(int irq, void *dev_id, struct pt_regs *);
175 static void i91u_intr6(int irq, void *dev_id, struct pt_regs *);
176 static void i91u_intr7(int irq, void *dev_id, struct pt_regs *);
178 static void i91u_panic(char *msg);
180 static void i91uSCBPost(BYTE * pHcb, BYTE * pScb);
182 /* ---- EXTERNAL FUNCTIONS ---- */
183 /* Get total number of adapters */
184 extern void init_i91uAdapter_table(void);
185 extern int Addi91u_into_Adapter_table(WORD, WORD, BYTE, BYTE, BYTE);
186 extern int tul_ReturnNumberOfAdapters(void);
187 extern void get_tulipPCIConfig(HCS * pHCB, int iChannel_index);
188 extern int init_tulip(HCS * pHCB, SCB * pSCB, int tul_num_scb, BYTE * pbBiosAdr, int reset_time);
189 extern SCB *tul_alloc_scb(HCS * pHCB);
190 extern int tul_abort_srb(HCS * pHCB, Scsi_Cmnd * pSRB);
191 extern void tul_exec_scb(HCS * pHCB, SCB * pSCB);
192 extern void tul_release_scb(HCS * pHCB, SCB * pSCB);
193 extern void tul_stop_bm(HCS * pHCB);
194 extern int tul_reset_scsi(HCS * pCurHcb, int seconds);
195 extern int tul_isr(HCS * pHCB);
196 extern int tul_reset(HCS * pHCB, Scsi_Cmnd * pSRB, unsigned char target);
197 extern int tul_reset_scsi_bus(HCS * pCurHcb);
198 extern int tul_device_reset(HCS * pCurHcb, ULONG pSrb, unsigned int target, unsigned int ResetFlags);
199 /* ---- EXTERNAL VARIABLES ---- */
200 extern HCS tul_hcs[];
202 const PCI_ID i91u_pci_devices[] = {
203 { INI_VENDOR_ID, I950_DEVICE_ID },
204 { INI_VENDOR_ID, I940_DEVICE_ID },
205 { INI_VENDOR_ID, I935_DEVICE_ID },
206 { INI_VENDOR_ID, I920_DEVICE_ID },
207 { DMX_VENDOR_ID, I920_DEVICE_ID },
213 /*****************************************************************************
214 Function name : i91uAppendSRBToQueue
215 Description : This function will push current request into save list
216 Input : pSRB - Pointer to SCSI request block.
217 pHCB - Pointer to host adapter structure
220 *****************************************************************************/
221 static void i91uAppendSRBToQueue(HCS * pHCB, Scsi_Cmnd * pSRB)
224 spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
226 pSRB->next = NULL; /* Pointer to next */
228 if (pHCB->pSRB_head == NULL)
229 pHCB->pSRB_head = pSRB;
231 pHCB->pSRB_tail->next = pSRB; /* Pointer to next */
232 pHCB->pSRB_tail = pSRB;
234 spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
238 /*****************************************************************************
239 Function name : i91uPopSRBFromQueue
240 Description : This function will pop current request from save list
241 Input : pHCB - Pointer to host adapter structure
243 Return : pSRB - Pointer to SCSI request block.
244 *****************************************************************************/
245 static Scsi_Cmnd *i91uPopSRBFromQueue(HCS * pHCB)
250 spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
252 if ((pSRB = pHCB->pSRB_head) != NULL) {
253 pHCB->pSRB_head = pHCB->pSRB_head->next;
256 spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
261 /* called from init/main.c */
263 void i91u_setup(char *str, int *ints)
266 i91u_panic("i91u: i91u_setup called twice.\n");
268 setup_called = ints[0];
272 setup_debug = ints[0] >= 1 ? ints[1] : DEBUG_DEFAULT;
276 int tul_NewReturnNumberOfAdapters(void)
278 struct pci_dev *pDev = NULL; /* Start from none */
284 init_i91uAdapter_table();
286 for (i = 0; i < TULSZ(i91u_pci_devices); i++)
288 while ((pDev = pci_find_device(i91u_pci_devices[i].vendor_id, i91u_pci_devices[i].device_id, pDev)) != NULL) {
289 if (pci_enable_device(pDev))
291 pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue);
292 wBIOS = (UWORD) (dRegValue & 0xFF);
293 if (((dRegValue & 0xFF00) >> 8) == 0xFF)
295 wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8));
296 if (Addi91u_into_Adapter_table(wBIOS,
297 (pDev->resource[0].start),
309 int i91u_detect(Scsi_Host_Template * tpnt)
313 struct Scsi_Host *hreg;
314 unsigned long i; /* 01/14/98 */
315 int ok = 0, iAdapters;
319 tpnt->proc_name = "INI9100U";
321 if (setup_called) { /* Setup by i91u_setup */
322 printk("i91u: processing commandline: ");
325 if (setup_called > 1) {
326 printk("\ni91u: %s\n", setup_str);
327 printk("i91u: usage: i91u[=<DEBUG>]\n");
328 i91u_panic("i91u panics in line %d", __LINE__);
330 i91u_debug = setup_debug;
333 /* Get total number of adapters in the motherboard */
335 iAdapters = tul_NewReturnNumberOfAdapters();
337 iAdapters = tul_ReturnNumberOfAdapters();
340 if (iAdapters == 0) /* If no tulip founded, return */
343 tul_num_ch = (iAdapters > tul_num_ch) ? tul_num_ch : iAdapters;
344 /* Update actually channel number */
345 if (tul_tag_enable) { /* 1.01i */
346 tul_num_scb = MAX_TARGETS * i91u_MAXQUEUE;
348 tul_num_scb = MAX_TARGETS + 3; /* 1-tape, 1-CD_ROM, 1- extra */
349 } /* Update actually SCBs per adapter */
351 /* Get total memory needed for HCS */
352 i = tul_num_ch * sizeof(HCS);
353 memset((unsigned char *) &tul_hcs[0], 0, i); /* Initialize tul_hcs 0 */
354 /* Get total memory needed for SCB */
356 for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) {
357 i = tul_num_ch * tul_num_scb * sizeof(SCB);
358 if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL)
361 if (tul_scb == NULL) {
362 printk("i91u: SCB memory allocation error\n");
365 memset((unsigned char *) tul_scb, 0, i);
368 for (i = 0; i < tul_num_ch * tul_num_scb; i++, pSCB++) {
369 pSCB->SCB_SGPAddr = (U32) VIRT_TO_BUS(&pSCB->SCB_SGList[0]);
372 for (i = 0, pHCB = &tul_hcs[0]; /* Get pointer for control block */
375 pHCB->pSRB_head = NULL; /* Initial SRB save queue */
376 pHCB->pSRB_tail = NULL; /* Initial SRB save queue */
377 pHCB->pSRB_lock = SPIN_LOCK_UNLOCKED; /* SRB save queue lock */
378 get_tulipPCIConfig(pHCB, i);
380 dBiosAdr = pHCB->HCS_BIOS;
381 dBiosAdr = (dBiosAdr << 4);
383 pbBiosAdr = phys_to_virt(dBiosAdr);
385 init_tulip(pHCB, tul_scb + (i * tul_num_scb), tul_num_scb, pbBiosAdr, 10);
386 request_region(pHCB->HCS_Base, 256, "i91u"); /* Register */
388 pHCB->HCS_Index = i; /* 7/29/98 */
389 hreg = scsi_register(tpnt, sizeof(HCS));
392 release_region(pHCB->HCS_Base, 256);
395 hreg->io_port = pHCB->HCS_Base;
396 hreg->n_io_port = 0xff;
397 hreg->can_queue = tul_num_scb; /* 03/05/98 */
398 hreg->unique_id = pHCB->HCS_Base;
399 hreg->max_id = pHCB->HCS_MaxTar;
400 hreg->max_lun = 32; /* 10/21/97 */
401 hreg->irq = pHCB->HCS_Intr;
402 hreg->this_id = pHCB->HCS_SCSI_ID; /* Assign HCS index */
403 hreg->base = (unsigned long)pHCB;
404 hreg->sg_tablesize = TOTAL_SG_ENTRY; /* Maximun support is 32 */
406 /* Initial tulip chip */
409 ok = request_irq(pHCB->HCS_Intr, i91u_intr0, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
412 ok = request_irq(pHCB->HCS_Intr, i91u_intr1, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
415 ok = request_irq(pHCB->HCS_Intr, i91u_intr2, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
418 ok = request_irq(pHCB->HCS_Intr, i91u_intr3, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
421 ok = request_irq(pHCB->HCS_Intr, i91u_intr4, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
424 ok = request_irq(pHCB->HCS_Intr, i91u_intr5, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
427 ok = request_irq(pHCB->HCS_Intr, i91u_intr6, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
430 ok = request_irq(pHCB->HCS_Intr, i91u_intr7, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
433 i91u_panic("i91u: Too many host adapters\n");
438 printk("i91u: bad IRQ %d.\n", pHCB->HCS_Intr);
439 printk(" Contact author.\n");
440 } else if (ok == -EBUSY)
441 printk("i91u: IRQ %d already in use. Configure another.\n",
444 printk("\ni91u: Unexpected error code on requesting IRQ %d.\n",
446 printk(" Contact author.\n");
448 i91u_panic("i91u: driver needs an IRQ.\n");
458 static void i91uBuildSCB(HCS * pHCB, SCB * pSCB, Scsi_Cmnd * SCpnt)
459 { /* Create corresponding SCB */
460 struct scatterlist *pSrbSG;
461 SG *pSG; /* Pointer to SG list */
465 pSCB->SCB_Post = i91uSCBPost; /* i91u's callback routine */
466 pSCB->SCB_Srb = SCpnt;
467 pSCB->SCB_Opcode = ExecSCSI;
468 pSCB->SCB_Flags = SCF_POST; /* After SCSI done, call post routine */
469 pSCB->SCB_Target = SCpnt->target;
470 pSCB->SCB_Lun = SCpnt->lun;
471 pSCB->SCB_Ident = SCpnt->lun | DISC_ALLOW;
472 pSCB->SCB_Flags |= SCF_SENSE; /* Turn on auto request sense */
474 pSCB->SCB_SensePtr = (U32) VIRT_TO_BUS(SCpnt->sense_buffer);
476 pSCB->SCB_SenseLen = SENSE_SIZE;
478 pSCB->SCB_CDBLen = SCpnt->cmd_len;
479 pSCB->SCB_HaStat = 0;
480 pSCB->SCB_TaStat = 0;
481 memcpy(&pSCB->SCB_CDB[0], &SCpnt->cmnd, SCpnt->cmd_len);
483 if (SCpnt->device->tagged_supported) { /* Tag Support */
484 pSCB->SCB_TagMsg = SIMPLE_QUEUE_TAG; /* Do simple tag only */
486 pSCB->SCB_TagMsg = 0; /* No tag support */
490 pSrbSG = (struct scatterlist *) SCpnt->request_buffer;
491 if (SCpnt->use_sg == 1) { /* If only one entry in the list *//* treat it as regular I/O */
492 pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(pSrbSG->address);
493 TotalLen = pSrbSG->length;
495 } else { /* Assign SG physical address */
496 pSCB->SCB_BufPtr = pSCB->SCB_SGPAddr;
497 pSCB->SCB_Flags |= SCF_SG; /* Turn on SG list flag */
498 for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0]; /* 1.01g */
500 i++, pSG++, pSrbSG++) {
501 pSG->SG_Ptr = (U32) VIRT_TO_BUS(pSrbSG->address);
502 TotalLen += pSG->SG_Len = pSrbSG->length;
506 pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ?
507 TotalLen : SCpnt->request_bufflen;
508 } else { /* Non SG */
509 pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(SCpnt->request_buffer);
510 pSCB->SCB_BufLen = SCpnt->request_bufflen;
518 * Queue a command and setup interrupts for a free bus.
520 int i91u_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
523 HCS *pHCB; /* Point to Host adapter control block */
525 if (SCpnt->lun > 16) { /* 07/22/98 */
527 SCpnt->result = (DID_TIME_OUT << 16);
528 done(SCpnt); /* Notify system DONE */
531 pHCB = (HCS *) SCpnt->host->base;
533 SCpnt->scsi_done = done;
534 /* Get free SCSI control block */
535 if ((pSCB = tul_alloc_scb(pHCB)) == NULL) {
536 i91uAppendSRBToQueue(pHCB, SCpnt); /* Buffer this request */
539 i91uBuildSCB(pHCB, pSCB, SCpnt);
540 tul_exec_scb(pHCB, pSCB); /* Start execute SCB */
545 * We only support command in interrupt-driven fashion
547 int i91u_command(Scsi_Cmnd * SCpnt)
549 printk("i91u: interrupt driven driver; use i91u_queue()\n");
554 * Abort a queued command
555 * (commands that are on the bus can't be aborted easily)
557 int i91u_abort(Scsi_Cmnd * SCpnt)
561 pHCB = (HCS *) SCpnt->host->base;
562 return tul_abort_srb(pHCB, SCpnt);
566 * Reset registers, reset a hanging bus and
567 * kill active and disconnected commands for target w/o soft reset
569 int i91u_reset(Scsi_Cmnd * SCpnt, unsigned int reset_flags)
570 { /* I need Host Control Block Information */
573 pHCB = (HCS *) SCpnt->host->base;
575 if (reset_flags & (SCSI_RESET_SUGGEST_BUS_RESET | SCSI_RESET_SUGGEST_HOST_RESET))
576 return tul_reset_scsi_bus(pHCB);
578 return tul_device_reset(pHCB, (ULONG) SCpnt, SCpnt->target, reset_flags);
582 * Return the "logical geometry"
584 int i91u_biosparam(Scsi_Disk * disk, kdev_t dev, int *info_array)
586 HCS *pHcb; /* Point to Host adapter control block */
589 pHcb = (HCS *) disk->device->host->base;
590 pTcb = &pHcb->HCS_Tcs[disk->device->id];
592 if (pTcb->TCS_DrvHead) {
593 info_array[0] = pTcb->TCS_DrvHead;
594 info_array[1] = pTcb->TCS_DrvSector;
595 info_array[2] = disk->capacity / pTcb->TCS_DrvHead / pTcb->TCS_DrvSector;
597 if (pTcb->TCS_DrvFlags & TCF_DRV_255_63) {
600 info_array[2] = disk->capacity / 255 / 63;
604 info_array[2] = disk->capacity >> 11;
608 #if defined(DEBUG_BIOSPARAM)
609 if (i91u_debug & debug_biosparam) {
610 printk("bios geometry: head=%d, sec=%d, cyl=%d\n",
611 info_array[0], info_array[1], info_array[2]);
612 printk("WARNING: check, if the bios geometry is correct.\n");
619 /*****************************************************************************
620 Function name : i91uSCBPost
621 Description : This is callback routine be called when tulip finish one
623 Input : pHCB - Pointer to host adapter control block.
624 pSCB - Pointer to SCSI control block.
627 *****************************************************************************/
628 static void i91uSCBPost(BYTE * pHcb, BYTE * pScb)
630 Scsi_Cmnd *pSRB; /* Pointer to SCSI request block */
636 if ((pSRB = pSCB->SCB_Srb) == 0) {
637 printk("i91uSCBPost: SRB pointer is empty\n");
639 tul_release_scb(pHCB, pSCB); /* Release SCB for current channel */
642 switch (pSCB->SCB_HaStat) {
644 case 0xa: /* Linked command complete without error and linked normally */
645 case 0xb: /* Linked command complete without error interrupt generated */
646 pSCB->SCB_HaStat = 0;
649 case 0x11: /* Selection time out-The initiator selection or target
650 reselection was not complete within the SCSI Time out period */
651 pSCB->SCB_HaStat = DID_TIME_OUT;
654 case 0x14: /* Target bus phase sequence failure-An invalid bus phase or bus
655 phase sequence was requested by the target. The host adapter
656 will generate a SCSI Reset Condition, notifying the host with
658 pSCB->SCB_HaStat = DID_RESET;
661 case 0x1a: /* SCB Aborted. 07/21/98 */
662 pSCB->SCB_HaStat = DID_ABORT;
665 case 0x12: /* Data overrun/underrun-The target attempted to transfer more data
666 than was allocated by the Data Length field or the sum of the
667 Scatter / Gather Data Length fields. */
668 case 0x13: /* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */
669 case 0x16: /* Invalid SCB Operation Code. */
672 printk("ini9100u: %x %x\n", pSCB->SCB_HaStat, pSCB->SCB_TaStat);
673 pSCB->SCB_HaStat = DID_ERROR; /* Couldn't find any better */
677 pSRB->result = pSCB->SCB_TaStat | (pSCB->SCB_HaStat << 16);
680 printk("pSRB is NULL\n");
682 pSRB->scsi_done(pSRB); /* Notify system DONE */
683 if ((pSRB = i91uPopSRBFromQueue(pHCB)) != NULL)
684 /* Find the next pending SRB */
685 { /* Assume resend will success */
687 i91uBuildSCB(pHCB, pSCB, pSRB); /* Create corresponding SCB */
689 tul_exec_scb(pHCB, pSCB); /* Start execute SCB */
690 } else { /* No Pending SRB */
691 tul_release_scb(pHCB, pSCB); /* Release SCB for current channel */
697 * Interrupts handler (main routine of the driver)
699 static void i91u_intr0(int irqno, void *dev_id, struct pt_regs *regs)
703 if (tul_hcs[0].HCS_Intr != irqno)
706 spin_lock_irqsave(&io_request_lock, flags);
708 tul_isr(&tul_hcs[0]);
710 spin_unlock_irqrestore(&io_request_lock, flags);
713 static void i91u_intr1(int irqno, void *dev_id, struct pt_regs *regs)
717 if (tul_hcs[1].HCS_Intr != irqno)
720 spin_lock_irqsave(&io_request_lock, flags);
722 tul_isr(&tul_hcs[1]);
724 spin_unlock_irqrestore(&io_request_lock, flags);
727 static void i91u_intr2(int irqno, void *dev_id, struct pt_regs *regs)
731 if (tul_hcs[2].HCS_Intr != irqno)
734 spin_lock_irqsave(&io_request_lock, flags);
736 tul_isr(&tul_hcs[2]);
738 spin_unlock_irqrestore(&io_request_lock, flags);
741 static void i91u_intr3(int irqno, void *dev_id, struct pt_regs *regs)
745 if (tul_hcs[3].HCS_Intr != irqno)
748 spin_lock_irqsave(&io_request_lock, flags);
750 tul_isr(&tul_hcs[3]);
752 spin_unlock_irqrestore(&io_request_lock, flags);
755 static void i91u_intr4(int irqno, void *dev_id, struct pt_regs *regs)
759 if (tul_hcs[4].HCS_Intr != irqno)
762 spin_lock_irqsave(&io_request_lock, flags);
764 tul_isr(&tul_hcs[4]);
766 spin_unlock_irqrestore(&io_request_lock, flags);
769 static void i91u_intr5(int irqno, void *dev_id, struct pt_regs *regs)
773 if (tul_hcs[5].HCS_Intr != irqno)
776 spin_lock_irqsave(&io_request_lock, flags);
778 tul_isr(&tul_hcs[5]);
780 spin_unlock_irqrestore(&io_request_lock, flags);
783 static void i91u_intr6(int irqno, void *dev_id, struct pt_regs *regs)
787 if (tul_hcs[6].HCS_Intr != irqno)
790 spin_lock_irqsave(&io_request_lock, flags);
792 tul_isr(&tul_hcs[6]);
794 spin_unlock_irqrestore(&io_request_lock, flags);
797 static void i91u_intr7(int irqno, void *dev_id, struct pt_regs *regs)
801 if (tul_hcs[7].HCS_Intr != irqno)
804 spin_lock_irqsave(&io_request_lock, flags);
806 tul_isr(&tul_hcs[7]);
808 spin_unlock_irqrestore(&io_request_lock, flags);
812 * Dump the current driver status and panic...
814 static void i91u_panic(char *msg)
816 printk("\ni91u_panic: %s\n", msg);
823 int i91u_release(struct Scsi_Host *hreg)
825 free_irq(hreg->irq, hreg);
826 release_region(hreg->io_port, 256);
829 MODULE_LICENSE("Dual BSD/GPL");