--- linux/drivers/scsi/pci2000.c Mon Mar 22 21:05:53 1999
+++ linux-2.2.4-pci2k/drivers/scsi/pci2000.c Wed Mar 24 13:35:39 1999
@@ -34,10 +34,8 @@
#include <linux/module.h>
#include <linux/kernel.h>
-#include <linux/head.h>
#include <linux/types.h>
#include <linux/string.h>
-#include <linux/bios32.h>
#include <linux/pci.h>
#include <linux/ioport.h>
#include <linux/delay.h>
@@ -570,58 +568,53 @@
****************************************************************/
int Pci2000_Detect (Scsi_Host_Template *tpnt)
{
- int pci_index = 0;
+ int num_found = 0;
struct Scsi_Host *pshost;
PADAPTER2000 padapter;
int z, zz;
int setirq;
+ struct pci_dev *pdev = NULL;
- if ( pcibios_present () )
- {
- for ( pci_index = 0; pci_index <= MAXADAPTER; ++pci_index )
- {
- UCHAR pci_bus, pci_device_fn;
-
- if ( pcibios_find_device (VENDOR_PSI, DEVICE_ROY_1, pci_index, &pci_bus, &pci_device_fn) != 0 )
- break;
-
- pshost = scsi_register (tpnt, sizeof(ADAPTER2000));
- padapter = HOSTDATA(pshost);
-
- pcibios_read_config_word (pci_bus, pci_device_fn, PCI_BASE_ADDRESS_1, &padapter->basePort);
- padapter->basePort &= 0xFFFE;
- DEB (printk ("\nBase Regs = %#04X", padapter->basePort)); // get the base I/O port address
- padapter->mb0 = padapter->basePort + RTR_MAILBOX; // get the 32 bit mail boxes
- padapter->mb1 = padapter->basePort + RTR_MAILBOX + 4;
- padapter->mb2 = padapter->basePort + RTR_MAILBOX + 8;
- padapter->mb3 = padapter->basePort + RTR_MAILBOX + 12;
- padapter->mb4 = padapter->basePort + RTR_MAILBOX + 16;
- padapter->cmd = padapter->basePort + RTR_LOCAL_DOORBELL; // command register
- padapter->tag = padapter->basePort + RTR_PCI_DOORBELL; // tag/response register
-
- if ( WaitReady (padapter) )
- goto unregister;
- outb_p (0x84, padapter->mb0);
- outb_p (CMD_SPECIFY, padapter->cmd);
- if ( WaitReady (padapter) )
- goto unregister;
+ if (!pci_present()) {
+ printk("pci2000: PCI BIOS not present\n");
+ return 0;
+ }
+ while ((pdev = pci_find_device(VENDOR_PSI, DEVICE_ROY_1, pdev)) != NULL) {
+ pshost = scsi_register (tpnt, sizeof(ADAPTER2000));
+ padapter = HOSTDATA(pshost);
+ padapter->basePort = pdev->base_address[1] & 0xFFFE;
+ DEB (printk("\nBase Regs = %#04X", padapter->basePort)); // get the base I/O port address
+
+ padapter->mb0 = padapter->basePort + RTR_MAILBOX; // get the 32 bit mail boxes
+ padapter->mb1 = padapter->basePort + RTR_MAILBOX + 4;
+ padapter->mb2 = padapter->basePort + RTR_MAILBOX + 8;
+ padapter->mb3 = padapter->basePort + RTR_MAILBOX + 12;
+ padapter->mb4 = padapter->basePort + RTR_MAILBOX + 16;
+ padapter->cmd = padapter->basePort + RTR_LOCAL_DOORBELL; // command register
+ padapter->tag = padapter->basePort + RTR_PCI_DOORBELL; // tag/response register
+ if ( WaitReady (padapter) )
+ goto unregister;
+ outb_p (0x84, padapter->mb0);
+ outb_p (CMD_SPECIFY, padapter->cmd);
+ if ( WaitReady (padapter) )
+ goto unregister;
- pcibios_read_config_byte (pci_bus, pci_device_fn, PCI_INTERRUPT_LINE, &pshost->irq);
- setirq = 1;
- for ( z = 0; z < pci_index; 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
+ pshost->irq = pdev->irq;
+ setirq = 1;
+ for ( z = 0; z < num_found; 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, 0, "pci2000", NULL) )
{
- if ( request_irq (pshost->irq, Irq_Handler, 0, "pci2000", NULL) )
- {
- printk ("Unable to allocate IRQ for PSI-2000 controller.\n");
- goto unregister;
- }
+ printk ("Unable to allocate IRQ for PSI-2000 controller.\n");
+ goto unregister;
}
- PsiHost[pci_index] = pshost; // save SCSI_HOST pointer
+ }
+ PsiHost[num_found] = pshost; // save SCSI_HOST pointer
pshost->unique_id = padapter->basePort;
pshost->max_id = 16;
@@ -633,13 +626,14 @@
printk("\nPSI-2000 Intelligent Storage SCSI CONTROLLER: at I/O = %X IRQ = %d\n", padapter->basePort, pshost->irq);
printk("Version %s, Compiled %s %s\n\n", PCI2000_VERSION, __DATE__, __TIME__);
+ if (++num_found >= MAXADAPTER)
+ break;
continue;
unregister:;
scsi_unregister (pshost);
- }
}
- NumAdapters = pci_index;
- return pci_index;
+ NumAdapters = num_found;
+ return num_found;
}
/****************************************************************
* Name: Pci2220i_Abort