1995-01-13 02:23:27 +00:00
|
|
|
/*
|
|
|
|
* Product specific probe and attach routines for:
|
1995-09-05 23:53:48 +00:00
|
|
|
* 3940, 2940, aic7870, and aic7850 SCSI controllers
|
1995-01-13 02:23:27 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 1995 Justin T. Gibbs
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice immediately at the beginning of the file, without modification,
|
|
|
|
* this list of conditions, and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Absolutely no warranty of function or purpose is made by the author
|
|
|
|
* Justin T. Gibbs.
|
|
|
|
* 4. Modifications may be freely made to this file if the above conditions
|
|
|
|
* are met.
|
1995-01-16 16:31:57 +00:00
|
|
|
*
|
1995-11-07 05:33:27 +00:00
|
|
|
* $Id: aic7870.c,v 1.18 1995/11/05 04:51:58 gibbs Exp $
|
1995-01-13 02:23:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <pci.h>
|
|
|
|
#if NPCI > 0
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1995-03-31 14:08:33 +00:00
|
|
|
#include <sys/malloc.h>
|
1995-04-15 21:38:34 +00:00
|
|
|
#include <sys/kernel.h>
|
1995-01-13 02:23:27 +00:00
|
|
|
#include <scsi/scsi_all.h>
|
|
|
|
#include <scsi/scsiconf.h>
|
1995-02-02 12:36:19 +00:00
|
|
|
#include <pci/pcireg.h>
|
1995-02-02 13:12:18 +00:00
|
|
|
#include <pci/pcivar.h>
|
1995-01-13 02:23:27 +00:00
|
|
|
#include <i386/scsi/aic7xxx.h>
|
|
|
|
|
|
|
|
#define PCI_BASEADR0 PCI_MAP_REG_START
|
1995-10-26 23:58:59 +00:00
|
|
|
#define PCI_DEVICE_ID_ADAPTEC_3940U 0x82789004ul
|
1995-10-08 17:46:11 +00:00
|
|
|
#define PCI_DEVICE_ID_ADAPTEC_2940U 0x81789004ul
|
1995-07-04 21:21:33 +00:00
|
|
|
#define PCI_DEVICE_ID_ADAPTEC_3940 0x72789004ul
|
1995-01-13 02:23:27 +00:00
|
|
|
#define PCI_DEVICE_ID_ADAPTEC_2940 0x71789004ul
|
1995-10-26 23:58:59 +00:00
|
|
|
#define PCI_DEVICE_ID_ADAPTEC_AIC7880 0x80789004ul
|
1995-01-22 00:47:50 +00:00
|
|
|
#define PCI_DEVICE_ID_ADAPTEC_AIC7870 0x70789004ul
|
1995-08-20 03:18:09 +00:00
|
|
|
#define PCI_DEVICE_ID_ADAPTEC_AIC7850 0x50789004ul
|
1995-01-13 02:23:27 +00:00
|
|
|
|
1995-09-05 23:53:48 +00:00
|
|
|
#define DEVCONFIG 0x40
|
|
|
|
#define MPORTMODE 0x00000400ul /* aic7870 only */
|
|
|
|
#define RAMPSM 0x00000200ul /* aic7870 only */
|
|
|
|
#define VOLSENSE 0x00000100ul
|
1995-10-26 23:58:59 +00:00
|
|
|
#define RAMENB 0x00000080ul
|
1995-09-05 23:53:48 +00:00
|
|
|
#define MRDCEN 0x00000040ul
|
|
|
|
#define EXTSCBTIME 0x00000020ul /* aic7870 only */
|
|
|
|
#define EXTSCBPEN 0x00000010ul /* aic7870 only */
|
|
|
|
#define BERREN 0x00000008ul
|
|
|
|
#define DACEN 0x00000004ul
|
|
|
|
#define STPWLEVEL 0x00000002ul
|
|
|
|
#define DIFACTNEGEN 0x00000001ul /* aic7870 only */
|
|
|
|
|
1995-01-13 02:23:27 +00:00
|
|
|
static char* aic7870_probe __P((pcici_t tag, pcidi_t type));
|
|
|
|
void aic7870_attach __P((pcici_t config_id, int unit));
|
|
|
|
|
1995-09-05 23:53:48 +00:00
|
|
|
static u_char aic3940_count;
|
1995-01-13 02:23:27 +00:00
|
|
|
|
1995-11-05 04:51:58 +00:00
|
|
|
struct pci_device ahc_pci_driver = {
|
1995-02-02 13:12:18 +00:00
|
|
|
"ahc",
|
1995-01-13 02:23:27 +00:00
|
|
|
aic7870_probe,
|
|
|
|
aic7870_attach,
|
1995-11-05 04:51:58 +00:00
|
|
|
&ahc_unit,
|
1995-03-17 04:27:21 +00:00
|
|
|
NULL
|
1995-01-13 02:23:27 +00:00
|
|
|
};
|
|
|
|
|
1995-11-05 04:51:58 +00:00
|
|
|
DATA_SET (pcidevice_set, ahc_pci_driver);
|
1995-02-02 13:12:18 +00:00
|
|
|
|
1995-05-30 08:16:23 +00:00
|
|
|
static char*
|
1995-01-13 02:23:27 +00:00
|
|
|
aic7870_probe (pcici_t tag, pcidi_t type)
|
1995-05-30 08:16:23 +00:00
|
|
|
{
|
1995-01-13 02:23:27 +00:00
|
|
|
switch(type) {
|
1995-10-26 23:58:59 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_3940U:
|
|
|
|
return ("Adaptec 3940 Ultra SCSI host adapter");
|
|
|
|
break;
|
1995-07-04 21:21:33 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_3940:
|
|
|
|
return ("Adaptec 3940 SCSI host adapter");
|
|
|
|
break;
|
1995-10-08 17:46:11 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_2940U:
|
|
|
|
return ("Adaptec 2940 Ultra SCSI host adapter");
|
|
|
|
break;
|
1995-01-13 02:23:27 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_2940:
|
1995-07-04 21:21:33 +00:00
|
|
|
return ("Adaptec 2940 SCSI host adapter");
|
1995-03-31 14:08:33 +00:00
|
|
|
break;
|
1995-10-26 23:58:59 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_AIC7880:
|
|
|
|
return ("Adaptec aic7880 Ultra SCSI host adapter");
|
|
|
|
break;
|
1995-01-22 00:47:50 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_AIC7870:
|
1995-03-31 14:08:33 +00:00
|
|
|
return ("Adaptec aic7870 SCSI host adapter");
|
|
|
|
break;
|
1995-06-11 19:33:05 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_AIC7850:
|
|
|
|
return ("Adaptec aic7850 SCSI host adapter");
|
|
|
|
break;
|
1995-01-13 02:23:27 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
aic7870_attach(config_id, unit)
|
|
|
|
pcici_t config_id;
|
|
|
|
int unit;
|
1995-05-30 08:16:23 +00:00
|
|
|
{
|
|
|
|
u_long io_port;
|
1995-10-26 23:58:59 +00:00
|
|
|
u_long id;
|
1995-03-31 14:08:33 +00:00
|
|
|
unsigned opri = 0;
|
|
|
|
ahc_type ahc_t = AHC_NONE;
|
1995-09-05 23:53:48 +00:00
|
|
|
ahc_flag ahc_f = AHC_FNONE;
|
1995-11-05 04:51:58 +00:00
|
|
|
struct ahc_data *ahc;
|
|
|
|
|
1995-03-31 14:08:33 +00:00
|
|
|
if(!(io_port = pci_conf_read(config_id, PCI_BASEADR0)))
|
1995-01-13 02:23:27 +00:00
|
|
|
return;
|
1995-03-31 14:08:33 +00:00
|
|
|
/*
|
|
|
|
* The first bit of PCI_BASEADR0 is always
|
1995-11-05 04:51:58 +00:00
|
|
|
* set hence we mask it off.
|
1995-03-31 14:08:33 +00:00
|
|
|
*/
|
1995-11-05 04:51:58 +00:00
|
|
|
io_port &= 0xfffffffe;
|
1995-03-31 14:08:33 +00:00
|
|
|
|
1995-10-26 23:58:59 +00:00
|
|
|
switch ((id = pci_conf_read(config_id, PCI_ID_REG))) {
|
|
|
|
case PCI_DEVICE_ID_ADAPTEC_3940U:
|
1995-07-04 21:21:33 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_3940:
|
1995-10-26 23:58:59 +00:00
|
|
|
if (id == PCI_DEVICE_ID_ADAPTEC_3940U)
|
|
|
|
ahc_t = AHC_394U;
|
|
|
|
else
|
|
|
|
ahc_t = AHC_394;
|
1995-09-05 23:53:48 +00:00
|
|
|
aic3940_count++;
|
|
|
|
if(!(aic3940_count & 0x01))
|
|
|
|
/* Even count implies second channel */
|
|
|
|
ahc_f |= AHC_CHNLB;
|
1995-10-26 23:58:59 +00:00
|
|
|
/* Even though it doesn't turn on RAMPS, it has them */
|
|
|
|
ahc_f |= AHC_EXTSCB;
|
1995-07-04 21:21:33 +00:00
|
|
|
break;
|
1995-10-08 17:46:11 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_2940U:
|
1995-10-26 23:58:59 +00:00
|
|
|
ahc_t = AHC_294U;
|
|
|
|
break;
|
1995-03-31 14:08:33 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_2940:
|
1995-05-30 08:16:23 +00:00
|
|
|
ahc_t = AHC_294;
|
1995-03-31 14:08:33 +00:00
|
|
|
break;
|
1995-10-26 23:58:59 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_AIC7880:
|
|
|
|
ahc_t = AHC_AIC7880;
|
|
|
|
break;
|
1995-03-31 14:08:33 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_AIC7870:
|
|
|
|
ahc_t = AHC_AIC7870;
|
|
|
|
break;
|
1995-06-11 19:33:05 +00:00
|
|
|
case PCI_DEVICE_ID_ADAPTEC_AIC7850:
|
|
|
|
ahc_t = AHC_AIC7850;
|
|
|
|
break;
|
1995-03-31 14:08:33 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1995-09-05 23:53:48 +00:00
|
|
|
if(ahc_t & AHC_AIC7870){
|
|
|
|
u_long devconfig = pci_conf_read(config_id, DEVCONFIG);
|
1995-10-26 23:58:59 +00:00
|
|
|
if(devconfig & (RAMPSM|RAMENB)) {
|
1995-09-05 23:53:48 +00:00
|
|
|
/*
|
|
|
|
* External SRAM present. Have the probe walk
|
|
|
|
* the SCBs to see how much SRAM we have and set
|
|
|
|
* the number of SCBs accordingly.
|
|
|
|
*/
|
|
|
|
ahc_f |= AHC_EXTSCB;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-11-05 04:51:58 +00:00
|
|
|
ahc_reset(io_port);
|
|
|
|
|
|
|
|
if(!(ahc = ahc_alloc(unit, io_port, ahc_t, ahc_f)))
|
|
|
|
return; /* XXX PCI code should take return status */
|
|
|
|
|
|
|
|
if(!(pci_map_int(config_id, ahcintr, (void *)ahc, &bio_imask))) {
|
|
|
|
ahc_free(ahc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Protect ourself from spurrious interrupts during
|
|
|
|
* intialization.
|
|
|
|
*/
|
|
|
|
opri = splbio();
|
|
|
|
|
|
|
|
if(ahc_init(unit)){
|
|
|
|
ahc_free(ahc);
|
1995-03-31 14:08:33 +00:00
|
|
|
splx(opri);
|
1995-11-05 04:51:58 +00:00
|
|
|
return; /* XXX PCI code should take return status */
|
1995-01-13 02:23:27 +00:00
|
|
|
}
|
1995-11-05 04:51:58 +00:00
|
|
|
|
|
|
|
ahc_attach(unit);
|
|
|
|
splx(opri);
|
1995-01-13 02:23:27 +00:00
|
|
|
return;
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1995-01-13 02:23:27 +00:00
|
|
|
|
|
|
|
#endif /* NPCI > 0 */
|