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 #error Please convert me to Documentation/DMA-mapping.txt
113 #ifndef LINUX_VERSION_CODE
114 #include <linux/version.h>
117 #include <linux/module.h>
118 #include <linux/errno.h>
119 #include <linux/delay.h>
120 #include <linux/pci.h>
121 #include <linux/init.h>
122 #include <linux/blkdev.h>
123 #include <linux/spinlock.h>
124 #include <linux/stat.h>
125 #include <linux/config.h>
126 #include <linux/kernel.h>
127 #include <linux/proc_fs.h>
128 #include <linux/string.h>
129 #include <linux/interrupt.h>
130 #include <linux/ioport.h>
131 #include <linux/sched.h>
132 #include <linux/slab.h>
138 #include "ini9100u.h"
141 unsigned int i91u_debug = DEBUG_DEFAULT;
144 static Scsi_Host_Template driver_template = {
145 .proc_name = "INI9100U",
146 .proc_info = "INI9100U",
148 .detect = i91u_detect,
149 .release = i91u_release,
150 .queuecommand = i91u_queue,
153 .bios_param = i91u_biosparam,
156 .sg_tablesize = SG_ALL,
158 .use_clustering = ENABLE_CLUSTERING,
160 #include "scsi_module.c"
162 char *i91uCopyright = "Copyright (C) 1996-98";
163 char *i91uInitioName = "by Initio Corporation";
164 char *i91uProductName = "INI-9X00U/UW";
165 char *i91uVersion = "v1.03g";
167 #define TULSZ(sz) (sizeof(sz) / sizeof(sz[0]))
168 #define TUL_RDWORD(x,y) (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
170 /* set by i91_setup according to the command line */
171 static int setup_called = 0;
173 static int tul_num_ch = 4; /* Maximum 4 adapters */
174 static int tul_num_scb;
175 static int tul_tag_enable = 1;
179 static int setup_debug = 0;
182 static char *setup_str = (char *) NULL;
184 static irqreturn_t i91u_intr0(int irq, void *dev_id, struct pt_regs *);
185 static irqreturn_t i91u_intr1(int irq, void *dev_id, struct pt_regs *);
186 static irqreturn_t i91u_intr2(int irq, void *dev_id, struct pt_regs *);
187 static irqreturn_t i91u_intr3(int irq, void *dev_id, struct pt_regs *);
188 static irqreturn_t i91u_intr4(int irq, void *dev_id, struct pt_regs *);
189 static irqreturn_t i91u_intr5(int irq, void *dev_id, struct pt_regs *);
190 static irqreturn_t i91u_intr6(int irq, void *dev_id, struct pt_regs *);
191 static irqreturn_t i91u_intr7(int irq, void *dev_id, struct pt_regs *);
193 static void i91u_panic(char *msg);
195 static void i91uSCBPost(BYTE * pHcb, BYTE * pScb);
197 /* ---- EXTERNAL FUNCTIONS ---- */
198 /* Get total number of adapters */
199 extern void init_i91uAdapter_table(void);
200 extern int Addi91u_into_Adapter_table(WORD, WORD, BYTE, BYTE, BYTE);
201 extern int tul_ReturnNumberOfAdapters(void);
202 extern void get_tulipPCIConfig(HCS * pHCB, int iChannel_index);
203 extern int init_tulip(HCS * pHCB, SCB * pSCB, int tul_num_scb, BYTE * pbBiosAdr, int reset_time);
204 extern SCB *tul_alloc_scb(HCS * pHCB);
205 extern int tul_abort_srb(HCS * pHCB, Scsi_Cmnd * pSRB);
206 extern void tul_exec_scb(HCS * pHCB, SCB * pSCB);
207 extern void tul_release_scb(HCS * pHCB, SCB * pSCB);
208 extern void tul_stop_bm(HCS * pHCB);
209 extern int tul_reset_scsi(HCS * pCurHcb, int seconds);
210 extern int tul_isr(HCS * pHCB);
211 extern int tul_reset(HCS * pHCB, Scsi_Cmnd * pSRB, unsigned char target);
212 extern int tul_reset_scsi_bus(HCS * pCurHcb);
213 extern int tul_device_reset(HCS * pCurHcb, ULONG pSrb, unsigned int target, unsigned int ResetFlags);
214 /* ---- EXTERNAL VARIABLES ---- */
215 extern HCS tul_hcs[];
217 const PCI_ID i91u_pci_devices[] = {
218 { INI_VENDOR_ID, I950_DEVICE_ID },
219 { INI_VENDOR_ID, I940_DEVICE_ID },
220 { INI_VENDOR_ID, I935_DEVICE_ID },
221 { INI_VENDOR_ID, I920_DEVICE_ID },
222 { DMX_VENDOR_ID, I920_DEVICE_ID },
228 /*****************************************************************************
229 Function name : i91uAppendSRBToQueue
230 Description : This function will push current request into save list
231 Input : pSRB - Pointer to SCSI request block.
232 pHCB - Pointer to host adapter structure
235 *****************************************************************************/
236 static void i91uAppendSRBToQueue(HCS * pHCB, Scsi_Cmnd * pSRB)
239 spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
241 pSRB->next = NULL; /* Pointer to next */
243 if (pHCB->pSRB_head == NULL)
244 pHCB->pSRB_head = pSRB;
246 pHCB->pSRB_tail->next = pSRB; /* Pointer to next */
247 pHCB->pSRB_tail = pSRB;
249 spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
253 /*****************************************************************************
254 Function name : i91uPopSRBFromQueue
255 Description : This function will pop current request from save list
256 Input : pHCB - Pointer to host adapter structure
258 Return : pSRB - Pointer to SCSI request block.
259 *****************************************************************************/
260 static Scsi_Cmnd *i91uPopSRBFromQueue(HCS * pHCB)
265 spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
267 if ((pSRB = pHCB->pSRB_head) != NULL) {
268 pHCB->pSRB_head = pHCB->pSRB_head->next;
271 spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
276 /* called from init/main.c */
278 void i91u_setup(char *str, int *ints)
281 i91u_panic("i91u: i91u_setup called twice.\n");
283 setup_called = ints[0];
287 setup_debug = ints[0] >= 1 ? ints[1] : DEBUG_DEFAULT;
291 int tul_NewReturnNumberOfAdapters(void)
293 struct pci_dev *pDev = NULL; /* Start from none */
299 init_i91uAdapter_table();
301 for (i = 0; i < TULSZ(i91u_pci_devices); i++)
303 while ((pDev = pci_find_device(i91u_pci_devices[i].vendor_id, i91u_pci_devices[i].device_id, pDev)) != NULL) {
304 if (pci_enable_device(pDev))
306 pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue);
307 wBIOS = (UWORD) (dRegValue & 0xFF);
308 if (((dRegValue & 0xFF00) >> 8) == 0xFF)
310 wBIOS = (wBIOS << 8) + ((UWORD) ((dRegValue & 0xFF00) >> 8));
311 if (Addi91u_into_Adapter_table(wBIOS,
312 (pDev->resource[0].start),
324 int i91u_detect(Scsi_Host_Template * tpnt)
328 struct Scsi_Host *hreg;
329 unsigned long i; /* 01/14/98 */
330 int ok = 0, iAdapters;
334 tpnt->proc_name = "INI9100U";
336 if (setup_called) { /* Setup by i91u_setup */
337 printk("i91u: processing commandline: ");
340 if (setup_called > 1) {
341 printk("\ni91u: %s\n", setup_str);
342 printk("i91u: usage: i91u[=<DEBUG>]\n");
343 i91u_panic("i91u panics in line %d", __LINE__);
345 i91u_debug = setup_debug;
348 /* Get total number of adapters in the motherboard */
350 iAdapters = tul_NewReturnNumberOfAdapters();
352 iAdapters = tul_ReturnNumberOfAdapters();
355 if (iAdapters == 0) /* If no tulip founded, return */
358 tul_num_ch = (iAdapters > tul_num_ch) ? tul_num_ch : iAdapters;
359 /* Update actually channel number */
360 if (tul_tag_enable) { /* 1.01i */
361 tul_num_scb = MAX_TARGETS * i91u_MAXQUEUE;
363 tul_num_scb = MAX_TARGETS + 3; /* 1-tape, 1-CD_ROM, 1- extra */
364 } /* Update actually SCBs per adapter */
366 /* Get total memory needed for HCS */
367 i = tul_num_ch * sizeof(HCS);
368 memset((unsigned char *) &tul_hcs[0], 0, i); /* Initialize tul_hcs 0 */
369 /* Get total memory needed for SCB */
371 for (; tul_num_scb >= MAX_TARGETS + 3; tul_num_scb--) {
372 i = tul_num_ch * tul_num_scb * sizeof(SCB);
373 if ((tul_scb = (SCB *) kmalloc(i, GFP_ATOMIC | GFP_DMA)) != NULL)
376 if (tul_scb == NULL) {
377 printk("i91u: SCB memory allocation error\n");
380 memset((unsigned char *) tul_scb, 0, i);
383 for (i = 0; i < tul_num_ch * tul_num_scb; i++, pSCB++) {
384 pSCB->SCB_SGPAddr = (U32) VIRT_TO_BUS(&pSCB->SCB_SGList[0]);
387 for (i = 0, pHCB = &tul_hcs[0]; /* Get pointer for control block */
390 pHCB->pSRB_head = NULL; /* Initial SRB save queue */
391 pHCB->pSRB_tail = NULL; /* Initial SRB save queue */
392 pHCB->pSRB_lock = SPIN_LOCK_UNLOCKED; /* SRB save queue lock */
393 get_tulipPCIConfig(pHCB, i);
395 dBiosAdr = pHCB->HCS_BIOS;
396 dBiosAdr = (dBiosAdr << 4);
398 pbBiosAdr = phys_to_virt(dBiosAdr);
400 init_tulip(pHCB, tul_scb + (i * tul_num_scb), tul_num_scb, pbBiosAdr, 10);
401 request_region(pHCB->HCS_Base, 256, "i91u"); /* Register */
403 pHCB->HCS_Index = i; /* 7/29/98 */
404 hreg = scsi_register(tpnt, sizeof(HCS));
407 release_region(pHCB->HCS_Base, 256);
410 hreg->io_port = pHCB->HCS_Base;
411 hreg->n_io_port = 0xff;
412 hreg->can_queue = tul_num_scb; /* 03/05/98 */
413 hreg->unique_id = pHCB->HCS_Base;
414 hreg->max_id = pHCB->HCS_MaxTar;
415 hreg->max_lun = 32; /* 10/21/97 */
416 hreg->irq = pHCB->HCS_Intr;
417 hreg->this_id = pHCB->HCS_SCSI_ID; /* Assign HCS index */
418 hreg->base = (unsigned long)pHCB;
419 hreg->sg_tablesize = TOTAL_SG_ENTRY; /* Maximun support is 32 */
421 /* Initial tulip chip */
424 ok = request_irq(pHCB->HCS_Intr, i91u_intr0, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
427 ok = request_irq(pHCB->HCS_Intr, i91u_intr1, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
430 ok = request_irq(pHCB->HCS_Intr, i91u_intr2, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
433 ok = request_irq(pHCB->HCS_Intr, i91u_intr3, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
436 ok = request_irq(pHCB->HCS_Intr, i91u_intr4, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
439 ok = request_irq(pHCB->HCS_Intr, i91u_intr5, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
442 ok = request_irq(pHCB->HCS_Intr, i91u_intr6, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
445 ok = request_irq(pHCB->HCS_Intr, i91u_intr7, SA_INTERRUPT | SA_SHIRQ, "i91u", hreg);
448 i91u_panic("i91u: Too many host adapters\n");
453 printk("i91u: bad IRQ %d.\n", pHCB->HCS_Intr);
454 printk(" Contact author.\n");
455 } else if (ok == -EBUSY)
456 printk("i91u: IRQ %d already in use. Configure another.\n",
459 printk("\ni91u: Unexpected error code on requesting IRQ %d.\n",
461 printk(" Contact author.\n");
463 i91u_panic("i91u: driver needs an IRQ.\n");
473 static void i91uBuildSCB(HCS * pHCB, SCB * pSCB, Scsi_Cmnd * SCpnt)
474 { /* Create corresponding SCB */
475 struct scatterlist *pSrbSG;
476 SG *pSG; /* Pointer to SG list */
480 pSCB->SCB_Post = i91uSCBPost; /* i91u's callback routine */
481 pSCB->SCB_Srb = SCpnt;
482 pSCB->SCB_Opcode = ExecSCSI;
483 pSCB->SCB_Flags = SCF_POST; /* After SCSI done, call post routine */
484 pSCB->SCB_Target = SCpnt->device->id;
485 pSCB->SCB_Lun = SCpnt->device->lun;
486 pSCB->SCB_Ident = SCpnt->device->lun | DISC_ALLOW;
487 pSCB->SCB_Flags |= SCF_SENSE; /* Turn on auto request sense */
489 pSCB->SCB_SensePtr = (U32) VIRT_TO_BUS(SCpnt->sense_buffer);
491 pSCB->SCB_SenseLen = SENSE_SIZE;
493 pSCB->SCB_CDBLen = SCpnt->cmd_len;
494 pSCB->SCB_HaStat = 0;
495 pSCB->SCB_TaStat = 0;
496 memcpy(&pSCB->SCB_CDB[0], &SCpnt->cmnd, SCpnt->cmd_len);
498 if (SCpnt->device->tagged_supported) { /* Tag Support */
499 pSCB->SCB_TagMsg = SIMPLE_QUEUE_TAG; /* Do simple tag only */
501 pSCB->SCB_TagMsg = 0; /* No tag support */
505 pSrbSG = (struct scatterlist *) SCpnt->request_buffer;
506 if (SCpnt->use_sg == 1) { /* If only one entry in the list *//* treat it as regular I/O */
507 pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(pSrbSG->address);
508 TotalLen = pSrbSG->length;
510 } else { /* Assign SG physical address */
511 pSCB->SCB_BufPtr = pSCB->SCB_SGPAddr;
512 pSCB->SCB_Flags |= SCF_SG; /* Turn on SG list flag */
513 for (i = 0, TotalLen = 0, pSG = &pSCB->SCB_SGList[0]; /* 1.01g */
515 i++, pSG++, pSrbSG++) {
516 pSG->SG_Ptr = (U32) VIRT_TO_BUS(pSrbSG->address);
517 TotalLen += pSG->SG_Len = pSrbSG->length;
521 pSCB->SCB_BufLen = (SCpnt->request_bufflen > TotalLen) ?
522 TotalLen : SCpnt->request_bufflen;
523 } else { /* Non SG */
524 pSCB->SCB_BufPtr = (U32) VIRT_TO_BUS(SCpnt->request_buffer);
525 pSCB->SCB_BufLen = SCpnt->request_bufflen;
533 * Queue a command and setup interrupts for a free bus.
535 int i91u_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
538 HCS *pHCB; /* Point to Host adapter control block */
540 if (SCpnt->device->lun > 16) { /* 07/22/98 */
542 SCpnt->result = (DID_TIME_OUT << 16);
543 done(SCpnt); /* Notify system DONE */
546 pHCB = (HCS *) SCpnt->device->host->base;
548 SCpnt->scsi_done = done;
549 /* Get free SCSI control block */
550 if ((pSCB = tul_alloc_scb(pHCB)) == NULL) {
551 i91uAppendSRBToQueue(pHCB, SCpnt); /* Buffer this request */
554 i91uBuildSCB(pHCB, pSCB, SCpnt);
555 tul_exec_scb(pHCB, pSCB); /* Start execute SCB */
560 * Abort a queued command
561 * (commands that are on the bus can't be aborted easily)
563 int i91u_abort(Scsi_Cmnd * SCpnt)
567 pHCB = (HCS *) SCpnt->device->host->base;
568 return tul_abort_srb(pHCB, SCpnt);
572 * Reset registers, reset a hanging bus and
573 * kill active and disconnected commands for target w/o soft reset
575 int i91u_reset(Scsi_Cmnd * SCpnt, unsigned int reset_flags)
576 { /* I need Host Control Block Information */
579 pHCB = (HCS *) SCpnt->device->host->base;
581 if (reset_flags & (SCSI_RESET_SUGGEST_BUS_RESET | SCSI_RESET_SUGGEST_HOST_RESET))
582 return tul_reset_scsi_bus(pHCB);
584 return tul_device_reset(pHCB, (ULONG) SCpnt, SCpnt->device->id, reset_flags);
588 * Return the "logical geometry"
590 int i91u_biosparam(struct scsi_device *sdev, struct block_device *dev,
591 sector_t capacity, int *info_array)
593 HCS *pHcb; /* Point to Host adapter control block */
596 pHcb = (HCS *) sdev->host->base;
597 pTcb = &pHcb->HCS_Tcs[sdev->id];
599 if (pTcb->TCS_DrvHead) {
600 info_array[0] = pTcb->TCS_DrvHead;
601 info_array[1] = pTcb->TCS_DrvSector;
602 info_array[2] = (unsigned long)capacity / pTcb->TCS_DrvHead / pTcb->TCS_DrvSector;
604 if (pTcb->TCS_DrvFlags & TCF_DRV_255_63) {
607 info_array[2] = (unsigned long)capacity / 255 / 63;
611 info_array[2] = (unsigned long)capacity >> 11;
615 #if defined(DEBUG_BIOSPARAM)
616 if (i91u_debug & debug_biosparam) {
617 printk("bios geometry: head=%d, sec=%d, cyl=%d\n",
618 info_array[0], info_array[1], info_array[2]);
619 printk("WARNING: check, if the bios geometry is correct.\n");
626 /*****************************************************************************
627 Function name : i91uSCBPost
628 Description : This is callback routine be called when tulip finish one
630 Input : pHCB - Pointer to host adapter control block.
631 pSCB - Pointer to SCSI control block.
634 *****************************************************************************/
635 static void i91uSCBPost(BYTE * pHcb, BYTE * pScb)
637 Scsi_Cmnd *pSRB; /* Pointer to SCSI request block */
643 if ((pSRB = pSCB->SCB_Srb) == 0) {
644 printk("i91uSCBPost: SRB pointer is empty\n");
646 tul_release_scb(pHCB, pSCB); /* Release SCB for current channel */
649 switch (pSCB->SCB_HaStat) {
651 case 0xa: /* Linked command complete without error and linked normally */
652 case 0xb: /* Linked command complete without error interrupt generated */
653 pSCB->SCB_HaStat = 0;
656 case 0x11: /* Selection time out-The initiator selection or target
657 reselection was not complete within the SCSI Time out period */
658 pSCB->SCB_HaStat = DID_TIME_OUT;
661 case 0x14: /* Target bus phase sequence failure-An invalid bus phase or bus
662 phase sequence was requested by the target. The host adapter
663 will generate a SCSI Reset Condition, notifying the host with
665 pSCB->SCB_HaStat = DID_RESET;
668 case 0x1a: /* SCB Aborted. 07/21/98 */
669 pSCB->SCB_HaStat = DID_ABORT;
672 case 0x12: /* Data overrun/underrun-The target attempted to transfer more data
673 than was allocated by the Data Length field or the sum of the
674 Scatter / Gather Data Length fields. */
675 case 0x13: /* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */
676 case 0x16: /* Invalid SCB Operation Code. */
679 printk("ini9100u: %x %x\n", pSCB->SCB_HaStat, pSCB->SCB_TaStat);
680 pSCB->SCB_HaStat = DID_ERROR; /* Couldn't find any better */
684 pSRB->result = pSCB->SCB_TaStat | (pSCB->SCB_HaStat << 16);
687 printk("pSRB is NULL\n");
689 pSRB->scsi_done(pSRB); /* Notify system DONE */
690 if ((pSRB = i91uPopSRBFromQueue(pHCB)) != NULL)
691 /* Find the next pending SRB */
692 { /* Assume resend will success */
694 i91uBuildSCB(pHCB, pSCB, pSRB); /* Create corresponding SCB */
696 tul_exec_scb(pHCB, pSCB); /* Start execute SCB */
697 } else { /* No Pending SRB */
698 tul_release_scb(pHCB, pSCB); /* Release SCB for current channel */
704 * Interrupts handler (main routine of the driver)
706 static irqreturn_t i91u_intr0(int irqno, void *dev_id, struct pt_regs *regs)
709 struct Scsi_Host *dev = dev_id;
711 if (tul_hcs[0].HCS_Intr != irqno)
714 spin_lock_irqsave(dev->host_lock, flags);
716 tul_isr(&tul_hcs[0]);
718 spin_unlock_irqrestore(dev->host_lock, flags);
722 static irqreturn_t i91u_intr1(int irqno, void *dev_id, struct pt_regs *regs)
725 struct Scsi_Host *dev = dev_id;
727 if (tul_hcs[1].HCS_Intr != irqno)
730 spin_lock_irqsave(dev->host_lock, flags);
732 tul_isr(&tul_hcs[1]);
734 spin_unlock_irqrestore(dev->host_lock, flags);
738 static irqreturn_t i91u_intr2(int irqno, void *dev_id, struct pt_regs *regs)
741 struct Scsi_Host *dev = dev_id;
743 if (tul_hcs[2].HCS_Intr != irqno)
746 spin_lock_irqsave(dev->host_lock, flags);
748 tul_isr(&tul_hcs[2]);
750 spin_unlock_irqrestore(dev->host_lock, flags);
754 static irqreturn_t i91u_intr3(int irqno, void *dev_id, struct pt_regs *regs)
757 struct Scsi_Host *dev = dev_id;
759 if (tul_hcs[3].HCS_Intr != irqno)
762 spin_lock_irqsave(dev->host_lock, flags);
764 tul_isr(&tul_hcs[3]);
766 spin_unlock_irqrestore(dev->host_lock, flags);
770 static irqreturn_t i91u_intr4(int irqno, void *dev_id, struct pt_regs *regs)
773 struct Scsi_Host *dev = dev_id;
775 if (tul_hcs[4].HCS_Intr != irqno)
778 spin_lock_irqsave(dev->host_lock, flags);
780 tul_isr(&tul_hcs[4]);
782 spin_unlock_irqrestore(dev->host_lock, flags);
786 static irqreturn_t i91u_intr5(int irqno, void *dev_id, struct pt_regs *regs)
789 struct Scsi_Host *dev = dev_id;
791 if (tul_hcs[5].HCS_Intr != irqno)
794 spin_lock_irqsave(dev->host_lock, flags);
796 tul_isr(&tul_hcs[5]);
798 spin_unlock_irqrestore(dev->host_lock, flags);
802 static irqreturn_t i91u_intr6(int irqno, void *dev_id, struct pt_regs *regs)
805 struct Scsi_Host *dev = dev_id;
807 if (tul_hcs[6].HCS_Intr != irqno)
810 spin_lock_irqsave(dev->host_lock, flags);
812 tul_isr(&tul_hcs[6]);
814 spin_unlock_irqrestore(dev->host_lock, flags);
818 static irqreturn_t i91u_intr7(int irqno, void *dev_id, struct pt_regs *regs)
821 struct Scsi_Host *dev = dev_id;
823 if (tul_hcs[7].HCS_Intr != irqno)
826 spin_lock_irqsave(dev->host_lock, flags);
828 tul_isr(&tul_hcs[7]);
830 spin_unlock_irqrestore(dev->host_lock, flags);
835 * Dump the current driver status and panic...
837 static void i91u_panic(char *msg)
839 printk("\ni91u_panic: %s\n", msg);
846 int i91u_release(struct Scsi_Host *hreg)
848 free_irq(hreg->irq, hreg);
849 release_region(hreg->io_port, 256);
852 MODULE_LICENSE("Dual BSD/GPL");