## Automatically generated incremental diff
## From:   linux-2.2.15-pre8
## To:     linux-2.2.15-pre9
## Robot:  $Id: make-incremental-diff,v 1.7 2001/12/04 05:19:54 hpa Exp $

diff -urN linux-2.2.15-pre8/Makefile linux/Makefile
--- linux-2.2.15-pre8/Makefile	Mon Dec  3 21:59:31 2001
+++ linux/Makefile	Mon Dec  3 21:59:37 2001
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 2
 SUBLEVEL = 15
-EXTRAVERSION = pre8
+EXTRAVERSION = pre9
 
 ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
 
diff -urN linux-2.2.15-pre8/arch/alpha/kernel/irq.c linux/arch/alpha/kernel/irq.c
--- linux-2.2.15-pre8/arch/alpha/kernel/irq.c	Mon Dec  3 21:59:31 2001
+++ linux/arch/alpha/kernel/irq.c	Mon Dec  3 21:59:37 2001
@@ -897,7 +897,7 @@
 {
 	wrent(entInt, 0);
 	alpha_mv.init_irq();
-	return memory
+	return memory;
 }
 
 /*
diff -urN linux-2.2.15-pre8/arch/sparc64/defconfig linux/arch/sparc64/defconfig
--- linux-2.2.15-pre8/arch/sparc64/defconfig	Mon Dec  3 21:59:31 2001
+++ linux/arch/sparc64/defconfig	Mon Dec  3 21:59:37 2001
@@ -260,6 +260,7 @@
 CONFIG_RTL8139=m
 CONFIG_NE2K_PCI=m
 CONFIG_EEXPRESS_PRO100=m
+CONFIG_SK98LIN=m
 
 #
 # Unix 98 PTY support
diff -urN linux-2.2.15-pre8/arch/sparc64/kernel/irq.c linux/arch/sparc64/kernel/irq.c
--- linux-2.2.15-pre8/arch/sparc64/kernel/irq.c	Mon Dec  3 21:59:31 2001
+++ linux/arch/sparc64/kernel/irq.c	Mon Dec  3 21:59:37 2001
@@ -1,4 +1,4 @@
-/* $Id: irq.c,v 1.76.2.1 1999/12/05 07:24:37 davem Exp $
+/* $Id: irq.c,v 1.76.2.2 2000/02/17 18:05:36 davem Exp $
  * irq.c: UltraSparc IRQ handling/init/registry.
  *
  * Copyright (C) 1997  David S. Miller  (davem@caip.rutgers.edu)
diff -urN linux-2.2.15-pre8/arch/sparc64/kernel/smp.c linux/arch/sparc64/kernel/smp.c
--- linux-2.2.15-pre8/arch/sparc64/kernel/smp.c	Mon Dec  3 21:59:31 2001
+++ linux/arch/sparc64/kernel/smp.c	Mon Dec  3 21:59:37 2001
@@ -169,7 +169,7 @@
 {
 	trap_init();
 	/* No memory allocation allowed on slave IRQ init */
-	init_IRQ(NULL);
+	init_IRQ(0UL);
 	smp_callin();
 	return cpu_idle(NULL);
 }
diff -urN linux-2.2.15-pre8/drivers/block/ide-cd.c linux/drivers/block/ide-cd.c
--- linux-2.2.15-pre8/drivers/block/ide-cd.c	Mon Dec  3 21:59:31 2001
+++ linux/drivers/block/ide-cd.c	Mon Dec  3 21:59:37 2001
@@ -313,6 +313,10 @@
 		    failed_command->c[0] == SCMD_READ_SUBCHANNEL)
 			return;
 	}
+
+	if (failed_command && (failed_command->c[0] == TEST_UNIT_READY))
+		return;
+
 	if (reqbuf->error_code == 0x70 && reqbuf->sense_key  == 0x02
 	 && ((reqbuf->asc        == 0x3a && reqbuf->ascq       == 0x00) ||
 	     (reqbuf->asc        == 0x04 && reqbuf->ascq       == 0x01)))
diff -urN linux-2.2.15-pre8/drivers/net/sk98lin/skcsum.c linux/drivers/net/sk98lin/skcsum.c
--- linux-2.2.15-pre8/drivers/net/sk98lin/skcsum.c	Mon Dec  3 21:59:31 2001
+++ linux/drivers/net/sk98lin/skcsum.c	Mon Dec  3 21:59:37 2001
@@ -140,11 +140,9 @@
  */
 #ifdef SK_LITTLE_ENDIAN
 #define SKCS_HTON16(Val16)	(((unsigned) (Val16) >> 8) | (((Val16) & 0xFF) << 8))
-#define SKCS_INV_HTON16(Val16)	(Val16)
 #endif	/* SK_LITTLE_ENDIAN */
 #ifdef SK_BIG_ENDIAN
 #define SKCS_HTON16(Val16)	(Val16)
-#define SKCS_INV_HTON16(Val16)	(((unsigned) (Val16) >> 8) | (((Val16) & 0xFF) << 8))
 #endif	/* SK_BIG_ENDIAN */
 #define SKCS_NTOH16(Val16)	SKCS_HTON16(Val16)
 
@@ -644,7 +642,7 @@
 		(unsigned long) SKCS_HTON16(IpDataLength) +
 
 		/* Add the TCP/UDP header checksum. */
-		(unsigned long) SKCS_INV_HTON16(IpDataChecksum);
+		(unsigned long) IpDataChecksum;
 
 	/* Add-in any carries. */
 
diff -urN linux-2.2.15-pre8/drivers/net/sk98lin/skge.c linux/drivers/net/sk98lin/skge.c
--- linux-2.2.15-pre8/drivers/net/sk98lin/skge.c	Mon Dec  3 21:59:31 2001
+++ linux/drivers/net/sk98lin/skge.c	Mon Dec  3 21:59:37 2001
@@ -348,6 +348,7 @@
 SK_AC		*pAC;
 struct pci_dev	*pdev = NULL;
 unsigned long	base_address;
+unsigned short	tmp;
 
 	if (probed)
 		return -ENODEV;
@@ -419,6 +420,15 @@
 
 		base_address = pdev->base_address[0];
 
