Import 2.3.49pre2
[davej-history.git] / drivers / scsi / pci2000.c
blob7f14fc61b4bc33b5fff35899a0069f2357148082
1 /****************************************************************************
2 * Perceptive Solutions, Inc. PCI-2000 device driver for Linux.
4 * pci2000.c - Linux Host Driver for PCI-2000 IntelliCache SCSI Adapters
6 * Copyright (c) 1997-1999 Perceptive Solutions, Inc.
7 * All Rights Reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that redistributions of source
11 * code retain the above copyright notice and this comment without
12 * modification.
14 * Technical updates and product information at:
15 * http://www.psidisk.com
17 * Please send questions, comments, bug reports to:
18 * tech@psidisk.com Technical Support
21 * Revisions 1.10 Jan-21-1999
22 * - Fixed sign on message to reflect proper controller name.
23 * - Added support for RAID status monitoring and control.
25 * Revisions 1.11 Mar-22-1999
26 * - Fixed control timeout to not lock up the entire system if
27 * controller goes offline completely.
29 * Revisions 1.12 Mar-26-1999
30 * - Fixed spinlock and PCI configuration.
32 ****************************************************************************/
33 #define PCI2000_VERSION "1.12"
35 #include <linux/module.h>
37 #include <linux/kernel.h>
38 #include <linux/types.h>
39 #include <linux/string.h>
40 #include <linux/pci.h>
41 #include <linux/ioport.h>
42 #include <linux/delay.h>
43 #include <linux/sched.h>
44 #include <linux/proc_fs.h>
45 #include <asm/dma.h>
46 #include <asm/system.h>
47 #include <asm/io.h>
48 #include <linux/blk.h>
49 #include "scsi.h"
50 #include "hosts.h"
51 #include <linux/stat.h>
53 #include "pci2000.h"
54 #include "psi_roy.h"
56 #if LINUX_VERSION_CODE >= LINUXVERSION(2,1,95)
57 #include <asm/spinlock.h>
58 #endif
59 #if LINUX_VERSION_CODE < LINUXVERSION(2,1,93)
60 #include <linux/bios32.h>
61 #endif
63 //#define DEBUG 1
65 #ifdef DEBUG
66 #define DEB(x) x
67 #define STOP_HERE {int st;for(st=0;st<100;st++){st=1;}}
68 #else
69 #define DEB(x)
70 #define STOP_HERE
71 #endif
73 typedef struct
75 ULONG address;
76 ULONG length;
77 } SCATGATH, *PSCATGATH;
79 typedef struct
81 Scsi_Cmnd *SCpnt;
82 SCATGATH scatGath[16];
83 UCHAR tag;
84 } DEV2000, *PDEV2000;
86 typedef struct
88 USHORT basePort;
89 USHORT mb0;
90 USHORT mb1;
91 USHORT mb2;
92 USHORT mb3;
93 USHORT mb4;
94 USHORT cmd;
95 USHORT tag;
96 ULONG irqOwned;
97 DEV2000 dev[MAX_BUS][MAX_UNITS];
98 } ADAPTER2000, *PADAPTER2000;
100 #define HOSTDATA(host) ((PADAPTER2000)&host->hostdata)
103 static struct Scsi_Host *PsiHost[MAXADAPTER] = {NULL,}; // One for each adapter
104 static int NumAdapters = 0;
105 /****************************************************************
106 * Name: WaitReady :LOCAL
108 * Description: Wait for controller ready.
110 * Parameters: padapter - Pointer adapter data structure.
112 * Returns: TRUE on not ready.
114 ****************************************************************/
115 static int WaitReady (PADAPTER2000 padapter)
117 ULONG z;
119 for ( z = 0; z < (TIMEOUT_COMMAND * 4); z++ )
121 if ( !inb_p (padapter->cmd) )
122 return FALSE;
123 udelay (250);
125 return TRUE;
127 /****************************************************************
128 * Name: WaitReadyLong :LOCAL
130 * Description: Wait for controller ready.
132 * Parameters: padapter - Pointer adapter data structure.
134 * Returns: TRUE on not ready.
136 ****************************************************************/
137 static int WaitReadyLong (PADAPTER2000 padapter)
139 ULONG z;
141 for ( z = 0; z < (5000 * 4); z++ )
143 if ( !inb_p (padapter->cmd) )
144 return FALSE;
145 udelay (250);
147 return TRUE;
149 /****************************************************************
150 * Name: OpDone :LOCAL
152 * Description: Clean up operation and issue done to caller.
154 * Parameters: SCpnt - Pointer to SCSI command structure.
155 * status - Caller status.
157 * Returns: Nothing.
159 ****************************************************************/
160 static void OpDone (Scsi_Cmnd *SCpnt, ULONG status)
162 SCpnt->result = status;
163 SCpnt->scsi_done (SCpnt);
165 /****************************************************************
166 * Name: Command :LOCAL
168 * Description: Issue queued command to the PCI-2000.
170 * Parameters: padapter - Pointer to adapter information structure.
171 * cmd - PCI-2000 command byte.
173 * Returns: Non-zero command tag if operation is accepted.
175 ****************************************************************/
176 static UCHAR Command (PADAPTER2000 padapter, UCHAR cmd)
178 outb_p (cmd, padapter->cmd);
179 if ( WaitReady (padapter) )
180 return 0;
182 if ( inw_p (padapter->mb0) )
183 return 0;
185 return inb_p (padapter->mb1);
187 /****************************************************************
188 * Name: BuildSgList :LOCAL
190 * Description: Build the scatter gather list for controller.
192 * Parameters: SCpnt - Pointer to SCSI command structure.
193 * padapter - Pointer to adapter information structure.
194 * pdev - Pointer to adapter device structure.
196 * Returns: Non-zero in not scatter gather.
198 ****************************************************************/
199 static int BuildSgList (Scsi_Cmnd *SCpnt, PADAPTER2000 padapter, PDEV2000 pdev)
201 int z;
203 if ( SCpnt->use_sg )
205 for ( z = 0; z < SCpnt->use_sg; z++ )
207 pdev->scatGath[z].address = virt_to_bus (((struct scatterlist *)SCpnt->request_buffer)[z].address);
208 pdev->scatGath[z].length = ((struct scatterlist *)SCpnt->request_buffer)[z].length;
210 outl (virt_to_bus (pdev->scatGath), padapter->mb2);
211 outl ((SCpnt->use_sg << 24) | SCpnt->request_bufflen, padapter->mb3);
212 return FALSE;
214 outl (virt_to_bus (SCpnt->request_buffer), padapter->mb2);
215 outl (SCpnt->request_bufflen, padapter->mb3);
216 return TRUE;
218 /*********************************************************************
219 * Name: PsiRaidCmd
221 * Description: Execute a simple command.
223 * Parameters: padapter - Pointer to adapter control structure.
224 * cmd - Roy command byte.
226 * Returns: Return error status.
228 ********************************************************************/
229 static int PsiRaidCmd (PADAPTER2000 padapter, char cmd)
231 if ( WaitReady (padapter) ) // test for command register ready
232 return DID_TIME_OUT;
233 outb_p (cmd, padapter->cmd); // issue command
234 if ( WaitReadyLong (padapter) ) // wait for adapter ready
235 return DID_TIME_OUT;
236 return DID_OK;
238 /****************************************************************
239 * Name: Irq_Handler :LOCAL
241 * Description: Interrupt handler.
243 * Parameters: irq - Hardware IRQ number.
244 * dev_id -
245 * regs -
247 * Returns: TRUE if drive is not ready in time.
249 ****************************************************************/
250 static void Irq_Handler (int irq, void *dev_id, struct pt_regs *regs)
252 struct Scsi_Host *shost = NULL; // Pointer to host data block
253 PADAPTER2000 padapter; // Pointer to adapter control structure
254 PDEV2000 pdev;
255 Scsi_Cmnd *SCpnt;
256 UCHAR tag = 0;
257 UCHAR tag0;
258 ULONG error;
259 int pun;
260 int bus;
261 int z;
262 #if LINUX_VERSION_CODE < LINUXVERSION(2,1,95)
263 int flags;
264 #else /* version >= v2.1.95 */
265 unsigned long flags;
266 #endif /* version >= v2.1.95 */
268 #if LINUX_VERSION_CODE < LINUXVERSION(2,1,95)
269 /* Disable interrupts, if they aren't already disabled. */
270 save_flags (flags);
271 cli ();
272 #else /* version >= v2.1.95 */
274 * Disable interrupts, if they aren't already disabled and acquire
275 * the I/O spinlock.
277 spin_lock_irqsave (&io_request_lock, flags);
278 #endif /* version >= v2.1.95 */
280 DEB(printk ("\npci2000 recieved interrupt "));
281 for ( z = 0; z < NumAdapters; z++ ) // scan for interrupt to process
283 if ( PsiHost[z]->irq == (UCHAR)(irq & 0xFF) )
285 tag = inb_p (HOSTDATA(PsiHost[z])->tag);
286 if ( tag )
288 shost = PsiHost[z];
289 break;
294 if ( !shost )
296 DEB (printk ("\npci2000: not my interrupt"));
297 goto irq_return;
300 padapter = HOSTDATA(shost);
302 tag0 = tag & 0x7F; // mask off the error bit
303 for ( bus = 0; bus < MAX_BUS; bus++ ) // scan the busses
305 for ( pun = 0; pun < MAX_UNITS; pun++ ) // scan the targets
307 pdev = &padapter->dev[bus][pun];
308 if ( !pdev->tag )
309 continue;
310 if ( pdev->tag == tag0 ) // is this it?
312 pdev->tag = 0;
313 SCpnt = pdev->SCpnt;
314 goto irqProceed;
319 outb_p (0xFF, padapter->tag); // clear the op interrupt
320 outb_p (CMD_DONE, padapter->cmd); // complete the op
321 goto irq_return;; // done, but, with what?
323 irqProceed:;
324 if ( tag & ERR08_TAGGED ) // is there an error here?
326 if ( WaitReady (padapter) )
328 OpDone (SCpnt, DID_TIME_OUT << 16);
329 goto irq_return;;
332 outb_p (tag0, padapter->mb0); // get real error code
333 outb_p (CMD_ERROR, padapter->cmd);
334 if ( WaitReady (padapter) ) // wait for controller to suck up the op
336 OpDone (SCpnt, DID_TIME_OUT << 16);
337 goto irq_return;;
340 error = inl (padapter->mb0); // get error data
341 outb_p (0xFF, padapter->tag); // clear the op interrupt
342 outb_p (CMD_DONE, padapter->cmd); // complete the op
344 DEB (printk ("status: %lX ", error));
345 if ( error == 0x00020002 ) // is this error a check condition?
347 if ( bus ) // are we doint SCSI commands?
349 OpDone (SCpnt, (DID_OK << 16) | 2);
350 goto irq_return;;
352 if ( *SCpnt->cmnd == SCSIOP_TEST_UNIT_READY )
353 OpDone (SCpnt, (DRIVER_SENSE << 24) | (DID_OK << 16) | 2); // test caller we have sense data too
354 else
355 OpDone (SCpnt, DID_ERROR << 16);
356 goto irq_return;;
358 OpDone (SCpnt, DID_ERROR << 16);
359 goto irq_return;;
362 outb_p (0xFF, padapter->tag); // clear the op interrupt
363 outb_p (CMD_DONE, padapter->cmd); // complete the op
364 OpDone (SCpnt, DID_OK << 16);
366 irq_return:;
367 #if LINUX_VERSION_CODE < LINUXVERSION(2,1,95)
369 * Restore the original flags which will enable interrupts
370 * if and only if they were enabled on entry.
372 restore_flags (flags);
373 #else /* version >= v2.1.95 */
375 * Release the I/O spinlock and restore the original flags
376 * which will enable interrupts if and only if they were
377 * enabled on entry.
379 spin_unlock_irqrestore (&io_request_lock, flags);
380 #endif /* version >= v2.1.95 */
382 /****************************************************************
383 * Name: Pci2000_QueueCommand
385 * Description: Process a queued command from the SCSI manager.
387 * Parameters: SCpnt - Pointer to SCSI command structure.
388 * done - Pointer to done function to call.
390 * Returns: Status code.
392 ****************************************************************/
393 int Pci2000_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
395 UCHAR *cdb = (UCHAR *)SCpnt->cmnd; // Pointer to SCSI CDB
396 PADAPTER2000 padapter = HOSTDATA(SCpnt->host); // Pointer to adapter control structure
397 int rc = -1; // command return code
398 UCHAR bus = SCpnt->channel;
399 UCHAR pun = SCpnt->target;
400 UCHAR lun = SCpnt->lun;
401 UCHAR cmd;
402 PDEV2000 pdev = &padapter->dev[bus][pun];
404 if ( !done )
406 printk("pci2000_queuecommand: %02X: done can't be NULL\n", *cdb);
407 return 0;
410 SCpnt->scsi_done = done;
411 pdev->SCpnt = SCpnt; // Save this command data
413 if ( WaitReady (padapter) )
415 rc = DID_ERROR;
416 goto finished;
419 outw_p (pun | (lun << 8), padapter->mb0);
421 if ( bus )
423 DEB (if(*cdb) printk ("\nCDB: %X- %X %X %X %X %X %X %X %X %X %X ", SCpnt->cmd_len, cdb[0], cdb[1], cdb[2], cdb[3], cdb[4], cdb[5], cdb[6], cdb[7], cdb[8], cdb[9]));
424 DEB (if(*cdb) printk ("\ntimeout_per_command: %d, timeout_total: %d, timeout: %d, internal_timout: %d", SCpnt->timeout_per_command,
425 SCpnt->timeout_total, SCpnt->timeout, SCpnt->internal_timeout));
426 outl (SCpnt->timeout_per_command, padapter->mb1);
427 outb_p (CMD_SCSI_TIMEOUT, padapter->cmd);
428 if ( WaitReady (padapter) )
430 rc = DID_ERROR;
431 goto finished;
434 outw_p (pun | (lun << 8), padapter->mb0);
435 outw_p (SCpnt->cmd_len << 8, padapter->mb0 + 2);
436 outl (virt_to_bus (cdb), padapter->mb1);
437 if ( BuildSgList (SCpnt, padapter, pdev) )
438 cmd = CMD_SCSI_THRU;
439 else
440 cmd = CMD_SCSI_THRU_SG;
441 if ( (pdev->tag = Command (padapter, cmd)) == 0 )
442 rc = DID_TIME_OUT;
443 goto finished;
445 else
447 if ( lun )
449 rc = DID_BAD_TARGET;
450 goto finished;
454 switch ( *cdb )
456 case SCSIOP_INQUIRY: // inquiry CDB
457 if ( cdb[2] == SC_MY_RAID )
459 switch ( cdb[3] )
461 case MY_SCSI_REBUILD:
462 OpDone (SCpnt, PsiRaidCmd (padapter, CMD_RAID_REBUILD) << 16);
463 return 0;
464 case MY_SCSI_ALARMMUTE:
465 OpDone (SCpnt, PsiRaidCmd (padapter, CMD_RAID_MUTE) << 16);
466 return 0;
467 case MY_SCSI_DEMOFAIL:
468 OpDone (SCpnt, PsiRaidCmd (padapter, CMD_RAID_FAIL) << 16);
469 return 0;
470 default:
471 if ( SCpnt->use_sg )
473 rc = DID_ERROR;
474 goto finished;
476 else
477 outl (virt_to_bus (SCpnt->request_buffer), padapter->mb2);
478 outl (cdb[5], padapter->mb0);
479 outl (cdb[3], padapter->mb3);
480 cmd = CMD_DASD_RAID_RQ;
481 break;
483 break;
486 if ( SCpnt->use_sg )
488 outl (virt_to_bus (((struct scatterlist *)(SCpnt->request_buffer))->address), padapter->mb2);
490 else
492 outl (virt_to_bus (SCpnt->request_buffer), padapter->mb2);
494 outl (SCpnt->request_bufflen, padapter->mb3);
495 cmd = CMD_DASD_SCSI_INQ;
496 break;
498 case SCSIOP_TEST_UNIT_READY: // test unit ready CDB
499 outl (virt_to_bus (SCpnt->sense_buffer), padapter->mb2);
500 outl (sizeof (SCpnt->sense_buffer), padapter->mb3);
501 cmd = CMD_TEST_READY;
502 break;
504 case SCSIOP_READ_CAPACITY: // read capctiy CDB
505 if ( SCpnt->use_sg )
507 outl (virt_to_bus (((struct scatterlist *)(SCpnt->request_buffer))->address), padapter->mb2);
509 else
511 outl (virt_to_bus (SCpnt->request_buffer), padapter->mb2);
513 outl (8, padapter->mb3);
514 cmd = CMD_DASD_CAP;
515 break;
516 case SCSIOP_VERIFY: // verify CDB
517 outw_p ((USHORT)cdb[8] | ((USHORT)cdb[7] << 8), padapter->mb0 + 2);
518 outl (XSCSI2LONG (&cdb[2]), padapter->mb1);
519 cmd = CMD_READ_SG;
520 break;
521 case SCSIOP_READ: // read10 CDB
522 outw_p ((USHORT)cdb[8] | ((USHORT)cdb[7] << 8), padapter->mb0 + 2);
523 outl (XSCSI2LONG (&cdb[2]), padapter->mb1);
524 if ( BuildSgList (SCpnt, padapter, pdev) )
525 cmd = CMD_READ;
526 else
527 cmd = CMD_READ_SG;
528 break;
529 case SCSIOP_READ6: // read6 CDB
530 outw_p (cdb[4], padapter->mb0 + 2);
531 outl ((SCSI2LONG (&cdb[1])) & 0x001FFFFF, padapter->mb1);
532 if ( BuildSgList (SCpnt, padapter, pdev) )
533 cmd = CMD_READ;
534 else
535 cmd = CMD_READ_SG;
536 break;
537 case SCSIOP_WRITE: // write10 CDB
538 outw_p ((USHORT)cdb[8] | ((USHORT)cdb[7] << 8), padapter->mb0 + 2);
539 outl (XSCSI2LONG (&cdb[2]), padapter->mb1);
540 if ( BuildSgList (SCpnt, padapter, pdev) )
541 cmd = CMD_WRITE;
542 else
543 cmd = CMD_WRITE_SG;
544 break;
545 case SCSIOP_WRITE6: // write6 CDB
546 outw_p (cdb[4], padapter->mb0 + 2);
547 outl ((SCSI2LONG (&cdb[1])) & 0x001FFFFF, padapter->mb1);
548 if ( BuildSgList (SCpnt, padapter, pdev) )
549 cmd = CMD_WRITE;
550 else
551 cmd = CMD_WRITE_SG;
552 break;
553 case SCSIOP_START_STOP_UNIT:
554 cmd = CMD_EJECT_MEDIA;
555 break;
556 case SCSIOP_MEDIUM_REMOVAL:
557 switch ( cdb[4] )
559 case 0:
560 cmd = CMD_UNLOCK_DOOR;
561 break;
562 case 1:
563 cmd = CMD_LOCK_DOOR;
564 break;
565 default:
566 cmd = 0;
567 break;
569 if ( cmd )
570 break;
571 default:
572 DEB (printk ("pci2000_queuecommand: Unsupported command %02X\n", *cdb));
573 OpDone (SCpnt, DID_ERROR << 16);
574 return 0;
577 if ( (pdev->tag = Command (padapter, cmd)) == 0 )
578 rc = DID_TIME_OUT;
579 finished:;
580 if ( rc != -1 )
581 OpDone (SCpnt, rc << 16);
582 return 0;
584 /****************************************************************
585 * Name: internal_done :LOCAL
587 * Description: Done handler for non-queued commands
589 * Parameters: SCpnt - Pointer to SCSI command structure.
591 * Returns: Nothing.
593 ****************************************************************/
594 static void internal_done (Scsi_Cmnd * SCpnt)
596 SCpnt->SCp.Status++;
598 /****************************************************************
599 * Name: Pci2000_Command
601 * Description: Process a command from the SCSI manager.
603 * Parameters: SCpnt - Pointer to SCSI command structure.
605 * Returns: Status code.
607 ****************************************************************/
608 int Pci2000_Command (Scsi_Cmnd *SCpnt)
610 DEB(printk("pci2000_command: ..calling pci2000_queuecommand\n"));
612 Pci2000_QueueCommand (SCpnt, internal_done);
614 SCpnt->SCp.Status = 0;
615 while (!SCpnt->SCp.Status)
616 barrier ();
617 return SCpnt->result;
619 /****************************************************************
620 * Name: Pci2000_Detect
622 * Description: Detect and initialize our boards.
624 * Parameters: tpnt - Pointer to SCSI host template structure.
626 * Returns: Number of adapters installed.
628 ****************************************************************/
629 int Pci2000_Detect (Scsi_Host_Template *tpnt)
631 int found = 0;
632 int installed = 0;
633 struct Scsi_Host *pshost;
634 PADAPTER2000 padapter;
635 int z, zz;
636 int setirq;
637 #if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
638 struct pci_dev *pdev = NULL;
639 #else
640 UCHAR pci_bus, pci_device_fn;
641 #endif
643 #if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
644 if ( !pci_present () )
645 #else
646 if ( !pcibios_present () )
647 #endif
649 printk ("pci2000: PCI BIOS not present\n");
650 return 0;
653 #if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
654 while ( (pdev = pci_find_device (VENDOR_PSI, DEVICE_ROY_1, pdev)) != NULL )
655 #else
656 while ( !pcibios_find_device (VENDOR_PSI, DEVICE_ROY_1, found, &pci_bus, &pci_device_fn) )
657 #endif
659 pshost = scsi_register (tpnt, sizeof(ADAPTER2000));
660 padapter = HOSTDATA(pshost);
662 #if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
663 padapter->basePort = pci_resource_start (pdev, 1);
664 #else
665 pcibios_read_config_word (pci_bus, pci_device_fn, PCI_BASE_ADDRESS_1, &padapter->basePort);
666 padapter->basePort &= 0xFFFE;
667 #endif
668 DEB (printk ("\nBase Regs = %#04X", padapter->basePort)); // get the base I/O port address
669 padapter->mb0 = padapter->basePort + RTR_MAILBOX; // get the 32 bit mail boxes
670 padapter->mb1 = padapter->basePort + RTR_MAILBOX + 4;
671 padapter->mb2 = padapter->basePort + RTR_MAILBOX + 8;
672 padapter->mb3 = padapter->basePort + RTR_MAILBOX + 12;
673 padapter->mb4 = padapter->basePort + RTR_MAILBOX + 16;
674 padapter->cmd = padapter->basePort + RTR_LOCAL_DOORBELL; // command register
675 padapter->tag = padapter->basePort + RTR_PCI_DOORBELL; // tag/response register
677 if ( WaitReady (padapter) )
678 goto unregister;
679 outb_p (0x84, padapter->mb0);
680 outb_p (CMD_SPECIFY, padapter->cmd);
681 if ( WaitReady (padapter) )
682 goto unregister;
684 #if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
685 pshost->irq = pdev->irq;
686 #else
687 pcibios_read_config_byte (pci_bus, pci_device_fn, PCI_INTERRUPT_LINE, &pshost->irq);
688 #endif
689 setirq = 1;
690 padapter->irqOwned = 0;
691 for ( z = 0; z < installed; z++ ) // scan for shared interrupts
693 if ( PsiHost[z]->irq == pshost->irq ) // if shared then, don't posses
694 setirq = 0;
696 if ( setirq ) // if not shared, posses
698 if ( request_irq (pshost->irq, Irq_Handler, SA_SHIRQ, "pci2000", padapter) < 0 )
700 if ( request_irq (pshost->irq, Irq_Handler, SA_INTERRUPT | SA_SHIRQ, "pci2000", padapter) < 0 )
702 printk ("Unable to allocate IRQ for PCI-2000 controller.\n");
703 goto unregister;
706 padapter->irqOwned = pshost->irq; // set IRQ as owned
708 PsiHost[installed] = pshost; // save SCSI_HOST pointer
710 pshost->io_port = padapter->basePort;
711 pshost->n_io_port = 0xFF;
712 pshost->unique_id = padapter->basePort;
713 pshost->max_id = 16;
714 pshost->max_channel = 1;
716 for ( zz = 0; zz < MAX_BUS; zz++ )
717 for ( z = 0; z < MAX_UNITS; z++ )
718 padapter->dev[zz][z].tag = 0;
720 printk("\nPSI-2000 Intelligent Storage SCSI CONTROLLER: at I/O = %X IRQ = %d\n", padapter->basePort, pshost->irq);
721 printk("Version %s, Compiled %s %s\n\n", PCI2000_VERSION, __DATE__, __TIME__);
722 found++;
723 if ( ++installed < MAXADAPTER )
724 continue;
725 break;
726 unregister:;
727 scsi_unregister (pshost);
728 found++;
730 NumAdapters = installed;
731 return installed;
733 /****************************************************************
734 * Name: Pci2000_Abort
736 * Description: Process the Abort command from the SCSI manager.
738 * Parameters: SCpnt - Pointer to SCSI command structure.
740 * Returns: Allways snooze.
742 ****************************************************************/
743 int Pci2000_Abort (Scsi_Cmnd *SCpnt)
745 DEB (printk ("pci2000_abort\n"));
746 return SCSI_ABORT_SNOOZE;
748 /****************************************************************
749 * Name: Pci2000_Reset
751 * Description: Process the Reset command from the SCSI manager.
753 * Parameters: SCpnt - Pointer to SCSI command structure.
754 * flags - Flags about the reset command
756 * Returns: No active command at this time, so this means
757 * that each time we got some kind of response the
758 * last time through. Tell the mid-level code to
759 * request sense information in order to decide what
760 * to do next.
762 ****************************************************************/
763 int Pci2000_Reset (Scsi_Cmnd *SCpnt, unsigned int reset_flags)
765 return SCSI_RESET_PUNT;
767 /****************************************************************
768 * Name: Pci2000_Release
770 * Description: Release resources allocated for a single each adapter.
772 * Parameters: pshost - Pointer to SCSI command structure.
774 * Returns: zero.
776 ****************************************************************/
777 int Pci2000_Release (struct Scsi_Host *pshost)
779 PADAPTER2000 padapter = HOSTDATA (pshost);
781 if ( padapter->irqOwned )
782 #if LINUX_VERSION_CODE < LINUXVERSION(1,3,70)
783 free_irq (pshost->irq);
784 #else /* version >= v1.3.70 */
785 free_irq (pshost->irq, padapter);
786 #endif /* version >= v1.3.70 */
787 release_region (pshost->io_port, pshost->n_io_port);
788 scsi_unregister(pshost);
789 return 0;
792 #include "sd.h"
793 /****************************************************************
794 * Name: Pci2000_BiosParam
796 * Description: Process the biosparam request from the SCSI manager to
797 * return C/H/S data.
799 * Parameters: disk - Pointer to SCSI disk structure.
800 * dev - Major/minor number from kernel.
801 * geom - Pointer to integer array to place geometry data.
803 * Returns: zero.
805 ****************************************************************/
806 int Pci2000_BiosParam (Scsi_Disk *disk, kdev_t dev, int geom[])
808 PADAPTER2000 padapter;
810 padapter = HOSTDATA(disk->device->host);
812 if ( WaitReady (padapter) )
813 return 0;
814 outb_p (disk->device->id, padapter->mb0);
815 outb_p (CMD_GET_PARMS, padapter->cmd);
816 if ( WaitReady (padapter) )
817 return 0;
819 geom[0] = inb_p (padapter->mb2 + 3);
820 geom[1] = inb_p (padapter->mb2 + 2);
821 geom[2] = inw_p (padapter->mb2);
822 return 0;
826 #ifdef MODULE
827 /* Eventually this will go into an include file, but this will be later */
828 Scsi_Host_Template driver_template = PCI2000;
830 #include "scsi_module.c"
831 #endif