1 /**************************************************************************
2 * Initio A100 device driver for Linux.
4 * Copyright (c) 1994-1998 Initio Corporation
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)
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.
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.
21 * --------------------------------------------------------------------------
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
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.
35 * Where this Software is combined with software released under the terms of
36 * the GNU General 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.
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
54 **************************************************************************
58 * This is the Linux low-level SCSI driver for Initio INIA100 SCSI host
60 * 09/24/98 hl - v1.02 initial production release.
61 * 12/19/98 bv - v1.02a Use spinlocks for 2.1.95 and up.
62 **************************************************************************/
64 #define CVT_LINUX_VERSION(V,P,S) (V * 65536 + P * 256 + S)
66 #ifndef LINUX_VERSION_CODE
67 #include <linux/version.h>
70 #include <linux/module.h>
74 #include <linux/errno.h>
75 #include <linux/delay.h>
76 #include <linux/pci.h>
77 #include <linux/init.h>
78 #include <linux/blk.h>
79 #include <linux/spinlock.h>
80 #include <linux/stat.h>
81 #include <linux/kernel.h>
82 #include <linux/string.h>
83 #include <linux/ioport.h>
84 #include <linux/sched.h>
85 #include <linux/proc_fs.h>
90 #include <linux/slab.h>
93 static Scsi_Host_Template driver_template = INIA100;
94 #include "scsi_module.c"
96 #define ORC_RDWORD(x,y) (short)(inl((int)((ULONG)((ULONG)x+(UCHAR)y)) ))
98 char *inia100_Copyright = "Copyright (C) 1998-99";
99 char *inia100_InitioName = "by Initio Corporation";
100 char *inia100_ProductName = "INI-A100U2W";
101 char *inia100_Version = "v1.02c";
103 /* set by inia100_setup according to the command line */
104 static int setup_called = 0;
105 static int orc_num_ch = MAX_SUPPORTED_ADAPTERS; /* Maximum 4 adapters */
107 /* ---- INTERNAL VARIABLES ---- */
108 #define NUMBER(arr) (sizeof(arr) / sizeof(arr[0]))
109 static char *setup_str = (char *) NULL;
111 static void inia100_intr0(int irq, void *dev_id, struct pt_regs *);
112 static void inia100_intr1(int irq, void *dev_id, struct pt_regs *);
113 static void inia100_intr2(int irq, void *dev_id, struct pt_regs *);
114 static void inia100_intr3(int irq, void *dev_id, struct pt_regs *);
115 static void inia100_intr4(int irq, void *dev_id, struct pt_regs *);
116 static void inia100_intr5(int irq, void *dev_id, struct pt_regs *);
117 static void inia100_intr6(int irq, void *dev_id, struct pt_regs *);
118 static void inia100_intr7(int irq, void *dev_id, struct pt_regs *);
120 static void inia100_panic(char *msg);
121 void inia100SCBPost(BYTE * pHcb, BYTE * pScb);
123 /* ---- EXTERNAL VARIABLES ---- */
124 extern int Addinia100_into_Adapter_table(WORD, WORD, BYTE, BYTE, BYTE);
125 extern void init_inia100Adapter_table(void);
126 extern ORC_SCB *orc_alloc_scb(ORC_HCS * hcsp);
127 extern void orc_exec_scb(ORC_HCS * hcsp, ORC_SCB * scbp);
128 extern void orc_release_scb(ORC_HCS * hcsp, ORC_SCB * scbp);
129 extern void orc_interrupt(ORC_HCS * hcsp);
130 extern int orc_device_reset(ORC_HCS * pHCB, ULONG SCpnt, unsigned int target, unsigned int ResetFlags);
131 extern int orc_reset_scsi_bus(ORC_HCS * pHCB);
132 extern int abort_SCB(ORC_HCS * hcsp, ORC_SCB * pScb);
133 extern int orc_abort_srb(ORC_HCS * hcsp, ULONG SCpnt);
134 extern void get_orcPCIConfig(ORC_HCS * pCurHcb, int ch_idx);
135 extern int init_orchid(ORC_HCS * hcsp);
137 extern int orc_num_scb;
138 extern ORC_HCS orc_hcs[];
140 /*****************************************************************************
141 Function name : inia100AppendSRBToQueue
142 Description : This function will push current request into save list
143 Input : pSRB - Pointer to SCSI request block.
144 pHCB - Pointer to host adapter structure
147 *****************************************************************************/
148 static void inia100AppendSRBToQueue(ORC_HCS * pHCB, Scsi_Cmnd * pSRB)
152 spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
154 pSRB->next = NULL; /* Pointer to next */
155 if (pHCB->pSRB_head == NULL)
156 pHCB->pSRB_head = pSRB;
158 pHCB->pSRB_tail->next = pSRB; /* Pointer to next */
159 pHCB->pSRB_tail = pSRB;
160 spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
164 /*****************************************************************************
165 Function name : inia100PopSRBFromQueue
166 Description : This function will pop current request from save list
167 Input : pHCB - Pointer to host adapter structure
169 Return : pSRB - Pointer to SCSI request block.
170 *****************************************************************************/
171 static Scsi_Cmnd *inia100PopSRBFromQueue(ORC_HCS * pHCB)
175 spin_lock_irqsave(&(pHCB->pSRB_lock), flags);
176 if ((pSRB = (Scsi_Cmnd *) pHCB->pSRB_head) != NULL) {
177 pHCB->pSRB_head = pHCB->pSRB_head->next;
180 spin_unlock_irqrestore(&(pHCB->pSRB_lock), flags);
184 /*****************************************************************************
185 Function name : inia100_setup
187 Input : pHCB - Pointer to host adapter structure
189 Return : pSRB - Pointer to SCSI request block.
190 *****************************************************************************/
191 void inia100_setup(char *str, int *ints)
194 inia100_panic("inia100: inia100_setup called twice.\n");
196 setup_called = ints[0];
200 /*****************************************************************************
201 Function name : orc_ReturnNumberOfAdapters
202 Description : This function will scan PCI bus to get all Orchid card
205 Return : SUCCESSFUL - Successful scan
206 ohterwise - No drives founded
207 *****************************************************************************/
208 int orc_ReturnNumberOfAdapters(void)
210 unsigned int i, iAdapters;
216 if (pcibios_present()) {
218 unsigned short vendor_id;
219 unsigned short device_id;
220 } const inia100_pci_devices[] =
222 {ORC_VENDOR_ID, I920_DEVICE_ID},
223 {ORC_VENDOR_ID, ORC_DEVICE_ID}
226 unsigned int dRegValue;
228 BYTE bPCIBusNum, bInterrupt, bPCIDeviceNum;
231 unsigned long page_offset, base;
234 struct pci_dev *pdev = NULL;
238 init_inia100Adapter_table();
239 for (i = 0; i < NUMBER(inia100_pci_devices); i++) {
241 while ((pdev = pci_find_device(inia100_pci_devices[i].vendor_id,
242 inia100_pci_devices[i].device_id,
245 if (pci_enable_device(pdev))
247 if (iAdapters >= MAX_SUPPORTED_ADAPTERS)
248 break; /* Never greater than maximum */
252 printk("inia100: The RAID controller is not supported by\n");
253 printk("inia100: this driver, we are ignoring it.\n");
257 * Read sundry information from PCI BIOS.
259 bPCIBusNum = pdev->bus->number;
260 bPCIDeviceNum = pdev->devfn;
261 dRegValue = pci_resource_start(pdev, 0);
262 if (dRegValue == -1) { /* Check return code */
263 printk("\n\rinia100: orchid read configuration error.\n");
264 return (0); /* Read configuration space error */
267 /* <02> read from base address + 0x50 offset to get the wBIOS balue. */
268 wBASE = (WORD) dRegValue;
270 /* Now read the interrupt line value */
271 dRegValue = pdev->irq;
272 bInterrupt = dRegValue; /* Assign interrupt line */
274 wBIOS = ORC_RDWORD(wBASE, 0x50);
276 pci_set_master(pdev);
279 base = wBASE & PAGE_MASK;
280 page_offset = wBASE - base;
283 * replace the next line with this one if you are using 2.1.x:
284 * temp_p->maddr = ioremap(base, page_offset + 256);
286 wBASE = ioremap(base, page_offset + 256);
288 wBASE += page_offset;
292 if (Addinia100_into_Adapter_table(wBIOS, wBASE, bInterrupt, bPCIBusNum,
293 bPCIDeviceNum) == SUCCESSFUL)
296 } /* while(pdev=....) */
297 } /* for PCI_DEVICES */
298 } /* PCI BIOS present */
302 /*****************************************************************************
303 Function name : inia100_detect
305 Input : pHCB - Pointer to host adapter structure
307 Return : pSRB - Pointer to SCSI request block.
308 *****************************************************************************/
309 int inia100_detect(Scsi_Host_Template * tpnt)
312 struct Scsi_Host *hreg;
314 U32 i; /* 01/14/98 */
315 int ok = 0, iAdapters;
319 tpnt->proc_name = "INIA100";
321 /* Setup by inia100_setup */
322 printk("inia100: processing commandline: ");
324 /* Get total number of adapters in the motherboard */
325 iAdapters = orc_ReturnNumberOfAdapters();
327 /* printk("inia100: Total Initio Adapters = %d\n", iAdapters); */
328 if (iAdapters == 0) /* If no orc founded, return */
331 orc_num_ch = (iAdapters > orc_num_ch) ? orc_num_ch : iAdapters;
332 orc_num_scb = ORC_MAXQUEUE;
334 /* clear the memory needed for HCS */
335 i = orc_num_ch * sizeof(ORC_HCS);
336 memset((unsigned char *) &orc_hcs[0], 0, i); /* Initialize orc_hcs 0 */
339 printk("orc_num_scb= %x orc_num_ch= %x hcsize= %x scbsize= %x escbsize= %x\n",
340 orc_num_scb, orc_num_ch, sizeof(ORC_HCS), sizeof(ORC_SCB), sizeof(ESCB));
343 for (i = 0, pHCB = &orc_hcs[0]; /* Get pointer for control block */
347 pHCB->pSRB_head = NULL; /* Initial SRB save queue */
348 pHCB->pSRB_tail = NULL; /* Initial SRB save queue */
349 pHCB->pSRB_lock = SPIN_LOCK_UNLOCKED; /* SRB save queue lock */
350 pHCB->BitAllocFlagLock = SPIN_LOCK_UNLOCKED;
351 /* Get total memory needed for SCB */
352 sz = orc_num_scb * sizeof(ORC_SCB);
353 if ((pHCB->HCS_virScbArray = (PVOID) kmalloc(sz, GFP_ATOMIC | GFP_DMA)) == NULL) {
354 printk("inia100: SCB memory allocation error\n");
357 memset((unsigned char *) pHCB->HCS_virScbArray, 0, sz);
358 pHCB->HCS_physScbArray = (U32) VIRT_TO_BUS(pHCB->HCS_virScbArray);
360 /* Get total memory needed for ESCB */
361 sz = orc_num_scb * sizeof(ESCB);
362 if ((pHCB->HCS_virEscbArray = (PVOID) kmalloc(sz, GFP_ATOMIC | GFP_DMA)) == NULL) {
363 printk("inia100: ESCB memory allocation error\n");
364 /* ?? does pHCB->HCS_virtScbArray leak ??*/
367 memset((unsigned char *) pHCB->HCS_virEscbArray, 0, sz);
368 pHCB->HCS_physEscbArray = (U32) VIRT_TO_BUS(pHCB->HCS_virEscbArray);
370 get_orcPCIConfig(pHCB, i);
372 dBiosAdr = pHCB->HCS_BIOS;
373 dBiosAdr = (dBiosAdr << 4);
375 pbBiosAdr = phys_to_virt(dBiosAdr);
377 if (init_orchid(pHCB)) { /* Initial orchid chip */
378 printk("inia100: initial orchid fail!!\n");
381 request_region(pHCB->HCS_Base, 256, "inia100"); /* Register */
383 hreg = scsi_register(tpnt, sizeof(ORC_HCS));
385 release_region(pHCB->HCS_Base, 256); /* Register */
388 hreg->io_port = pHCB->HCS_Base;
389 hreg->n_io_port = 0xff;
390 hreg->can_queue = orc_num_scb; /* 03/05/98 */
392 hreg->unique_id = pHCB->HCS_Base;
393 hreg->max_id = pHCB->HCS_MaxTar;
395 hreg->max_lun = 32; /* 10/21/97 */
398 hreg->max_channel = 1;
400 hreg->irq = pHCB->HCS_Intr;
401 hreg->this_id = pHCB->HCS_SCSI_ID; /* Assign HCS index */
402 hreg->base = (unsigned long)pHCB;
405 hreg->sg_tablesize = TOTAL_SG_ENTRY; /* Maximun support is 32 */
407 hreg->sg_tablesize = SG_NONE; /* No SG */
410 /* Initial orc chip */
413 ok = request_irq(pHCB->HCS_Intr, inia100_intr0, SA_INTERRUPT | SA_SHIRQ, "inia100", hreg);
416 ok = request_irq(pHCB->HCS_Intr, inia100_intr1, SA_INTERRUPT | SA_SHIRQ, "inia100", hreg);
419 ok = request_irq(pHCB->HCS_Intr, inia100_intr2, SA_INTERRUPT | SA_SHIRQ, "inia100", hreg);
422 ok = request_irq(pHCB->HCS_Intr, inia100_intr3, SA_INTERRUPT | SA_SHIRQ, "inia100", hreg);
425 ok = request_irq(pHCB->HCS_Intr, inia100_intr4, SA_INTERRUPT | SA_SHIRQ, "inia100", hreg);
428 ok = request_irq(pHCB->HCS_Intr, inia100_intr5, SA_INTERRUPT | SA_SHIRQ, "inia100", hreg);
431 ok = request_irq(pHCB->HCS_Intr, inia100_intr6, SA_INTERRUPT | SA_SHIRQ, "inia100", hreg);
434 ok = request_irq(pHCB->HCS_Intr, inia100_intr7, SA_INTERRUPT | SA_SHIRQ, "inia100", hreg);
437 inia100_panic("inia100: Too many host adapters\n");
443 printk("inia100: bad IRQ %d.\n", pHCB->HCS_Intr);
444 printk(" Contact author.\n");
447 printk("inia100: IRQ %d already in use. Configure another.\n", pHCB->HCS_Intr);
449 printk("\ninia100: Unexpected error code on requesting IRQ %d.\n",
451 printk(" Contact author.\n");
454 inia100_panic("inia100: driver needs an IRQ.\n");
463 /*****************************************************************************
464 Function name : inia100BuildSCB
466 Input : pHCB - Pointer to host adapter structure
468 Return : pSRB - Pointer to SCSI request block.
469 *****************************************************************************/
470 static void inia100BuildSCB(ORC_HCS * pHCB, ORC_SCB * pSCB, Scsi_Cmnd * SCpnt)
471 { /* Create corresponding SCB */
472 struct scatterlist *pSrbSG;
473 ORC_SG *pSG; /* Pointer to SG list */
478 pEScb = pSCB->SCB_EScb;
479 pEScb->SCB_Srb = SCpnt;
482 pSCB->SCB_Opcode = ORC_EXECSCSI;
483 pSCB->SCB_Flags = SCF_NO_DCHK; /* Clear done bit */
484 pSCB->SCB_Target = SCpnt->target;
485 pSCB->SCB_Lun = SCpnt->lun;
486 pSCB->SCB_Reserved0 = 0;
487 pSCB->SCB_Reserved1 = 0;
490 if ((pSCB->SCB_XferLen = (U32) SCpnt->request_bufflen)) {
491 pSG = (ORC_SG *) & pEScb->ESCB_SGList[0];
494 pSCB->SCB_SGLen = (U32) (SCpnt->use_sg * 8);
495 pSrbSG = (struct scatterlist *) SCpnt->request_buffer;
496 for (i = 0; i < SCpnt->use_sg; i++, pSG++, pSrbSG++) {
497 pSG->SG_Ptr = (U32) (VIRT_TO_BUS(pSrbSG->address));
498 pSG->SG_Len = (U32) pSrbSG->length;
499 TotalLen += (U32) pSrbSG->length;
501 } else { /* Non SG */
502 pSCB->SCB_SGLen = 0x8;
503 pSG->SG_Ptr = (U32) (VIRT_TO_BUS(SCpnt->request_buffer));
504 pSG->SG_Len = (U32) SCpnt->request_bufflen;
507 pSCB->SCB_SGPAddr = (U32) pSCB->SCB_SensePAddr;
508 pSCB->SCB_HaStat = 0;
509 pSCB->SCB_TaStat = 0;
510 pSCB->SCB_Link = 0xFF;
511 pSCB->SCB_SenseLen = SENSE_SIZE;
512 pSCB->SCB_CDBLen = SCpnt->cmd_len;
513 if (pSCB->SCB_CDBLen >= IMAX_CDB) {
514 printk("max cdb length= %x\b", SCpnt->cmd_len);
515 pSCB->SCB_CDBLen = IMAX_CDB;
517 pSCB->SCB_Ident = SCpnt->lun | DISC_ALLOW;
518 if (SCpnt->device->tagged_supported) { /* Tag Support */
519 pSCB->SCB_TagMsg = SIMPLE_QUEUE_TAG; /* Do simple tag only */
521 pSCB->SCB_TagMsg = 0; /* No tag support */
523 memcpy(&pSCB->SCB_CDB[0], &SCpnt->cmnd, pSCB->SCB_CDBLen);
527 /*****************************************************************************
528 Function name : inia100_queue
529 Description : Queue a command and setup interrupts for a free bus.
530 Input : pHCB - Pointer to host adapter structure
532 Return : pSRB - Pointer to SCSI request block.
533 *****************************************************************************/
534 int inia100_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
536 register ORC_SCB *pSCB;
537 ORC_HCS *pHCB; /* Point to Host adapter control block */
539 if (SCpnt->lun > 16) {
540 SCpnt->result = (DID_TIME_OUT << 16);
541 done(SCpnt); /* Notify system DONE */
544 pHCB = (ORC_HCS *) SCpnt->host->base;
545 SCpnt->scsi_done = done;
546 /* Get free SCSI control block */
547 if ((pSCB = orc_alloc_scb(pHCB)) == NULL) {
548 inia100AppendSRBToQueue(pHCB, SCpnt); /* Buffer this request */
549 /* printk("inia100_entry: can't allocate SCB\n"); */
552 inia100BuildSCB(pHCB, pSCB, SCpnt);
553 orc_exec_scb(pHCB, pSCB); /* Start execute SCB */
558 /*****************************************************************************
559 Function name : inia100_command
560 Description : We only support command in interrupt-driven fashion
561 Input : pHCB - Pointer to host adapter structure
563 Return : pSRB - Pointer to SCSI request block.
564 *****************************************************************************/
565 int inia100_command(Scsi_Cmnd * SCpnt)
567 printk("inia100: interrupt driven driver; use inia100_queue()\n");
571 /*****************************************************************************
572 Function name : inia100_abort
573 Description : Abort a queued command.
574 (commands that are on the bus can't be aborted easily)
575 Input : pHCB - Pointer to host adapter structure
577 Return : pSRB - Pointer to SCSI request block.
578 *****************************************************************************/
579 int inia100_abort(Scsi_Cmnd * SCpnt)
583 hcsp = (ORC_HCS *) SCpnt->host->base;
584 return orc_abort_srb(hcsp, (ULONG) SCpnt);
587 /*****************************************************************************
588 Function name : inia100_reset
589 Description : Reset registers, reset a hanging bus and
590 kill active and disconnected commands for target w/o soft reset
591 Input : pHCB - Pointer to host adapter structure
593 Return : pSRB - Pointer to SCSI request block.
594 *****************************************************************************/
595 int inia100_reset(Scsi_Cmnd * SCpnt, unsigned int reset_flags)
596 { /* I need Host Control Block Information */
598 pHCB = (ORC_HCS *) SCpnt->host->base;
600 if (reset_flags & (SCSI_RESET_SUGGEST_BUS_RESET | SCSI_RESET_SUGGEST_HOST_RESET))
601 return orc_reset_scsi_bus(pHCB);
603 return orc_device_reset(pHCB, (ULONG) SCpnt, SCpnt->target, reset_flags);
607 /*****************************************************************************
608 Function name : inia100SCBPost
609 Description : This is callback routine be called when orc finish one
611 Input : pHCB - Pointer to host adapter control block.
612 pSCB - Pointer to SCSI control block.
615 *****************************************************************************/
616 void inia100SCBPost(BYTE * pHcb, BYTE * pScb)
618 Scsi_Cmnd *pSRB; /* Pointer to SCSI request block */
623 pHCB = (ORC_HCS *) pHcb;
624 pSCB = (ORC_SCB *) pScb;
625 pEScb = pSCB->SCB_EScb;
626 if ((pSRB = (Scsi_Cmnd *) pEScb->SCB_Srb) == 0) {
627 printk("inia100SCBPost: SRB pointer is empty\n");
628 orc_release_scb(pHCB, pSCB); /* Release SCB for current channel */
631 pEScb->SCB_Srb = NULL;
633 switch (pSCB->SCB_HaStat) {
635 case 0xa: /* Linked command complete without error and linked normally */
636 case 0xb: /* Linked command complete without error interrupt generated */
637 pSCB->SCB_HaStat = 0;
640 case 0x11: /* Selection time out-The initiator selection or target
641 reselection was not complete within the SCSI Time out period */
642 pSCB->SCB_HaStat = DID_TIME_OUT;
645 case 0x14: /* Target bus phase sequence failure-An invalid bus phase or bus
646 phase sequence was requested by the target. The host adapter
647 will generate a SCSI Reset Condition, notifying the host with
649 pSCB->SCB_HaStat = DID_RESET;
652 case 0x1a: /* SCB Aborted. 07/21/98 */
653 pSCB->SCB_HaStat = DID_ABORT;
656 case 0x12: /* Data overrun/underrun-The target attempted to transfer more data
657 than was allocated by the Data Length field or the sum of the
658 Scatter / Gather Data Length fields. */
659 case 0x13: /* Unexpected bus free-The target dropped the SCSI BSY at an unexpected time. */
660 case 0x16: /* Invalid CCB Operation Code-The first byte of the CCB was invalid. */
663 printk("inia100: %x %x\n", pSCB->SCB_HaStat, pSCB->SCB_TaStat);
664 pSCB->SCB_HaStat = DID_ERROR; /* Couldn't find any better */
668 if (pSCB->SCB_TaStat == 2) { /* Check condition */
669 memcpy((unsigned char *) &pSRB->sense_buffer[0],
670 (unsigned char *) &pEScb->ESCB_SGList[0], SENSE_SIZE);
672 pSRB->result = pSCB->SCB_TaStat | (pSCB->SCB_HaStat << 16);
673 pSRB->scsi_done(pSRB); /* Notify system DONE */
675 /* Find the next pending SRB */
676 if ((pSRB = inia100PopSRBFromQueue(pHCB)) != NULL) { /* Assume resend will success */
678 inia100BuildSCB(pHCB, pSCB, pSRB); /* Create corresponding SCB */
679 orc_exec_scb(pHCB, pSCB); /* Start execute SCB */
680 } else { /* No Pending SRB */
681 orc_release_scb(pHCB, pSCB); /* Release SCB for current channel */
686 /*****************************************************************************
687 Function name : inia100_biosparam
688 Description : Return the "logical geometry"
689 Input : pHCB - Pointer to host adapter structure
691 Return : pSRB - Pointer to SCSI request block.
692 *****************************************************************************/
693 int inia100_biosparam(Scsi_Disk * disk, kdev_t dev, int *info_array)
695 ORC_HCS *pHcb; /* Point to Host adapter control block */
698 pHcb = (ORC_HCS *) disk->device->host->base;
699 pTcb = &pHcb->HCS_Tcs[disk->device->id];
701 if (pTcb->TCS_DrvHead) {
702 info_array[0] = pTcb->TCS_DrvHead;
703 info_array[1] = pTcb->TCS_DrvSector;
704 info_array[2] = disk->capacity / pTcb->TCS_DrvHead / pTcb->TCS_DrvSector;
706 if (pTcb->TCS_DrvFlags & TCF_DRV_255_63) {
709 info_array[2] = disk->capacity / 255 / 63;
713 info_array[2] = disk->capacity >> 11;
720 static void subIntr(ORC_HCS * pHCB, int irqno)
724 spin_lock_irqsave(&io_request_lock, flags);
726 if (pHCB->HCS_Intr != irqno) {
727 spin_unlock_irqrestore(&io_request_lock, flags);
732 spin_unlock_irqrestore(&io_request_lock, flags);
736 * Interrupts handler (main routine of the driver)
738 static void inia100_intr0(int irqno, void *dev_id, struct pt_regs *regs)
740 subIntr(&orc_hcs[0], irqno);
743 static void inia100_intr1(int irqno, void *dev_id, struct pt_regs *regs)
745 subIntr(&orc_hcs[1], irqno);
748 static void inia100_intr2(int irqno, void *dev_id, struct pt_regs *regs)
750 subIntr(&orc_hcs[2], irqno);
753 static void inia100_intr3(int irqno, void *dev_id, struct pt_regs *regs)
755 subIntr(&orc_hcs[3], irqno);
758 static void inia100_intr4(int irqno, void *dev_id, struct pt_regs *regs)
760 subIntr(&orc_hcs[4], irqno);
763 static void inia100_intr5(int irqno, void *dev_id, struct pt_regs *regs)
765 subIntr(&orc_hcs[5], irqno);
768 static void inia100_intr6(int irqno, void *dev_id, struct pt_regs *regs)
770 subIntr(&orc_hcs[6], irqno);
773 static void inia100_intr7(int irqno, void *dev_id, struct pt_regs *regs)
775 subIntr(&orc_hcs[7], irqno);
779 * Dump the current driver status and panic...
781 static void inia100_panic(char *msg)
783 printk("\ninia100_panic: %s\n", msg);
784 panic("inia100 panic");
790 int inia100_release(struct Scsi_Host *hreg)
792 free_irq(hreg->irq, hreg);
793 release_region(hreg->io_port, 256);
797 MODULE_LICENSE("Dual BSD/GPL");
798 /*#include "inia100scsi.c" */