+#ifdef __sparc_v9__
+		/* SPARC machines do not initialize the chache line size */
+                pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 64);
+		/* SPARC machines do not set "Memory write and invalidate" */
+                pci_read_config_word(pdev, PCI_COMMAND, &tmp);
+		tmp |= PCI_COMMAND_INVALIDATE;
+                pci_write_config_word(pdev, PCI_COMMAND, tmp);
+#endif 
+
 #ifdef SK_BIG_ENDIAN
 		/*
 		 * On big endian machines, we use the adapter's aibility of
@@ -1916,8 +1926,10 @@
 			/* hardware checksum */
 			Type = ntohs(*((short*)&pMsg->data[12]));
 			if (Type == 0x800) {
-				Csum1= pRxd->TcpSums & 0xffff;
-				Csum2=(pRxd->TcpSums >> 16) & 0xffff;
+				/* the hardware calculates the checksums in LITTLE ENDIAN */
+				/* so turn them around for BIG ENDIAN machines */
+				Csum1= le16_to_cpu(pRxd->TcpSums & 0xffff);
+				Csum2= le16_to_cpu((pRxd->TcpSums >> 16) & 0xffff);
 				if ((Csum1 & 0xfffe) && (Csum2 & 0xfffe)) {
 					Result = SkCsGetReceiveInfo(pAC,
 						&pMsg->data[14], 
@@ -3490,8 +3502,10 @@
 		pRlmtMbuf = (SK_MBUF*) Param.pParaPtr;
 		pMsg = (struct sk_buff*) pRlmtMbuf->pOs;
 		skb_put(pMsg, pRlmtMbuf->Length);
-		XmitFrame(pAC, &pAC->TxPort[pRlmtMbuf->PortIdx][TX_PRIO_LOW],
-			pMsg);
+		if (XmitFrame(pAC, &pAC->TxPort[pRlmtMbuf->PortIdx][TX_PRIO_LOW],
+			pMsg) < 0) {
+			dev_kfree_skb(pMsg);
+		}
 		break;
 	default:
 		break;
diff -urN linux-2.2.15-pre8/drivers/scsi/pci2000.c linux/drivers/scsi/pci2000.c
--- linux-2.2.15-pre8/drivers/scsi/pci2000.c	Tue Apr 13 07:54:02 1999
+++ linux/drivers/scsi/pci2000.c	Mon Dec  3 21:59:38 2001
@@ -128,6 +128,28 @@
 	return TRUE;
 	}
 /****************************************************************
+ *	Name:			WaitReadyLong	:LOCAL
+ *
+ *	Description:	Wait for controller ready.
+ *
+ *	Parameters:		padapter - Pointer adapter data structure.
+ *
+ *	Returns:		TRUE on not ready.
+ *
+ ****************************************************************/
+static int WaitReadyLong (PADAPTER2000 padapter)
+	{
+	ULONG	z;
+
+	for ( z = 0;  z < (5000 * 4);  z++ )
+		{
+		if ( !inb_p (padapter->cmd) )
+			return FALSE;
+		udelay (250);
+		};								
+	return TRUE;
+	}
+/****************************************************************
  *	Name:	OpDone	:LOCAL
  *
  *	Description:	Clean up operation and issue done to caller.
@@ -212,7 +234,7 @@
 	if ( WaitReady (padapter) )						// test for command register ready
 		return DID_TIME_OUT;
 	outb_p (cmd, padapter->cmd);					// issue command
-	if ( WaitReady (padapter) )						// wait for adapter ready
+	if ( WaitReadyLong (padapter) )					// wait for adapter ready
 		return DID_TIME_OUT;
 	return DID_OK;
 	}
@@ -810,4 +832,3 @@
 
 #include "scsi_module.c"
 #endif
-
diff -urN linux-2.2.15-pre8/drivers/scsi/pci2220i.c linux/drivers/scsi/pci2220i.c
--- linux-2.2.15-pre8/drivers/scsi/pci2220i.c	Tue Apr 13 07:54:02 1999
+++ linux/drivers/scsi/pci2220i.c	Mon Dec  3 21:59:38 2001
@@ -24,8 +24,15 @@
  *	Revisions 1.11		Mar-26-1999
  *		- Fixed spinlock and PCI configuration.
  *
+ *	Revision 2.00		December-1-1999
+ *		- Added code for the PCI-2240I controller
+ *		- Added code for ATAPI devices.
+ *		- Double buffer for scatter/gather support
+ *
  ****************************************************************************/
 
+//#define DEBUG 1
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
@@ -46,6 +53,7 @@
 #include "scsi.h"
 #include "hosts.h"
 #include "pci2220i.h"
+#include "psi_dale.h"
 
 #if LINUX_VERSION_CODE >= LINUXVERSION(2,1,95)
 #include <asm/spinlock.h>
@@ -54,20 +62,14 @@
 #include <linux/bios32.h>
 #endif
 
-#define	PCI2220I_VERSION		"1.11"
-//#define	READ_CMD				IDE_COMMAND_READ
-//#define	WRITE_CMD				IDE_COMMAND_WRITE
-//#define	MAX_BUS_MASTER_BLOCKS	1		// This is the maximum we can bus master
+#define	PCI2220I_VERSION		"2.00"
 #define	READ_CMD				IDE_CMD_READ_MULTIPLE
 #define	WRITE_CMD				IDE_CMD_WRITE_MULTIPLE
 #define	MAX_BUS_MASTER_BLOCKS	SECTORSXFER		// This is the maximum we can bus master
 
-
 struct proc_dir_entry Proc_Scsi_Pci2220i =
 	{ PROC_SCSI_PCI2220I, 8, "pci2220i", S_IFDIR | S_IRUGO | S_IXUGO, 2 };
 
-//#define DEBUG 1
-
 #ifdef DEBUG
 #define DEB(x) x
 #define STOP_HERE()	{int st;for(st=0;st<100;st++){st=1;}}
@@ -81,10 +83,10 @@
 
 typedef struct
 	{
-	UCHAR		   	device;				// device code
 	UCHAR			byte6;				// device select register image
 	UCHAR			spigot;				// spigot number
-	UCHAR			sparebyte;			// placeholder
+	UCHAR			spigots[2];			// RAID spigots
+	UCHAR			deviceID[2];		// device ID codes
 	USHORT			sectors;			// number of sectors per track
 	USHORT			heads;				// number of heads
 	USHORT			cylinders;			// number of cylinders for this device
@@ -94,12 +96,17 @@
 	ULONG			lastsectorlba[2];	// last addressable sector on the drive
 	USHORT			raid;				// RAID active flag
 	USHORT			mirrorRecon;
-	UCHAR			hotRecon;
+	UCHAR			reconOn;
 	USHORT			reconCount;
+	USHORT			reconIsStarting;	// indicate hot reconstruct is starting
+	UCHAR			cmdDrqInt;			// flag for command interrupt
+	UCHAR			packet;				// command packet size in bytes
 	}	OUR_DEVICE, *POUR_DEVICE;	
 
 typedef struct
 	{
+	USHORT		 bigD;					// identity is a PCI-2240I if true, otherwise a PCI-2220I
+	USHORT		 atapi;					// this interface is for ATAPI devices only
 	USHORT		 regDmaDesc;			// address of the DMA discriptor register for direction of transfer
 	USHORT		 regDmaCmdStat;			// Byte #1 of DMA command status register
 	USHORT		 regDmaAddrPci;			// 32 bit register for PCI address of DMA
@@ -128,16 +135,21 @@
 	USHORT		 timingPIO;				// TRUE if PIO timing is active
 	ULONG		 timingAddress;			// address to use on adapter for current timing mode
 	ULONG		 irqOwned;				// owned IRQ or zero if shared
-	OUR_DEVICE	 device[DALE_MAXDRIVES];
-	DISK_MIRROR	*raidData[8];
+	UCHAR		 numberOfDrives;		// saved number of drives on this controller
+	UCHAR		 failRegister;			// current inverted data in fail register
+	OUR_DEVICE	 device[BIGD_MAXDRIVES];
+	DISK_MIRROR	*raidData[BIGD_MAXDRIVES];
 	ULONG		 startSector;
 	USHORT		 sectorCount;
+	ULONG		 readCount;
+	UCHAR		*currentSgBuffer;
+	ULONG		 currentSgCount;
+	USHORT		 nextSg;
 	UCHAR		 cmd;
 	Scsi_Cmnd	*SCpnt;
-	VOID		*buffer;
 	POUR_DEVICE	 pdev;					// current device opearating on
+	USHORT		 devInReconIndex;
 	USHORT		 expectingIRQ;
-	USHORT		 reconIsStarting;		// indicate hot reconstruct is starting
 	USHORT		 reconOn;				// Hot reconstruct is to be done.
 	USHORT		 reconPhase;			// Hot reconstruct operation is in progress.
 	ULONG		 reconSize;
@@ -147,6 +159,9 @@
 	struct timer_list	reconTimer;	
 	struct timer_list	timer;
 	UCHAR		*kBuffer;
+	UCHAR		 reqSense;
+	UCHAR		 atapiCdb[16];
+	UCHAR		 atapiSpecial;
 	}	ADAPTER2220I, *PADAPTER2220I;
 
 #define HOSTDATA(host) ((PADAPTER2220I)&host->hostdata)
@@ -161,12 +176,41 @@
 
 static struct	Scsi_Host 	   *PsiHost[MAXADAPTER] = {NULL,};  // One for each adapter
 static			int				NumAdapters = 0;
+static			int				Installed = 0;
 static			SETUP			DaleSetup;
-static			DISK_MIRROR		DiskMirror[2];
-static			ULONG			ModeArray[] = {DALE_DATA_MODE2, DALE_DATA_MODE3, DALE_DATA_MODE4, DALE_DATA_MODE4P};
+static			DISK_MIRROR		DiskMirror[BIGD_MAXDRIVES];
+static			ULONG			ModeArray[] = {DALE_DATA_MODE2, DALE_DATA_MODE3, DALE_DATA_MODE4, DALE_DATA_MODE5};
+static			ULONG			ModeArray2[] = {BIGD_DATA_MODE2, BIGD_DATA_MODE3, BIGD_DATA_MODE4, BIGD_DATA_MODE5};
 
 static void ReconTimerExpiry (unsigned long data);
 
+/*******************************************************************************************************
+ *	Name:			Alarm
+ *
+ *	Description:	Sound the for the given device
+ *
+ *	Parameters:		padapter - Pointer adapter data structure.
+ *					device	 - Device number.
+ *	
+ *	Returns:		Nothing.
+ *
+ ******************************************************************************************************/
+static void Alarm (PADAPTER2220I padapter, UCHAR device)
+	{
+	UCHAR	zc;
+
+	if ( padapter->bigD )
+		{
+		zc = device | (FAIL_ANY | FAIL_AUDIBLE);
+		if ( padapter->failRegister & FAIL_ANY ) 
+			zc |= FAIL_MULTIPLE;
+		
+		padapter->failRegister = zc;
+		outb_p (~zc, padapter->regFail);
+		}
+	else
+		outb_p (0x3C | (1 << device), padapter->regFail);			// sound alarm and set fail light		
+	}
 /****************************************************************
  *	Name:	MuteAlarm	:LOCAL
  *
@@ -181,8 +225,16 @@
 	{
 	UCHAR	old;
 
-	old = (inb_p (padapter->regStatSel) >> 3) | (inb_p (padapter->regStatSel) & 0x83);
-	outb_p (old | 0x40, padapter->regFail);
+	if ( padapter->bigD )
+		{
+		padapter->failRegister &= ~FAIL_AUDIBLE;
+		outb_p (~padapter->failRegister, padapter->regFail);
+		}
+	else
+		{
+		old = (inb_p (padapter->regStatSel) >> 3) | (inb_p (padapter->regStatSel) & 0x83);
+		outb_p (old | 0x40, padapter->regFail);
+		}
 	}
 /****************************************************************
  *	Name:	WaitReady	:LOCAL
@@ -223,17 +275,17 @@
 	ULONG	z;
 	UCHAR	status;
 
-	for ( z = 0;  z < (250 * 4);  z++ )				// wait up to 1/4 second
+	for ( z = 0;  z < (125 * 16);  z++ )				// wait up to 1/4 second
 		{
 		status = inb_p (padapter->regStatCmd);
 		if ( (status & (IDE_STATUS_DRDY | IDE_STATUS_BUSY)) == IDE_STATUS_DRDY )
 			{
-			DEB (printk ("\nPCI2220I:  Reset took %ld mSec to be ready", z / 4));
+			DEB (printk ("\nPCI2220I:  Reset took %ld mSec to be ready", z / 8));
 			return 0;
 			}
-		udelay (250);
+		udelay (125);
 		}
-	DEB (printk ("\nPCI2220I:  Reset took more than 1 Second to come ready, Disk Failure"));
+	DEB (printk ("\nPCI2220I:  Reset took more than 2 Seconds to come ready, Disk Failure"));
 	return status;
 	}
 /****************************************************************
@@ -261,6 +313,52 @@
 	return status;
 	}
 /****************************************************************
+ *	Name:	AtapiWaitReady	:LOCAL
+ *
+ *	Description:	Wait for device busy and DRQ to be cleared.
+ *
+ *	Parameters:		padapter - Pointer adapter data structure.
+ *					msec	 - Number of milliseconds to wait.
+ *
+ *	Returns:		TRUE if drive does not clear busy in time.
+ *
+ ****************************************************************/
+static int AtapiWaitReady (PADAPTER2220I padapter, int msec)
+	{
+	int z;
+
+	for ( z = 0;  z < (msec * 16);  z++ )
+		{
+		if ( !(inb_p (padapter->regStatCmd) & (IDE_STATUS_BUSY | IDE_STATUS_DRQ)) )
+			return FALSE;
+		udelay (125);
+		}
+	return TRUE;
+	}
+/****************************************************************
+ *	Name:	AtapiWaitDrq	:LOCAL
+ *
+ *	Description:	Wait for device ready for data transfer.
+ *
+ *	Parameters:		padapter - Pointer adapter data structure.
+ *					msec	 - Number of milliseconds to wait.
+ *
+ *	Returns:		TRUE if drive does not assert DRQ in time.
+ *
+ ****************************************************************/
+static int AtapiWaitDrq (PADAPTER2220I padapter, int msec)
+	{
+	ULONG	z;
+
+	for ( z = 0;  z < (msec * 16);  z++ )
+		{
+		if ( inb_p (padapter->regStatCmd) & IDE_STATUS_DRQ )
+			return 0;
+		udelay (128);
+		}
+	return TRUE;
+	}
+/****************************************************************
  *	Name:	HardReset	:LOCAL
  *
  *	Description:	Wait for device ready for data transfer.
@@ -274,24 +372,113 @@
  ****************************************************************/
 static int HardReset (PADAPTER2220I padapter, POUR_DEVICE pdev, UCHAR spigot)
 	{
-	SelectSpigot (padapter, spigot | 0x80);
+	DEB (printk ("\npci2220i:RESET  spigot = %X  devices = %d, %d", spigot, pdev->deviceID[0], pdev->deviceID[1]));
+	udelay (100000);										// just wait 100 mSec to let drives flush	
+	SelectSpigot (padapter, spigot | SEL_IRQ_OFF);
 	
 	outb_p (0x0E, padapter->regAltStat);					// reset the suvivor
 	udelay (100);											// wait a little	
 	outb_p (0x08, padapter->regAltStat);					// clear the reset
 	udelay (100);
-	outb_p (0xA0, padapter->regLba24);						//Specify drive
 
-	outb_p (pdev->byte6, padapter->regLba24);				// select the drive
+	outb_p (0xA0, padapter->regLba24);						// select the master drive
 	if ( WaitReadyReset (padapter) )
+		{
+		DEB (printk ("\npci2220i: master not ready after reset"));
 		return TRUE;
+		}
+	outb_p (0xB0, padapter->regLba24);						// try the slave drive
+	if ( (inb_p (padapter->regStatCmd) & (IDE_STATUS_DRDY | IDE_STATUS_BUSY)) == IDE_STATUS_DRDY ) 
+		{
+		DEB (printk ("\nPCI2220I: initializing slave drive on spigot %X", spigot));
+		outb_p (SECTORSXFER, padapter->regSectCount);
+		WriteCommand (padapter, IDE_CMD_SET_MULTIPLE);	
+		if ( WaitReady (padapter) )
+			{
+			DEB (printk ("\npci2220i: slave not ready after set multiple"));
+			return TRUE;
+			}
+		}
+	
+	outb_p (0xA0, padapter->regLba24);				// select the drive
 	outb_p (SECTORSXFER, padapter->regSectCount);
 	WriteCommand (padapter, IDE_CMD_SET_MULTIPLE);	
 	if ( WaitReady (padapter) )
+		{
+		DEB (printk ("\npci2220i: master not ready after set multiple"));
+		return TRUE;
+		}
+	return FALSE;
+	}
+/****************************************************************
+ *	Name:	AtapiReset	:LOCAL
+ *
+ *	Description:	Wait for device ready for data transfer.
+ *
+ *	Parameters:		padapter - Pointer adapter data structure.
+ *					pdev	 - Pointer to device.
+ *
+ *	Returns:		TRUE if drive does not come ready.
+ *
+ ****************************************************************/
+static int AtapiReset (PADAPTER2220I padapter, POUR_DEVICE pdev)
+	{
+	SelectSpigot (padapter, pdev->spigot);
+	AtapiDevice (padapter, pdev->byte6);
+	AtapiCountLo (padapter, 0);
+	AtapiCountHi (padapter, 0);
+	WriteCommand (padapter, IDE_COMMAND_ATAPI_RESET);
+	udelay (125);
+	if ( AtapiWaitReady (padapter, 1000) )
+		return TRUE;
+	if ( inb_p (padapter->regStatCmd) || (inb_p (padapter->regLba8) != 0x14) || (inb_p (padapter->regLba16) != 0xEB) )
 		return TRUE;
 	return FALSE;
 	}
 /****************************************************************
+ *	Name:	WalkScatGath	:LOCAL
+ *
+ *	Description:	Transfer data to/from scatter/gather buffers.
+ *
+ *	Parameters:		padapter - Pointer adapter data structure.
+ *					datain   - TRUE if data read.
+ *					length   - Number of bytes to transfer.
+ *
+ *	Returns:		Nothing.
+ *
+ ****************************************************************/
+static void WalkScatGath (PADAPTER2220I padapter, UCHAR datain, ULONG length)
+	{
+	ULONG	 count;
+	UCHAR	*buffer = padapter->kBuffer;
+
+	while ( length )
+		{
+		count = ( length > padapter->currentSgCount ) ? padapter->currentSgCount : length; 
+		
+		if ( datain )
+			memcpy (padapter->currentSgBuffer, buffer, count);
+		else
+			memcpy (buffer, padapter->currentSgBuffer, count);
+
+		padapter->currentSgCount -= count;
+		if ( !padapter->currentSgCount )
+			{
+			if ( padapter->nextSg < padapter->SCpnt->use_sg )
+				{
+				padapter->currentSgBuffer = ((struct scatterlist *)padapter->SCpnt->request_buffer)[padapter->nextSg].address;
+				padapter->currentSgCount = ((struct scatterlist *)padapter->SCpnt->request_buffer)[padapter->nextSg].length;
+				padapter->nextSg++;
+				}
+			}
+		else
+			padapter->currentSgBuffer += count;
+
+		length -= count;
+		buffer += count;
+		}
+	}
+/****************************************************************
  *	Name:	BusMaster	:LOCAL
  *
  *	Description:	Do a bus master I/O.
@@ -300,34 +487,84 @@
  *					datain	 - TRUE if data read.
  *					irq		 - TRUE if bus master interrupt expected.
  *
- *	Returns:		TRUE if drive does not assert DRQ in time.
+ *	Returns:		Nothing.
  *
  ****************************************************************/
 static void BusMaster (PADAPTER2220I padapter, UCHAR datain, UCHAR irq)
 	{
 	ULONG zl;
 	
-	outl (padapter->timingAddress, padapter->regDmaAddrLoc);
-	outl (virt_to_bus (padapter->buffer), padapter->regDmaAddrPci);
-	zl = (padapter->sectorCount > MAX_BUS_MASTER_BLOCKS) ? MAX_BUS_MASTER_BLOCKS : padapter->sectorCount;
+	zl = ( padapter->sectorCount > MAX_BUS_MASTER_BLOCKS ) ? MAX_BUS_MASTER_BLOCKS : padapter->sectorCount;
 	padapter->sectorCount -= zl;
 	zl *= (ULONG)BYTES_PER_SECTOR;
-	padapter->buffer += zl;
-	outl (zl, padapter->regDmaCount);
+
 	if ( datain )
 		{
-		outb_p (8, padapter->regDmaDesc);						// read operation
-		if ( irq && !padapter->sectorCount )
-			outb_p (5, padapter->regDmaMode);					// interrupt on
+		padapter->readCount = zl;
+		outb_p (8, padapter->regDmaDesc);							// read operation
+		if ( padapter->bigD )
+			{
+			if ( irq && !padapter->sectorCount )
+				outb_p (0x0C, padapter->regDmaMode);				// interrupt on
+			else
+				outb_p (0x08, padapter->regDmaMode);				// no interrupt
+			}
+		else 
+			{
+			if ( irq && !padapter->sectorCount )
+				outb_p (0x05, padapter->regDmaMode);				// interrupt on
+			else
+				outb_p (0x01, padapter->regDmaMode);				// no interrupt
+			}
+		}
+	else
+		{
+		outb_p (0x00, padapter->regDmaDesc);						// write operation
+		if ( padapter->bigD )
+			outb_p (0x08, padapter->regDmaMode);					// no interrupt						
 		else
-			outb_p (1, padapter->regDmaMode);					// no interrupt
+			outb_p (0x01, padapter->regDmaMode);					// no interrupt
+		WalkScatGath (padapter, FALSE, zl);	
+		}
+	
+	outl (padapter->timingAddress, padapter->regDmaAddrLoc);
+	outl (virt_to_bus (padapter->kBuffer), padapter->regDmaAddrPci);
+	outl (zl, padapter->regDmaCount);
+	outb_p (0x03, padapter->regDmaCmdStat);							// kick the DMA engine in gear
+	}
+/****************************************************************
+ *	Name:	AtapiBusMaster	:LOCAL
+ *
+ *	Description:	Do a bus master I/O.
+ *
+ *	Parameters:		padapter - Pointer adapter data structure.
+ *					datain	 - TRUE if data read.
+ *					length	 - Number of bytes to transfer.
+ *
+ *	Returns:		Nothing.
+ *
+ ****************************************************************/
+static void AtapiBusMaster (PADAPTER2220I padapter, UCHAR datain, ULONG length)
+	{
+	outl (padapter->timingAddress, padapter->regDmaAddrLoc);
+	outl (virt_to_bus (padapter->kBuffer), padapter->regDmaAddrPci);
+	outl (length, padapter->regDmaCount);
+	if ( datain )
+		{
+		if ( padapter->readCount )
+				WalkScatGath (padapter, TRUE, padapter->readCount);
+		outb_p (0x08, padapter->regDmaDesc);						// read operation
+		outb_p (0x08, padapter->regDmaMode);						// no interrupt
+		padapter->readCount = length;
 		}
 	else
 		{
-		outb_p (0, padapter->regDmaDesc);						// write operation
-		outb_p (1, padapter->regDmaMode);						// no interrupt
+		outb_p (0x00, padapter->regDmaDesc);						// write operation
+		outb_p (0x08, padapter->regDmaMode);						// no interrupt						
+		if ( !padapter->atapiSpecial )
+			WalkScatGath (padapter, FALSE, length);	
 		}
-	outb_p (0x03, padapter->regDmaCmdStat);						// kick the DMA engine in gear
+	outb_p (0x03, padapter->regDmaCmdStat);							// kick the DMA engine in gear
 	}
 /****************************************************************
  *	Name:	WriteData	:LOCAL
@@ -348,9 +585,9 @@
 		if ( padapter->timingPIO )
 			{
 			zl = (padapter->sectorCount > MAX_BUS_MASTER_BLOCKS) ? MAX_BUS_MASTER_BLOCKS : padapter->sectorCount;
-			outsw (padapter->regData, padapter->buffer, zl * (BYTES_PER_SECTOR / 2));
+			WalkScatGath (padapter, FALSE, zl * BYTES_PER_SECTOR);
+			outsw (padapter->regData, padapter->kBuffer, zl * (BYTES_PER_SECTOR / 2));
 			padapter->sectorCount -= zl;
-			padapter->buffer += zl * BYTES_PER_SECTOR;
 			}
 		else
 			BusMaster (padapter, 0, 0);
@@ -364,31 +601,32 @@
  *
  *	Description:	Write data to device.
  *
- *	Parameters:		padapter - Pointer adapter data structure.
+ *	Parameters:		padapter - Pointer to adapter structure.
+ *					pdev	 - Pointer to device structure
  *
- *	Returns:		TRUE if drive does not assert DRQ in time.
+ *	Returns:		Index + 1 of drive not failed or zero for OK.
  *
  ****************************************************************/
-static int WriteDataBoth (PADAPTER2220I padapter)
+static int WriteDataBoth (PADAPTER2220I padapter, POUR_DEVICE pdev)
 	{
 	ULONG	zl;
 	UCHAR	status0, status1;
 
-	SelectSpigot (padapter, 1);
+	SelectSpigot (padapter, pdev->spigots[0]);
 	status0 = WaitDrq (padapter);
 	if ( !status0 )
 		{
-		SelectSpigot (padapter, 2);
+		SelectSpigot (padapter, pdev->spigots[1]);
 		status1 = WaitDrq (padapter);
 		if ( !status1 )
 			{
-			SelectSpigot (padapter, 3);
+			SelectSpigot (padapter, pdev->spigots[0] | pdev->spigots[1] | padapter->bigD);
 			if ( padapter->timingPIO )
 				{
 				zl = (padapter->sectorCount > MAX_BUS_MASTER_BLOCKS) ? MAX_BUS_MASTER_BLOCKS : padapter->sectorCount;
-				outsw (padapter->regData, padapter->buffer, zl * (BYTES_PER_SECTOR / 2));
+				WalkScatGath (padapter, FALSE, zl * BYTES_PER_SECTOR);
+				outsw (padapter->regData, padapter->kBuffer, zl * (BYTES_PER_SECTOR / 2));
 				padapter->sectorCount -= zl;
-				padapter->buffer += zl * BYTES_PER_SECTOR;
 				}
 			else
 				BusMaster (padapter, 0, 0);
@@ -397,8 +635,8 @@
 		}
 	padapter->cmd = 0;												// null out the command byte
 	if ( status0 )
-		return 1;
-	return 2;
+		return 2;
+	return 1;
 	}
 /****************************************************************
  *	Name:	IdeCmd	:LOCAL
@@ -415,7 +653,7 @@
 	{
 	UCHAR	status;
 
-	SelectSpigot (padapter, pdev->spigot);							// select the spigot
+	SelectSpigot (padapter, pdev->spigot | padapter->bigD);							// select the spigot
 	outb_p (pdev->byte6 | ((UCHAR *)(&padapter->startSector))[3], padapter->regLba24);			// select the drive
 	status = WaitReady (padapter);
 	if ( !status )
@@ -438,26 +676,27 @@
  *	Description:	Process an IDE command to both drivers.
  *
  *	Parameters:		padapter - Pointer adapter data structure.
+ *					pdev	 - Pointer to device structure
  *
- *	Returns:		Zero if no error or spigot of error.
+ *	Returns:		Index + 1 of drive not failed or zero for OK.
  *
  ****************************************************************/
-static UCHAR IdeCmdBoth (PADAPTER2220I padapter)
+static UCHAR IdeCmdBoth (PADAPTER2220I padapter, POUR_DEVICE pdev)
 	{
 	UCHAR	status0;
 	UCHAR	status1;
 
-	SelectSpigot (padapter, 3);										// select the spigots
+	SelectSpigot (padapter, pdev->spigots[0] | pdev->spigots[1]);								// select the spigots
 	outb_p (padapter->pdev->byte6 | ((UCHAR *)(&padapter->startSector))[3], padapter->regLba24);// select the drive
-	SelectSpigot (padapter, 1);
+	SelectSpigot (padapter, pdev->spigots[0]);
 	status0 = WaitReady (padapter);
 	if ( !status0 )
 		{
-		SelectSpigot (padapter, 2);
+		SelectSpigot (padapter, pdev->spigots[1]);
 		status1 = WaitReady (padapter);
 		if ( !status1 )
 			{
-			SelectSpigot (padapter, 3);
+			SelectSpigot (padapter, pdev->spigots[0] | pdev->spigots[1] | padapter->bigD);
 			outb_p (padapter->sectorCount, padapter->regSectCount);
 			outb_p (((UCHAR *)(&padapter->startSector))[0], padapter->regLba0);
 			outb_p (((UCHAR *)(&padapter->startSector))[1], padapter->regLba8);
@@ -469,8 +708,8 @@
 		}
 	padapter->cmd = 0;									// null out the command byte
 	if ( status0 )
-		return 1;
-	return 2;
+		return 2;
+	return 1;
 	}
 /****************************************************************
  *	Name:	OpDone	:LOCAL
@@ -507,6 +746,7 @@
 		{
 		padapter->cmd = 0;
 		padapter->SCpnt = NULL;	
+		padapter->pdev = NULL;
 		SCpnt->result = result;
 		SCpnt->scsi_done (SCpnt);
 		if ( padapter->reconOn && !padapter->reconTimer.data )
@@ -533,8 +773,8 @@
 	{
 	PIDENTIFY_DATA	pid = (PIDENTIFY_DATA)padapter->kBuffer;
 
-	SelectSpigot (padapter, spigot | 0x80);						// select the spigot
-	outb_p (device << 4, padapter->regLba24);				// select the drive
+	SelectSpigot (padapter, spigot | SEL_IRQ_OFF);					// select the spigot
+	outb_p ((device << 4) | 0xA0, padapter->regLba24);				// select the drive
 	if ( WaitReady (padapter) )
 		return 0;
 	WriteCommand (padapter, IDE_COMMAND_IDENTIFY);	
@@ -544,6 +784,192 @@
 	return (pid->LBATotalSectors - 1);
 	}
 /****************************************************************
+ *	Name:	AtapiIdentify	:LOCAL
+ *
+ *	Description:	Do an intline inquiry on a drive.
+ *
+ *	Parameters:		padapter - Pointer to host data block.
+ *					pdev	 - Pointer to device table.
+ *
+ *	Returns:		TRUE on error.
+ *
+ ****************************************************************/
+static ULONG AtapiIdentify (PADAPTER2220I padapter, POUR_DEVICE pdev)
+	{
+	ATAPI_GENERAL_0		ag0;
+	USHORT				zs;
+	int					z;
+
+	AtapiDevice (padapter, pdev->byte6);	
+	WriteCommand (padapter, IDE_COMMAND_ATAPI_IDENTIFY);	
+	if ( AtapiWaitDrq (padapter, 3000) )
+		return TRUE;
+
+	*(USHORT *)&ag0 = inw_p (padapter->regData);
+	for ( z = 0;  z < 255;  z++ )
+		zs = inw_p (padapter->regData);
+
+	if ( ag0.ProtocolType == 2 )
+		{
+		if ( ag0.CmdDrqType == 1 )
+			pdev->cmdDrqInt = TRUE;
+		switch ( ag0.CmdPacketSize )
+			{
+			case 0:
+				pdev->packet = 6;
+				break;
+			case 1:
+				pdev->packet = 8;
+				break;
+			default:
+				pdev->packet = 6;
+				break;
+			}
+		return FALSE;
+		}
+	return TRUE;
+	}
+/****************************************************************
+ *	Name:	Atapi2Scsi
+ *
+ *	Description:	Convert ATAPI data to SCSI data.
+ *
+ *	Parameters:		padapter - Pointer adapter data structure.
+ *					SCpnt	 - Pointer to SCSI command structure.
+ *
+ *	Returns:		Nothing.
+ *
+ ****************************************************************/
+void Atapi2Scsi (PADAPTER2220I padapter, Scsi_Cmnd *SCpnt)
+	{
+	UCHAR	*buff = padapter->currentSgBuffer;
+ 
+	switch ( SCpnt->cmnd[0] )
+		{
+		case SCSIOP_MODE_SENSE:
+			buff[0] = padapter->kBuffer[1];
+			buff[1] = padapter->kBuffer[2];
+			buff[2] = padapter->kBuffer[3];
+			buff[3] = padapter->kBuffer[7];
+			memcpy (&buff[4], &padapter->kBuffer[8], padapter->atapiCdb[8] - 8);
+			break;
+		case SCSIOP_INQUIRY:
+			padapter->kBuffer[2] = 2;
+			memcpy (buff, padapter->kBuffer, padapter->currentSgCount);
+			break;		
+		default:
+			if ( padapter->readCount )
+				WalkScatGath (padapter, TRUE, padapter->readCount);
+			break;
+		}
+	}
+/****************************************************************
+ *	Name:	Scsi2Atapi
+ *
+ *	Description:	Convert SCSI packet command to Atapi packet command.
+ *
+ *	Parameters:		padapter - Pointer adapter data structure.
+ *					SCpnt	 - Pointer to SCSI command structure.
+ *
+ *	Returns:		Nothing.
+ *
+ ****************************************************************/
+static void Scsi2Atapi (PADAPTER2220I padapter, Scsi_Cmnd *SCpnt)
+	{
+	UCHAR	*cdb = SCpnt->cmnd;
+	UCHAR	*buff = padapter->currentSgBuffer;
+
+	switch (cdb[0]) 
+		{
+		case SCSIOP_READ6:
+            padapter->atapiCdb[0] = SCSIOP_READ;
+			padapter->atapiCdb[1] = cdb[1] & 0xE0;
+            padapter->atapiCdb[3] = cdb[1] & 0x1F;
+			padapter->atapiCdb[4] = cdb[2];
+			padapter->atapiCdb[5] = cdb[3];
+			padapter->atapiCdb[8] = cdb[4];
+			padapter->atapiCdb[9] = cdb[5];
+			break;
+		case SCSIOP_WRITE6:
+            padapter->atapiCdb[0] = SCSIOP_WRITE;
+			padapter->atapiCdb[1] = cdb[1] & 0xE0;
+            padapter->atapiCdb[3] = cdb[1] & 0x1F;
+			padapter->atapiCdb[4] = cdb[2];
+			padapter->atapiCdb[5] = cdb[3];
+			padapter->atapiCdb[8] = cdb[4];
+			padapter->atapiCdb[9] = cdb[5];
+			break;
+        case SCSIOP_MODE_SENSE: 
+            padapter->atapiCdb[0] = SCSIOP_MODE_SENSE10;
+			padapter->atapiCdb[2] = cdb[2];
+			padapter->atapiCdb[8] = cdb[4] + 4;
+            break;
+
+        case SCSIOP_MODE_SELECT: 
+			padapter->atapiSpecial = TRUE;
+			padapter->atapiCdb[0] = SCSIOP_MODE_SELECT10;
+			padapter->atapiCdb[1] = cdb[1] | 0x10;
+			memcpy (padapter->kBuffer, buff, 4);
+			padapter->kBuffer[4] = padapter->kBuffer[5] = 0;
+			padapter->kBuffer[6] = padapter->kBuffer[7] = 0;
+			memcpy (&padapter->kBuffer[8], &buff[4], cdb[4] - 4);
+			padapter->atapiCdb[8] = cdb[4] + 4;
+			break;
+	    }
+	}
+/****************************************************************
+ *	Name:	AtapiSendCdb
+ *
+ *	Description:	Send the CDB packet to the device.
+ *
+ *	Parameters:		padapter - Pointer adapter data structure.
+ *					pdev	 - Pointer to device.
+ *					cdb		 - Pointer to 16 byte SCSI cdb.
+ *
+ *	Returns:		Nothing.
+ *
+ ****************************************************************/
+static void AtapiSendCdb (PADAPTER2220I padapter, POUR_DEVICE pdev, CHAR *cdb)
+	{
+	DEB (printk ("\nPCI2242I: CDB: %X %X %X %X %X %X %X %X %X %X %X %X", cdb[0], cdb[1], cdb[2], cdb[3], cdb[4], cdb[5], cdb[6], cdb[7], cdb[8], cdb[9], cdb[10], cdb[11]));
+	outsw (padapter->regData, cdb, pdev->packet);
+	}
+/****************************************************************
+ *	Name:	AtapiRequestSense
+ *
+ *	Description:	Send the CDB packet to the device.
+ *
+ *	Parameters:		padapter - Pointer adapter data structure.
+ *					pdev	 - Pointer to device.
+ *					SCpnt	 - Pointer to SCSI command structure.
+ *					pass	 - If true then this is the second pass to send cdb.
+ *
+ *	Returns:		TRUE on error.
+ *
+ ****************************************************************/
+static int AtapiRequestSense (PADAPTER2220I padapter, POUR_DEVICE pdev, Scsi_Cmnd *SCpnt, UCHAR pass)
+	{
+	UCHAR	cdb[16] = {SCSIOP_REQUEST_SENSE,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0};		
+	
+	DEB (printk ("\nPCI2242I: AUTO REQUEST SENSE"));
+	cdb[4] = (UCHAR)(sizeof (SCpnt->sense_buffer));
+	if ( !pass )
+		{
+		padapter->reqSense = TRUE;
+	 	AtapiCountLo (padapter, cdb[4]);						
+		AtapiCountHi (padapter, 0);						
+		outb_p (0, padapter->regError);						
+		WriteCommand (padapter, IDE_COMMAND_ATAPI_PACKET);
+		if ( pdev->cmdDrqInt )
+			return FALSE;
+
+		if ( AtapiWaitDrq (padapter, 500) )
+			return TRUE;
+		}
+	AtapiSendCdb (padapter, pdev, cdb);	
+	return FALSE;
+	}
+/****************************************************************
  *	Name:	InlineReadSignature	:LOCAL
  *
  *	Description:	Do an inline read RAID sigature.
@@ -558,10 +984,9 @@
 static UCHAR InlineReadSignature (PADAPTER2220I padapter, POUR_DEVICE pdev, int index)
 	{
 	UCHAR	status;
-	UCHAR	spigot = 1 << index;
 	ULONG	zl = pdev->lastsectorlba[index];
 
-	SelectSpigot (padapter, spigot | 0x80);				// select the spigot without interrupts
+	SelectSpigot (padapter, pdev->spigots[index] | SEL_IRQ_OFF);	// select the spigot without interrupts
 	outb_p (pdev->byte6 | ((UCHAR *)&zl)[3], padapter->regLba24);		
 	status = WaitReady (padapter);
 	if ( !status )
@@ -600,6 +1025,10 @@
 	UCHAR			error;
 
 	padapter->expectingIRQ = 0;
+#ifdef DEBUG
+	printk (" @@@@@@  status: %X @@@@@@@ ", status);
+	STOP_HERE();	
+#endif
 	if ( status & IDE_STATUS_WRITE_FAULT )
 		{
 		return DID_PARITY << 16;
@@ -687,25 +1116,33 @@
  ******************************************************************************************************/
 static int InitFailover (PADAPTER2220I padapter, POUR_DEVICE pdev)
 	{
-	UCHAR			 spigot;
+	UCHAR	spigot;
 	
-	DEB (printk ("\npci2220i:  Initialize failover process - survivor = %d", padapter->survivor));
+	DEB (printk ("\npci2220i:  Initialize failover process - survivor = %d", pdev->deviceID[padapter->survivor]));
 	pdev->raid = FALSE;									//initializes system for non raid mode
-	pdev->hotRecon = 0;
-	padapter->reconOn = FALSE;
-	spigot = (padapter->survivor) ? 2 : 1;	
+	pdev->reconOn = FALSE;
+	spigot = pdev->spigots[padapter->survivor];	
 
 	if ( pdev->DiskMirror[padapter->survivor].status & UCBF_REBUILD )
-		return (TRUE); 	
+		{
+		DEB (printk ("\n         failed, is survivor"));
+		return (TRUE); 
+		}
 
 	if ( HardReset (padapter, pdev, spigot) )
+		{
+		DEB (printk ("\n         failed, reset"));
 		return TRUE;
+		}
 
-	outb_p (0x3C | spigot, padapter->regFail);			// sound alarm and set fail light		
+	Alarm (padapter, pdev->deviceID[padapter->survivor ^ 1]);
 	pdev->DiskMirror[padapter->survivor].status = UCBF_MIRRORED | UCBF_SURVIVOR;	//clear present status
 	
 	if ( WriteSignature (padapter, pdev, spigot, padapter->survivor) )
+		{
+		DEB (printk ("\n         failed, write signature"));
 		return TRUE;
+		}
 	padapter->failinprog = TRUE;
 	return FALSE;
 	}
@@ -758,7 +1195,7 @@
 			{
 			case RECON_PHASE_MARKING:
 			case RECON_PHASE_LAST:
-				padapter->survivor = (pdev->spigot ^ 3) >> 1;
+				padapter->survivor = ( pdev->spigot == pdev->spigots[0] ) ? 1 : 0;
 				DEB (printk ("\npci2220i: FAILURE 1"));
 				if ( InitFailover (padapter, pdev) )
 					OpDone (padapter, DID_ERROR << 16);
@@ -769,7 +1206,7 @@
 				goto timerExpiryDone;
 
 			case RECON_PHASE_COPY:
-				padapter->survivor = (pdev->spigot) >> 1;
+				padapter->survivor = ( pdev->spigot == pdev->spigots[0] ) ? 0 : 1;
 				DEB (printk ("\npci2220i: FAILURE 2"));
 				DEB (printk ("\n       spig/stat = %X", inb_p (padapter->regStatSel));
 				if ( InitFailover (padapter, pdev) )
@@ -777,14 +1214,14 @@
 				goto timerExpiryDone;
 
 			case RECON_PHASE_UPDATE:
-				padapter->survivor = (pdev->spigot) >> 1;
+				padapter->survivor = ( pdev->spigot == pdev->spigots[0] ) ? 0 : 1;
 				DEB (printk ("\npci2220i: FAILURE 3")));
 				if ( InitFailover (padapter, pdev) )
 					OpDone (padapter, DID_ERROR << 16);
 				goto timerExpiryDone;
 
 			case RECON_PHASE_END:
-				padapter->survivor = (pdev->spigot) >> 1;
+				padapter->survivor = ( pdev->spigot == pdev->spigots[0] ) ? 0 : 1;
 				DEB (printk ("\npci2220i: FAILURE 4"));
 				if ( InitFailover (padapter, pdev) )
 					OpDone (padapter, DID_ERROR << 16);
@@ -803,17 +1240,21 @@
 			if ( padapter->cmd == WRITE_CMD )
 				{
 				DEB (printk ("in RAID write operation"));
-				if ( inb_p (padapter->regStatSel) & 1 )
+				temp = ( pdev->spigot & (SEL_1 | SEL_2) ) ? SEL_1 : SEL_3;
+				if ( inb_p (padapter->regStatSel) & temp )
 					{
-					SelectSpigot (padapter, 0x81 ); // Masking the interrupt during spigot select
+					DEB (printk ("\npci2220i: Determined A OK"));
+					SelectSpigot (padapter, temp | SEL_IRQ_OFF); // Masking the interrupt during spigot select
 					temp = inb_p (padapter->regStatCmd);
 					}
 				else
 					temp = IDE_STATUS_BUSY;
 
-				if ( inb (padapter->regStatSel) & 2 )
+				temp1 = ( pdev->spigot & (SEL_1 | SEL_2) ) ? SEL_2 : SEL_4;
+				if ( inb (padapter->regStatSel) & temp1 )
 					{
-					SelectSpigot (padapter, 0x82 ); // Masking the interrupt during spigot select
+					DEB (printk ("\npci2220i: Determined B OK"));
+					SelectSpigot (padapter, temp1 | SEL_IRQ_OFF); // Masking the interrupt during spigot select
 					temp1 = inb_p (padapter->regStatCmd);
 					}
 				else
@@ -821,6 +1262,7 @@
 			
 				if ( (temp & IDE_STATUS_BUSY) || (temp1 & IDE_STATUS_BUSY) )
 					{
+					DEB (printk ("\npci2220i: Status A: %X   B: %X", temp & 0xFF, temp1 & 0xFF));
 	 				if ( (temp & IDE_STATUS_BUSY) && (temp1 & IDE_STATUS_BUSY) ) 
 						{
 						status = temp;
@@ -828,11 +1270,10 @@
 						}		
 					else	
 						{
-						if (temp & IDE_STATUS_BUSY)
+						if ( temp & IDE_STATUS_BUSY )
 							padapter->survivor = 1;
 						else
 							padapter->survivor = 0;
-						DEB (printk ("\npci2220i: FAILURE 5"));
 						if ( InitFailover (padapter, pdev) )
 							{
 							status = inb_p (padapter->regStatCmd);
@@ -845,7 +1286,7 @@
 			else
 				{
 				DEB (printk ("in RAID read operation"));
-				padapter->survivor = (pdev->spigot ^ 3) >> 1;
+				padapter->survivor = ( pdev->spigot == pdev->spigots[0] ) ? 0 : 1;
 				DEB (printk ("\npci2220i: FAILURE 6"));
 				if ( InitFailover (padapter, pdev) )
 					{
@@ -898,7 +1339,6 @@
 	pdev->DiskMirror[index ^ 1].status = UCBF_MIRRORED | UCBF_REBUILD;
 	pdev->DiskMirror[index ^ 1].reconstructPoint = 0;						// start the reconstruct
 	pdev->reconCount = 1990;												// mark target drive early
-	pdev->hotRecon = 1 >> index;
 	return pdev->DiskMirror[index].reconstructPoint;
 	}
 /****************************************************************
@@ -920,6 +1360,7 @@
 	USHORT			minmode;
 	ULONG			zl;
 	UCHAR			zc;
+	USHORT			z;
 #if LINUX_VERSION_CODE < LINUXVERSION(2,1,95)
     int				flags;
 #else /* version >= v2.1.95 */
@@ -942,23 +1383,43 @@
 	if ( padapter->SCpnt )
 		goto reconTimerExpiry;
 
-	pdev = padapter->device;
-	pid = (PIDENTIFY_DATA)padapter->kBuffer;
 	padapter->reconTimer.data = 0;
+	for ( z = padapter->devInReconIndex + 1;  z < BIGD_MAXDRIVES;  z++ )
+		{
+		if ( padapter->device[z].reconOn )
+			break;
+		}
+	if ( z < BIGD_MAXDRIVES )
+		pdev = &padapter->device[z];
+	else
+		{
+		for ( z = 0;  z < BIGD_MAXDRIVES;  z++ )
+			{
+			if ( padapter->device[z].reconOn )
+				break;
+			}
+		if ( z < BIGD_MAXDRIVES )
+			pdev = &padapter->device[z];
+		else
+			{
+			padapter->reconOn = FALSE;
+			goto reconTimerExpiry;
+			}
+		}
+
+	padapter->devInReconIndex = z;
+	pid = (PIDENTIFY_DATA)padapter->kBuffer;
 	padapter->pdev = pdev;
-	if ( padapter->reconIsStarting )
+	if ( pdev->reconIsStarting )
 		{
-		padapter->reconIsStarting = FALSE;
-		padapter->reconOn = FALSE;
-		pdev->hotRecon = FALSE;
+		pdev->reconIsStarting = FALSE;
+		pdev->reconOn = FALSE;
 
-		if ( (pdev->DiskMirror[0].signature == SIGNATURE) && (pdev->DiskMirror[1].signature == SIGNATURE) &&
+		while ( (pdev->DiskMirror[0].signature == SIGNATURE) && (pdev->DiskMirror[1].signature == SIGNATURE) &&
 			 (pdev->DiskMirror[0].pairIdentifier == (pdev->DiskMirror[1].pairIdentifier ^ 1)) )
 			{
 			if ( (pdev->DiskMirror[0].status & UCBF_MATCHED) && (pdev->DiskMirror[1].status & UCBF_MATCHED) )
-				{
-				goto reconTimerExpiry;
-				}
+				break;;
 
 			if ( pdev->DiskMirror[0].status & UCBF_SURVIVOR )				// is first drive survivor?
 				testsize = SetReconstruct (pdev, 0);
@@ -969,33 +1430,38 @@
 			if ( (pdev->DiskMirror[0].status & UCBF_REBUILD) || (pdev->DiskMirror[1].status & UCBF_REBUILD) )
 				{
 				if ( pdev->DiskMirror[0].status & UCBF_REBUILD )
-					{
-					pdev->hotRecon = 1;
 					pdev->mirrorRecon = 0;
-					}
 				else
-					{
-					pdev->hotRecon = 2;
 					pdev->mirrorRecon = 1;
-					}
+				pdev->reconOn = TRUE;
 				}
+			break;
 			}
 
-		if ( !pdev->hotRecon )
+		if ( !pdev->reconOn )
 			goto reconTimerExpiry;
 
-		zc = ((inb_p (padapter->regStatSel) >> 3) | inb_p (padapter->regStatSel)) & 0x83;		// mute the alarm
-		outb_p (zc | pdev->hotRecon | 0x40, padapter->regFail);
+		if ( padapter->bigD )
+			{
+			padapter->failRegister = 0;
+			outb_p (~padapter->failRegister, padapter->regFail);
+			}
+		else
+			{
+			zc = ((inb_p (padapter->regStatSel) >> 3) | inb_p (padapter->regStatSel)) & 0x83;		// mute the alarm
+			outb_p (0xFF, padapter->regFail);
+			}
 
 		while ( 1 )
 			{
-			if ( HardReset (padapter, pdev, pdev->hotRecon) )
+			DEB (printk ("\npci2220i: hard reset issue"));
+			if ( HardReset (padapter, pdev, pdev->spigots[pdev->mirrorRecon]) )
 				{
 				DEB (printk ("\npci2220i: sub 1"));
 				break;
 				}
 
-			pdev->lastsectorlba[pdev->mirrorRecon] = InlineIdentify (padapter, pdev->hotRecon, 0);
+			pdev->lastsectorlba[pdev->mirrorRecon] = InlineIdentify (padapter, pdev->spigots[pdev->mirrorRecon], pdev->deviceID[pdev->mirrorRecon] & 1);
 
 			if ( pdev->lastsectorlba[pdev->mirrorRecon] < testsize )
 				{
@@ -1051,12 +1517,11 @@
 			break;
 			}
 
-		if ( !padapter->reconOn )
+		if ( !pdev->reconOn )
 			{		
-			pdev->hotRecon = FALSE;
 			padapter->survivor = pdev->mirrorRecon ^ 1;
 			padapter->reconPhase = RECON_PHASE_FAILOVER;
-				DEB (printk ("\npci2220i: FAILURE 7"));
+			DEB (printk ("\npci2220i: FAILURE 7"));
 			InitFailover (padapter, pdev);
 			goto reconTimerExpiry;
 			}
@@ -1075,11 +1540,11 @@
 	if ( pdev->reconCount++ > 2000 )
 		{
 		pdev->reconCount = 0;
-		if ( WriteSignature (padapter, pdev, pdev->hotRecon, pdev->mirrorRecon) )
+		if ( WriteSignature (padapter, pdev, pdev->spigots[pdev->mirrorRecon], pdev->mirrorRecon) )
 			{
 			padapter->survivor = pdev->mirrorRecon ^ 1;
 			padapter->reconPhase = RECON_PHASE_FAILOVER;
-				DEB (printk ("\npci2220i: FAILURE 8"));
+			DEB (printk ("\npci2220i: FAILURE 8"));
 			InitFailover (padapter, pdev);
 			goto reconTimerExpiry;
 			}
@@ -1094,30 +1559,30 @@
 
 	if ( padapter->reconSize )
 		{
-		SelectSpigot (padapter, 3);										// select the spigots
-		outb_p (pdev->byte6 | ((UCHAR *)(&zl))[3], padapter->regLba24);// select the drive
+		SelectSpigot (padapter, pdev->spigots[0] | pdev->spigots[1]);	// select the spigots
+		outb_p (pdev->byte6 | ((UCHAR *)(&zl))[3], padapter->regLba24);	// select the drive
 		SelectSpigot (padapter, pdev->spigot);
 		if ( WaitReady (padapter) )
 			goto reconTimerExpiry;
 
-		SelectSpigot (padapter, pdev->hotRecon);
+		SelectSpigot (padapter, pdev->spigots[pdev->mirrorRecon]);
 		if ( WaitReady (padapter) )
 			{
 			padapter->survivor = pdev->mirrorRecon ^ 1;
 			padapter->reconPhase = RECON_PHASE_FAILOVER;
-				DEB (printk ("\npci2220i: FAILURE 9"));
+			DEB (printk ("\npci2220i: FAILURE 9"));
 			InitFailover (padapter, pdev);
 			goto reconTimerExpiry;
 			}
 	
-		SelectSpigot (padapter, 3);
+		SelectSpigot (padapter, pdev->spigots[0] | pdev->spigots[1]);
 		outb_p (padapter->reconSize & 0xFF, padapter->regSectCount);
 		outb_p (((UCHAR *)(&zl))[0], padapter->regLba0);
 		outb_p (((UCHAR *)(&zl))[1], padapter->regLba8);
 		outb_p (((UCHAR *)(&zl))[2], padapter->regLba16);
 		padapter->expectingIRQ = TRUE;
 		padapter->reconPhase = RECON_PHASE_READY;
-		SelectSpigot (padapter, pdev->hotRecon);
+		SelectSpigot (padapter, pdev->spigots[pdev->mirrorRecon]);
 		WriteCommand (padapter, WRITE_CMD);
 		StartTimer (padapter);
 		SelectSpigot (padapter, pdev->spigot);
@@ -1167,6 +1632,9 @@
 	Scsi_Cmnd		   *SCpnt;
 	UCHAR				status;
 	UCHAR				status1;
+	ATAPI_STATUS		statusa;
+	ATAPI_REASON		reasona;
+	ATAPI_ERROR			errora;
 	int					z;
 	ULONG				zl;
 #if LINUX_VERSION_CODE < LINUXVERSION(2,1,95)
@@ -1210,15 +1678,77 @@
 	padapter = HOSTDATA(shost);
 	pdev = padapter->pdev;
 	SCpnt = padapter->SCpnt;
+	outb_p (0x08, padapter->regDmaCmdStat);									// cancel interrupt from DMA engine
 
-	if ( !padapter->expectingIRQ || !(SCpnt || padapter->reconPhase) )
+	if ( padapter->atapi && SCpnt )
+		{
+		*(char *)&statusa = inb_p (padapter->regStatCmd);						// read the device status
+		*(char *)&reasona = inb_p (padapter->regSectCount);						// read the device interrupt reason
+	
+		if ( !statusa.bsy )
+			{
+			if ( statusa.drq )													// test for transfer phase
+				{
+				if ( !reasona.cod )												// test for data phase
+					{
+					z = (ULONG)inb_p (padapter->regLba8) | (ULONG)(inb_p (padapter->regLba16) << 8);
+					if ( padapter->reqSense )
+						insw (padapter->regData, SCpnt->sense_buffer, z / 2);
+					else
+						AtapiBusMaster (padapter, reasona.io, z);
+					goto irq_return;
+					}
+				if ( reasona.cod && !reasona.io )								// test for command packet phase
+					{
+					if ( padapter->reqSense )
+						AtapiRequestSense (padapter, pdev, SCpnt, TRUE);
+					else
+						AtapiSendCdb (padapter, pdev, padapter->atapiCdb);
+					goto irq_return;
+					}
+				}
+			else
+				{
+				if ( reasona.io && statusa.drdy )								// test for status phase
+					{
+					Atapi2Scsi (padapter, SCpnt);
+					if ( statusa.check )
+						{
+						*(UCHAR *)&errora = inb_p (padapter->regError);			// read the device error
+						if ( errora.senseKey )
+							{
+							if ( padapter->reqSense || AtapiRequestSense (padapter, pdev, SCpnt, FALSE) )
+								OpDone (padapter, DID_ERROR << 16);
+							}
+						else
+							{
+							if ( errora.ili || errora.abort )
+								OpDone (padapter, DID_ERROR << 16);
+							else
+								OpDone (padapter, DID_OK << 16);	
+							}
+						}
+					else
+						if ( padapter->reqSense )
+							{
+							DEB (printk ("PCI2242I: Sense codes - %X %X %X ", ((UCHAR *)SCpnt->sense_buffer)[0], ((UCHAR *)SCpnt->sense_buffer)[12], ((UCHAR *)SCpnt->sense_buffer)[13]));
+							OpDone (padapter, (DRIVER_SENSE << 24) | (DID_OK << 16) | 2);
+							}
+						else
+							OpDone (padapter, DID_OK << 16);	
+					}
+				}
+			}		
+		goto irq_return;
+		}
+	
+	if ( !padapter->expectingIRQ || !(SCpnt || padapter->reconPhase) )
 		{
 		DEB(printk ("\npci2220i Unsolicited interrupt\n"));
 		STOP_HERE ();
 		goto irq_return;
 		}
 	padapter->expectingIRQ = 0;
-	outb_p (0x08, padapter->regDmaCmdStat);									// cancel interrupt from DMA engine
 
 	if ( padapter->failinprog )
 		{
@@ -1233,7 +1763,7 @@
 		else
 			{
 			DEB (printk ("\npci2220i: restarting failed opertation."));
-			pdev->spigot = (padapter->survivor) ? 2 : 1;
+			pdev->spigot = (padapter->survivor) ? pdev->spigots[1] : pdev->spigots[0];
 			del_timer (&padapter->timer);
 			if ( padapter->reconPhase )
 				OpDone (padapter, DID_OK << 16);
@@ -1255,15 +1785,15 @@
 					{
 					if ( status & (IDE_STATUS_ERROR | IDE_STATUS_WRITE_FAULT) )
 						{
-						padapter->survivor = (pdev->spigot ^ 3) >> 1;
+						padapter->survivor = ( pdev->spigot == pdev->spigots[0] ) ? 1 : 0;
 						DEB (printk ("\npci2220i: FAILURE 10"));
 						if ( InitFailover (padapter, pdev) )
 							OpDone (padapter, DecodeError (padapter, status));
 						goto irq_return;
 						}
-					if ( WriteSignature (padapter, pdev, pdev->hotRecon, pdev->mirrorRecon) )
+					if ( WriteSignature (padapter, pdev, pdev->spigots[pdev->mirrorRecon], pdev->mirrorRecon) )
 						{
-						padapter->survivor = (pdev->spigot) >> 1;
+						padapter->survivor = ( pdev->spigot == pdev->spigots[0] ) ? 0 : 1;
 						DEB (printk ("\npci2220i: FAILURE 11"));
 						if ( InitFailover (padapter, pdev) )
 							OpDone (padapter, DecodeError (padapter, status));
@@ -1283,17 +1813,17 @@
 					OpDone (padapter, DecodeError (padapter, status));
 					goto irq_return;
 					}
-				SelectSpigot (padapter, pdev->hotRecon);
+				SelectSpigot (padapter, pdev->spigots[pdev->mirrorRecon]);
 				if ( WaitDrq (padapter) )
 					{
 					del_timer (&padapter->timer);
-					padapter->survivor = (pdev->spigot) >> 1;
-				DEB (printk ("\npci2220i: FAILURE 12"));
+					padapter->survivor = ( pdev->spigot == pdev->spigots[0] ) ? 0 : 1;
+					DEB (printk ("\npci2220i: FAILURE 12"));
 					if ( InitFailover (padapter, pdev) )
 						OpDone (padapter, DecodeError (padapter, status));
 					goto irq_return;
 					}
-				SelectSpigot (padapter, pdev->spigot | 0x40);
+				SelectSpigot (padapter, pdev->spigot | SEL_COPY | padapter->bigD);
 				padapter->reconPhase = RECON_PHASE_COPY;
 				padapter->expectingIRQ = TRUE;
 				if ( padapter->timingPIO )
@@ -1302,11 +1832,22 @@
 					}
 				else
 					{
-					outl (padapter->timingAddress, padapter->regDmaAddrLoc);
+					if ( (padapter->timingMode > 3) )
+						{
+						if ( padapter->bigD )
+							outl (BIGD_DATA_MODE3, padapter->regDmaAddrLoc);
+						else
+							outl (DALE_DATA_MODE3, padapter->regDmaAddrLoc);
+						}
+					else
+						outl (padapter->timingAddress, padapter->regDmaAddrLoc);
 					outl (virt_to_bus (padapter->kBuffer), padapter->regDmaAddrPci);
 					outl (padapter->reconSize * BYTES_PER_SECTOR, padapter->regDmaCount);
 					outb_p (8, padapter->regDmaDesc);						// read operation
-					outb_p (1, padapter->regDmaMode);						// no interrupt
+					if ( padapter->bigD )
+						outb_p (8, padapter->regDmaMode);					// no interrupt
+					else
+						outb_p (1, padapter->regDmaMode);					// no interrupt
 					outb_p (0x03, padapter->regDmaCmdStat);					// kick the DMA engine in gear
 					}
 				goto irq_return;
@@ -1315,13 +1856,14 @@
 				pdev->DiskMirror[pdev->mirrorRecon].reconstructPoint += padapter->reconSize;
 
 			case RECON_PHASE_UPDATE:
-				SelectSpigot (padapter, pdev->hotRecon | 0x80);
+				SelectSpigot (padapter, pdev->spigots[pdev->mirrorRecon] | SEL_IRQ_OFF);
 				status = inb_p (padapter->regStatCmd);						// read the device status
 				del_timer (&padapter->timer);
 				if ( status & (IDE_STATUS_ERROR | IDE_STATUS_WRITE_FAULT) )
 					{
-					padapter->survivor = (pdev->spigot) >> 1;
+					padapter->survivor = ( pdev->spigot == pdev->spigots[0] ) ? 0 : 1;
 					DEB (printk ("\npci2220i: FAILURE 13"));
+					DEB (printk ("\n  status register = %X   error = %X", status, inb_p (padapter->regError)));
 					if ( InitFailover (padapter, pdev) )
 						OpDone (padapter, DecodeError (padapter, status));
 					goto irq_return;
@@ -1334,14 +1876,29 @@
 				del_timer (&padapter->timer);
 				if ( status & (IDE_STATUS_ERROR | IDE_STATUS_WRITE_FAULT) )
 					{
-					padapter->survivor = (pdev->spigot) >> 1;
-				DEB (printk ("\npci2220i: FAILURE 14"));
+					padapter->survivor = ( pdev->spigot == pdev->spigots[0] ) ? 0 : 1;
+					DEB (printk ("\npci2220i: FAILURE 14"));
 					if ( InitFailover (padapter, pdev) )
 						OpDone (padapter, DecodeError (padapter, status));
 					goto irq_return;
 					}
-				padapter->reconOn = FALSE;
-				pdev->hotRecon = 0;
+				pdev->reconOn = 0;
+				if ( padapter->bigD )
+					{
+					for ( z = 0;  z < padapter->numberOfDrives;  z++ )
+						{
+						if ( padapter->device[z].DiskMirror[0].status & UCBF_SURVIVOR )
+							{
+							Alarm (padapter, padapter->device[z].deviceID[0] ^ 2);
+							MuteAlarm (padapter);
+							}
+						if ( padapter->device[z].DiskMirror[1].status & UCBF_SURVIVOR )
+							{
+							Alarm (padapter, padapter->device[z].deviceID[1] ^ 2);
+							MuteAlarm (padapter);
+							}
+						}
+					}
 				OpDone (padapter, DID_OK << 16);
 				goto irq_return;
 
@@ -1360,9 +1917,9 @@
 					{
 					if ( pdev->raid )
 						{
-						padapter->survivor = (pdev->spigot ^ 3) >> 1;
+						padapter->survivor = ( pdev->spigot == pdev->spigots[0] ) ? 1 : 0;
 						del_timer (&padapter->timer);
-				DEB (printk ("\npci2220i: FAILURE 15"));
+						DEB (printk ("\npci2220i: FAILURE 15"));
 						if ( !InitFailover (padapter, pdev) )
 							goto irq_return;
 						}
@@ -1370,10 +1927,9 @@
 					}
 				if ( padapter->timingPIO )
 					{
-					zl = (padapter->sectorCount > MAX_BUS_MASTER_BLOCKS) ? MAX_BUS_MASTER_BLOCKS : padapter->sectorCount;
-					insw (padapter->regData, padapter->buffer, zl * (BYTES_PER_SECTOR / 2));
-					padapter->sectorCount -= zl;
-					padapter->buffer += zl * BYTES_PER_SECTOR;
+					insw (padapter->regData, padapter->kBuffer, padapter->readCount / 2);
+					padapter->sectorCount -= padapter->readCount / BYTES_PER_SECTOR;
+					WalkScatGath (padapter, TRUE, padapter->readCount);
 					if ( !padapter->sectorCount )
 						{
 						status = 0;
@@ -1381,32 +1937,40 @@
 						}
 					}
 				else
+					{
+					if ( padapter->readCount )
+						WalkScatGath (padapter, TRUE, padapter->readCount);
 					BusMaster (padapter, 1, 1);
+					}
 				padapter->expectingIRQ = TRUE;
 				goto irq_return;
 				}
+			if ( padapter->readCount && !padapter->timingPIO )
+				WalkScatGath (padapter, TRUE, padapter->readCount);
 			status = 0;
 			break;
 
 		case WRITE_CMD:
-			SelectSpigot (padapter, pdev->spigot | 0x80);				
-			status = inb_p (padapter->regStatCmd);								// read the device status
 			if ( pdev->raid )
 				{
-				SelectSpigot (padapter, (pdev->spigot ^ 3) | 0x80);				
-				status1 = inb_p (padapter->regStatCmd);							// read the device status
+				SelectSpigot (padapter, pdev->spigots[0] | SEL_IRQ_OFF);				
+				status = inb_p (padapter->regStatCmd);								// read the device status
+				SelectSpigot (padapter, pdev->spigots[1] | SEL_IRQ_OFF);				
+				status1 = inb_p (padapter->regStatCmd);								// read the device status
 				}
 			else
+				SelectSpigot (padapter, pdev->spigot | SEL_IRQ_OFF);				
+				status = inb_p (padapter->regStatCmd);								// read the device status
 				status1 = 0;
 		
 			if ( status & (IDE_STATUS_ERROR | IDE_STATUS_WRITE_FAULT) )
 				{	
 				if ( pdev->raid && !(status1 & (IDE_STATUS_ERROR | IDE_STATUS_WRITE_FAULT)) )
 					{
-					padapter->survivor = (pdev->spigot ^ 3) >> 1;
+					padapter->survivor = 1;
 					del_timer (&padapter->timer);
-				SelectSpigot (padapter, pdev->spigot | 0x80);
-				DEB (printk ("\npci2220i: FAILURE 16  status = %X  error = %X", status, inb_p (padapter->regError)));
+					SelectSpigot (padapter, pdev->spigot | SEL_IRQ_OFF);
+					DEB (printk ("\npci2220i: FAILURE 16  status = %X  error = %X", status, inb_p (padapter->regError)));
 					if ( !InitFailover (padapter, pdev) )
 						goto irq_return;
 					}
@@ -1416,9 +1980,9 @@
 				{
 				if ( status1 & (IDE_STATUS_ERROR | IDE_STATUS_WRITE_FAULT) )
 					{	
-					padapter->survivor = pdev->spigot >> 1;
+					padapter->survivor = 0;
 					del_timer (&padapter->timer);
-				DEB (printk ("\npci2220i: FAILURE 17  status = %X  error = %X", status1, inb_p (padapter->regError)));
+					DEB (printk ("\npci2220i: FAILURE 17  status = %X  error = %X", status1, inb_p (padapter->regError)));
 					if ( !InitFailover (padapter, pdev) )
 						goto irq_return;
 					status = status1;
@@ -1426,15 +1990,15 @@
 					}
 				if ( padapter->sectorCount )
 					{
-					status = WriteDataBoth (padapter);
+					status = WriteDataBoth (padapter, pdev);
 					if ( status )
 						{
-						padapter->survivor = (status ^ 3) >> 1;
+						padapter->survivor = status >> 1;
 						del_timer (&padapter->timer);
-				DEB (printk ("\npci2220i: FAILURE 18"));
+						DEB (printk ("\npci2220i: FAILURE 18"));
 						if ( !InitFailover (padapter, pdev) )
 							goto irq_return;
-						SelectSpigot (padapter, status | 0x80);				
+						SelectSpigot (padapter, pdev->spigots[status] | SEL_IRQ_OFF);				
 						status = inb_p (padapter->regStatCmd);								// read the device status
 						break;
 						}
@@ -1446,7 +2010,7 @@
 				}
 			if ( padapter->sectorCount )	
 				{	
-				SelectSpigot (padapter, pdev->spigot);
+				SelectSpigot (padapter, pdev->spigot | padapter->bigD);
 				status = WriteData (padapter);
 				if ( status )
 					break;
@@ -1549,14 +2113,88 @@
 	PDEVICE_RAID1	pdr;
 
 	SCpnt->scsi_done = done;
-	padapter->buffer = SCpnt->request_buffer;
 	padapter->SCpnt = SCpnt;  									// Save this command data
+	padapter->readCount = 0;
+
+	if ( SCpnt->use_sg )
+		{
+		padapter->currentSgBuffer = ((struct scatterlist *)SCpnt->request_buffer)[0].address;
+		padapter->currentSgCount = ((struct scatterlist *)SCpnt->request_buffer)[0].length;
+		}
+	else
+		{
+		padapter->currentSgBuffer = SCpnt->request_buffer;
+		padapter->currentSgCount = SCpnt->request_bufflen;
+		}
+	padapter->nextSg = 1;
+
 	if ( !done )
 		{
 		printk("pci2220i_queuecommand: %02X: done can't be NULL\n", *cdb);
 		return 0;
 		}
 	
+	if ( padapter->atapi )
+		{
+		UCHAR			zlo, zhi;
+
+		DEB (printk ("\nPCI2242I: ID %d, LUN %d opcode %X ", SCpnt->target, SCpnt->lun, *cdb));
+		padapter->pdev = pdev;
+		if ( !pdev->byte6 || SCpnt->lun )
+			{
+			OpDone (padapter, DID_BAD_TARGET << 16);
+			return 0;
+			}
+	
+		padapter->atapiSpecial = FALSE;
+		padapter->reqSense = FALSE;
+		memset (padapter->atapiCdb, 0, 16);
+		SelectSpigot (padapter, pdev->spigot);									// select the spigot
+		AtapiDevice (padapter, pdev->byte6);									// select the drive
+		if ( AtapiWaitReady (padapter, 100) )
+			{
+			OpDone (padapter, DID_NO_CONNECT << 16);
+			return 0;
+			}
+
+		switch ( cdb[0] ) 
+			{
+			case SCSIOP_MODE_SENSE:
+			case SCSIOP_MODE_SELECT:
+				Scsi2Atapi (padapter, SCpnt);
+				z = SCpnt->request_bufflen + 4;
+				break;
+			case SCSIOP_READ6:
+			case SCSIOP_WRITE6:
+				Scsi2Atapi (padapter, SCpnt);
+				z = SCpnt->request_bufflen;
+				break;
+			default:
+				memcpy (padapter->atapiCdb, cdb, SCpnt->cmd_len);
+				z = SCpnt->request_bufflen;
+				break;
+			}
+		if ( z > ATAPI_TRANSFER )
+			z = ATAPI_TRANSFER;
+	    zlo = (UCHAR)(z & 0xFF);
+	    zhi = (UCHAR)(z >> 8);
+
+	 	AtapiCountLo (padapter, zlo);						
+	   	AtapiCountHi (padapter, zhi);						
+	   	outb_p (0, padapter->regError);						
+		WriteCommand (padapter, IDE_COMMAND_ATAPI_PACKET);
+		if ( pdev->cmdDrqInt )
+			return 0;
+
+		if ( AtapiWaitDrq (padapter, 500) )
+			{
+			OpDone (padapter, DID_ERROR << 16);
+			return 0;
+			}
+		AtapiSendCdb (padapter, pdev, padapter->atapiCdb);	
+		return 0;
+		}
+	
 	if ( padapter->reconPhase )
 		return 0;
 	if ( padapter->reconTimer.data )
@@ -1565,12 +2203,11 @@
 		padapter->reconTimer.data = 0;
 		}
 		
-	if ( !pdev->device || SCpnt->lun )
+	if ( (SCpnt->target >= padapter->numberOfDrives) || SCpnt->lun )
 		{
 		OpDone (padapter, DID_BAD_TARGET << 16);
 		return 0;
 		}
-
 	
 	switch ( *cdb )
 		{
@@ -1581,7 +2218,15 @@
 				switch ( cdb[3] ) 
 					{
 					case MY_SCSI_REBUILD:
-						padapter->reconOn = padapter->reconIsStarting = TRUE;
+						for ( z = 0;  z < padapter->numberOfDrives;  z++ )
+							{
+							pdev = &padapter->device[z];
+							if ( ((pdev->DiskMirror[0].status & UCBF_SURVIVOR) && (pdev->DiskMirror[1].status & UCBF_MIRRORED)) ||
+								 ((pdev->DiskMirror[1].status & UCBF_SURVIVOR) && (pdev->DiskMirror[0].status & UCBF_MIRRORED)) )
+								{
+								padapter->reconOn = pdev->reconOn = pdev->reconIsStarting = TRUE;
+								}
+							}
 						OpDone (padapter, DID_OK << 16);
 						break;
 					case MY_SCSI_ALARMMUTE:
@@ -1598,7 +2243,10 @@
 						if ( padapter->raidData[z] )
 							{
 							memcpy (&pdr->DiskRaid1, padapter->raidData[z], sizeof (DISK_MIRROR));
-							pdr->TotalSectors = padapter->device[0].blocks;
+							if ( padapter->raidData[z]->reconstructPoint > padapter->raidData[z ^ 2]->reconstructPoint )
+								pdr->TotalSectors = padapter->raidData[z]->reconstructPoint;
+							else
+								pdr->TotalSectors = padapter->raidData[z ^ 2]->reconstructPoint;
 							}
 						else
 							memset (pdr, 0, sizeof (DEVICE_RAID1));
@@ -1661,6 +2309,7 @@
 
 	while ( padapter->demoFail )
 		{
+		pdev = padapter->pdev = &padapter->device[0];
 		padapter->demoFail = FALSE;
 		if ( !pdev->raid || 
 			 (pdev->DiskMirror[0].status & UCBF_SURVIVOR) || 
@@ -1673,7 +2322,7 @@
 		else
 			padapter->survivor = 0;
 				DEB (printk ("\npci2220i: FAILURE 19"));
-		if ( InitFailover (padapter, pdev ) )
+		if ( InitFailover (padapter, pdev) )
 			break;
 		return 0;
 		}
@@ -1681,14 +2330,14 @@
 	StartTimer (padapter);
 	if ( pdev->raid && (padapter->cmd == WRITE_CMD) )
 		{
-		rc = IdeCmdBoth (padapter);
+		rc = IdeCmdBoth (padapter, pdev);
 		if ( !rc )
-			rc = WriteDataBoth (padapter);
+			rc = WriteDataBoth (padapter, pdev);
 		if ( rc )
 			{
 			del_timer (&padapter->timer);
 			padapter->expectingIRQ = 0;
-			padapter->survivor = (rc ^ 3) >> 1;
+			padapter->survivor = rc >> 1;
 				DEB (printk ("\npci2220i: FAILURE 20"));
 			if ( InitFailover (padapter, pdev) )
 				{
@@ -1719,7 +2368,6 @@
 		}
 	return 0;
 	}
-
 static void internal_done(Scsi_Cmnd *SCpnt)
 	{
 	SCpnt->SCp.Status++;
@@ -1755,25 +2403,192 @@
  *	Returns:		Nothing.
  *
  ****************************************************************/
-VOID ReadFlash (PADAPTER2220I padapter, VOID *pdata, ULONG base, ULONG length)
+static VOID ReadFlash (PADAPTER2220I padapter, VOID *pdata, ULONG base, ULONG length)
 	{
 	ULONG	 oldremap;
 	UCHAR	 olddesc;
 	ULONG	 z;
 	UCHAR	*pd = (UCHAR *)pdata;
 
-	oldremap = inl (padapter->regRemap);									// save values to restore later
+	oldremap = inl (padapter->regRemap);							// save values to restore later
 	olddesc  = inb_p (padapter->regDesc);
 
-	outl (base | 1, padapter->regRemap);									// remap to Flash space as specified
-	outb_p (0x40, padapter->regDesc);										// describe remap region as 8 bit
-	for ( z = 0;  z < length;  z++)											// get "length" data count
-		*pd++ = inb_p (padapter->regBase + z);								// read in the data
+	outl (base | 1, padapter->regRemap);							// remap to Flash space as specified
+	outb_p (0x40, padapter->regDesc);								// describe remap region as 8 bit
+	for ( z = 0;  z < length;  z++)									// get "length" data count
+		*pd++ = inb_p (padapter->regBase + z);						// read in the data
 
-	outl (oldremap, padapter->regRemap);									// restore remap register values
+	outl (oldremap, padapter->regRemap);							// restore remap register values
 	outb_p (olddesc, padapter->regDesc);
 	}
 /****************************************************************
+ *	Name:			GetRegs
+ *
+ *	Description:	Initialize the regester information.
+ *
+ *	Parameters:		pshost		  - Pointer to SCSI host data structure.
+ *					bigd		  - PCI-2240I identifier
+ *					pcidev		  - Pointer to device data structure.
+ *					pci_bus		  - PCI bus number.
+ *					pci_device_fn - PCI device and function number.
+ *
+ *	Returns:		TRUE if failure to install.
+ *
+ ****************************************************************/
+#if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
+static USHORT GetRegs (struct Scsi_Host *pshost, BOOL bigd, struct pci_dev *pcidev)
+#else
+static USHORT GetRegs (struct Scsi_Host *pshost, BOOL bigd, UCHAR pci_bus, UCHAR pci_device_fn)
+#endif
+	{
+	PADAPTER2220I	padapter;
+	int				setirq;
+	int				z;
+	USHORT			zr, zl;
+
+	padapter = HOSTDATA(pshost);
+	memset (padapter, 0, sizeof (ADAPTER2220I));
+	memset (&DaleSetup, 0, sizeof (DaleSetup));
+	memset (DiskMirror, 0, sizeof (DiskMirror));
+
+#if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
+	zr = pcidev->base_address[1] & 0xFFFE;
+	zl = pcidev->base_address[2] & 0xFFFE;
+#else
+	pcibios_read_config_word (pci_bus, pci_device_fn, PCI_BASE_ADDRESS_1, &zr);
+	zr &= 0xFFFE;
+	pcibios_read_config_word (pci_bus, pci_device_fn, PCI_BASE_ADDRESS_2, &zl);
+	zl &= 0xFFFE;
+#endif
+	padapter->basePort = zr;
+	padapter->regRemap		= zr + RTR_LOCAL_REMAP;					// 32 bit local space remap
+	padapter->regDesc		= zr + RTR_REGIONS;	  					// 32 bit local region descriptor
+	padapter->regRange		= zr + RTR_LOCAL_RANGE;					// 32 bit local range
+	padapter->regIrqControl	= zr + RTR_INT_CONTROL_STATUS;			// 16 bit interupt control and status
+	padapter->regScratchPad	= zr + RTR_MAILBOX;	  					// 16 byte scratchpad I/O base address
+
+	padapter->regBase		= zl;
+	padapter->regData		= zl + REG_DATA;						// data register I/O address
+	padapter->regError		= zl + REG_ERROR;						// error register I/O address
+	padapter->regSectCount	= zl + REG_SECTOR_COUNT;				// sector count register I/O address
+	padapter->regLba0		= zl + REG_LBA_0;						// least significant byte of LBA
+	padapter->regLba8		= zl + REG_LBA_8;						// next least significant byte of LBA
+	padapter->regLba16		= zl + REG_LBA_16;						// next most significan byte of LBA
+	padapter->regLba24		= zl + REG_LBA_24;						// head and most 4 significant bits of LBA
+	padapter->regStatCmd	= zl + REG_STAT_CMD;					// status on read and command on write register
+	padapter->regStatSel	= zl + REG_STAT_SEL;					// board status on read and spigot select on write register
+	padapter->regFail		= zl + REG_FAIL;
+	padapter->regAltStat	= zl + REG_ALT_STAT;
+
+	if ( bigd )
+		{
+		padapter->regDmaDesc	= zr + RTR_DMA0_DESC_PTR;			// address of the DMA discriptor register for direction of transfer
+		padapter->regDmaCmdStat	= zr + RTR_DMA_COMMAND_STATUS;		// Byte #0 of DMA command status register
+		padapter->regDmaAddrPci	= zr + RTR_DMA0_PCI_ADDR;			// 32 bit register for PCI address of DMA
+		padapter->regDmaAddrLoc	= zr + RTR_DMA0_LOCAL_ADDR;			// 32 bit register for local bus address of DMA
+		padapter->regDmaCount	= zr + RTR_DMA0_COUNT;				// 32 bit register for DMA transfer count
+		padapter->regDmaMode	= zr + RTR_DMA0_MODE + 1;			// 32 bit register for DMA mode control
+		padapter->bigD			= SEL_NEW_SPEED_1;					// set spigot speed control bit
+		}
+	else
+		{
+		padapter->regDmaDesc	= zl + RTL_DMA1_DESC_PTR;			// address of the DMA discriptor register for direction of transfer
+		padapter->regDmaCmdStat	= zl + RTL_DMA_COMMAND_STATUS + 1;	// Byte #1 of DMA command status register
+		padapter->regDmaAddrPci	= zl + RTL_DMA1_PCI_ADDR;			// 32 bit register for PCI address of DMA
+		padapter->regDmaAddrLoc	= zl + RTL_DMA1_LOCAL_ADDR;			// 32 bit register for local bus address of DMA
+		padapter->regDmaCount	= zl + RTL_DMA1_COUNT;				// 32 bit register for DMA transfer count
+		padapter->regDmaMode	= zl + RTL_DMA1_MODE + 1;			// 32 bit register for DMA mode control
+		}
+
+	padapter->numberOfDrives = inb_p (padapter->regScratchPad + BIGD_NUM_DRIVES);
+	if ( !bigd && !padapter->numberOfDrives )						// if no devices on this board
+		return TRUE;
+
+#if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
+	pshost->irq = pcidev->irq;
+#else
+	pcibios_read_config_byte (pci_bus, pci_device_fn, PCI_INTERRUPT_LINE, &pshost->irq);
+#endif
+	setirq = 1;
+	for ( z = 0;  z < Installed;  z++ )								// scan for shared interrupts
+		{
+		if ( PsiHost[z]->irq == pshost->irq )						// if shared then, don't posses
+			setirq = 0;
+		}
+	if ( setirq )													// if not shared, posses
+		{
+		if ( request_irq (pshost->irq, Irq_Handler, SA_SHIRQ, "pci2220i", padapter) < 0 )
+			{
+			if ( request_irq (pshost->irq, Irq_Handler, SA_INTERRUPT | SA_SHIRQ, "pci2220i", padapter) < 0 )
+				{
+				printk ("Unable to allocate IRQ for PCI-2220I controller.\n");
+				return TRUE;
+				}
+			}
+		padapter->irqOwned = pshost->irq;							// set IRQ as owned
+		}
+	if ( padapter->numberOfDrives )
+		padapter->kBuffer = kmalloc (SECTORSXFER * BYTES_PER_SECTOR, GFP_DMA | GFP_ATOMIC);
+	else
+		padapter->kBuffer = kmalloc (ATAPI_TRANSFER, GFP_DMA | GFP_ATOMIC);
+	if ( !padapter->kBuffer )
+		{
+		printk ("Unable to allocate DMA buffer for PCI-2220I controller.\n");
+#if LINUX_VERSION_CODE < LINUXVERSION(1,3,70)
+		free_irq (pshost->irq);
+#else /* version >= v1.3.70 */
+		free_irq (pshost->irq, padapter);
+#endif /* version >= v1.3.70 */
+		return TRUE;
+		}
+
+	PsiHost[Installed]	= pshost;									// save SCSI_HOST pointer
+
+	pshost->io_port		= padapter->basePort;
+	pshost->n_io_port	= 0xFF;
+	pshost->unique_id	= padapter->regBase;
+
+	outb_p (0x01, padapter->regRange);								// fix our range register because other drivers want to tromp on it
+
+	padapter->timingMode = inb_p (padapter->regScratchPad + DALE_TIMING_MODE);
+	if ( padapter->timingMode >= 2 )
+		{
+		if ( bigd )
+			padapter->timingAddress	= ModeArray2[padapter->timingMode - 2];
+		else
+			padapter->timingAddress	= ModeArray[padapter->timingMode - 2];
+		}
+	else
+		padapter->timingPIO = TRUE;
+
+	ReadFlash (padapter, &DaleSetup, DALE_FLASH_SETUP, sizeof (SETUP));
+	ReadFlash (padapter, &DiskMirror, DALE_FLASH_RAID, sizeof (DiskMirror));
+
+	return FALSE;
+	}
+/****************************************************************
+ *	Name:			SetupFinish
+ *
+ *	Description:	Complete the driver initialization process for a card
+ *
+ *	Parameters:		padapter  - Pointer to SCSI host data structure.
+ *					str		  - Pointer to board type string.
+ *
+ *	Returns:		Nothing.
+ *
+ ****************************************************************/
+VOID SetupFinish (PADAPTER2220I padapter, char *str, int irq)
+	{
+	init_timer (&padapter->timer);
+	padapter->timer.function = TimerExpiry;
+	padapter->timer.data = (unsigned long)padapter;
+	init_timer (&padapter->reconTimer);
+	padapter->reconTimer.function = ReconTimerExpiry;
+	padapter->reconTimer.data = (unsigned long)padapter;
+	printk("\nPCI-%sI EIDE CONTROLLER: at I/O = %X/%X  IRQ = %d\n", str, padapter->basePort, padapter->regBase, irq);
+	printk("Version %s, Compiled %s %s\n\n", PCI2220I_VERSION, __DATE__, __TIME__);
+	}	
+/****************************************************************
  *	Name:	Pci2220i_Detect
  *
  *	Description:	Detect and initialize our boards.
@@ -1785,20 +2600,18 @@
  ****************************************************************/
 int Pci2220i_Detect (Scsi_Host_Template *tpnt)
 	{
-	int					found = 0;
-	int					installed = 0;
 	struct Scsi_Host   *pshost;
 	PADAPTER2220I	    padapter;
+	POUR_DEVICE			pdev;
 	int					unit;
 	int					z;
-	USHORT				zs;
-	USHORT				raidon = FALSE;
-	int					setirq;
-	UCHAR				spigot1 = FALSE;
-	UCHAR				spigot2 = FALSE;
+	USHORT				raidon;
+	UCHAR				spigot1, spigot2;
+	UCHAR				device;
 #if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
-	struct pci_dev	   *pdev = NULL;
+	struct pci_dev	   *pcidev = NULL;
 #else
+	int					found;
 	UCHAR				pci_bus, pci_device_fn;
 #endif
 
@@ -1813,206 +2626,258 @@
 		}
 
 #if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
-	while ( (pdev = pci_find_device (VENDOR_PSI, DEVICE_DALE_1, pdev)) != NULL )
+	while ( (pcidev = pci_find_device (VENDOR_PSI, DEVICE_DALE_1, pcidev)) != NULL )
 #else
-	while ( !pcibios_find_device (VENDOR_PSI, DEVICE_DALE_1, found, &pci_bus, &pci_device_fn) )
+	found = 0;
+	while ( !pcibios_find_device (VENDOR_PSI, DEVICE_DALE_1, found++, &pci_bus, &pci_device_fn) )
 #endif
 		{
 		pshost = scsi_register (tpnt, sizeof(ADAPTER2220I));
 		padapter = HOSTDATA(pshost);
-		memset (padapter, 0, sizeof (ADAPTER2220I));
-
-#if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
-		zs = pdev->base_address[1] & 0xFFFE;
-#else
-		pcibios_read_config_word (pci_bus, pci_device_fn, PCI_BASE_ADDRESS_1, &zs);
-		zs &= 0xFFFE;
-#endif
-		padapter->basePort = zs;
-		padapter->regRemap		= zs + RTR_LOCAL_REMAP;				// 32 bit local space remap
-		padapter->regDesc		= zs + RTR_REGIONS;	  				// 32 bit local region descriptor
-		padapter->regRange		= zs + RTR_LOCAL_RANGE;				// 32 bit local range
-		padapter->regIrqControl	= zs + RTR_INT_CONTROL_STATUS;		// 16 bit interupt control and status
-		padapter->regScratchPad	= zs + RTR_MAILBOX;	  				// 16 byte scratchpad I/O base address
 
 #if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
-		zs = pdev->base_address[2] & 0xFFFE;
+		if ( GetRegs (pshost, FALSE, pcidev) )
 #else
-		pcibios_read_config_word (pci_bus, pci_device_fn, PCI_BASE_ADDRESS_2, &zs);
-		zs &= 0xFFFE;
+		if ( GetRegs (pshost, FALSE, pci_bus, pci_device_fn) )
 #endif
-		padapter->regBase		= zs;
-		padapter->regData		= zs + REG_DATA;					// data register I/O address
-		padapter->regError		= zs + REG_ERROR;					// error register I/O address
-		padapter->regSectCount	= zs + REG_SECTOR_COUNT;			// sector count register I/O address
-		padapter->regLba0		= zs + REG_LBA_0;					// least significant byte of LBA
-		padapter->regLba8		= zs + REG_LBA_8;					// next least significant byte of LBA
-		padapter->regLba16		= zs + REG_LBA_16;					// next most significan byte of LBA
-		padapter->regLba24		= zs + REG_LBA_24;					// head and most 4 significant bits of LBA
-		padapter->regStatCmd	= zs + REG_STAT_CMD;				// status on read and command on write register
-		padapter->regStatSel	= zs + REG_STAT_SEL;				// board status on read and spigot select on write register
-		padapter->regFail		= zs + REG_FAIL;
-		padapter->regAltStat	= zs + REG_ALT_STAT;
-
-		padapter->regDmaDesc	= zs + RTL_DMA1_DESC_PTR;			// address of the DMA discriptor register for direction of transfer
-		padapter->regDmaCmdStat	= zs + RTL_DMA_COMMAND_STATUS + 1;	// Byte #1 of DMA command status register
-		padapter->regDmaAddrPci	= zs + RTL_DMA1_PCI_ADDR;			// 32 bit register for PCI address of DMA
-		padapter->regDmaAddrLoc	= zs + RTL_DMA1_LOCAL_ADDR;			// 32 bit register for local bus address of DMA
-		padapter->regDmaCount	= zs + RTL_DMA1_COUNT;				// 32 bit register for DMA transfer count
-		padapter->regDmaMode	= zs + RTL_DMA1_MODE + 1;			// 32 bit register for DMA mode control
-
-		if ( !inb_p (padapter->regScratchPad + DALE_NUM_DRIVES) )	// if no devices on this board
 			goto unregister;
 
-#if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
-		pshost->irq = pdev->irq;
-#else
-		pcibios_read_config_byte (pci_bus, pci_device_fn, PCI_INTERRUPT_LINE, &pshost->irq);
-#endif
-		setirq = 1;
-		for ( z = 0;  z < installed;  z++ )							// scan for shared interrupts
-			{
-			if ( PsiHost[z]->irq == pshost->irq )					// if shared then, don't posses
-				setirq = 0;
-			}
-		if ( setirq )												// if not shared, posses
-			{
-			if ( request_irq (pshost->irq, Irq_Handler, SA_SHIRQ, "pci2220i", padapter) < 0 )
-				{
-				if ( request_irq (pshost->irq, Irq_Handler, SA_INTERRUPT | SA_SHIRQ, "pci2220i", padapter) < 0 )
-					{
-					printk ("Unable to allocate IRQ for PCI-2220I controller.\n");
-					goto unregister;
-					}
-				}
-			padapter->irqOwned = pshost->irq;						// set IRQ as owned
-			}
-		padapter->kBuffer = kmalloc (SECTORSXFER * BYTES_PER_SECTOR, GFP_DMA | GFP_ATOMIC);
-		if ( !padapter->kBuffer )
-			{
-			printk ("Unable to allocate DMA buffer for PCI-2220I controller.\n");
-#if LINUX_VERSION_CODE < LINUXVERSION(1,3,70)
-			free_irq (pshost->irq);
-#else /* version >= v1.3.70 */
-			free_irq (pshost->irq, padapter);
-#endif /* version >= v1.3.70 */
-			goto unregister;
-			}
-		PsiHost[installed]	= pshost;								// save SCSI_HOST pointer
-
-		pshost->io_port		= padapter->basePort;
-		pshost->n_io_port	= 0xFF;
-		pshost->unique_id	= padapter->regBase;
-		pshost->max_id		= 4;
-
-		outb_p (0x01, padapter->regRange);							// fix our range register because other drivers want to tromp on it
-
-		padapter->timingMode = inb_p (padapter->regScratchPad + DALE_TIMING_MODE);
-		if ( padapter->timingMode >= 2 )
-			padapter->timingAddress	= ModeArray[padapter->timingMode - 2];
-		else
-			padapter->timingPIO = TRUE;
-			
-		ReadFlash (padapter, &DaleSetup, DALE_FLASH_SETUP, sizeof (SETUP));
-		for ( z = 0;  z < inb_p (padapter->regScratchPad + DALE_NUM_DRIVES);  ++z )
+		pshost->max_id = padapter->numberOfDrives;
+		for ( z = 0;  z < padapter->numberOfDrives;  z++ )
 			{
 			unit = inb_p (padapter->regScratchPad + DALE_CHANNEL_DEVICE_0 + z) & 0x0F;
-			padapter->device[z].device	 = inb_p (padapter->regScratchPad + DALE_SCRATH_DEVICE_0 + unit);
-			padapter->device[z].byte6	 = (UCHAR)(((unit & 1) << 4) | 0xE0);
-			padapter->device[z].spigot	 = (UCHAR)(1 << (unit >> 1));
-			padapter->device[z].sectors	 = DaleSetup.setupDevice[unit].sectors;
-			padapter->device[z].heads	 = DaleSetup.setupDevice[unit].heads;
-			padapter->device[z].cylinders = DaleSetup.setupDevice[unit].cylinders;
-			padapter->device[z].blocks	 = DaleSetup.setupDevice[unit].blocks;
+			pdev = &padapter->device[z];
+			pdev->byte6		= (UCHAR)(((unit & 1) << 4) | 0xE0);
+			pdev->spigot	= (UCHAR)(1 << (unit >> 1));
+			pdev->sectors	= DaleSetup.setupDevice[unit].sectors;
+			pdev->heads		= DaleSetup.setupDevice[unit].heads;
+			pdev->cylinders = DaleSetup.setupDevice[unit].cylinders;
+			pdev->blocks	= DaleSetup.setupDevice[unit].blocks;
 
 			if ( !z )
 				{
-				ReadFlash (padapter, &DiskMirror, DALE_FLASH_RAID, sizeof (DiskMirror));
 				DiskMirror[0].status = inb_p (padapter->regScratchPad + DALE_RAID_0_STATUS);		
 				DiskMirror[1].status = inb_p (padapter->regScratchPad + DALE_RAID_1_STATUS);		
 				if ( (DiskMirror[0].signature == SIGNATURE) && (DiskMirror[1].signature == SIGNATURE) &&
 				     (DiskMirror[0].pairIdentifier == (DiskMirror[1].pairIdentifier ^ 1)) )
 					{			 
 					raidon = TRUE;
+					if ( unit > (unit ^ 2) )
+						unit = unit ^ 2;
 					}	
+				else
+					raidon = FALSE;
 
-				memcpy (padapter->device[z].DiskMirror, DiskMirror, sizeof (DiskMirror));
-				padapter->raidData[0] = &padapter->device[z].DiskMirror[0];
-				padapter->raidData[2] = &padapter->device[z].DiskMirror[1];
+				memcpy (pdev->DiskMirror, DiskMirror, sizeof (DiskMirror));
+				padapter->raidData[0] = &pdev->DiskMirror[0];
+				padapter->raidData[2] = &pdev->DiskMirror[1];
 				
-				if ( raidon )
-					{
-					padapter->device[z].lastsectorlba[0] = InlineIdentify (padapter, 1, 0);
-					padapter->device[z].lastsectorlba[1] = InlineIdentify (padapter, 2, 0);
+				spigot1 = spigot2 = FALSE;
+				pdev->spigots[0] = 1;
+				pdev->spigots[1] = 2;
+				pdev->lastsectorlba[0] = InlineIdentify (padapter, 1, 0);
+				pdev->lastsectorlba[1] = InlineIdentify (padapter, 2, 0);
 						
-					if ( !(DiskMirror[1].status & UCBF_SURVIVOR) && padapter->device[z].lastsectorlba[0] )
-						spigot1 = TRUE;
-					if ( !(DiskMirror[0].status & UCBF_SURVIVOR) && padapter->device[z].lastsectorlba[1] )
-						spigot2 = TRUE;
-					if ( DiskMirror[0].status & UCBF_SURVIVOR & DiskMirror[1].status & UCBF_SURVIVOR )
-						spigot1 = TRUE;
-
-					if ( spigot1 && (DiskMirror[0].status & UCBF_REBUILD) )
-						InlineReadSignature (padapter, &padapter->device[z], 0);
-					if ( spigot2 && (DiskMirror[1].status & UCBF_REBUILD) )
-						InlineReadSignature (padapter, &padapter->device[z], 1);
-
-					if ( spigot1 && spigot2 )
+				if ( !(pdev->DiskMirror[1].status & UCBF_SURVIVOR) && pdev->lastsectorlba[0] )
+					spigot1 = TRUE;
+				if ( !(pdev->DiskMirror[0].status & UCBF_SURVIVOR) && pdev->lastsectorlba[1] )
+					spigot2 = TRUE;
+				if ( pdev->DiskMirror[0].status & DiskMirror[1].status & UCBF_SURVIVOR )
+					spigot1 = TRUE;
+
+				if ( spigot1 && (pdev->DiskMirror[0].status & UCBF_REBUILD) )
+					InlineReadSignature (padapter, pdev, 0);
+				if ( spigot2 && (pdev->DiskMirror[1].status & UCBF_REBUILD) )
+					InlineReadSignature (padapter, pdev, 1);
+
+				if ( spigot1 && spigot2 && raidon )
+					{
+					pdev->raid = 1;
+					if ( pdev->DiskMirror[0].status & UCBF_REBUILD )
+						pdev->spigot = 2;
+					else
+						pdev->spigot = 1;
+					if ( (pdev->DiskMirror[0].status & UCBF_REBUILD) || (pdev->DiskMirror[1].status & UCBF_REBUILD) )
+						padapter->reconOn = pdev->reconOn = pdev->reconIsStarting = TRUE;
+					}
+				else
+					{
+					if ( spigot1 )
 						{
-						padapter->device[z].raid = 1;
-						if ( DiskMirror[0].status & UCBF_REBUILD )
-							padapter->device[z].spigot = 2;
-						else
-							padapter->device[z].spigot = 1;
-						if ( (DiskMirror[0].status & UCBF_REBUILD) || (DiskMirror[1].status & UCBF_REBUILD) )
-							{
-							padapter->reconOn = padapter->reconIsStarting = TRUE;
-							}
+						if ( pdev->DiskMirror[0].status & UCBF_REBUILD )
+							goto unregister;
+						pdev->DiskMirror[0].status = UCBF_MIRRORED | UCBF_SURVIVOR;
+						pdev->spigot = 1;
 						}
 					else
 						{
-						if ( spigot1 )
-							{
-							if ( DiskMirror[0].status & UCBF_REBUILD )
-								goto unregister;
-							DiskMirror[0].status = UCBF_MIRRORED | UCBF_SURVIVOR;
-							padapter->device[z].spigot = 1;
-							}
-						else
+						if ( pdev->DiskMirror[1].status & UCBF_REBUILD )
+							goto unregister;
+						pdev->DiskMirror[1].status = UCBF_MIRRORED | UCBF_SURVIVOR;
+						pdev->spigot = 2;
+						}
+					if ( DaleSetup.rebootRebuild && raidon )
+						padapter->reconOn = pdev->reconOn = pdev->reconIsStarting = TRUE;
+					}
+			
+				if ( raidon )
+					break;
+				}
+			}
+
+		SetupFinish (padapter, "2220", pshost->irq);
+	
+		if ( ++Installed < MAXADAPTER )
+			continue;
+		break;;
+unregister:;
+		scsi_unregister (pshost);
+		}
+
+#if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
+	while ( (pcidev = pci_find_device (VENDOR_PSI, DEVICE_BIGD_1, pcidev)) != NULL )
+#else
+	found = 0;
+	while ( !pcibios_find_device (VENDOR_PSI, DEVICE_BIGD_1, found++, &pci_bus, &pci_device_fn) )
+#endif
+		{
+		pshost = scsi_register (tpnt, sizeof(ADAPTER2220I));
+		padapter = HOSTDATA(pshost);
+
+#if LINUX_VERSION_CODE > LINUXVERSION(2,1,92)
+		if ( GetRegs (pshost, TRUE, pcidev) )
+#else
+		if ( GetRegs (pshost, TRUE, pci_bus, pci_device_fn) )
+#endif
+			goto unregister1;
+
+		for ( z = 0;  z < BIGD_MAXDRIVES;  z++ )
+			DiskMirror[z].status = inb_p (padapter->regScratchPad + BIGD_RAID_0_STATUS + z);		
+
+		pshost->max_id = padapter->numberOfDrives;
+		padapter->failRegister = inb_p (padapter->regScratchPad + BIGD_ALARM_IMAGE);
+		for ( z = 0;  z < padapter->numberOfDrives;  z++ )
+			{
+			unit = inb_p (padapter->regScratchPad + BIGD_DEVICE_0 + z);
+			pdev = &padapter->device[z];
+			pdev->byte6		= (UCHAR)(((unit & 1) << 4) | 0xE0);
+			pdev->spigot	= (UCHAR)(1 << (unit >> 1));
+			pdev->sectors	= DaleSetup.setupDevice[unit].sectors;
+			pdev->heads		= DaleSetup.setupDevice[unit].heads;
+			pdev->cylinders = DaleSetup.setupDevice[unit].cylinders;
+			pdev->blocks	= DaleSetup.setupDevice[unit].blocks;
+			
+			if ( (DiskMirror[unit].signature == SIGNATURE) && (DiskMirror[unit ^ 2].signature == SIGNATURE) &&
+			     (DiskMirror[unit].pairIdentifier == (DiskMirror[unit ^ 2].pairIdentifier ^ 1)) )
+				{			 
+				raidon = TRUE;
+				if ( unit > (unit ^ 2) )
+					unit = unit ^ 2;
+				}	
+			else
+				raidon = FALSE;
+				
+			spigot1 = spigot2 = FALSE;
+			memcpy (&pdev->DiskMirror[0], &DiskMirror[unit], sizeof (DISK_MIRROR));
+			memcpy (&pdev->DiskMirror[1], &DiskMirror[unit ^ 2], sizeof (DISK_MIRROR));
+			padapter->raidData[unit]	 = &pdev->DiskMirror[0];
+			padapter->raidData[unit ^ 2] = &pdev->DiskMirror[1];
+			pdev->spigots[0] = 1 << (unit >> 1);
+			pdev->spigots[1] = 1 << ((unit ^ 2) >> 1);
+			pdev->deviceID[0] = unit;
+			pdev->deviceID[1] = unit ^ 2;
+			pdev->lastsectorlba[0] = InlineIdentify (padapter, pdev->spigots[0], unit & 1);
+			pdev->lastsectorlba[1] = InlineIdentify (padapter, pdev->spigots[1], unit & 1);
+
+			if ( !(pdev->DiskMirror[1].status & UCBF_SURVIVOR) && pdev->lastsectorlba[0] )
+				spigot1 = TRUE;
+			if ( !(pdev->DiskMirror[0].status & UCBF_SURVIVOR) && pdev->lastsectorlba[1] )
+				spigot2 = TRUE;
+			if ( pdev->DiskMirror[0].status & pdev->DiskMirror[1].status & UCBF_SURVIVOR )
+				spigot1 = TRUE;
+
+			if ( spigot1 && (pdev->DiskMirror[0].status & UCBF_REBUILD) )
+				InlineReadSignature (padapter, pdev, 0);
+			if ( spigot2 && (pdev->DiskMirror[1].status & UCBF_REBUILD) )
+				InlineReadSignature (padapter, pdev, 1);
+
+			if ( spigot1 && spigot2 && raidon )
+				{
+				pdev->raid = 1;
+				if ( pdev->DiskMirror[0].status & UCBF_REBUILD )
+					pdev->spigot = pdev->spigots[1];
+				else
+					pdev->spigot = pdev->spigots[0];
+				if ( (pdev->DiskMirror[0].status & UCBF_REBUILD) || (pdev->DiskMirror[1].status & UCBF_REBUILD) )
+					padapter->reconOn = pdev->reconOn = pdev->reconIsStarting = TRUE;
+				}
+			else
+				{
+				if ( spigot1 )
+					{
+					if ( pdev->DiskMirror[0].status & UCBF_REBUILD )
+						goto unregister1;
+					pdev->DiskMirror[0].status = UCBF_MIRRORED | UCBF_SURVIVOR;
+					pdev->spigot = pdev->spigots[0];
+					}
+				else
+					{
+					if ( pdev->DiskMirror[1].status & UCBF_REBUILD )
+						goto unregister;
+					pdev->DiskMirror[1].status = UCBF_MIRRORED | UCBF_SURVIVOR;
+					pdev->spigot = pdev->spigots[1];
+					}
+				if ( DaleSetup.rebootRebuild && raidon )
+					padapter->reconOn = pdev->reconOn = pdev->reconIsStarting = TRUE;
+				}
+			}
+		
+		if ( !padapter->numberOfDrives )									// If no ATA devices then scan ATAPI
+			{
+			unit = 0;
+			for ( spigot1 = 0;  spigot1 < 4;  spigot1++ )
+				{
+				for ( device = 0;  device < 2;  device++ )
+					{
+					DEB (printk ("\nPCI2242I: scanning for ID %d ", (spigot1 * 2) + device));
+					pdev = &(padapter->device[(spigot1 * 2) + device]);
+					pdev->byte6 = 0x0A | (device << 4);
+					pdev->spigot = 1 << spigot1;
+					if ( !AtapiReset (padapter, pdev) )
+						{
+						DEB (printk (" Device found "));
+						if ( !AtapiIdentify (padapter, pdev) )
 							{
-							if ( DiskMirror[1].status & UCBF_REBUILD )
-								goto unregister;
-							DiskMirror[1].status = UCBF_MIRRORED | UCBF_SURVIVOR;
-							padapter->device[z].spigot = 2;
+							DEB (printk (" Device verified"));
+							unit++;
+							continue;
 							}
-						if ( DaleSetup.rebootRebuil )
-							padapter->reconOn = padapter->reconIsStarting = TRUE;
 						}
-				
-					break;
+					pdev->spigot = pdev->byte6 = 0;
 					}
 				}
+
+			if ( unit )
+				{
+				padapter->atapi = TRUE;
+				padapter->timingAddress = DALE_DATA_MODE3;
+				outw_p (0x0900, padapter->regIrqControl);					// Turn our interrupts on
+				outw_p (0x0C41, padapter->regDmaMode - 1);					// setup for 16 bits, ready enabled, done IRQ enabled, no incriment
+				outb_p (0xFF, padapter->regFail);							// all fail lights and alarm off
+				pshost->max_id = 8;
+				}
 			}
-			
-		init_timer (&padapter->timer);
-		padapter->timer.function = TimerExpiry;
-		padapter->timer.data = (unsigned long)padapter;
-		init_timer (&padapter->reconTimer);
-		padapter->reconTimer.function = ReconTimerExpiry;
-		padapter->reconTimer.data = (unsigned long)padapter;
-		printk("\nPCI-2220I EIDE CONTROLLER: at I/O = %X/%X  IRQ = %d\n", padapter->basePort, padapter->regBase, pshost->irq);
-		printk("Version %s, Compiled %s %s\n\n", PCI2220I_VERSION, __DATE__, __TIME__);
-		found++;
-		if ( ++installed < MAXADAPTER )
+		SetupFinish (padapter, "2240", pshost->irq);
+		
+		if ( ++Installed < MAXADAPTER )
 			continue;
 		break;;
-unregister:;
+unregister1:;
 		scsi_unregister (pshost);
-		found++;
 		}
-	
-	NumAdapters = installed;
-	return installed;
+
+	NumAdapters = Installed;
+	return Installed;
 	}
 /****************************************************************
  *	Name:	Pci2220i_Abort
@@ -2026,6 +2891,19 @@
  ****************************************************************/
 int Pci2220i_Abort (Scsi_Cmnd *SCpnt)
 	{
+	PADAPTER2220I	padapter = HOSTDATA(SCpnt->host);			// Pointer to adapter control structure
+	POUR_DEVICE		pdev	 = &padapter->device[SCpnt->target];// Pointer to device information
+
+	if ( !padapter->SCpnt )
+		return SCSI_ABORT_NOT_RUNNING;
+	
+	if ( padapter->atapi )
+		{
+		if ( AtapiReset (padapter, pdev) )
+			return SCSI_ABORT_ERROR;
+		OpDone (padapter, DID_ABORT << 16);
+		return SCSI_ABORT_SUCCESS;
+		}
 	return SCSI_ABORT_SNOOZE;
 	}
 /****************************************************************
@@ -2045,6 +2923,15 @@
  ****************************************************************/
 int Pci2220i_Reset (Scsi_Cmnd *SCpnt, unsigned int reset_flags)
 	{
+	PADAPTER2220I	padapter = HOSTDATA(SCpnt->host);			// Pointer to adapter control structure
+	POUR_DEVICE		pdev	 = &padapter->device[SCpnt->target];// Pointer to device information
+
+	if ( padapter->atapi )
+		{
+		if ( AtapiReset (padapter, pdev) )
+			return SCSI_RESET_ERROR;
+		return SCSI_RESET_SUCCESS;
+		}
 	return SCSI_RESET_PUNT;
 	}
 /****************************************************************
@@ -2060,6 +2947,7 @@
 int Pci2220i_Release (struct Scsi_Host *pshost)
 	{
     PADAPTER2220I	padapter = HOSTDATA (pshost);
+	USHORT			z;
 
 	if ( padapter->reconOn )
 		{
@@ -2074,8 +2962,22 @@
 		}
 
 	// save RAID status on the board
-	outb_p (DiskMirror[0].status, padapter->regScratchPad + DALE_RAID_0_STATUS);		
-	outb_p (DiskMirror[1].status, padapter->regScratchPad + DALE_RAID_1_STATUS);		
+	if ( padapter->bigD )
+		{
+		outb_p (padapter->failRegister, padapter->regScratchPad + BIGD_ALARM_IMAGE);
+		for ( z = 0;  z < BIGD_MAXDRIVES;  z++ )
+			{
+			if ( padapter->raidData )
+				outb_p (padapter->raidData[z]->status, padapter->regScratchPad + BIGD_RAID_0_STATUS + z);	
+			else
+				outb_p (0, padapter->regScratchPad + BIGD_RAID_0_STATUS);	
+			}
+		}
+	else
+		{
+		outb_p (padapter->device[0].DiskMirror[0].status, padapter->regScratchPad + DALE_RAID_0_STATUS);		
+		outb_p (padapter->device[0].DiskMirror[1].status, padapter->regScratchPad + DALE_RAID_1_STATUS);		
+		}
 
 	if ( padapter->irqOwned )
 #if LINUX_VERSION_CODE < LINUXVERSION(1,3,70)
@@ -2108,11 +3010,14 @@
 	{
 	POUR_DEVICE	pdev;
 
-	pdev = &(HOSTDATA(disk->device->host)->device[disk->device->id]);
+	if ( !(HOSTDATA(disk->device->host))->atapi )
+		{
+		pdev = &(HOSTDATA(disk->device->host)->device[disk->device->id]);
 
-	geom[0] = pdev->heads;
-	geom[1] = pdev->sectors;
-	geom[2] = pdev->cylinders;
+		geom[0] = pdev->heads;
+		geom[1] = pdev->sectors;
+		geom[2] = pdev->cylinders;
+		}
 	return 0;
 	}
 
diff -urN linux-2.2.15-pre8/drivers/scsi/pci2220i.h linux/drivers/scsi/pci2220i.h
--- linux-2.2.15-pre8/drivers/scsi/pci2220i.h	Tue May 11 10:36:37 1999
+++ linux/drivers/scsi/pci2220i.h	Mon Dec  3 21:59:38 2001
@@ -21,265 +21,11 @@
 #ifndef _PCI2220I_H
 #define _PCI2220I_H
 
-#ifndef	PSI_EIDE_SCSIOP
-#define	PSI_EIDE_SCSIOP	1
-
 #ifndef LINUX_VERSION_CODE
 #include <linux/version.h>
 #endif 
 #define	LINUXVERSION(v,p,s)    (((v)<<16) + ((p)<<8) + (s))
 
-/************************************************/
-/*		Some defines that we like 				*/
-/************************************************/
-#define	CHAR		char
-#define	UCHAR		unsigned char
-#define	SHORT		short
-#define	USHORT		unsigned short
-#define	BOOL		unsigned short
-#define	LONG		long
-#define	ULONG		unsigned long
-#define	VOID		void
-
-#include "psi_dale.h"
-
-/************************************************/
-/*		Timeout konstants		 				*/
-/************************************************/
-#define	TIMEOUT_READY				100			// 100 mSec
-#define	TIMEOUT_DRQ					300			// 300 mSec
-#define	TIMEOUT_DATA				(3 * HZ)	// 3 seconds
-
-/************************************************/
-/*		Misc. macros			 				*/
-/************************************************/
-#define ANY2SCSI(up, p)					\
-((UCHAR *)up)[0] = (((ULONG)(p)) >> 8);	\
-((UCHAR *)up)[1] = ((ULONG)(p));
-
-#define SCSI2LONG(up)					\
-( (((long)*(((UCHAR *)up))) << 16)		\
-+ (((long)(((UCHAR *)up)[1])) << 8)		\
-+ ((long)(((UCHAR *)up)[2])) )
-
-#define XANY2SCSI(up, p)				\
-((UCHAR *)up)[0] = ((long)(p)) >> 24;	\
-((UCHAR *)up)[1] = ((long)(p)) >> 16;	\
-((UCHAR *)up)[2] = ((long)(p)) >> 8;	\
-((UCHAR *)up)[3] = ((long)(p));
-
-#define XSCSI2LONG(up)					\
-( (((long)(((UCHAR *)up)[0])) << 24)	\
-+ (((long)(((UCHAR *)up)[1])) << 16)	\
-+ (((long)(((UCHAR *)up)[2])) <<  8)	\
-+ ((long)(((UCHAR *)up)[3])) )
-
-#define	SelectSpigot(padapter,spigot)	outb_p (spigot, padapter->regStatSel)
-#define WriteCommand(padapter,cmd)		outb_p (cmd, padapter->regStatCmd)
-
-/************************************************/
-/*		SCSI CDB operation codes 				*/
-/************************************************/
-#define SCSIOP_TEST_UNIT_READY		0x00
-#define SCSIOP_REZERO_UNIT			0x01
-#define SCSIOP_REWIND				0x01
-#define SCSIOP_REQUEST_BLOCK_ADDR	0x02
-#define SCSIOP_REQUEST_SENSE		0x03
-#define SCSIOP_FORMAT_UNIT			0x04
-#define SCSIOP_READ_BLOCK_LIMITS	0x05
-#define SCSIOP_REASSIGN_BLOCKS		0x07
-#define SCSIOP_READ6				0x08
-#define SCSIOP_RECEIVE				0x08
-#define SCSIOP_WRITE6				0x0A
-#define SCSIOP_PRINT				0x0A
-#define SCSIOP_SEND					0x0A
-#define SCSIOP_SEEK6				0x0B
-#define SCSIOP_TRACK_SELECT			0x0B
-#define SCSIOP_SLEW_PRINT			0x0B
-#define SCSIOP_SEEK_BLOCK			0x0C
-#define SCSIOP_PARTITION			0x0D
-#define SCSIOP_READ_REVERSE			0x0F
-#define SCSIOP_WRITE_FILEMARKS		0x10
-#define SCSIOP_FLUSH_BUFFER			0x10
-#define SCSIOP_SPACE				0x11
-#define SCSIOP_INQUIRY				0x12
-#define SCSIOP_VERIFY6				0x13
-#define SCSIOP_RECOVER_BUF_DATA		0x14
-#define SCSIOP_MODE_SELECT			0x15
-#define SCSIOP_RESERVE_UNIT			0x16
-#define SCSIOP_RELEASE_UNIT			0x17
-#define SCSIOP_COPY					0x18
-#define SCSIOP_ERASE				0x19
-#define SCSIOP_MODE_SENSE			0x1A
-#define SCSIOP_START_STOP_UNIT		0x1B
-#define SCSIOP_STOP_PRINT			0x1B
-#define SCSIOP_LOAD_UNLOAD			0x1B
-#define SCSIOP_RECEIVE_DIAGNOSTIC	0x1C
-#define SCSIOP_SEND_DIAGNOSTIC		0x1D
-#define SCSIOP_MEDIUM_REMOVAL		0x1E
-#define SCSIOP_READ_CAPACITY		0x25
-#define SCSIOP_READ					0x28
-#define SCSIOP_WRITE				0x2A
-#define SCSIOP_SEEK					0x2B
-#define SCSIOP_LOCATE				0x2B
-#define SCSIOP_WRITE_VERIFY			0x2E
-#define SCSIOP_VERIFY				0x2F
-#define SCSIOP_SEARCH_DATA_HIGH		0x30
-#define SCSIOP_SEARCH_DATA_EQUAL	0x31
-#define SCSIOP_SEARCH_DATA_LOW		0x32
-#define SCSIOP_SET_LIMITS			0x33
-#define SCSIOP_READ_POSITION		0x34
-#define SCSIOP_SYNCHRONIZE_CACHE	0x35
-#define SCSIOP_COMPARE				0x39
-#define SCSIOP_COPY_COMPARE			0x3A
-#define SCSIOP_WRITE_DATA_BUFF		0x3B
-#define SCSIOP_READ_DATA_BUFF		0x3C
-#define SCSIOP_CHANGE_DEFINITION	0x40
-#define SCSIOP_READ_SUB_CHANNEL		0x42
-#define SCSIOP_READ_TOC				0x43
-#define SCSIOP_READ_HEADER			0x44
-#define SCSIOP_PLAY_AUDIO			0x45
-#define SCSIOP_PLAY_AUDIO_MSF		0x47
-#define SCSIOP_PLAY_TRACK_INDEX		0x48
-#define SCSIOP_PLAY_TRACK_RELATIVE	0x49
-#define SCSIOP_PAUSE_RESUME			0x4B
-#define SCSIOP_LOG_SELECT			0x4C
-#define SCSIOP_LOG_SENSE			0x4D
-#define SCSIOP_MODE_SELECT10		0x55
-#define SCSIOP_MODE_SENSE10			0x5A
-#define SCSIOP_LOAD_UNLOAD_SLOT		0xA6
-#define SCSIOP_MECHANISM_STATUS		0xBD
-#define SCSIOP_READ_CD				0xBE
-
-// IDE command definitions
-#define IDE_COMMAND_ATAPI_RESET		0x08
-#define IDE_COMMAND_READ			0x20
-#define IDE_COMMAND_WRITE			0x30
-#define IDE_COMMAND_RECALIBRATE		0x10
-#define IDE_COMMAND_SEEK			0x70
-#define IDE_COMMAND_SET_PARAMETERS	0x91
-#define IDE_COMMAND_VERIFY			0x40
-#define IDE_COMMAND_ATAPI_PACKET	0xA0
-#define IDE_COMMAND_ATAPI_IDENTIFY	0xA1
-#define	IDE_CMD_READ_MULTIPLE		0xC4
-#define	IDE_CMD_WRITE_MULTIPLE		0xC5
-#define	IDE_CMD_SET_MULTIPLE		0xC6
-#define IDE_COMMAND_IDENTIFY		0xEC
-
-// IDE status definitions
-#define IDE_STATUS_ERROR			0x01
-#define IDE_STATUS_INDEX			0x02
-#define IDE_STATUS_CORRECTED_ERROR	0x04
-#define IDE_STATUS_DRQ				0x08
-#define IDE_STATUS_DSC				0x10
-#define	IDE_STATUS_WRITE_FAULT		0x20
-#define IDE_STATUS_DRDY				0x40
-#define IDE_STATUS_BUSY				0x80
-
-// IDE error definitions
-#define	IDE_ERROR_AMNF				0x01
-#define	IDE_ERROR_TKONF				0x02
-#define	IDE_ERROR_ABRT				0x04
-#define	IDE_ERROR_MCR				0x08
-#define	IDE_ERROR_IDFN				0x10
-#define	IDE_ERROR_MC				0x20
-#define	IDE_ERROR_UNC				0x40
-#define	IDE_ERROR_BBK				0x80
-
-// SCSI read capacity structure
-typedef	struct _READ_CAPACITY_DATA
-	{
-	ULONG blks;				/* total blocks (converted to little endian) */
-	ULONG blksiz;			/* size of each (converted to little endian) */
-	}	READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
-
-// SCSI inquiry data
-typedef struct _INQUIRYDATA
-	{
-	UCHAR DeviceType			:5;
-	UCHAR DeviceTypeQualifier	:3;
-	UCHAR DeviceTypeModifier	:7;
-	UCHAR RemovableMedia		:1;
-    UCHAR Versions;
-    UCHAR ResponseDataFormat;
-    UCHAR AdditionalLength;
-    UCHAR Reserved[2];
-	UCHAR SoftReset				:1;
-	UCHAR CommandQueue			:1;
-	UCHAR Reserved2				:1;
-	UCHAR LinkedCommands		:1;
-	UCHAR Synchronous			:1;
-	UCHAR Wide16Bit				:1;
-	UCHAR Wide32Bit				:1;
-	UCHAR RelativeAddressing	:1;
-    UCHAR VendorId[8];
-    UCHAR ProductId[16];
-    UCHAR ProductRevisionLevel[4];
-    UCHAR VendorSpecific[20];
-    UCHAR Reserved3[40];
-	}	INQUIRYDATA, *PINQUIRYDATA;
-
-// IDE IDENTIFY data
-#pragma pack (1)
-#pragma align 1
-typedef struct _IDENTIFY_DATA
-	{
-    USHORT	GeneralConfiguration;		//  0
-    USHORT	NumberOfCylinders;			//  1
-    USHORT	Reserved1;					//  2
-    USHORT	NumberOfHeads;				//  3
-    USHORT	UnformattedBytesPerTrack;	//  4
-    USHORT	UnformattedBytesPerSector;	//  5
-    USHORT	SectorsPerTrack;			//  6
-	USHORT	NumBytesISG;				//  7 Byte Len - inter-sector gap
-	USHORT	NumBytesSync;				//  8          - sync field
-	USHORT	NumWordsVUS;				//  9 Len - Vendor Unique Info
-    USHORT	SerialNumber[10];			// 10
-    USHORT	BufferType;					// 20
-    USHORT	BufferSectorSize;			// 21
-    USHORT	NumberOfEccBytes;			// 22
-    USHORT	FirmwareRevision[4];		// 23
-    USHORT	ModelNumber[20];			// 27
-	USHORT	NumSectorsPerInt	:8;		// 47 Multiple Mode - Sec/Blk
-	USHORT	Reserved2			:8;		// 47
-	USHORT	DoubleWordMode;				// 48 flag for double word mode capable
-	USHORT	VendorUnique1		:8;		// 49
-	USHORT	SupportDMA			:1;		// 49 DMA supported
-	USHORT	SupportLBA			:1;		// 49 LBA supported
-	USHORT	SupportIORDYDisable	:1;		// 49 IORDY can be disabled
-	USHORT	SupportIORDY		:1;		// 49 IORDY supported
-	USHORT	ReservedPsuedoDMA	:1;		// 49 reserved for pseudo DMA mode support
-	USHORT	Reserved3			:3;		// 49
-	USHORT	Reserved4;					// 50
-	USHORT	Reserved5			:8;		// 51 Transfer Cycle Timing - PIO
-	USHORT	PIOCycleTime		:8;		// 51 Transfer Cycle Timing - PIO
-	USHORT	Reserved6			:8;		// 52                       - DMA
-	USHORT	DMACycleTime		:8;		// 52                       - DMA
-	USHORT	Valid_54_58			:1;		// 53 words 54 - 58 are vaild
-	USHORT	Valid_64_70			:1;		// 53 words 64 - 70 are valid
-	USHORT	Reserved7			:14;	// 53
-	USHORT	LogNumCyl;					// 54 Current Translation - Num Cyl
-	USHORT	LogNumHeads;				// 55                       Num Heads
-	USHORT	LogSectorsPerTrack;			// 56                       Sec/Trk
-	ULONG	LogTotalSectors;			// 57                       Total Sec
-	USHORT	CurrentNumSecPerInt	:8;		// 59 current setting for number of sectors per interrupt
-	USHORT	ValidNumSecPerInt	:1;		// 59 Current setting is valid for number of sectors per interrupt
-	USHORT	Reserved8			:7;		// 59
-	ULONG	LBATotalSectors;			// 60 LBA Mode - Sectors
-	USHORT	DMASWordFlags;				// 62
-	USHORT	DMAMWordFlags;				// 63
-	USHORT	AdvancedPIOSupport  :8;		// 64 Flow control PIO transfer modes supported
-	USHORT	Reserved9			:8;		// 64
-	USHORT	MinMultiDMACycle;			// 65 minimum multiword DMA transfer cycle time per word
-	USHORT	RecomendDMACycle;			// 66 Manufacturer's recommende multiword DMA transfer cycle time
-	USHORT	MinPIOCycleWithoutFlow;		// 67 Minimum PIO transfer cycle time without flow control
-	USHORT	MinPIOCylceWithFlow;		// 68 Minimum PIO transfer cycle time with IORDY flow control
-	USHORT	ReservedSpace[256-69];		// 69
-	}	IDENTIFY_DATA, *PIDENTIFY_DATA;
-#pragma pack ()
-#pragma align 0
-#endif	// PSI_EIDE_SCSIOP
-
 // function prototypes
 int Pci2220i_Detect			(Scsi_Host_Template *tpnt);
 int Pci2220i_Command		(Scsi_Cmnd *SCpnt);
@@ -301,7 +47,7 @@
 		module:						NULL,									\
 		proc_dir:					&Proc_Scsi_Pci2220i,					\
 		proc_info:					NULL,	/* let's not bloat the kernel */\
-		name:						"PCI-2220I EIDE Disk Controller",		\
+		name:						"PCI-2220I/PCI-2240I",					\
 		detect:						Pci2220i_Detect,						\
 		release:					Pci2220i_Release,						\
 		info:						NULL,	/* let's not bloat the kernel */\
@@ -318,7 +64,7 @@
 		bios_param:					Pci2220i_BiosParam,						\
 		can_queue:					1,										\
 		this_id:					-1,										\
-		sg_tablesize:				SG_NONE,								\
+		sg_tablesize:				SG_ALL,								\
 		cmd_per_lun:				1,										\
 		present:					0,										\
 		unchecked_isa_dma:			0,										\
@@ -329,7 +75,7 @@
 #define PCI2220I { NULL, NULL,						\
 			&Proc_Scsi_Pci2220i,/* proc_dir_entry */\
 			NULL,		                			\
-			"PCI-2220I EIDE Disk Controller",		\
+			"PCI-2220I/PCI-2240I",					\
 			Pci2220i_Detect,						\
 			Pci2220i_Release,						\
 			NULL,	 								\
@@ -341,7 +87,7 @@
 			Pci2220i_BiosParam,                 	\
 			1, 										\
 			-1, 									\
-			SG_NONE,		 						\
+			SG_ALL,		 						\
 			1, 										\
 			0, 										\
 			0, 										\
diff -urN linux-2.2.15-pre8/drivers/scsi/psi_dale.h linux/drivers/scsi/psi_dale.h
--- linux-2.2.15-pre8/drivers/scsi/psi_dale.h	Tue Apr 13 07:54:02 1999
+++ linux/drivers/scsi/psi_dale.h	Mon Dec  3 21:59:38 2001
@@ -20,16 +20,32 @@
  ****************************************************************************/
 
 /************************************************/
+/*		Some defines that we like 				*/
+/************************************************/
+#define	CHAR		char
+#define	UCHAR		unsigned char
+#define	SHORT		short
+#define	USHORT		unsigned short
+#define	BOOL		unsigned short
+#define	LONG		long
+#define	ULONG		unsigned long
+#define	VOID		void
+
+/************************************************/
 /*		Dale PCI setup							*/
 /************************************************/
 #define	VENDOR_PSI			0x1256
 #define	DEVICE_DALE_1		0x4401		/* 'D1' */
+#define	DEVICE_BIGD_1		0x4201		/* 'B1' */
+#define	DEVICE_BIGD_2		0x4202		/* 'B2' */
 
 /************************************************/
 /*		Misc konstants							*/
 /************************************************/
 #define	DALE_MAXDRIVES			4
+#define	BIGD_MAXDRIVES			8
 #define	SECTORSXFER				8
+#define	ATAPI_TRANSFER			8192
 #define	BYTES_PER_SECTOR		512
 #define	DEFAULT_TIMING_MODE		5
 
@@ -49,90 +65,136 @@
 /************************************************/
 /*		DALE Register address offsets			*/
 /************************************************/
-#define	REG_DATA						0x80
-#define	REG_ERROR						0x84
-#define	REG_SECTOR_COUNT				0x88
-#define	REG_LBA_0						0x8C
-#define	REG_LBA_8						0x90
-#define	REG_LBA_16						0x94
-#define	REG_LBA_24						0x98
-#define	REG_STAT_CMD					0x9C
-#define	REG_STAT_SEL					0xA0
-#define	REG_FAIL						0xB0
-#define	REG_ALT_STAT					0xB8
-#define	REG_DRIVE_ADRS					0xBC
-
-#define	DALE_DATA_SLOW					0x00040000L
-#define	DALE_DATA_MODE2					0x00040000L
-#define	DALE_DATA_MODE3					0x00050000L
-#define	DALE_DATA_MODE4					0x00060000L
-#define	DALE_DATA_MODE4P				0x00070000L
-
-#define RTR_LOCAL_RANGE					0x000
-#define RTR_LOCAL_REMAP					0x004
-#define RTR_EXP_RANGE					0x010
-#define RTR_EXP_REMAP					0x014
-#define RTR_REGIONS						0x018
-#define RTR_DM_MASK						0x01C
-#define RTR_DM_LOCAL_BASE				0x020
-#define RTR_DM_IO_BASE					0x024
-#define RTR_DM_PCI_REMAP				0x028
-#define RTR_DM_IO_CONFIG				0x02C
-#define RTR_MAILBOX						0x040
-#define RTR_LOCAL_DOORBELL				0x060
-#define RTR_PCI_DOORBELL				0x064
-#define RTR_INT_CONTROL_STATUS 			0x068
-#define RTR_EEPROM_CONTROL_STATUS		0x06C
-
-#define RTL_DMA0_MODE					0x00
-#define RTL_DMA0_PCI_ADDR				0x04
-#define RTL_DMA0_LOCAL_ADDR				0x08
-#define RTL_DMA0_COUNT					0x0C
-#define RTL_DMA0_DESC_PTR				0x10
-#define RTL_DMA1_MODE					0x14
-#define RTL_DMA1_PCI_ADDR				0x18
-#define RTL_DMA1_LOCAL_ADDR				0x1C
-#define RTL_DMA1_COUNT					0x20
-#define RTL_DMA1_DESC_PTR				0x24
-#define RTL_DMA_COMMAND_STATUS			0x28
-#define RTL_DMA_ARB0					0x2C
-#define RTL_DMA_ARB1					0x30
+#define	REG_DATA					0x80
+#define	REG_ERROR					0x84
+#define	REG_SECTOR_COUNT			0x88
+#define	REG_LBA_0					0x8C
+#define	REG_LBA_8					0x90
+#define	REG_LBA_16					0x94
+#define	REG_LBA_24					0x98
+#define	REG_STAT_CMD				0x9C
+#define	REG_STAT_SEL				0xA0
+#define	REG_FAIL					0xB0
+#define	REG_ALT_STAT				0xB8
+#define	REG_DRIVE_ADRS				0xBC
+
+#define	DALE_DATA_SLOW				0x00040000L
+#define	DALE_DATA_MODE2				0x00040000L
+#define	DALE_DATA_MODE3				0x00050000L
+#define	DALE_DATA_MODE4				0x00060000L
+#define	DALE_DATA_MODE5				0x00070000L
+
+#define	BIGD_DATA_SLOW				0x00000000L
+#define	BIGD_DATA_MODE0				0x00000000L
+#define	BIGD_DATA_MODE2				0x00000000L
+#define	BIGD_DATA_MODE3				0x00000008L
+#define	BIGD_DATA_MODE4				0x00000010L
+#define	BIGD_DATA_MODE5				0x00000020L
+
+#define RTR_LOCAL_RANGE				0x000
+#define RTR_LOCAL_REMAP				0x004
+#define RTR_EXP_RANGE				0x010
+#define RTR_EXP_REMAP				0x014
+#define RTR_REGIONS					0x018
+#define RTR_DM_MASK					0x01C
+#define RTR_DM_LOCAL_BASE			0x020
+#define RTR_DM_IO_BASE				0x024
+#define RTR_DM_PCI_REMAP			0x028
+#define RTR_DM_IO_CONFIG			0x02C
+#define RTR_MAILBOX					0x040
+#define RTR_LOCAL_DOORBELL			0x060
+#define RTR_PCI_DOORBELL			0x064
+#define RTR_INT_CONTROL_STATUS 		0x068
+#define RTR_EEPROM_CONTROL_STATUS	0x06C
+
+#define RTR_DMA0_MODE				0x0080
+#define RTR_DMA0_PCI_ADDR			0x0084
+#define RTR_DMA0_LOCAL_ADDR			0x0088
+#define RTR_DMA0_COUNT				0x008C
+#define RTR_DMA0_DESC_PTR			0x0090
+#define RTR_DMA1_MODE				0x0094
+#define RTR_DMA1_PCI_ADDR			0x0098
+#define RTR_DMA1_LOCAL_ADDR			0x009C
+#define RTR_DMA1_COUNT				0x00A0
+#define RTR_DMA1_DESC_PTR			0x00A4
+#define RTR_DMA_COMMAND_STATUS		0x00A8
+#define RTR_DMA_ARB0				0x00AC
+#define RTR_DMA_ARB1				0x00B0
+
+#define RTL_DMA0_MODE				0x00
+#define RTL_DMA0_PCI_ADDR			0x04
+#define RTL_DMA0_LOCAL_ADDR			0x08
+#define RTL_DMA0_COUNT				0x0C
+#define RTL_DMA0_DESC_PTR			0x10
+#define RTL_DMA1_MODE				0x14
+#define RTL_DMA1_PCI_ADDR			0x18
+#define RTL_DMA1_LOCAL_ADDR			0x1C
+#define RTL_DMA1_COUNT				0x20
+#define RTL_DMA1_DESC_PTR			0x24
+#define RTL_DMA_COMMAND_STATUS		0x28
+#define RTL_DMA_ARB0				0x2C
+#define RTL_DMA_ARB1				0x30
 
 /************************************************/
 /*		Dale Scratchpad locations				*/
 /************************************************/
-#define	DALE_CHANNEL_DEVICE_0			0		// device channel locations
-#define	DALE_CHANNEL_DEVICE_1			1
-#define	DALE_CHANNEL_DEVICE_2			2
-#define	DALE_CHANNEL_DEVICE_3			3
-
-#define	DALE_SCRATH_DEVICE_0			4		// device type codes
-#define	DALE_SCRATH_DEVICE_1			5
-#define DALE_SCRATH_DEVICE_2			6
-#define	DALE_SCRATH_DEVICE_3			7
-
-#define	DALE_RAID_0_STATUS				8
-#define DALE_RAID_1_STATUS				9
-
-#define	DALE_TIMING_MODE				12		// bus master timing mode (2, 3, 4, 5)
-#define	DALE_NUM_DRIVES					13		// number of addressable drives on this board
-#define	DALE_RAID_ON					14 		// RAID status On
-#define	DALE_LAST_ERROR					15		// Last error code from BIOS
+#define	DALE_CHANNEL_DEVICE_0		0		// device channel locations
+#define	DALE_CHANNEL_DEVICE_1		1
+#define	DALE_CHANNEL_DEVICE_2		2
+#define	DALE_CHANNEL_DEVICE_3		3
+
+#define	DALE_SCRATCH_DEVICE_0		4		// device type codes
+#define	DALE_SCRATCH_DEVICE_1		5
+#define DALE_SCRATCH_DEVICE_2		6
+#define	DALE_SCRATCH_DEVICE_3		7
+
+#define	DALE_RAID_0_STATUS			8
+#define DALE_RAID_1_STATUS			9
+
+#define	DALE_TIMING_MODE			12		// bus master timing mode (2, 3, 4, 5)
+#define	DALE_NUM_DRIVES				13		// number of addressable drives on this board
+#define	DALE_RAID_ON				14 		// RAID status On
+#define	DALE_LAST_ERROR				15		// Last error code from BIOS
+
+/************************************************/
+/*		BigD Scratchpad locations				*/
+/************************************************/
+#define	BIGD_DEVICE_0			0		// device channel locations
+#define	BIGD_DEVICE_1			1
+#define	BIGD_DEVICE_2			2
+#define	BIGD_DEVICE_3			3
+
+#define	BIGD_DEVICE_4			4		// device type codes
+#define	BIGD_DEVICE_5			5
+#define BIGD_DEVICE_6			6
+#define	BIGD_DEVICE_7			7
+
+#define	BIGD_ALARM_IMAGE		11		// ~image of alarm fail register		
+#define	BIGD_TIMING_MODE		12		// bus master timing mode (2, 3, 4, 5)
+#define	BIGD_NUM_DRIVES			13		// number of addressable drives on this board
+#define	BIGD_RAID_ON			14 		// RAID status is on for the whole board
+#define	BIGD_LAST_ERROR			15		// Last error code from BIOS
+
+#define	BIGD_RAID_0_STATUS		16
+#define BIGD_RAID_1_STATUS		17
+#define	BIGD_RAID_2_STATUS		18
+#define	BIGD_RAID_3_STATUS		19
+#define	BIGD_RAID_4_STATUS		20
+#define BIGD_RAID_5_STATUS		21
+#define	BIGD_RAID_6_STATUS		22
+#define	BIGD_RAID_7_STATUS		23
 
 /************************************************/
 /*		Dale cable select bits					*/
 /************************************************/
-#define	SEL_NONE						0x00
-#define	SEL_1							0x01
-#define	SEL_2							0x02
-
-/************************************************/
-/*		Programmable Interrupt Controller		*/
-/************************************************/
-#define	PIC1							0x20		// first 8259 base port address
-#define	PIC2							0xA0		// second 8259 base port address
-#define	INT_OCW1						1			// Operation Control Word 1: IRQ mask
-#define	EOI								0x20		// non-specific end-of-interrupt
+#define	SEL_NONE					0x00
+#define	SEL_1						0x01
+#define	SEL_2						0x02
+#define	SEL_3						0x04
+#define	SEL_4						0x08
+#define	SEL_NEW_SPEED_1				0x20
+#define	SEL_COPY					0x40
+#define	SEL_IRQ_OFF					0x80
 
 /************************************************/
 /*		Device/Geometry controls				*/
@@ -149,6 +211,18 @@
 #define	DEVICE_DASD_LBA				0x4				// LBA compatible device
 
 /************************************************/
+/*		BigD fail register bits					*/
+/************************************************/
+#define	FAIL_NONE				0x00
+#define	FAIL_0					0x01
+#define	FAIL_1					0x02
+#define	FAIL_2					0x04
+#define	FAIL_MULTIPLE			0x08
+#define	FAIL_GOOD				0x20
+#define	FAIL_AUDIBLE			0x40
+#define	FAIL_ANY				0x80
+
+/************************************************/
 /*		Setup Structure Definitions				*/
 /************************************************/
 typedef struct		// device setup parameters
@@ -168,11 +242,11 @@
 	BOOL			promptBIOS;
 	BOOL			fastFormat;
 	BOOL			shareInterrupt;
-	BOOL			rebootRebuil;
+	BOOL			rebootRebuild;
 	USHORT			timingMode;
 	USHORT			spare5;
 	USHORT			spare6;
-	SETUP_DEVICE	setupDevice[4];
+	SETUP_DEVICE	setupDevice[BIGD_MAXDRIVES];
 	}	SETUP, *PSETUP;
 
 /************************************************/
@@ -210,3 +284,281 @@
 #define	MY_SCSI_REBUILD		0x40			// byte 1 subcommand to reconstruct a mirrored pair
 #define MY_SCSI_DEMOFAIL	0x54			// byte 1 subcommand for RAID failure demonstration
 #define	MY_SCSI_ALARMMUTE	0x60			// byte 1 subcommand to mute any alarm currently on
+
+/************************************************/
+/*		Timeout konstants		 				*/
+/************************************************/
+#define	TIMEOUT_READY				100			// 100 mSec
+#define	TIMEOUT_DRQ					300			// 300 mSec
+#define	TIMEOUT_DATA				(3 * HZ)	// 3 seconds
+
+/************************************************/
+/*		Misc. macros			 				*/
+/************************************************/
+#define ANY2SCSI(up, p)					\
+((UCHAR *)up)[0] = (((ULONG)(p)) >> 8);	\
+((UCHAR *)up)[1] = ((ULONG)(p));
+
+#define SCSI2LONG(up)					\
+( (((long)*(((UCHAR *)up))) << 16)		\
++ (((long)(((UCHAR *)up)[1])) << 8)		\
++ ((long)(((UCHAR *)up)[2])) )
+
+#define XANY2SCSI(up, p)				\
+((UCHAR *)up)[0] = ((long)(p)) >> 24;	\
+((UCHAR *)up)[1] = ((long)(p)) >> 16;	\
+((UCHAR *)up)[2] = ((long)(p)) >> 8;	\
+((UCHAR *)up)[3] = ((long)(p));
+
+#define XSCSI2LONG(up)					\
+( (((long)(((UCHAR *)up)[0])) << 24)	\
++ (((long)(((UCHAR *)up)[1])) << 16)	\
++ (((long)(((UCHAR *)up)[2])) <<  8)	\
++ ((long)(((UCHAR *)up)[3])) )
+
+#define	SelectSpigot(padapter,spigot)	outb_p (spigot, padapter->regStatSel)
+#define WriteCommand(padapter,cmd)		outb_p (cmd, padapter->regStatCmd)
+#define	AtapiDevice(padapter,b)			outb_p (b, padapter->regLba24);
+#define	AtapiCountLo(padapter,b)		outb_p (b, padapter->regLba8)
+#define	AtapiCountHi(padapter,b)		outb_p (b, padapter->regLba16)
+
+/************************************************/
+/*		SCSI CDB operation codes 				*/
+/************************************************/
+#define SCSIOP_TEST_UNIT_READY		0x00
+#define SCSIOP_REZERO_UNIT			0x01
+#define SCSIOP_REWIND				0x01
+#define SCSIOP_REQUEST_BLOCK_ADDR	0x02
+#define SCSIOP_REQUEST_SENSE		0x03
+#define SCSIOP_FORMAT_UNIT			0x04
+#define SCSIOP_READ_BLOCK_LIMITS	0x05
+#define SCSIOP_REASSIGN_BLOCKS		0x07
+#define SCSIOP_READ6				0x08
+#define SCSIOP_RECEIVE				0x08
+#define SCSIOP_WRITE6				0x0A
+#define SCSIOP_PRINT				0x0A
+#define SCSIOP_SEND					0x0A
+#define SCSIOP_SEEK6				0x0B
+#define SCSIOP_TRACK_SELECT			0x0B
+#define SCSIOP_SLEW_PRINT			0x0B
+#define SCSIOP_SEEK_BLOCK			0x0C
+#define SCSIOP_PARTITION			0x0D
+#define SCSIOP_READ_REVERSE			0x0F
+#define SCSIOP_WRITE_FILEMARKS		0x10
+#define SCSIOP_FLUSH_BUFFER			0x10
+#define SCSIOP_SPACE				0x11
+#define SCSIOP_INQUIRY				0x12
+#define SCSIOP_VERIFY6				0x13
+#define SCSIOP_RECOVER_BUF_DATA		0x14
+#define SCSIOP_MODE_SELECT			0x15
+#define SCSIOP_RESERVE_UNIT			0x16
+#define SCSIOP_RELEASE_UNIT			0x17
+#define SCSIOP_COPY					0x18
+#define SCSIOP_ERASE				0x19
+#define SCSIOP_MODE_SENSE			0x1A
+#define SCSIOP_START_STOP_UNIT		0x1B
+#define SCSIOP_STOP_PRINT			0x1B
+#define SCSIOP_LOAD_UNLOAD			0x1B
+#define SCSIOP_RECEIVE_DIAGNOSTIC	0x1C
+#define SCSIOP_SEND_DIAGNOSTIC		0x1D
+#define SCSIOP_MEDIUM_REMOVAL		0x1E
+#define SCSIOP_READ_CAPACITY		0x25
+#define SCSIOP_READ					0x28
+#define SCSIOP_WRITE				0x2A
+#define SCSIOP_SEEK					0x2B
+#define SCSIOP_LOCATE				0x2B
+#define SCSIOP_WRITE_VERIFY			0x2E
+#define SCSIOP_VERIFY				0x2F
+#define SCSIOP_SEARCH_DATA_HIGH		0x30
+#define SCSIOP_SEARCH_DATA_EQUAL	0x31
+#define SCSIOP_SEARCH_DATA_LOW		0x32
+#define SCSIOP_SET_LIMITS			0x33
+#define SCSIOP_READ_POSITION		0x34
+#define SCSIOP_SYNCHRONIZE_CACHE	0x35
+#define SCSIOP_COMPARE				0x39
+#define SCSIOP_COPY_COMPARE			0x3A
+#define SCSIOP_WRITE_DATA_BUFF		0x3B
+#define SCSIOP_READ_DATA_BUFF		0x3C
+#define SCSIOP_CHANGE_DEFINITION	0x40
+#define SCSIOP_READ_SUB_CHANNEL		0x42
+#define SCSIOP_READ_TOC				0x43
+#define SCSIOP_READ_HEADER			0x44
+#define SCSIOP_PLAY_AUDIO			0x45
+#define SCSIOP_PLAY_AUDIO_MSF		0x47
+#define SCSIOP_PLAY_TRACK_INDEX		0x48
+#define SCSIOP_PLAY_TRACK_RELATIVE	0x49
+#define SCSIOP_PAUSE_RESUME			0x4B
+#define SCSIOP_LOG_SELECT			0x4C
+#define SCSIOP_LOG_SENSE			0x4D
+#define SCSIOP_MODE_SELECT10		0x55
+#define SCSIOP_MODE_SENSE10			0x5A
+#define SCSIOP_LOAD_UNLOAD_SLOT		0xA6
+#define SCSIOP_MECHANISM_STATUS		0xBD
+#define SCSIOP_READ_CD				0xBE
+
+// IDE command definitions
+#define IDE_COMMAND_ATAPI_RESET		0x08
+#define IDE_COMMAND_READ			0x20
+#define IDE_COMMAND_WRITE			0x30
+#define IDE_COMMAND_RECALIBRATE		0x10
+#define IDE_COMMAND_SEEK			0x70
+#define IDE_COMMAND_SET_PARAMETERS	0x91
+#define IDE_COMMAND_VERIFY			0x40
+#define IDE_COMMAND_ATAPI_PACKET	0xA0
+#define IDE_COMMAND_ATAPI_IDENTIFY	0xA1
+#define	IDE_CMD_READ_MULTIPLE		0xC4
+#define	IDE_CMD_WRITE_MULTIPLE		0xC5
+#define	IDE_CMD_SET_MULTIPLE		0xC6
+#define IDE_COMMAND_IDENTIFY		0xEC
+
+// IDE status definitions
+#define IDE_STATUS_ERROR			0x01
+#define IDE_STATUS_INDEX			0x02
+#define IDE_STATUS_CORRECTED_ERROR	0x04
+#define IDE_STATUS_DRQ				0x08
+#define IDE_STATUS_DSC				0x10
+#define	IDE_STATUS_WRITE_FAULT		0x20
+#define IDE_STATUS_DRDY				0x40
+#define IDE_STATUS_BUSY				0x80
+
+typedef struct _ATAPI_STATUS
+	{
+	CHAR	check		:1;
+	CHAR	reserved1	:1;
+	CHAR	corr		:1;
+	CHAR	drq			:1;
+	CHAR	dsc			:1;
+	CHAR	reserved2	:1;
+	CHAR	drdy		:1;
+	CHAR	bsy			:1;
+	}	ATAPI_STATUS;
+
+typedef struct _ATAPI_REASON
+	{
+	CHAR	cod			:1;
+	CHAR	io			:1;
+	CHAR	reserved1	:6;
+	}	ATAPI_REASON;
+
+typedef struct _ATAPI_ERROR
+	{
+	CHAR	ili			:1;
+	CHAR	eom			:1;
+	CHAR	abort		:1;
+	CHAR	mcr			:1;
+	CHAR	senseKey	:4;
+	}	ATAPI_ERROR;
+
+// IDE error definitions
+#define	IDE_ERROR_AMNF				0x01
+#define	IDE_ERROR_TKONF				0x02
+#define	IDE_ERROR_ABRT				0x04
+#define	IDE_ERROR_MCR				0x08
+#define	IDE_ERROR_IDFN				0x10
+#define	IDE_ERROR_MC				0x20
+#define	IDE_ERROR_UNC				0x40
+#define	IDE_ERROR_BBK				0x80
+
+// SCSI read capacity structure
+typedef	struct _READ_CAPACITY_DATA
+	{
+	ULONG blks;				/* total blocks (converted to little endian) */
+	ULONG blksiz;			/* size of each (converted to little endian) */
+	}	READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
+
+// SCSI inquiry data
+typedef struct _INQUIRYDATA
+	{
+	UCHAR DeviceType			:5;
+	UCHAR DeviceTypeQualifier	:3;
+	UCHAR DeviceTypeModifier	:7;
+	UCHAR RemovableMedia		:1;
+    UCHAR Versions;
+    UCHAR ResponseDataFormat;
+    UCHAR AdditionalLength;
+    UCHAR Reserved[2];
+	UCHAR SoftReset				:1;
+	UCHAR CommandQueue			:1;
+	UCHAR Reserved2				:1;
+	UCHAR LinkedCommands		:1;
+	UCHAR Synchronous			:1;
+	UCHAR Wide16Bit				:1;
+	UCHAR Wide32Bit				:1;
+	UCHAR RelativeAddressing	:1;
+    UCHAR VendorId[8];
+    UCHAR ProductId[16];
+    UCHAR ProductRevisionLevel[4];
+    UCHAR VendorSpecific[20];
+    UCHAR Reserved3[40];
+	}	INQUIRYDATA, *PINQUIRYDATA;
+
+// IDE IDENTIFY data
+#pragma pack (1)
+typedef struct _IDENTIFY_DATA
+	{
+    USHORT	GeneralConfiguration;		//  0
+    USHORT	NumberOfCylinders;			//  1
+    USHORT	Reserved1;					//  2
+    USHORT	NumberOfHeads;				//  3
+    USHORT	UnformattedBytesPerTrack;	//  4
+    USHORT	UnformattedBytesPerSector;	//  5
+    USHORT	SectorsPerTrack;			//  6
+	USHORT	NumBytesISG;				//  7 Byte Len - inter-sector gap
+	USHORT	NumBytesSync;				//  8          - sync field
+	USHORT	NumWordsVUS;				//  9 Len - Vendor Unique Info
+    USHORT	SerialNumber[10];			// 10
+    USHORT	BufferType;					// 20
+    USHORT	BufferSectorSize;			// 21
+    USHORT	NumberOfEccBytes;			// 22
+    USHORT	FirmwareRevision[4];		// 23
+    USHORT	ModelNumber[20];			// 27
+	USHORT	NumSectorsPerInt	:8;		// 47 Multiple Mode - Sec/Blk
+	USHORT	Reserved2			:8;		// 47
+	USHORT	DoubleWordMode;				// 48 flag for double word mode capable
+	USHORT	VendorUnique1		:8;		// 49
+	USHORT	SupportDMA			:1;		// 49 DMA supported
+	USHORT	SupportLBA			:1;		// 49 LBA supported
+	USHORT	SupportIORDYDisable	:1;		// 49 IORDY can be disabled
+	USHORT	SupportIORDY		:1;		// 49 IORDY supported
+	USHORT	ReservedPsuedoDMA	:1;		// 49 reserved for pseudo DMA mode support
+	USHORT	Reserved3			:3;		// 49
+	USHORT	Reserved4;					// 50
+	USHORT	Reserved5			:8;		// 51 Transfer Cycle Timing - PIO
+	USHORT	PIOCycleTime		:8;		// 51 Transfer Cycle Timing - PIO
+	USHORT	Reserved6			:8;		// 52                       - DMA
+	USHORT	DMACycleTime		:8;		// 52                       - DMA
+	USHORT	Valid_54_58			:1;		// 53 words 54 - 58 are vaild
+	USHORT	Valid_64_70			:1;		// 53 words 64 - 70 are valid
+	USHORT	Reserved7			:14;	// 53
+	USHORT	LogNumCyl;					// 54 Current Translation - Num Cyl
+	USHORT	LogNumHeads;				// 55                       Num Heads
+	USHORT	LogSectorsPerTrack;			// 56                       Sec/Trk
+	ULONG	LogTotalSectors;			// 57                       Total Sec
+	USHORT	CurrentNumSecPerInt	:8;		// 59 current setting for number of sectors per interrupt
+	USHORT	ValidNumSecPerInt	:1;		// 59 Current setting is valid for number of sectors per interrupt
+	USHORT	Reserved8			:7;		// 59
+	ULONG	LBATotalSectors;			// 60 LBA Mode - Sectors
+	USHORT	DMASWordFlags;				// 62
+	USHORT	DMAMWordFlags;				// 63
+	USHORT	AdvancedPIOSupport  :8;		// 64 Flow control PIO transfer modes supported
+	USHORT	Reserved9			:8;		// 64
+	USHORT	MinMultiDMACycle;			// 65 minimum multiword DMA transfer cycle time per word
+	USHORT	RecomendDMACycle;			// 66 Manufacturer's recommende multiword DMA transfer cycle time
+	USHORT	MinPIOCycleWithoutFlow;		// 67 Minimum PIO transfer cycle time without flow control
+	USHORT	MinPIOCylceWithFlow;		// 68 Minimum PIO transfer cycle time with IORDY flow control
+	USHORT	ReservedSpace[256-69];		// 69
+	}	IDENTIFY_DATA, *PIDENTIFY_DATA;
+
+// ATAPI configuration bits
+typedef struct _ATAPI_GENERAL_0
+	{
+	USHORT	CmdPacketSize		:2;		// Command packet size
+	USHORT	Reserved1			:3;
+	USHORT	CmdDrqType			:2;
+	USHORT	Removable			:1;
+	USHORT	DeviceType			:5;
+	USHORT	Reserved2			:1;
+	USHORT	ProtocolType		:2;
+	}	ATAPI_GENERAL_0;
+
+#pragma pack ()
diff -urN linux-2.2.15-pre8/drivers/scsi/qlogicfc.c linux/drivers/scsi/qlogicfc.c
--- linux-2.2.15-pre8/drivers/scsi/qlogicfc.c	Mon Dec  3 21:59:32 2001
+++ linux/drivers/scsi/qlogicfc.c	Mon Dec  3 21:59:38 2001
@@ -64,7 +64,7 @@
 /* Configuration section **************************************************** */
 
 /* Set the following macro to 1 to reload the ISP2x00's firmware.  This is
-   version 1.15.37 of the isp2100's firmware and version 2.00.16 of the 
+   version 1.17.30 of the isp2100's firmware and version 2.00.40 of the 
    isp2200's firmware. 
 */
 
@@ -91,7 +91,7 @@
 /* #define TRACE_ISP             1 */
 
 
-#define DEFAULT_LOOP_COUNT	10000000
+#define DEFAULT_LOOP_COUNT	1000000000
 
 /* End Configuration section ************************************************ */
 
@@ -632,6 +632,17 @@
 #define QLOGICFC_MAX_LUN	128
 #define QLOGICFC_MAX_LOOP_ID 	0x7d
 
+/* the following connection options only apply to the 2200.  i have only
+ * had success with LOOP_ONLY and P2P_ONLY.
+ */
+
+#define LOOP_ONLY              0
+#define P2P_ONLY               1
+#define LOOP_PREFERED          2
+#define P2P_PREFERED           3
+
+#define CONNECTION_PREFERENCE  LOOP_ONLY
+
 /* adapter_state values */
 #define AS_FIRMWARE_DEAD      -1
 #define AS_LOOP_DOWN           0
@@ -769,7 +780,7 @@
 			hostdata->queued = 0;
 			/* set up the control block */
 			hostdata->control_block.version = 0x1;
-			hostdata->control_block.firm_opts = 0x000e;
+			hostdata->control_block.firm_opts = 0x800e;
 			hostdata->control_block.max_frame_len = 2048;
 			hostdata->control_block.max_iocb = QLOGICFC_REQ_QUEUE_LEN;
 			hostdata->control_block.exec_throttle = QLOGICFC_CMD_PER_LUN;
@@ -787,6 +798,8 @@
 			hostdata->control_block.req_queue_addr_lo = virt_to_bus_low32(hostdata->req);
 			hostdata->control_block.req_queue_addr_high = virt_to_bus_high32(hostdata->req);
 
+
+			hostdata->control_block.add_firm_opts |= CONNECTION_PREFERENCE<<4;
 			hostdata->adapter_state = AS_LOOP_DOWN;
 			hostdata->explore_timer.data = 1;
 			hostdata->host_id = hosts;
