summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorSteve Murphree <smurph@cvs.openbsd.org>2002-02-16 04:36:34 +0000
committerSteve Murphree <smurph@cvs.openbsd.org>2002-02-16 04:36:34 +0000
commit2fda0f547528c28c4079e1a7e0ae5302ce7e71ca (patch)
treea2787ca49818f01b4ede919387cadb7cb30c8bf5 /sys/arch/i386
parent9e8307bd1d6169bbdad4887400e0660f6d26e1ea (diff)
New port of FreeBSD's ahc driver
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/isa/ahc_isa.c94
1 files changed, 63 insertions, 31 deletions
diff --git a/sys/arch/i386/isa/ahc_isa.c b/sys/arch/i386/isa/ahc_isa.c
index e504eeafa3e..7be50b00ead 100644
--- a/sys/arch/i386/isa/ahc_isa.c
+++ b/sys/arch/i386/isa/ahc_isa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ahc_isa.c,v 1.5 2000/03/22 02:57:17 smurph Exp $ */
+/* $OpenBSD: ahc_isa.c,v 1.6 2002/02/16 04:36:32 smurph Exp $ */
/* $NetBSD: ahc_isa.c,v 1.5 1996/10/21 22:27:39 thorpej Exp $ */
/*
@@ -83,8 +83,9 @@
#include <dev/eisa/eisadevs.h>
#include <dev/ic/aic7xxxreg.h>
-#include <dev/ic/aic7xxxvar.h>
-#include <dev/ic/smc93cx6var.h>
+#include <dev/ic/aic7xxx_openbsd.h>
+#include <dev/ic/aic7xxx_inline.h>
+#include <dev/ic/aic7xxx_93cx6.h>
#ifdef DEBUG
#define bootverbose 1
@@ -102,7 +103,6 @@
/*
* I/O port offsets
*/
-#define INTDEF 0x5cul /* Interrupt Definition Register */
#define AHC_ISA_VID (EISA_SLOTOFF_VID - AHC_ISA_SLOT_OFFSET)
#define AHC_ISA_PID (EISA_SLOTOFF_PID - AHC_ISA_SLOT_OFFSET)
#define AHC_ISA_PRIMING AHC_ISA_VID /* enable vendor/product ID */
@@ -159,7 +159,7 @@ ahc_isa_irq(iot, ioh)
bus_space_write_1(iot, ioh, HCNTRL, hcntrl | PAUSE);
intdef = bus_space_read_1(iot, ioh, INTDEF);
- switch (irq = (intdef & 0xf)) {
+ switch (irq = (intdef & VECTOR)) {
case 9:
case 10:
case 11:
@@ -346,7 +346,6 @@ ahc_isa_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
- ahc_chip chip;
struct ahc_softc *ahc = (void *)self;
struct isa_attach_args *ia = aux;
bus_space_tag_t iot = ia->ia_iot;
@@ -354,10 +353,24 @@ ahc_isa_attach(parent, self, aux)
int irq;
char idstring[EISA_IDSTRINGLEN];
const char *model;
- u_char channel = 'A';
-
- ahc->sc_dmat = ia->ia_dmat;
- chip = AHC_VL; /* We are a VL Bus Controller */
+ u_int intdef;
+ /*
+ * We really don't allocate our softc, but
+ * we need to do the initialization. And this
+ * also allocates the platform_data structure.
+ */
+ ahc_alloc(ahc, ahc->sc_dev.dv_xname);
+
+ ahc_set_name(ahc, ahc->sc_dev.dv_xname);
+ ahc_set_unit(ahc, ahc->sc_dev.dv_unit);
+
+ /* set dma tags */
+ ahc->parent_dmat = ia->ia_dmat;
+ ahc->buffer_dmat = ia->ia_dmat;
+ ahc->shared_data_dmat = ia->ia_dmat;
+
+ ahc->chip = AHC_VL; /* We are a VL Bus Controller */
+
if (bus_space_map(iot, ia->ia_iobase, ia->ia_iosize, 0, &ioh))
panic("ahc_isa_attach: could not map slot I/O addresses");
if (!ahc_isa_idstring(iot, ioh, idstring))
@@ -367,16 +380,23 @@ ahc_isa_attach(parent, self, aux)
if (strcmp(idstring, "ADP7756") == 0) {
model = EISA_PRODUCT_ADP7756;
- chip |= AHC_AIC7770;
} else if (strcmp(idstring, "ADP7757") == 0) {
model = EISA_PRODUCT_ADP7757;
- chip |= AHC_AIC7770;
} else {
panic("ahc_isa_attach: Unknown device type %s", idstring);
}
printf(": %s\n", model);
-
- ahc_construct(ahc, iot, ioh, chip, AHC_FNONE, AHC_AIC7770_FE, channel);
+
+ ahc->channel = 'A';
+ ahc->channel_b = 'B';
+ ahc->chip = AHC_AIC7770;
+ ahc->features = AHC_AIC7770_FE;
+ ahc->bugs |= AHC_TMODE_WIDEODD_BUG;
+ ahc->flags |= AHC_PAGESCBS;
+
+ /* set tag and handle */
+ ahc->tag = iot;
+ ahc->bsh = ioh;
#ifdef DEBUG
/*
@@ -387,10 +407,14 @@ ahc_isa_attach(parent, self, aux)
ahc->pause & IRQMS ? "Level Sensitive" : "Edge Triggered");
#endif
- ahc->channel = 'A';
- ahc->channel_b = 'B';
if (ahc_reset(ahc) != 0)
return;
+
+ /* See if we are edge triggered */
+ intdef = ahc_inb(ahc, INTDEF);
+ if ((intdef & EDGE_TRIG) != 0)
+ ahc->flags |= AHC_EDGE_INTERRUPT;
+
/*
* Now that we know we own the resources we need, do the
* card initialization.
@@ -410,10 +434,10 @@ ahc_isa_attach(parent, self, aux)
u_char sblkctl;
u_char sblkctl_orig;
- sblkctl_orig = AHC_INB(ahc, SBLKCTL);
+ sblkctl_orig = ahc_inb(ahc, SBLKCTL);
sblkctl = sblkctl_orig ^ AUTOFLUSHDIS;
- AHC_OUTB(ahc, SBLKCTL, sblkctl);
- sblkctl = AHC_INB(ahc, SBLKCTL);
+ ahc_outb(ahc, SBLKCTL, sblkctl);
+ sblkctl = ahc_inb(ahc, SBLKCTL);
if(sblkctl != sblkctl_orig)
{
id_string = "aic7770 >= Rev E, ";
@@ -421,7 +445,7 @@ ahc_isa_attach(parent, self, aux)
* Ensure autoflush is enabled
*/
sblkctl &= ~AUTOFLUSHDIS;
- AHC_OUTB(ahc, SBLKCTL, sblkctl);
+ ahc_outb(ahc, SBLKCTL, sblkctl);
/* Allow paging on this adapter */
ahc->flags |= AHC_PAGESCBS;
@@ -434,9 +458,9 @@ ahc_isa_attach(parent, self, aux)
/* Setup the FIFO threshold and the bus off time */
{
- u_char hostconf = AHC_INB(ahc, HOSTCONF);
- AHC_OUTB(ahc, BUSSPD, hostconf & DFTHRSH);
- AHC_OUTB(ahc, BUSTIME, (hostconf << 2) & BOFF);
+ u_char hostconf = ahc_inb(ahc, HOSTCONF);
+ ahc_outb(ahc, BUSSPD, hostconf & DFTHRSH);
+ ahc_outb(ahc, BUSTIME, (hostconf << 2) & BOFF);
}
/*
@@ -446,26 +470,36 @@ ahc_isa_attach(parent, self, aux)
ahc_free(ahc);
return;
}
+
+ /* Special func to force negotiation */
+ ahc_force_neg(ahc);
+
+ /*
+ * Link this softc in with all other ahc instances.
+ */
+ ahc_softc_insert(ahc);
/*
* Enable the board's BUS drivers
*/
- AHC_OUTB(ahc, BCTL, ENABLE);
+ ahc_outb(ahc, BCTL, ENABLE);
/*
* The IRQMS bit enables level sensitive interrupts only allow
* IRQ sharing if its set.
*/
- ahc->sc_ih = isa_intr_establish(ia->ia_ic, irq,
- ahc->pause & IRQMS ? IST_LEVEL : IST_EDGE, IPL_BIO, ahc_intr,
+ ahc->platform_data->ih = isa_intr_establish(ia->ia_ic, irq,
+ ahc->pause & IRQMS ? IST_LEVEL : IST_EDGE, IPL_BIO, ahc_platform_intr,
ahc, ahc->sc_dev.dv_xname);
- if (ahc->sc_ih == NULL) {
+ if (ahc->platform_data->ih == NULL) {
printf("%s: couldn't establish interrupt\n",
ahc->sc_dev.dv_xname);
ahc_free(ahc);
return;
}
+ ahc_intr_enable(ahc, TRUE);
+
/* Attach sub-devices - always succeeds */
ahc_attach(ahc);
}
@@ -482,8 +516,6 @@ aha2840_load_seeprom(struct ahc_softc *ahc)
u_int8_t scsi_conf;
int have_seeprom;
- sd.sd_tag = ahc->sc_iot;
- sd.sd_bsh = ahc->sc_ioh;
sd.sd_control_offset = SEECTL_2840;
sd.sd_status_offset = STATUS_2840;
sd.sd_dataout_offset = STATUS_2840;
@@ -497,8 +529,8 @@ aha2840_load_seeprom(struct ahc_softc *ahc)
if (bootverbose)
printf("%s: Reading SEEPROM...", ahc_name(ahc));
- have_seeprom = read_seeprom(&sd,
- (u_int16_t *)&sc,
+ have_seeprom = read_seeprom(&sd,
+ (u_int16_t *)&sc,
/*start_addr*/0,
sizeof(sc)/2);