summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-01-15 01:40:33 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-01-15 01:40:33 +0000
commit336305543ad5abd4f77606599e1896b29af0386b (patch)
tree2cdcbffc078b4d3f04514f158f214da3e579f9b5
parent034bc9e87c409d8b2f8deaf131a099ff2c17e9ba (diff)
from netbsd:
Add the "ahe" driver, autoconfiguration support for the aic7xxx-based Adaptec 2[78]4x SCSI controllers, from Michael Graff <explorer@flame.org>. Fixes PR #1594 from Noriyuki Soda <soda@sra.co.jp> in a different way.
-rw-r--r--sys/dev/ic/aic7xxx.c25
-rw-r--r--sys/dev/isa/aha284x.c189
-rw-r--r--sys/dev/isa/files.isa6
-rw-r--r--sys/dev/pci/files.pci5
4 files changed, 210 insertions, 15 deletions
diff --git a/sys/dev/ic/aic7xxx.c b/sys/dev/ic/aic7xxx.c
index dd2ddf0a9fc..806b1e559d8 100644
--- a/sys/dev/ic/aic7xxx.c
+++ b/sys/dev/ic/aic7xxx.c
@@ -1,4 +1,4 @@
-/* $NetBSD: aic7xxx.c,v 1.1 1995/10/09 09:49:30 mycroft Exp $ */
+/* $NetBSD: aic7xxx.c,v 1.2 1996/01/13 02:05:22 thorpej Exp $ */
/*
* Generic driver for the aic7xxx based adaptec SCSI controllers
@@ -536,10 +536,10 @@ ahc_print_scb(scb)
scb->SG_segment_count,
scb->SG_list_pointer);
printf("\tsg_addr:%x sg_len:%d\n",
- scb->ahc_dma[0].addr,
- scb->ahc_dma[0].len);
+ scb->ahc_dma[0].seg_addr,
+ scb->ahc_dma[0].seg_len);
printf(" size:%d\n",
- (int)&scb->next - (int)scb);
+ (int)&scb->next_waiting - (int)scb);
}
void
@@ -1003,7 +1003,7 @@ ahcintr(ahc)
ahc_getscb(iobase, scb);
-#ifdef AHC_DEBUG
+#ifdef AHC_MORE_DEBUG
if (xs->sc_link->target == DEBUGTARGET)
ahc_print_scb(scb);
#endif
@@ -1418,19 +1418,19 @@ ahc_init(ahc)
switch (ahc->type) {
case AHC_274:
- printf(": 274x ", ahc->sc_dev.dv_xname);
+ printf("%s: 274x ", ahc->sc_dev.dv_xname);
ahc->maxscbs = 0x4;
break;
case AHC_284:
- printf(": 284x ", ahc->sc_dev.dv_xname);
+ printf("%s: 284x ", ahc->sc_dev.dv_xname);
ahc->maxscbs = 0x4;
break;
case AHC_AIC7870:
case AHC_294:
if (ahc->type == AHC_AIC7870)
- printf(": aic7870 ", ahc->sc_dev.dv_xname);
+ printf("%s: aic7870 ", ahc->sc_dev.dv_xname);
else
- printf(": 294x ", ahc->sc_dev.dv_xname);
+ printf("%s: 294x ", ahc->sc_dev.dv_xname);
ahc->maxscbs = 0x10;
#define DFTHRESH 3
outb(DSPCISTATUS + iobase, DFTHRESH << 6);
@@ -1442,6 +1442,9 @@ ahc_init(ahc)
/* In case we are a wide card */
outb(HA_SCSICONF + 1 + iobase, 0x07);
break;
+ default:
+ printf("%s: unknown(0x%x) ", ahc->sc_dev.dv_xname, ahc->type);
+ break;
}
/* Determine channel configuration and who we are on the scsi bus. */
@@ -1466,7 +1469,7 @@ ahc_init(ahc)
outb(HA_FLAGS + iobase, TWIN_BUS);
break;
default:
- printf(" Unsupported adapter type. %x Ignoring\n",sblkctl);
+ printf(" Unsupported adapter type. %x Ignoring\n", sblkctl);
return(-1);
}
@@ -1839,7 +1842,7 @@ ahc_scsi_cmd(xs)
scb->SG_segment_count = 0;
}
-#ifdef AHC_DEBUG
+#ifdef AHC_MORE_DEBUG
if (sc_link->target == DEBUGTARGET)
ahc_print_scb(scb);
#endif
diff --git a/sys/dev/isa/aha284x.c b/sys/dev/isa/aha284x.c
new file mode 100644
index 00000000000..91824287421
--- /dev/null
+++ b/sys/dev/isa/aha284x.c
@@ -0,0 +1,189 @@
+/* $NetBSD: aha284x.c,v 1.2 1996/01/13 02:06:30 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1996 Michael Graff. 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, 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Michael Graff.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <scsi/scsi_all.h>
+#include <scsi/scsiconf.h>
+
+#include <dev/isa/isavar.h>
+
+#include <dev/ic/aic7xxxvar.h>
+
+#include <machine/pio.h>
+
+static int ahe_probe __P((struct device *, void *, void *));
+static void ahe_attach __P((struct device *, struct device *, void *));
+
+struct cfdriver ahecd = {
+ NULL, /* devices found */
+ "ahe", /* device name */
+ ahe_probe, /* match routine */
+ ahe_attach, /* attach routine */
+ DV_DULL, /* device class */
+ sizeof(struct ahc_softc), /* size of private dev data */
+};
+
+/*
+ * shouldn't this be in aic7xxxvar.h?
+ */
+int ahcintr __P((void *));
+
+/*
+ * Standard EISA Host ID regs (Offset from slot base)
+ * These seem to work on the aha284x as well (VLB card)
+ */
+#define HID0 0xC80 /* 0,1: msb of ID2, 2-7: ID1 */
+#define HID1 0xC81 /* 0-4: ID3, 5-7: LSB ID2 */
+#define HID2 0xC82 /* product */
+#define HID3 0xC83 /* firmware revision */
+
+#define CHAR1(B1,B2) (((B1>>2) & 0x1F) | '@')
+#define CHAR2(B1,B2) (((B1<<3) & 0x18) | ((B2>>5) & 0x7)|'@')
+#define CHAR3(B1,B2) ((B2 & 0x1F) | '@')
+
+typedef struct {
+ ahc_type type;
+ unsigned char id; /* The Last EISA Host ID reg */
+} aic7770_sig;
+
+aic7770_sig valid_ids[] = {
+ /* Entries of other tested adaptors should be added here */
+ { AHC_274, 0x70 }, /*aic7770 on Motherboard*/
+ { AHC_274, 0x71 }, /*274x*/
+ { AHC_284, 0x56 }, /*284x, BIOS enabled*/
+ { AHC_284, 0x57 } /*284x, BIOS disabled*/
+};
+
+int
+ahe_probe(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct ahc_softc *ahc = match;
+ struct isa_attach_args *ia = aux;
+
+ char intdef;
+ int iobase;
+ u_char sig_id[4];
+ int i;
+
+#ifdef NEWCONFIG
+ if (ia->ia_iobase == IOBASEUNK)
+ return 0;
+#endif
+
+ /*
+ * Make the offsets the same as for EISA
+ *
+ * I have NO idea why the values in aic7xxx.c are all 0xc00 too
+ * high, but this hack fixes it. This is the same hack that's in
+ * the 294x pci code.
+ */
+ iobase = ia->ia_iobase - 0xc00;
+
+ for (i = 0; i < sizeof(sig_id); i++) {
+ /*
+ * An outb is required to prime these
+ * registers on VL cards
+ */
+ outb(iobase + HID0, HID0 + i);
+ sig_id[i] = inb(iobase + HID0 + i);
+ }
+
+ if (sig_id[0] == 0xff)
+ return 0;
+
+ if (CHAR1(sig_id[0], sig_id[1]) != 'A'
+ || CHAR2(sig_id[0], sig_id[1]) != 'D'
+ || CHAR3(sig_id[0], sig_id[1]) != 'P'
+ || sig_id[2] != 0x77)
+ return 0;
+
+ ahc->type = 0;
+
+ for (i = 0; i < sizeof(valid_ids)/sizeof(aic7770_sig); i++)
+ if (sig_id[3] == valid_ids[i].id) {
+ ahc->type = valid_ids[i].type;
+ break;
+ }
+
+ if (ahc->type == 0)
+ printf("%s: Unknown board type 0x%02x\n",
+ ahc->sc_dev.dv_xname, sig_id[3]);
+
+ if (ahcprobe(ahc, iobase) == 0)
+ return 0;
+
+ /*
+ * set up some other isa variables and make certain the irq the
+ * card is set at matches the one in the configuration file,
+ * it is wa defined there
+ */
+
+ ia->ia_iosize = 0x100; /* address range for the card */
+
+ if (ia->ia_irq == IRQUNK)
+ ia->ia_irq = ahc->sc_irq; /* probed from the card */
+ else
+ if (ia->ia_irq != ahc->sc_irq) {
+ printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
+ ahc->sc_dev.dv_xname, ia->ia_irq, ahc->sc_irq);
+ return 0;
+ }
+
+ /* Must be ok... */
+ return 1;
+}
+
+void
+ahe_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct ahc_softc *ahc = (void *)self;
+ struct isa_attach_args *ia = aux;
+
+#ifdef NEWCONFIG
+ isa_establish(&ahc->sc_id, &ahc->sc_dev);
+#endif
+ ahc->sc_ih = isa_intr_establish(ia->ia_irq, IST_EDGE, IPL_BIO,
+ ahcintr, ahc);
+
+ /*
+ * attach the devices on the bus
+ */
+ ahcattach(ahc);
+}
diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa
index 9f83fefe196..99ac2a0ed60 100644
--- a/sys/dev/isa/files.isa
+++ b/sys/dev/isa/files.isa
@@ -1,4 +1,4 @@
-# $NetBSD: files.isa,v 1.9 1995/11/10 19:39:21 christos Exp $
+# $NetBSD: files.isa,v 1.10 1996/01/13 02:05:15 thorpej Exp $
#
# Config.new file and device description for machine-independent ISA code.
# Included by ports that need it. Requires that the SCSI files be
@@ -68,6 +68,10 @@ file dev/isa/aha1542.c aha
device aic at isa: scsi, isadma
file dev/isa/aic6360.c aic
+# Adaptec 7770-based EISA, VLB, etc. controllers
+device ahe at isa: scsi, aic7xxx
+file dev/isa/aha284x.c ahe
+
# BusLogic BT-74x EISA family (XXX; should be EISA. it's special)
device bt at isa: scsi, isadma
file dev/isa/bt742a.c bt
diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci
index 973792dddab..a31ebfdcb3f 100644
--- a/sys/dev/pci/files.pci
+++ b/sys/dev/pci/files.pci
@@ -1,4 +1,4 @@
-# $NetBSD: files.pci,v 1.8 1995/10/10 12:16:54 mycroft Exp $
+# $NetBSD: files.pci,v 1.9 1996/01/13 02:05:18 thorpej Exp $
#
# Config.new file and device description for machine-independent PCI code.
# Included by ports that need it. Requires that the SCSI files be
@@ -23,6 +23,5 @@ device ncr at pci: scsi
file dev/pci/ncr.c ncr
# Adaptec 7870 chips
-device ahc at pci: scsi
+device ahc at pci: scsi, aic7xxx
file dev/pci/aic7870.c ahc
-file dev/ic/aic7xxx.c ahc