1994-11-17 20:22:31 +00:00
|
|
|
/*
|
1995-01-13 02:23:27 +00:00
|
|
|
* Product specific probe and attach routines for:
|
|
|
|
* 27/284X and aic7770 motherboard SCSI controllers
|
1994-11-17 20:22:31 +00:00
|
|
|
*
|
1995-01-13 02:23:27 +00:00
|
|
|
* Copyright (c) 1995 Justin T. Gibbs
|
|
|
|
* All rights reserved.
|
1994-11-17 20:22:31 +00:00
|
|
|
*
|
1995-01-13 02:23:27 +00:00
|
|
|
* 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:34 +00:00
|
|
|
*
|
1996-01-03 06:28:01 +00:00
|
|
|
* $Id: aic7770.c,v 1.20 1995/12/14 23:23:48 bde Exp $
|
1994-11-17 20:22:31 +00:00
|
|
|
*/
|
|
|
|
|
1995-11-05 04:42:50 +00:00
|
|
|
#include "eisa.h"
|
|
|
|
#if NEISA > 0
|
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1995-11-05 04:42:50 +00:00
|
|
|
#include <sys/devconf.h>
|
|
|
|
#include <sys/kernel.h>
|
1996-01-03 06:28:01 +00:00
|
|
|
|
1994-11-17 20:22:31 +00:00
|
|
|
#include <scsi/scsi_all.h>
|
|
|
|
#include <scsi/scsiconf.h>
|
1996-01-03 06:28:01 +00:00
|
|
|
|
1995-11-05 04:42:50 +00:00
|
|
|
#include <machine/clock.h>
|
1996-01-03 06:28:01 +00:00
|
|
|
|
1995-11-05 04:42:50 +00:00
|
|
|
#include <i386/eisa/eisaconf.h>
|
1995-01-13 02:23:27 +00:00
|
|
|
#include <i386/scsi/aic7xxx.h>
|
1995-11-05 04:42:50 +00:00
|
|
|
#include <dev/aic7xxx/aic7xxx_reg.h>
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-11-05 04:42:50 +00:00
|
|
|
#define EISA_DEVICE_ID_ADAPTEC_AIC7770 0x04907770
|
|
|
|
#define EISA_DEVICE_ID_ADAPTEC_274x 0x04907771
|
|
|
|
#define EISA_DEVICE_ID_ADAPTEC_284xB 0x04907756 /* BIOS enabled */
|
|
|
|
#define EISA_DEVICE_ID_ADAPTEC_284x 0x04907757 /* BIOS disabled*/
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-11-05 04:42:50 +00:00
|
|
|
#define AHC_EISA_IOSIZE 0x100
|
|
|
|
#define INTDEF 0x5cul /* Interrupt Definition Register */
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-11-29 10:12:34 +00:00
|
|
|
static int aic7770probe __P((void));
|
|
|
|
static int aic7770_attach __P((struct eisa_device *e_dev));
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-11-29 10:12:34 +00:00
|
|
|
static struct eisa_driver ahc_eisa_driver = {
|
1995-11-05 04:42:50 +00:00
|
|
|
"ahc",
|
|
|
|
aic7770probe,
|
|
|
|
aic7770_attach,
|
|
|
|
/*shutdown*/NULL,
|
|
|
|
&ahc_unit
|
|
|
|
};
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-11-05 04:42:50 +00:00
|
|
|
DATA_SET (eisadriver_set, ahc_eisa_driver);
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-11-05 04:42:50 +00:00
|
|
|
static struct kern_devconf kdc_aic7770 = {
|
1995-01-13 02:23:27 +00:00
|
|
|
0, 0, 0, /* filled in by dev_attach */
|
1995-11-05 04:42:50 +00:00
|
|
|
"ahc", 0, { MDDT_EISA, 0, "bio" },
|
|
|
|
eisa_generic_externalize, 0, 0, EISA_EXTERNALLEN,
|
|
|
|
&kdc_eisa0, /* parent */
|
1995-01-13 02:23:27 +00:00
|
|
|
0, /* parentdata */
|
1995-04-12 20:48:13 +00:00
|
|
|
DC_UNCONFIGURED, /* always start out here */
|
1995-11-05 04:42:50 +00:00
|
|
|
NULL,
|
1995-04-12 20:48:13 +00:00
|
|
|
DC_CLS_MISC /* host adapters aren't special */
|
1995-11-05 04:42:50 +00:00
|
|
|
};
|
1994-11-18 20:34:30 +00:00
|
|
|
|
1996-01-03 06:28:01 +00:00
|
|
|
|
1995-12-14 23:23:48 +00:00
|
|
|
static char *aic7770_match __P((eisa_id_t type));
|
|
|
|
|
1995-11-05 04:42:50 +00:00
|
|
|
static char*
|
|
|
|
aic7770_match(type)
|
|
|
|
eisa_id_t type;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1995-11-05 04:42:50 +00:00
|
|
|
switch(type) {
|
|
|
|
case EISA_DEVICE_ID_ADAPTEC_AIC7770:
|
|
|
|
return ("Adaptec aic7770 SCSI host adapter");
|
|
|
|
break;
|
|
|
|
case EISA_DEVICE_ID_ADAPTEC_274x:
|
|
|
|
return ("Adaptec 274X SCSI host adapter");
|
|
|
|
break;
|
|
|
|
case EISA_DEVICE_ID_ADAPTEC_284xB:
|
|
|
|
case EISA_DEVICE_ID_ADAPTEC_284x:
|
|
|
|
return ("Adaptec 284X SCSI host adapter");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return (NULL);
|
1995-05-30 08:16:23 +00:00
|
|
|
}
|
1994-11-17 20:22:31 +00:00
|
|
|
|
1995-11-29 10:12:34 +00:00
|
|
|
static int
|
1995-11-05 04:42:50 +00:00
|
|
|
aic7770probe(void)
|
1995-05-30 08:16:23 +00:00
|
|
|
{
|
1995-11-05 04:42:50 +00:00
|
|
|
u_long iobase;
|
|
|
|
char intdef;
|
|
|
|
u_long irq;
|
|
|
|
struct eisa_device *e_dev = NULL;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
while ((e_dev = eisa_match_dev(e_dev, aic7770_match))) {
|
|
|
|
iobase = e_dev->ioconf.iobase;
|
|
|
|
ahc_reset(iobase);
|
|
|
|
|
|
|
|
eisa_add_iospace(e_dev, iobase, AHC_EISA_IOSIZE);
|
|
|
|
intdef = inb(INTDEF + iobase);
|
|
|
|
switch (intdef & 0xf) {
|
|
|
|
case 9:
|
|
|
|
irq = 9;
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
irq = 10;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
irq = 11;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
irq = 12;
|
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
irq = 14;
|
|
|
|
break;
|
|
|
|
case 15:
|
|
|
|
irq = 15;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("aic7770 at slot %d: illegal "
|
|
|
|
"irq setting %d\n", e_dev->ioconf.slot,
|
|
|
|
intdef);
|
|
|
|
continue;
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
1995-11-05 04:42:50 +00:00
|
|
|
eisa_add_intr(e_dev, irq);
|
|
|
|
eisa_registerdev(e_dev, &ahc_eisa_driver, &kdc_aic7770);
|
1995-11-09 07:14:11 +00:00
|
|
|
if(e_dev->id == EISA_DEVICE_ID_ADAPTEC_284xB
|
|
|
|
|| e_dev->id == EISA_DEVICE_ID_ADAPTEC_284x) {
|
1996-01-03 06:28:01 +00:00
|
|
|
/* Our real parent is the isa bus. Say so. */
|
1995-11-09 07:14:11 +00:00
|
|
|
e_dev->kdc->kdc_parent = &kdc_isa0;
|
|
|
|
}
|
1995-11-05 04:42:50 +00:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
return count;
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1995-11-29 10:12:34 +00:00
|
|
|
static int
|
1995-11-05 04:42:50 +00:00
|
|
|
aic7770_attach(e_dev)
|
|
|
|
struct eisa_device *e_dev;
|
1994-11-17 20:22:31 +00:00
|
|
|
{
|
1995-11-05 04:42:50 +00:00
|
|
|
ahc_type type;
|
|
|
|
struct ahc_data *ahc;
|
1996-01-03 06:28:01 +00:00
|
|
|
u_long iobase;
|
1995-11-05 04:42:50 +00:00
|
|
|
int unit = e_dev->unit;
|
|
|
|
int irq = ffs(e_dev->ioconf.irq) - 1;
|
|
|
|
|
|
|
|
switch(e_dev->id) {
|
|
|
|
case EISA_DEVICE_ID_ADAPTEC_AIC7770:
|
|
|
|
type = AHC_AIC7770;
|
|
|
|
break;
|
|
|
|
case EISA_DEVICE_ID_ADAPTEC_274x:
|
|
|
|
type = AHC_274;
|
|
|
|
break;
|
|
|
|
case EISA_DEVICE_ID_ADAPTEC_284xB:
|
|
|
|
case EISA_DEVICE_ID_ADAPTEC_284x:
|
|
|
|
type = AHC_284;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("aic7770_attach: Unknown device type!\n");
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(ahc = ahc_alloc(unit, e_dev->ioconf.iobase, type, AHC_FNONE)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
eisa_reg_start(e_dev);
|
|
|
|
if(eisa_reg_iospace(e_dev, e_dev->ioconf.iobase, AHC_EISA_IOSIZE)) {
|
|
|
|
ahc_free(ahc);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The IRQMS bit enables level sensitive interrupts only allow
|
|
|
|
* IRQ sharing if its set.
|
|
|
|
*/
|
|
|
|
if(eisa_reg_intr(e_dev, irq, ahc_eisa_intr, (void *)ahc, &bio_imask,
|
|
|
|
/*shared ==*/ahc->pause & IRQMS)) {
|
|
|
|
ahc_free(ahc);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
eisa_reg_end(e_dev);
|
|
|
|
|
|
|
|
/*
|
1996-01-03 06:28:01 +00:00
|
|
|
* Tell the user what type of interrupts we're using.
|
|
|
|
* usefull for debugging irq problems
|
|
|
|
*/
|
|
|
|
if(bootverbose) {
|
|
|
|
if(ahc->pause & IRQMS)
|
|
|
|
printf("ahc%d: Using Level Sensitive "
|
|
|
|
"Interrupts\n", unit);
|
|
|
|
else
|
|
|
|
printf("ahc%d: Using Edge Triggered "
|
|
|
|
"Interrupts\n", unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now that we know we own the resources we need, do the
|
1995-11-05 04:42:50 +00:00
|
|
|
* card initialization.
|
|
|
|
*/
|
1996-01-03 06:28:01 +00:00
|
|
|
iobase = ahc->baseport;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First, the aic7770 card specific setup.
|
|
|
|
*/
|
|
|
|
switch( ahc->type ) {
|
|
|
|
case AHC_AIC7770:
|
|
|
|
{
|
|
|
|
/* XXX
|
|
|
|
* It would be really nice to know if the BIOS
|
|
|
|
* was installed for the motherboard controllers,
|
|
|
|
* but I don't know how to yet. Assume its enabled
|
|
|
|
* for now.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AHC_274:
|
|
|
|
{
|
|
|
|
if((inb(HA_274_BIOSCTRL + iobase) & BIOSMODE) == BIOSDISABLED)
|
|
|
|
ahc->flags |= AHC_USEDEFAULTS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AHC_284:
|
|
|
|
{
|
|
|
|
/* XXX
|
|
|
|
* All values are automagically intialized at
|
|
|
|
* POST for these cards, so we can always rely
|
|
|
|
* on the Scratch Ram values. However, we should
|
|
|
|
* read the SEEPROM here (Dan has the code to do
|
|
|
|
* it) so we can say what kind of translation the
|
|
|
|
* BIOS is using. Printing out the geometry could
|
|
|
|
* save a lot of users the grief of failed installs.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if we have a Rev E or higher aic7770. Anything below a
|
|
|
|
* Rev E will have a R/O autoflush disable configuration bit.
|
|
|
|
* Its still not clear exactly what is differenent about the Rev E.
|
|
|
|
* We think it has more QINFIFO and QOUTFIFO space to support
|
|
|
|
* "paging" SCBs so you can have more than 4 commands active at
|
|
|
|
* once. We may use this information later.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
char *id_string;
|
|
|
|
u_char sblkctl;
|
|
|
|
u_char sblkctl_orig;
|
|
|
|
|
|
|
|
sblkctl_orig = inb(SBLKCTL + iobase);
|
|
|
|
sblkctl = sblkctl_orig ^ AUTOFLUSHDIS;
|
|
|
|
outb(SBLKCTL + iobase, sblkctl);
|
|
|
|
sblkctl = inb(SBLKCTL + iobase);
|
|
|
|
if(sblkctl != sblkctl_orig)
|
|
|
|
{
|
|
|
|
id_string = "aic7770 >= Rev E, ";
|
|
|
|
/*
|
|
|
|
* Ensure autoflush is enabled
|
|
|
|
*/
|
|
|
|
sblkctl &= ~AUTOFLUSHDIS;
|
|
|
|
outb(SBLKCTL + iobase, sblkctl);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
id_string = "aic7770 <= Rev C, ";
|
|
|
|
|
|
|
|
printf("ahc%d: %s", unit, id_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only four SCBs on these cards. If we ever do SCB paging,
|
|
|
|
* we could support 255 on the Rev E cards.
|
|
|
|
*/
|
|
|
|
ahc->maxscbs = 0x4;
|
|
|
|
|
|
|
|
/* Setup the FIFO threshold and the bus off time */
|
|
|
|
if(ahc->flags & AHC_USEDEFAULTS) {
|
|
|
|
outb(BUSSPD + iobase, DFTHRSH_100);
|
|
|
|
outb(BUSTIME + iobase, BOFF_60BCLKS);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
u_char hostconf = inb(HOSTCONF + iobase);
|
|
|
|
outb(BUSSPD + iobase, hostconf & DFTHRSH);
|
|
|
|
outb(BUSTIME + iobase, (hostconf << 2) & BOFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic aic7xxx initialization.
|
|
|
|
*/
|
|
|
|
if(ahc_init(ahc)){
|
1995-11-05 04:42:50 +00:00
|
|
|
ahc_free(ahc);
|
|
|
|
/*
|
1996-01-03 06:28:01 +00:00
|
|
|
* The board's IRQ line is not yet enabled so its safe
|
1995-11-05 04:42:50 +00:00
|
|
|
* to release the irq.
|
|
|
|
*/
|
|
|
|
eisa_release_intr(e_dev, irq, ahc_eisa_intr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1996-01-03 06:28:01 +00:00
|
|
|
/*
|
|
|
|
* Enable the board's BUS drivers
|
|
|
|
*/
|
|
|
|
outb(BCTL + iobase, ENABLE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable our interrupt handler.
|
|
|
|
*/
|
|
|
|
if(eisa_enable_intr(e_dev, irq)) {
|
|
|
|
ahc_free(ahc);
|
|
|
|
eisa_release_intr(e_dev, irq, ahc_eisa_intr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1995-11-05 04:42:50 +00:00
|
|
|
e_dev->kdc->kdc_state = DC_BUSY; /* host adapters always busy */
|
|
|
|
|
|
|
|
/* Attach sub-devices - always succeeds */
|
1996-01-03 06:28:01 +00:00
|
|
|
ahc_attach(ahc);
|
1995-11-05 04:42:50 +00:00
|
|
|
|
1996-01-03 06:28:01 +00:00
|
|
|
return 0;
|
1994-11-17 20:22:31 +00:00
|
|
|
}
|
|
|
|
|
1995-11-05 04:42:50 +00:00
|
|
|
#endif /* NEISA > 0 */
|