Split `esp' driver and DMA engine into separate front-end files.

The Sbus front-ends have all been moved to `sys/dev/sbus', while
the `obio' front-ends remain here.
This commit is contained in:
pk 1998-08-29 20:49:35 +00:00
parent 1f0567dd53
commit e4091cb757
7 changed files with 133 additions and 1667 deletions

View File

@ -1,717 +0,0 @@
/* $NetBSD: dma.c,v 1.56 1998/08/28 20:14:36 pk Exp $ */
/*
* Copyright (c) 1994 Paul Kranenburg. All rights reserved.
* Copyright (c) 1994 Peter Galbavy. 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 Peter Galbavy.
* 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/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/buf.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <vm/vm.h>
#include <machine/bus.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <dev/scsipi/scsi_all.h>
#include <dev/scsipi/scsipi_all.h>
#include <dev/scsipi/scsiconf.h>
#include <dev/ic/ncr53c9xreg.h>
#include <dev/ic/ncr53c9xvar.h>
#include <dev/sbus/sbusvar.h>
#include <sparc/dev/dmareg.h>
#include <sparc/dev/dmavar.h>
#include <sparc/dev/espvar.h>
int dmamatch_sbus __P((struct device *, struct cfdata *, void *));
void dmaattach_sbus __P((struct device *, struct device *, void *));
int dmamatch_obio __P((struct device *, struct cfdata *, void *));
void dmaattach_obio __P((struct device *, struct device *, void *));
void dma_identify __P((struct dma_softc *));
int dmaprint __P((void *, const char *));
void dma_reset __P((struct dma_softc *, int));
void espdma_reset __P((struct dma_softc *));
void ledma_reset __P((struct dma_softc *));
void dma_enintr __P((struct dma_softc *));
int dma_isintr __P((struct dma_softc *));
int espdmaintr __P((void *));
int ledmaintr __P((void *));
int dma_setup __P((struct dma_softc *, caddr_t *, size_t *,
int, size_t *));
void dma_go __P((struct dma_softc *));
void *dmabus_intr_establish __P((
bus_space_tag_t,
int, /*level*/
int, /*flags*/
int (*) __P((void *)), /*handler*/
void *)); /*handler arg*/
static bus_space_tag_t dma_alloc_bustag __P((struct dma_softc *sc));
struct cfattach dma_sbus_ca = {
sizeof(struct dma_softc), dmamatch_sbus, dmaattach_sbus
};
struct cfattach ledma_ca = {
sizeof(struct dma_softc), dmamatch_sbus, dmaattach_sbus
};
struct cfattach dma_obio_ca = {
sizeof(struct dma_softc), dmamatch_obio, dmaattach_obio
};
int
dmaprint(aux, busname)
void *aux;
const char *busname;
{
struct sbus_attach_args *sa = aux;
bus_space_tag_t t = sa->sa_bustag;
struct dma_softc *sc = t->cookie;
sa->sa_bustag = sc->sc_bustag; /* XXX */
sbus_print(aux, busname); /* XXX */
sa->sa_bustag = t; /* XXX */
return (UNCONF);
}
int
dmamatch_sbus(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct sbus_attach_args *sa = aux;
return (strcmp(cf->cf_driver->cd_name, sa->sa_name) == 0 ||
strcmp("espdma", sa->sa_name) == 0);
}
int
dmamatch_obio(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
union obio_attach_args *uoba = aux;
struct obio4_attach_args *oba;
if (uoba->uoba_isobio4 == 0)
return (0);
oba = &uoba->uoba_oba4;
return (bus_space_probe(oba->oba_bustag, 0, oba->oba_paddr,
4, /* probe size */
0, /* offset */
0, /* flags */
NULL, NULL));
}
void
dmaattach_sbus(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct sbus_attach_args *sa = aux;
struct dma_softc *sc = (void *)self;
bus_space_handle_t bh;
struct bootpath *bp;
bus_space_tag_t sbt;
int sbusburst;
int node;
sc->sc_bustag = sa->sa_bustag;
sc->sc_dmatag = sa->sa_dmatag;
/* Map registers */
if (sa->sa_npromvaddrs != 0)
sc->sc_regs = (struct dma_regs *)sa->sa_promvaddrs[0];
else {
if (sbus_bus_map(sa->sa_bustag, sa->sa_slot,
sa->sa_offset,
sizeof(struct dma_regs),
0, 0, &bh) != 0) {
printf("dmaattach_sbus: cannot map registers\n");
return;
}
sc->sc_regs = (struct dma_regs *)bh;
}
/*
* Get transfer burst size from PROM and plug it into the
* controller registers. This is needed on the Sun4m; do
* others need it too?
*/
sbusburst = ((struct sbus_softc *)parent)->sc_burst;
if (sbusburst == 0)
sbusburst = SBUS_BURST_32 - 1; /* 1->16 */
sc->sc_burst = getpropint(sa->sa_node,"burst-sizes", -1);
if (sc->sc_burst == -1)
/* take SBus burst sizes */
sc->sc_burst = sbusburst;
/* Clamp at parent's burst sizes */
sc->sc_burst &= sbusburst;
if (sc->sc_dev.dv_cfdata->cf_attach == &ledma_ca) {
char *cabletype;
/*
* Check to see which cable type is currently active and set the
* appropriate bit in the ledma csr so that it gets used. If we
* didn't netboot, the PROM won't have the "cable-selection"
* property; default to TP and then the user can change it via
* a "media" option to ifconfig.
*/
cabletype = getpropstring(sa->sa_node, "cable-selection");
if (strcmp(cabletype, "tpe") == 0) {
sc->sc_regs->csr |= DE_AUI_TP;
} else if (strcmp(cabletype, "aui") == 0) {
sc->sc_regs->csr &= ~DE_AUI_TP;
} else {
/* assume TP if nothing there */
sc->sc_regs->csr |= DE_AUI_TP;
}
delay(20000); /* manual says we need 20ms delay */
}
/* Propagate bootpath */
bp = NULL;
if (sa->sa_bp != NULL) {
char *bpname = sa->sa_bp->name;
if (strcmp(bpname, "espdma") == 0)
/* We call everything "dma" */
bpname = "dma";
if (strcmp(bpname, self->dv_cfdata->cf_driver->cd_name) == 0)
bp = sa->sa_bp + 1;
}
/* Allocate a dmamap */
if (bus_dmamap_create(sc->sc_dmatag, 16*1024*1024, 1, 16*1024*1024,
0, BUS_DMA_WAITOK, &sc->sc_dmamap) != 0) {
printf("%s: dma map create failed\n", self->dv_xname);
return;
}
sbus_establish(&sc->sc_sd, &sc->sc_dev);
sbt = dma_alloc_bustag(sc);
dma_identify(sc);
/* Attach children */
for (node = firstchild(sa->sa_node); node; node = nextsibling(node)) {
struct sbus_attach_args sa;
sbus_setup_attach_args((struct sbus_softc *)parent,
sbt, sc->sc_dmatag, node, bp, &sa);
(void) config_found(&sc->sc_dev, (void *)&sa, dmaprint);
sbus_destroy_attach_args(&sa);
}
}
void
dmaattach_obio(parent, self, aux)
struct device *parent, *self;
void *aux;
{
union obio_attach_args *uoba = aux;
struct obio4_attach_args *oba = &uoba->uoba_oba4;
struct dma_softc *sc = (void *)self;
bus_space_handle_t bh;
sc->sc_bustag = oba->oba_bustag;
sc->sc_dmatag = oba->oba_dmatag;
if (obio_bus_map(oba->oba_bustag, oba->oba_paddr,
0, sizeof(struct dma_regs),
0, 0,
&bh) != 0) {
printf("dmaattach_obio: cannot map registers\n");
return;
}
sc->sc_regs = (struct dma_regs *)bh;
dma_identify(sc);
}
/*
* Attach all the sub-devices we can find
*/
void
dma_identify(sc)
struct dma_softc *sc;
{
printf(": rev ");
sc->sc_rev = sc->sc_regs->csr & D_DEV_ID;
switch (sc->sc_rev) {
case DMAREV_0:
printf("0");
break;
case DMAREV_ESC:
printf("esc");
break;
case DMAREV_1:
printf("1");
break;
case DMAREV_PLUS:
printf("1+");
break;
case DMAREV_2:
printf("2");
break;
default:
printf("unknown (0x%x)", sc->sc_rev);
}
printf("\n");
/* indirect functions */
if (sc->sc_dev.dv_cfdata->cf_attach == &ledma_ca) {
sc->reset = ledma_reset;
sc->intr = ledmaintr;
} else {
sc->reset = espdma_reset;
sc->intr = espdmaintr;
}
sc->enintr = dma_enintr;
sc->isintr = dma_isintr;
sc->setup = dma_setup;
sc->go = dma_go;
}
void *
dmabus_intr_establish(t, level, flags, handler, arg)
bus_space_tag_t t;
int level;
int flags;
int (*handler) __P((void *));
void *arg;
{
struct dma_softc *sc = t->cookie;
if (sc->intr == ledmaintr) { /* XXX - for now; do esp later */
sc->sc_intrchain = handler;
sc->sc_intrchainarg = arg;
handler = ledmaintr;
arg = sc;
}
return (bus_intr_establish(sc->sc_bustag, level, flags, handler, arg));
}
#define DMAWAIT(SC, COND, MSG, DONTPANIC) do if (COND) { \
int count = 500000; \
while ((COND) && --count > 0) DELAY(1); \
if (count == 0) { \
printf("%s: line %d: CSR = 0x%lx\n", __FILE__, __LINE__, \
(SC)->sc_regs->csr); \
if (DONTPANIC) \
printf(MSG); \
else \
panic(MSG); \
} \
} while (0)
#define DMA_DRAIN(sc, dontpanic) do { \
/* \
* DMA rev0 & rev1: we are not allowed to touch the DMA "flush" \
* and "drain" bits while it is still thinking about a \
* request. \
* other revs: D_R_PEND bit reads as 0 \
*/ \
DMAWAIT(sc, sc->sc_regs->csr & D_R_PEND, "R_PEND", dontpanic); \
/* \
* Select drain bit based on revision \
* also clears errors and D_TC flag \
*/ \
if (sc->sc_rev == DMAREV_1 || sc->sc_rev == DMAREV_0) \
DMACSR(sc) |= D_DRAIN; \
else \
DMACSR(sc) |= D_INVALIDATE; \
/* \
* Wait for draining to finish \
* rev0 & rev1 call this PACKCNT \
*/ \
DMAWAIT(sc, sc->sc_regs->csr & D_DRAINING, "DRAINING", dontpanic);\
} while(0)
#define DMA_FLUSH(sc, dontpanic) do { \
int csr; \
/* \
* DMA rev0 & rev1: we are not allowed to touch the DMA "flush" \
* and "drain" bits while it is still thinking about a \
* request. \
* other revs: D_R_PEND bit reads as 0 \
*/ \
DMAWAIT(sc, sc->sc_regs->csr & D_R_PEND, "R_PEND", dontpanic); \
csr = DMACSR(sc); \
csr &= ~(D_WRITE|D_EN_DMA); \
csr |= D_INVALIDATE; \
DMACSR(sc) = csr; \
} while(0)
void
dma_reset(sc, isledma)
struct dma_softc *sc;
int isledma;
{
DMA_FLUSH(sc, 1);
DMACSR(sc) |= D_RESET; /* reset DMA */
DELAY(200); /* what should this be ? */
/*DMAWAIT1(sc); why was this here? */
DMACSR(sc) &= ~D_RESET; /* de-assert reset line */
DMACSR(sc) |= D_INT_EN; /* enable interrupts */
if (sc->sc_rev > DMAREV_1 && isledma == 0)
DMACSR(sc) |= D_FASTER;
switch (sc->sc_rev) {
case DMAREV_2:
sc->sc_regs->csr &= ~D_BURST_SIZE; /* must clear first */
if (sc->sc_burst & SBUS_BURST_32) {
DMACSR(sc) |= D_BURST_32;
} else if (sc->sc_burst & SBUS_BURST_16) {
DMACSR(sc) |= D_BURST_16;
} else {
DMACSR(sc) |= D_BURST_0;
}
break;
case DMAREV_ESC:
DMACSR(sc) |= D_AUTODRAIN; /* Auto-drain */
if (sc->sc_burst & SBUS_BURST_32) {
DMACSR(sc) &= ~0x800;
} else
DMACSR(sc) |= 0x800;
break;
default:
}
sc->sc_active = 0; /* and of course we aren't */
}
void
espdma_reset(sc)
struct dma_softc *sc;
{
dma_reset(sc, 0);
}
void
ledma_reset(sc)
struct dma_softc *sc;
{
dma_reset(sc, 1);
}
void
dma_enintr(sc)
struct dma_softc *sc;
{
sc->sc_regs->csr |= D_INT_EN;
}
int
dma_isintr(sc)
struct dma_softc *sc;
{
return (sc->sc_regs->csr & (D_INT_PEND|D_ERR_PEND));
}
#define DMAMAX(a) (0x01000000 - ((a) & 0x00ffffff))
/*
* setup a dma transfer
*/
int
dma_setup(sc, addr, len, datain, dmasize)
struct dma_softc *sc;
caddr_t *addr;
size_t *len;
int datain;
size_t *dmasize; /* IN-OUT */
{
u_long csr;
DMA_FLUSH(sc, 0);
#if 0
DMACSR(sc) &= ~D_INT_EN;
#endif
sc->sc_dmaaddr = addr;
sc->sc_dmalen = len;
NCR_DMA(("%s: start %d@%p,%d\n", sc->sc_dev.dv_xname,
*sc->sc_dmalen, *sc->sc_dmaaddr, datain ? 1 : 0));
/*
* the rules say we cannot transfer more than the limit
* of this DMA chip (64k for old and 16Mb for new),
* and we cannot cross a 16Mb boundary.
*/
*dmasize = sc->sc_dmasize =
min(*dmasize, DMAMAX((size_t) *sc->sc_dmaaddr));
NCR_DMA(("dma_setup: dmasize = %d\n", sc->sc_dmasize));
/* Program the DMA address */
if (sc->sc_dmasize) {
sc->sc_dvmaaddr = *sc->sc_dmaaddr;
if (bus_dmamap_load(sc->sc_dmatag, sc->sc_dmamap,
*sc->sc_dmaaddr, sc->sc_dmasize,
NULL /* kernel address */,
BUS_DMA_NOWAIT))
panic("dma: cannot allocate DVMA address");
DMADDR(sc) = (caddr_t)sc->sc_dmamap->dm_segs[0].ds_addr;
bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap,
(bus_addr_t)sc->sc_dvmaaddr, sc->sc_dmasize,
datain
? BUS_DMASYNC_PREREAD
: BUS_DMASYNC_PREWRITE);
}
if (sc->sc_rev == DMAREV_ESC) {
/* DMA ESC chip bug work-around */
register long bcnt = sc->sc_dmasize;
register long eaddr = bcnt + (long)*sc->sc_dmaaddr;
if ((eaddr & PGOFSET) != 0)
bcnt = roundup(bcnt, NBPG);
DMACNT(sc) = bcnt;
}
/* Setup DMA control register */
csr = DMACSR(sc);
if (datain)
csr |= D_WRITE;
else
csr &= ~D_WRITE;
csr |= D_INT_EN;
DMACSR(sc) = csr;
return 0;
}
void
dma_go(sc)
struct dma_softc *sc;
{
/* Start DMA */
DMACSR(sc) |= D_EN_DMA;
sc->sc_active = 1;
}
/*
* Pseudo (chained) interrupt from the esp driver to kick the
* current running DMA transfer. I am replying on espintr() to
* pickup and clean errors for now
*
* return 1 if it was a DMA continue.
*/
int
espdmaintr(arg)
void *arg;
{
struct dma_softc *sc = arg;
struct ncr53c9x_softc *nsc = &sc->sc_esp->sc_ncr53c9x;
char bits[64];
int trans, resid;
u_long csr;
csr = DMACSR(sc);
NCR_DMA(("%s: intr: addr %p, csr %s\n", sc->sc_dev.dv_xname,
DMADDR(sc), bitmask_snprintf(csr, DMACSRBITS, bits,
sizeof(bits))));
if (csr & D_ERR_PEND) {
DMACSR(sc) &= ~D_EN_DMA; /* Stop DMA */
DMACSR(sc) |= D_INVALIDATE;
printf("%s: error: csr=%s\n", sc->sc_dev.dv_xname,
bitmask_snprintf(csr, DMACSRBITS, bits, sizeof(bits)));
return -1;
}
/* This is an "assertion" :) */
if (sc->sc_active == 0)
panic("dmaintr: DMA wasn't active");
DMA_DRAIN(sc, 0);
/* DMA has stopped */
DMACSR(sc) &= ~D_EN_DMA;
sc->sc_active = 0;
if (sc->sc_dmasize == 0) {
/* A "Transfer Pad" operation completed */
NCR_DMA(("dmaintr: discarded %d bytes (tcl=%d, tcm=%d)\n",
NCR_READ_REG(nsc, NCR_TCL) |
(NCR_READ_REG(nsc, NCR_TCM) << 8),
NCR_READ_REG(nsc, NCR_TCL),
NCR_READ_REG(nsc, NCR_TCM)));
return 0;
}
resid = 0;
/*
* If a transfer onto the SCSI bus gets interrupted by the device
* (e.g. for a SAVEPOINTER message), the data in the FIFO counts
* as residual since the ESP counter registers get decremented as
* bytes are clocked into the FIFO.
*/
if (!(csr & D_WRITE) &&
(resid = (NCR_READ_REG(nsc, NCR_FFLAG) & NCRFIFO_FF)) != 0) {
NCR_DMA(("dmaintr: empty esp FIFO of %d ", resid));
}
if ((nsc->sc_espstat & NCRSTAT_TC) == 0) {
/*
* `Terminal count' is off, so read the residue
* out of the ESP counter registers.
*/
resid += (NCR_READ_REG(nsc, NCR_TCL) |
(NCR_READ_REG(nsc, NCR_TCM) << 8) |
((nsc->sc_cfg2 & NCRCFG2_FE)
? (NCR_READ_REG(nsc, NCR_TCH) << 16)
: 0));
if (resid == 0 && sc->sc_dmasize == 65536 &&
(nsc->sc_cfg2 & NCRCFG2_FE) == 0)
/* A transfer of 64K is encoded as `TCL=TCM=0' */
resid = 65536;
}
trans = sc->sc_dmasize - resid;
if (trans < 0) { /* transferred < 0 ? */
#if 0
/*
* This situation can happen in perfectly normal operation
* if the ESP is reselected while using DMA to select
* another target. As such, don't print the warning.
*/
printf("%s: xfer (%d) > req (%d)\n",
sc->sc_dev.dv_xname, trans, sc->sc_dmasize);
#endif
trans = sc->sc_dmasize;
}
NCR_DMA(("dmaintr: tcl=%d, tcm=%d, tch=%d; trans=%d, resid=%d\n",
NCR_READ_REG(nsc, NCR_TCL),
NCR_READ_REG(nsc, NCR_TCM),
(nsc->sc_cfg2 & NCRCFG2_FE)
? NCR_READ_REG(nsc, NCR_TCH) : 0,
trans, resid));
if (sc->sc_dmamap->dm_nsegs > 0) {
bus_dmamap_sync(sc->sc_dmatag, sc->sc_dmamap,
(bus_addr_t)sc->sc_dvmaaddr, sc->sc_dmasize,
(csr & D_WRITE) != 0
? BUS_DMASYNC_POSTREAD
: BUS_DMASYNC_POSTWRITE);
bus_dmamap_unload(sc->sc_dmatag, sc->sc_dmamap);
}
*sc->sc_dmalen -= trans;
*sc->sc_dmaaddr += trans;
#if 0 /* this is not normal operation just yet */
if (*sc->sc_dmalen == 0 ||
nsc->sc_phase != nsc->sc_prevphase)
return 0;
/* and again */
dma_start(sc, sc->sc_dmaaddr, sc->sc_dmalen, DMACSR(sc) & D_WRITE);
return 1;
#endif
return 0;
}
/*
* Pseudo (chained) interrupt to le driver to handle DMA errors.
*/
int
ledmaintr(arg)
void *arg;
{
struct dma_softc *sc = arg;
char bits[64];
u_long csr;
static int dodrain=0;
csr = DMACSR(sc);
if (csr & D_ERR_PEND) {
DMACSR(sc) &= ~D_EN_DMA; /* Stop DMA */
DMACSR(sc) |= D_INVALIDATE;
printf("%s: error: csr=%s\n", sc->sc_dev.dv_xname,
bitmask_snprintf(csr, DMACSRBITS, bits, sizeof(bits)));
DMA_RESET(sc);
dodrain = 1;
}
if (dodrain) { /* XXX - is this necessary with D_DSBL_WRINVAL on? */
#define E_DRAIN 0x400 /* XXX: fix dmareg.h */
int i = 10;
while (i-- > 0 && (sc->sc_regs->csr & D_DRAINING))
delay(1);
}
return (*sc->sc_intrchain)(sc->sc_intrchainarg);
}
bus_space_tag_t
dma_alloc_bustag(sc)
struct dma_softc *sc;
{
bus_space_tag_t sbt;
sbt = (bus_space_tag_t)
malloc(sizeof(struct sparc_bus_space_tag), M_DEVBUF, M_NOWAIT);
if (sbt == NULL)
return (NULL);
bzero(sbt, sizeof *sbt);
sbt->cookie = sc;
sbt->parent = sc->sc_bustag;
sbt->sparc_intr_establish = dmabus_intr_establish;
return (sbt);
}

View File

@ -1,12 +1,11 @@
/* $NetBSD: espvar.h,v 1.21 1998/03/21 20:29:57 pk Exp $ */
/* $NetBSD: dma_obio.c,v 1.1 1998/08/29 20:49:35 pk Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
* NASA Ames Research Center.
* by Paul Kranenburg.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -18,8 +17,8 @@
* 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 the NetBSD
* Foundation, Inc. and its contributors.
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
@ -37,21 +36,72 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
struct esp_softc {
struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */
bus_space_tag_t sc_bustag;
bus_dma_tag_t sc_dmatag;
struct sbusdev sc_sd; /* sbus device */
struct intrhand sc_ih; /* intr handler */
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/errno.h>
#include <sys/device.h>
#include <sys/malloc.h>
volatile u_char *sc_reg; /* the registers */
struct dma_softc *sc_dma; /* pointer to my dma */
#include <machine/bus.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
/* openprom stuff */
int sc_node; /* PROM node ID */
int sc_pri; /* SBUS priority */
#include <dev/sbus/sbusvar.h>
#include <dev/ic/lsi64854reg.h>
#include <dev/ic/lsi64854var.h>
int dmamatch_obio __P((struct device *, struct cfdata *, void *));
void dmaattach_obio __P((struct device *, struct device *, void *));
struct cfattach dma_obio_ca = {
sizeof(struct lsi64854_softc), dmamatch_obio, dmaattach_obio
};
#define SAME_ESP(sc, bp, sa) \
((bp->val[0] == sa->sa_slot && bp->val[1] == sa->sa_offset) || \
(bp->val[0] == -1 && bp->val[1] == sc->sc_dev.dv_unit))
int
dmamatch_obio(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
union obio_attach_args *uoba = aux;
struct obio4_attach_args *oba;
if (uoba->uoba_isobio4 == 0)
return (0);
oba = &uoba->uoba_oba4;
return (bus_space_probe(oba->oba_bustag, 0, oba->oba_paddr,
4, /* probe size */
0, /* offset */
0, /* flags */
NULL, NULL));
}
void
dmaattach_obio(parent, self, aux)
struct device *parent, *self;
void *aux;
{
union obio_attach_args *uoba = aux;
struct obio4_attach_args *oba = &uoba->uoba_oba4;
struct lsi64854_softc *sc = (void *)self;
bus_space_handle_t bh;
sc->sc_bustag = oba->oba_bustag;
sc->sc_dmatag = oba->oba_dmatag;
if (obio_bus_map(oba->oba_bustag, oba->oba_paddr,
0, sizeof(struct dma_regs),
0, 0,
&bh) != 0) {
printf("dmaattach_obio: cannot map registers\n");
return;
}
sc->sc_regs = bh;
lsi64854_attach(sc);
}

View File

@ -1,83 +0,0 @@
/* $NetBSD: dmareg.h,v 1.11 1998/07/27 19:16:49 pk Exp $ */
/*
* Copyright (c) 1994 Peter Galbavy. 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 Peter Galbavy.
* 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.
*/
#define DMACSRBITS "\020\01INT\02ERR\03DR1\04DR2\05IEN\011WRITE\016ENCNT\017TC\032DMAON"
struct dma_regs {
volatile u_long csr; /* DMA CSR */
#define D_INT_PEND 0x00000001 /* interrupt pending */
#define D_ERR_PEND 0x00000002 /* error pending */
#define D_DRAINING 0x0000000c /* fifo draining */
#define D_INT_EN 0x00000010 /* interrupt enable */
#define D_INVALIDATE 0x00000020 /* invalidate fifo */
#define D_SLAVE_ERR 0x00000040 /* slave access size error */
#define D_DRAIN 0x00000040 /* rev0,1,esc: drain fifo */
#define D_RESET 0x00000080 /* reset scsi */
#define D_WRITE 0x00000100 /* 1 = dev -> mem */
#define D_EN_DMA 0x00000200 /* enable DMA requests */
#define D_R_PEND 0x00000400 /* rev0,1: request pending */
#define D_ESC_BURST 0x00000800 /* DMA ESC: 16 byte bursts */
#define D_EN_CNT 0x00002000 /* enable byte counter */
#define D_TC 0x00004000 /* terminal count */
#define D_DSBL_CSR_DRN 0x00010000 /* disable fifo drain on csr */
#define D_DSBL_SCSI_DRN 0x00020000 /* disable fifo drain on reg */
#define D_BURST_SIZE 0x000c0000 /* sbus read/write burst size */
#define D_BURST_0 0x00080000 /* no bursts (SCSI-only) */
#define D_BURST_16 0x00000000 /* 16-byte bursts */
#define D_BURST_32 0x00040000 /* 32-byte bursts */
#define D_AUTODRAIN 0x00040000 /* DMA ESC: Auto-drain */
#define D_DIAG 0x00100000 /* disable fifo drain on addr */
#define D_TWO_CYCLE 0x00200000 /* 2 clocks per transfer */
#define D_FASTER 0x00400000 /* 3 clocks per transfer */
#define DE_AUI_TP 0x00400000 /* 1 for TP, 0 for AUI */
#define D_TCI_DIS 0x00800000 /* disable intr on D_TC */
#define D_EN_NEXT 0x01000000 /* enable auto next address */
#define D_DMA_ON 0x02000000 /* enable dma from scsi */
#define D_A_LOADED 0x04000000 /* address loaded */
#define D_NA_LOADED 0x08000000 /* next address loaded */
#define D_DEV_ID 0xf0000000 /* device ID */
#define DMAREV_0 0x00000000 /* Sunray DMA */
#define DMAREV_ESC 0x40000000 /* DMA ESC array */
#define DMAREV_1 0x80000000 /* 'DMA' */
#define DMAREV_PLUS 0x90000000 /* 'DMA+' */
#define DMAREV_2 0xa0000000 /* 'DMA2' */
volatile caddr_t addr;
#define DMA_D_ADDR 0x01 /* DMA ADDR (in u_longs) */
volatile u_long bcnt; /* DMA COUNT (in u_longs) */
#define D_BCNT_MASK 0x00ffffff /* only 24 bits */
volatile u_long test; /* DMA TEST (in u_longs) */
#define en_testcsr addr /* enet registers overlap */
#define en_cachev bcnt
#define en_bar test
};

View File

@ -1,69 +0,0 @@
/* $NetBSD: dmavar.h,v 1.13 1998/07/30 22:42:04 pk Exp $ */
/*
* Copyright (c) 1994 Peter Galbavy. 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 Peter Galbavy.
* 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.
*/
struct dma_softc {
struct device sc_dev; /* us as a device */
struct sbusdev sc_sd; /* sbus device */
bus_space_tag_t sc_bustag; /* bus tags */
bus_dma_tag_t sc_dmatag;
struct esp_softc *sc_esp; /* my scsi */
struct le_softc *sc_le; /* my ethernet */
struct dma_regs *sc_regs; /* the registers */
int sc_active; /* DMA active ? */
u_int sc_rev; /* revision */
int sc_node; /* PROM node ID */
int sc_burst; /* DVMA burst size in effect */
caddr_t sc_dvmaaddr; /* DVMA cookie */
size_t sc_dmasize;
caddr_t *sc_dmaaddr;
size_t *sc_dmalen;
bus_dmamap_t sc_dmamap; /* DMA map for bus_dma_* */
void (*reset)(struct dma_softc *); /* reset routine */
void (*enintr)(struct dma_softc *); /* enable interrupts */
int (*isintr)(struct dma_softc *); /* interrupt ? */
int (*intr)(void *); /* interrupt ! */
int (*setup)(struct dma_softc *, caddr_t *, size_t *, int, size_t *);
void (*go)(struct dma_softc *);
int (*sc_intrchain)(void *); /* next handler in intr chain */
void *sc_intrchainarg; /* arg for next intr handler */
};
#define DMACSR(sc) (sc->sc_regs->csr)
#define DMADDR(sc) (sc->sc_regs->addr)
#define DMACNT(sc) (sc->sc_regs->bcnt)
/* DMA engine functions */
#define DMA_ENINTR(r) (((r)->enintr)(r))
#define DMA_ISINTR(r) (((r)->isintr)(r))
#define DMA_RESET(r) (((r)->reset)(r))
#define DMA_INTR(r) (((r)->intr)(r))
#define DMA_ISACTIVE(r) ((r)->sc_active)
#define DMA_SETUP(a, b, c, d, e) (((a)->setup)(a, b, c, d, e))
#define DMA_GO(r) (((r)->go)(r))

View File

@ -1,12 +1,12 @@
/* $NetBSD: esp.c,v 1.77 1998/08/15 05:16:43 mycroft Exp $ */
/* $NetBSD: esp_obio.c,v 1.1 1998/08/29 20:49:37 pk Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
* Simulation Facility, NASA Ames Research Center.
* by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace
* Simulation Facility, NASA Ames Research Center; Paul Kranenburg.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -37,57 +37,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 1994 Peter Galbavy
* Copyright (c) 1995 Paul Kranenburg
* 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 Peter Galbavy
* 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.
*/
/*
* Based on aic6360 by Jarle Greipsland
*
* Acknowledgements: Many of the algorithms used in this driver are
* inspired by the work of Julian Elischer (julian@tfs.com) and
* Charles Hannum (mycroft@duality.gnu.ai.mit.edu). Thanks a million!
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/device.h>
#include <sys/buf.h>
#include <sys/proc.h>
#include <sys/user.h>
#include <sys/queue.h>
#include <dev/scsipi/scsi_all.h>
#include <dev/scsipi/scsipi_all.h>
@ -98,41 +54,39 @@
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <dev/ic/lsi64854reg.h>
#include <dev/ic/lsi64854var.h>
#include <dev/ic/ncr53c9xreg.h>
#include <dev/ic/ncr53c9xvar.h>
#include <dev/sbus/sbusvar.h>
#include <sparc/dev/dmareg.h>
#include <sparc/dev/dmavar.h>
#include <sparc/dev/espvar.h>
void espattach_sbus __P((struct device *, struct device *, void *));
struct esp_softc {
struct ncr53c9x_softc sc_ncr53c9x; /* glue to MI code */
bus_space_tag_t sc_bustag;
bus_dma_tag_t sc_dmatag;
bus_space_handle_t sc_reg; /* the registers */
struct lsi64854_softc *sc_dma; /* pointer to my dma */
};
void espattach_obio __P((struct device *, struct device *, void *));
void espattach_dma __P((struct device *, struct device *, void *));
int espmatch_sbus __P((struct device *, struct cfdata *, void *));
int espmatch_obio __P((struct device *, struct cfdata *, void *));
void espattach __P((struct esp_softc *));
/* Linkup to the rest of the kernel */
struct cfattach esp_sbus_ca = {
sizeof(struct esp_softc), espmatch_sbus, espattach_sbus
};
struct cfattach esp_dma_ca = {
sizeof(struct esp_softc), espmatch_sbus, espattach_dma
};
struct cfattach esp_obio_ca = {
sizeof(struct esp_softc), espmatch_obio, espattach_obio
};
struct scsipi_adapter esp_switch = {
static struct scsipi_adapter esp_obio_switch = {
ncr53c9x_scsi_cmd,
minphys, /* no max at this level; handled by DMA code */
NULL,
NULL,
};
struct scsipi_device esp_dev = {
static struct scsipi_device esp_obio_dev = {
NULL, /* Use default error handler */
NULL, /* have a queue, served by this */
NULL, /* have no async handler */
@ -142,18 +96,18 @@ struct scsipi_device esp_dev = {
/*
* Functions and the switch for the MI code.
*/
u_char esp_read_reg __P((struct ncr53c9x_softc *, int));
void esp_write_reg __P((struct ncr53c9x_softc *, int, u_char));
int esp_dma_isintr __P((struct ncr53c9x_softc *));
void esp_dma_reset __P((struct ncr53c9x_softc *));
int esp_dma_intr __P((struct ncr53c9x_softc *));
int esp_dma_setup __P((struct ncr53c9x_softc *, caddr_t *,
size_t *, int, size_t *));
void esp_dma_go __P((struct ncr53c9x_softc *));
void esp_dma_stop __P((struct ncr53c9x_softc *));
int esp_dma_isactive __P((struct ncr53c9x_softc *));
static u_char esp_read_reg __P((struct ncr53c9x_softc *, int));
static void esp_write_reg __P((struct ncr53c9x_softc *, int, u_char));
static int esp_dma_isintr __P((struct ncr53c9x_softc *));
static void esp_dma_reset __P((struct ncr53c9x_softc *));
static int esp_dma_intr __P((struct ncr53c9x_softc *));
static int esp_dma_setup __P((struct ncr53c9x_softc *, caddr_t *,
size_t *, int, size_t *));
static void esp_dma_go __P((struct ncr53c9x_softc *));
static void esp_dma_stop __P((struct ncr53c9x_softc *));
static int esp_dma_isactive __P((struct ncr53c9x_softc *));
struct ncr53c9x_glue esp_glue = {
static struct ncr53c9x_glue esp_obio_glue = {
esp_read_reg,
esp_write_reg,
esp_dma_isintr,
@ -166,17 +120,6 @@ struct ncr53c9x_glue esp_glue = {
NULL, /* gl_clear_latched_intr */
};
int
espmatch_sbus(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct sbus_attach_args *sa = aux;
return (strcmp(cf->cf_driver->cd_name, sa->sa_name) == 0);
}
int
espmatch_obio(parent, cf, aux)
struct device *parent;
@ -197,131 +140,6 @@ espmatch_obio(parent, cf, aux)
NULL, NULL));
}
void
espattach_sbus(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct esp_softc *esc = (void *)self;
struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x;
struct sbus_attach_args *sa = aux;
esc->sc_bustag = sa->sa_bustag;
esc->sc_dmatag = sa->sa_dmatag;
sc->sc_id = getpropint(sa->sa_node, "initiator-id", 7);
sc->sc_freq = getpropint(sa->sa_node, "clock-frequency", -1);
if (sc->sc_freq < 0)
sc->sc_freq = ((struct sbus_softc *)
sc->sc_dev.dv_parent)->sc_clockfreq;
/*
* Find the DMA by poking around the dma device structures
*
* What happens here is that if the dma driver has not been
* configured, then this returns a NULL pointer. Then when the
* dma actually gets configured, it does the opposing test, and
* if the sc->sc_esp field in it's softc is NULL, then tries to
* find the matching esp driver.
*/
esc->sc_dma = (struct dma_softc *)getdevunit("dma", sc->sc_dev.dv_unit);
/*
* and a back pointer to us, for DMA
*/
if (esc->sc_dma)
esc->sc_dma->sc_esp = esc;
else {
printf("\n");
panic("espattach: no dma found");
}
/*
* Map my registers in, if they aren't already in virtual
* address space.
*/
if (sa->sa_npromvaddrs)
esc->sc_reg = (volatile u_char *) sa->sa_promvaddrs[0];
else {
bus_space_handle_t bh;
if (sbus_bus_map(sa->sa_bustag, sa->sa_slot,
sa->sa_offset,
sa->sa_size,
BUS_SPACE_MAP_LINEAR,
0, &bh) != 0) {
printf("%s @ sbus: cannot map registers\n",
self->dv_xname);
return;
}
esc->sc_reg = (volatile u_char *)bh;
}
esc->sc_pri = sa->sa_pri;
/* add me to the sbus structures */
esc->sc_sd.sd_reset = (void *) ncr53c9x_reset;
sbus_establish(&esc->sc_sd, &sc->sc_dev);
if (sa->sa_bp != NULL && strcmp(sa->sa_bp->name, "esp") == 0 &&
SAME_ESP(sc, sa->sa_bp, sa))
bootpath_store(1, sa->sa_bp + 1);
espattach(esc);
}
void
espattach_dma(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct esp_softc *esc = (void *)self;
struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x;
struct sbus_attach_args *sa = aux;
esc->sc_bustag = sa->sa_bustag;
esc->sc_dmatag = sa->sa_dmatag;
sc->sc_id = getpropint(sa->sa_node, "initiator-id", 7);
sc->sc_freq = getpropint(sa->sa_node, "clock-frequency", -1);
esc->sc_dma = (struct dma_softc *)parent;
esc->sc_dma->sc_esp = esc;
/*
* Map my registers in, if they aren't already in virtual
* address space.
*/
if (sa->sa_npromvaddrs)
esc->sc_reg = (volatile u_char *) sa->sa_promvaddrs[0];
else {
bus_space_handle_t bh;
if (bus_space_map2(sa->sa_bustag,
sa->sa_slot,
sa->sa_offset,
sa->sa_size,
BUS_SPACE_MAP_LINEAR,
0, &bh) != 0) {
printf("%s @ dma: cannot map registers\n",
self->dv_xname);
return;
}
esc->sc_reg = (volatile u_char *)bh;
}
/* Establish interrupt handler */
esc->sc_pri = sa->sa_pri;
/* Assume SBus is grandparent */
esc->sc_sd.sd_reset = (void *) ncr53c9x_reset;
sbus_establish(&esc->sc_sd, parent);
if (sa->sa_bp != NULL && strcmp(sa->sa_bp->name, "esp") == 0 &&
SAME_ESP(sc, sa->sa_bp, sa))
bootpath_store(1, sa->sa_bp + 1);
espattach(esc);
}
void
espattach_obio(parent, self, aux)
struct device *parent, *self;
@ -342,13 +160,14 @@ espattach_obio(parent, self, aux)
/*
* Find the DMA by poking around the dma device structures
*/
esc->sc_dma = (struct dma_softc *)getdevunit("dma", sc->sc_dev.dv_unit);
esc->sc_dma = (struct lsi64854_softc *)
getdevunit("dma", sc->sc_dev.dv_unit);
/*
* and a back pointer to us, for DMA
*/
if (esc->sc_dma)
esc->sc_dma->sc_esp = esc;
esc->sc_dma->sc_ncr53c9x = sc;
else {
printf("\n");
panic("espattach: no dma found");
@ -363,35 +182,18 @@ espattach_obio(parent, self, aux)
return;
}
esc->sc_reg = (volatile u_char *)bh;
esc->sc_pri = oba->oba_pri;
esc->sc_reg = bh;
if (oba->oba_bp != NULL && strcmp(oba->oba_bp->name, "esp") == 0 &&
oba->oba_bp->val[0] == -1 &&
oba->oba_bp->val[1] == sc->sc_dev.dv_unit)
bootpath_store(1, oba->oba_bp + 1);
espattach(esc);
}
/*
* Attach this instance, and then all the sub-devices
*/
void
espattach(esc)
struct esp_softc *esc;
{
struct ncr53c9x_softc *sc = &esc->sc_ncr53c9x;
void *icookie;
/*
* Set up glue for MI code early; we use some of it here.
*/
sc->sc_glue = &esp_glue;
#if 0
printf(" pri %d", esc->sc_pri);
#endif
sc->sc_glue = &esp_obio_glue;
/* gimme Mhz */
sc->sc_freq /= 1000000;
@ -475,15 +277,15 @@ espattach(esc)
}
/* Establish interrupt channel */
icookie = bus_intr_establish(esc->sc_bustag,
esc->sc_pri, 0,
(int(*)__P((void*)))ncr53c9x_intr, sc);
bus_intr_establish(esc->sc_bustag,
oba->oba_pri, 0,
(int(*)__P((void*)))ncr53c9x_intr, sc);
/* register interrupt stats */
evcnt_attach(&sc->sc_dev, "intr", &sc->sc_intrcnt);
/* Do the common parts of attachment. */
ncr53c9x_attach(sc, &esp_switch, &esp_dev);
ncr53c9x_attach(sc, &esp_obio_switch, &esp_obio_dev);
/* Turn on target selection using the `dma' method */
ncr53c9x_dmaselect = 1;
@ -502,19 +304,18 @@ esp_read_reg(sc, reg)
{
struct esp_softc *esc = (struct esp_softc *)sc;
return (esc->sc_reg[reg * 4]);
return (bus_space_read_1(esc->sc_bustag, esc->sc_reg, reg * 4));
}
void
esp_write_reg(sc, reg, val)
esp_write_reg(sc, reg, v)
struct ncr53c9x_softc *sc;
int reg;
u_char val;
u_char v;
{
struct esp_softc *esc = (struct esp_softc *)sc;
u_char v = val;
esc->sc_reg[reg * 4] = v;
bus_space_write_1(esc->sc_bustag, esc->sc_reg, reg * 4, v);
}
int
@ -571,8 +372,11 @@ esp_dma_stop(sc)
struct ncr53c9x_softc *sc;
{
struct esp_softc *esc = (struct esp_softc *)sc;
u_int32_t csr;
DMACSR(esc->sc_dma) &= ~D_EN_DMA;
csr = L64854_GCSR(esc->sc_dma);
csr &= ~D_EN_DMA;
L64854_SCSR(esc->sc_dma, csr);
}
int

View File

@ -1,464 +0,0 @@
/* $NetBSD: if_le_ledma.c,v 1.4 1998/08/28 20:07:52 pk Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
* Simulation Facility, NASA Ames Research Center.
*
* 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 the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``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 FOUNDATION OR CONTRIBUTORS
* 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.
*/
/*-
* Copyright (c) 1996
* The President and Fellows of Harvard College. All rights reserved.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell and Rick Macklem.
*
* 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 Aaron Brown and
* Harvard University.
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)if_le.c 8.2 (Berkeley) 11/16/93
*/
#include "opt_inet.h"
#include "bpfilter.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/syslog.h>
#include <sys/socket.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <net/if.h>
#include <net/if_ether.h>
#include <net/if_media.h>
#ifdef INET
#include <netinet/in.h>
#include <netinet/if_inarp.h>
#endif
#include <machine/autoconf.h>
#include <machine/cpu.h>
#include <dev/sbus/sbusvar.h>
#include <sparc/dev/dmareg.h>
#include <sparc/dev/dmavar.h>
#include <dev/ic/lancereg.h>
#include <dev/ic/lancevar.h>
#include <dev/ic/am7990reg.h>
#include <dev/ic/am7990var.h>
/*
* LANCE registers.
*/
struct lereg1 {
volatile u_int16_t ler1_rdp; /* data port */
volatile u_int16_t ler1_rap; /* register select port */
};
struct le_softc {
struct am7990_softc sc_am7990; /* glue to MI code */
struct sbusdev sc_sd; /* sbus device */
bus_space_tag_t sc_bustag;
bus_dma_tag_t sc_dmatag;
struct lereg1 *sc_r1; /* LANCE registers */
struct dma_softc *sc_dma; /* pointer to my dma */
u_long sc_laddr; /* LANCE DMA address */
};
#define MEMSIZE (16*1024) /* LANCE memory size */
#define LEDMA_BOUNDARY (16*1024*1024) /* must not cross 16MB boundary */
int lematch_ledma __P((struct device *, struct cfdata *, void *));
void leattach_ledma __P((struct device *, struct device *, void *));
/*
* Media types supported by the Sun4m.
*/
static int lemedia[] = {
IFM_ETHER|IFM_10_T,
IFM_ETHER|IFM_10_5,
IFM_ETHER|IFM_AUTO,
};
#define NLEMEDIA (sizeof(lemedia) / sizeof(lemedia[0]))
void lesetutp __P((struct lance_softc *));
void lesetaui __P((struct lance_softc *));
int lemediachange __P((struct lance_softc *));
void lemediastatus __P((struct lance_softc *, struct ifmediareq *));
struct cfattach le_ledma_ca = {
sizeof(struct le_softc), lematch_ledma, leattach_ledma
};
extern struct cfdriver le_cd;
#if defined(_KERNEL) && !defined(_LKM)
#include "opt_ddb.h"
#endif
#ifdef DDB
#define integrate
#define hide
#else
#define integrate static __inline
#define hide static
#endif
static void lewrcsr __P((struct lance_softc *, u_int16_t, u_int16_t));
static u_int16_t lerdcsr __P((struct lance_softc *, u_int16_t));
hide void lehwreset __P((struct lance_softc *));
hide void lehwinit __P((struct lance_softc *));
hide void lenocarrier __P((struct lance_softc *));
static void
lewrcsr(sc, port, val)
struct lance_softc *sc;
u_int16_t port, val;
{
struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
ler1->ler1_rap = port;
ler1->ler1_rdp = val;
#if defined(SUN4M)
/*
* We need to flush the Sbus->Mbus write buffers. This can most
* easily be accomplished by reading back the register that we
* just wrote (thanks to Chris Torek for this solution).
*/
if (CPU_ISSUN4M) {
volatile u_int16_t discard;
discard = ler1->ler1_rdp;
}
#endif
}
static u_int16_t
lerdcsr(sc, port)
struct lance_softc *sc;
u_int16_t port;
{
struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
u_int16_t val;
ler1->ler1_rap = port;
val = ler1->ler1_rdp;
return (val);
}
void
lesetutp(sc)
struct lance_softc *sc;
{
struct le_softc *lesc = (struct le_softc *)sc;
lesc->sc_dma->sc_regs->csr |= DE_AUI_TP;
delay(20000); /* must not touch le for 20ms */
}
void
lesetaui(sc)
struct lance_softc *sc;
{
struct le_softc *lesc = (struct le_softc *)sc;
lesc->sc_dma->sc_regs->csr &= ~DE_AUI_TP;
delay(20000); /* must not touch le for 20ms */
}
int
lemediachange(sc)
struct lance_softc *sc;
{
struct ifmedia *ifm = &sc->sc_media;
if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
return (EINVAL);
/*
* Switch to the selected media. If autoselect is
* set, we don't really have to do anything. We'll
* switch to the other media when we detect loss of
* carrier.
*/
switch (IFM_SUBTYPE(ifm->ifm_media)) {
case IFM_10_T:
lesetutp(sc);
break;
case IFM_10_5:
lesetaui(sc);
break;
case IFM_AUTO:
break;
default:
return (EINVAL);
}
return (0);
}
void
lemediastatus(sc, ifmr)
struct lance_softc *sc;
struct ifmediareq *ifmr;
{
struct le_softc *lesc = (struct le_softc *)sc;
/*
* Notify the world which media we're currently using.
*/
if (lesc->sc_dma->sc_regs->csr & DE_AUI_TP)
ifmr->ifm_active = IFM_ETHER|IFM_10_T;
else
ifmr->ifm_active = IFM_ETHER|IFM_10_5;
}
hide void
lehwreset(sc)
struct lance_softc *sc;
{
struct le_softc *lesc = (struct le_softc *)sc;
struct dma_softc *dma = lesc->sc_dma;
u_long aui_bit;
/*
* Reset DMA channel.
*/
aui_bit = dma->sc_regs->csr & DE_AUI_TP;
DMA_RESET(dma);
dma->sc_regs->en_bar = lesc->sc_laddr & 0xff000000;
DMA_ENINTR(dma);
#define D_DSBL_WRINVAL D_DSBL_SCSI_DRN /* XXX: fix dmareg.h */
/*
* Disable E-cache invalidates on chip writes.
* Retain previous cable selection bit.
*/
dma->sc_regs->csr |= (D_DSBL_WRINVAL | aui_bit);
}
hide void
lehwinit(sc)
struct lance_softc *sc;
{
/*
* Make sure we're using the currently-enabled media type.
* XXX Actually, this is probably unnecessary, now.
*/
switch (IFM_SUBTYPE(sc->sc_media.ifm_cur->ifm_media)) {
case IFM_10_T:
lesetutp(sc);
break;
case IFM_10_5:
lesetaui(sc);
break;
}
}
hide void
lenocarrier(sc)
struct lance_softc *sc;
{
struct le_softc *lesc = (struct le_softc *)sc;
/*
* Check if the user has requested a certain cable type, and
* if so, honor that request.
*/
printf("%s: lost carrier on ", sc->sc_dev.dv_xname);
if (lesc->sc_dma->sc_regs->csr & DE_AUI_TP) {
printf("UTP port");
switch (IFM_SUBTYPE(sc->sc_media.ifm_media)) {
case IFM_10_5:
case IFM_AUTO:
printf(", switching to AUI port");
lesetaui(sc);
}
} else {
printf("AUI port");
switch (IFM_SUBTYPE(sc->sc_media.ifm_media)) {
case IFM_10_T:
case IFM_AUTO:
printf(", switching to UTP port");
lesetutp(sc);
}
}
printf("\n");
}
int
lematch_ledma(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
{
struct sbus_attach_args *sa = aux;
return (strcmp(cf->cf_driver->cd_name, sa->sa_name) == 0);
}
#define SAME_LANCE(bp, sa) \
((bp->val[0] == sa->sa_slot && bp->val[1] == sa->sa_offset) || \
(bp->val[0] == -1 && bp->val[1] == sc->sc_dev.dv_unit))
void
leattach_ledma(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct sbus_attach_args *sa = aux;
struct le_softc *lesc = (struct le_softc *)self;
struct lance_softc *sc = &lesc->sc_am7990.lsc;
bus_space_handle_t bh;
bus_dma_segment_t seg;
int rseg, error;
/* XXX the following declarations should be elsewhere */
extern void myetheraddr __P((u_char *));
/* Establish link to `ledma' device */
lesc->sc_dma = (struct dma_softc *)parent;
lesc->sc_dma->sc_le = lesc;
lesc->sc_bustag = sa->sa_bustag;
lesc->sc_dmatag = sa->sa_dmatag;
/* Map device registers */
if (bus_space_map2(sa->sa_bustag,
sa->sa_slot,
sa->sa_offset,
sizeof(struct lereg1),
BUS_SPACE_MAP_LINEAR,
0, &bh) != 0) {
printf("%s @ ledma: cannot map registers\n", self->dv_xname);
return;
}
lesc->sc_r1 = (struct lereg1 *)bh;
/* Allocate buffer memory */
sc->sc_memsize = MEMSIZE;
error = bus_dmamem_alloc(lesc->sc_dmatag, MEMSIZE, NBPG, LEDMA_BOUNDARY,
&seg, 1, &rseg, BUS_DMA_NOWAIT);
if (error) {
printf("leattach_ledma: DMA buffer alloc error %d\n", error);
return;
}
error = bus_dmamem_map(lesc->sc_dmatag, &seg, rseg, MEMSIZE,
(caddr_t *)&sc->sc_mem,
BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
if (error) {
printf("%s @ ledma: DMA buffer map error %d\n",
self->dv_xname, error);
return;
}
sc->sc_addr = seg.ds_addr & 0xffffff;
sc->sc_conf3 = LE_C3_BSWP | LE_C3_ACON | LE_C3_BCON;
lesc->sc_laddr = seg.ds_addr;
/* Assume SBus is grandparent */
lesc->sc_sd.sd_reset = (void *)lance_reset;
sbus_establish(&lesc->sc_sd, parent);
if (sa->sa_bp != NULL && strcmp(sa->sa_bp->name, le_cd.cd_name) == 0 &&
SAME_LANCE(sa->sa_bp, sa))
sa->sa_bp->dev = &sc->sc_dev;
sc->sc_mediachange = lemediachange;
sc->sc_mediastatus = lemediastatus;
sc->sc_supmedia = lemedia;
sc->sc_nsupmedia = NLEMEDIA;
sc->sc_defaultmedia = IFM_ETHER|IFM_AUTO;
myetheraddr(sc->sc_enaddr);
sc->sc_copytodesc = lance_copytobuf_contig;
sc->sc_copyfromdesc = lance_copyfrombuf_contig;
sc->sc_copytobuf = lance_copytobuf_contig;
sc->sc_copyfrombuf = lance_copyfrombuf_contig;
sc->sc_zerobuf = lance_zerobuf_contig;
sc->sc_rdcsr = lerdcsr;
sc->sc_wrcsr = lewrcsr;
sc->sc_hwinit = lehwinit;
sc->sc_nocarrier = lenocarrier;
sc->sc_hwreset = lehwreset;
am7990_config(&lesc->sc_am7990);
(void)bus_intr_establish(lesc->sc_bustag, sa->sa_pri, 0,
am7990_intr, sc);
/* now initialize DMA */
lehwreset(sc);
}

View File

@ -1,12 +1,12 @@
/* $NetBSD: if_le_obio.c,v 1.4 1998/08/15 10:51:16 mycroft Exp $ */
/* $NetBSD: if_le_obio.c,v 1.5 1998/08/29 20:49:37 pk Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace
* Simulation Facility, NASA Ames Research Center.
* by Charles M. Hannum; Jason R. Thorpe of the Numerical Aerospace
* Simulation Facility, NASA Ames Research Center; Paul Kranenburg.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -37,68 +37,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/*-
* Copyright (c) 1996
* The President and Fellows of Harvard College. All rights reserved.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Ralph Campbell and Rick Macklem.
*
* 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 Aaron Brown and
* Harvard University.
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)if_le.c 8.2 (Berkeley) 11/16/93
*/
#include "opt_inet.h"
#include "bpfilter.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/syslog.h>
#include <sys/socket.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_ether.h>
#include <net/if_media.h>
#ifdef INET
#include <netinet/in.h>
#include <netinet/if_inarp.h>
#endif
#include <machine/autoconf.h>
#include <machine/cpu.h>
@ -110,16 +61,14 @@
/*
* LANCE registers.
*/
struct lereg1 {
volatile u_int16_t ler1_rdp; /* data port */
volatile u_int16_t ler1_rap; /* register select port */
};
#define LEREG1_RDP 0 /* Register Data port */
#define LEREG1_RAP 2 /* Register Address port */
struct le_softc {
struct am7990_softc sc_am7990; /* glue to MI code */
bus_space_tag_t sc_bustag;
bus_dma_tag_t sc_dmatag;
struct lereg1 *sc_r1; /* LANCE registers */
struct am7990_softc sc_am7990; /* glue to MI code */
bus_space_tag_t sc_bustag;
bus_dma_tag_t sc_dmatag;
bus_space_handle_t sc_reg; /* LANCE registers */
};
#define MEMSIZE 0x4000 /* LANCE memory size */
@ -161,10 +110,10 @@ lewrcsr(sc, port, val)
struct lance_softc *sc;
u_int16_t port, val;
{
struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
struct le_softc *lesc = (struct le_softc *)sc;
ler1->ler1_rap = port;
ler1->ler1_rdp = val;
bus_space_write_2(lesc->sc_bustag, lesc->sc_reg, LEREG1_RAP, port);
bus_space_write_2(lesc->sc_bustag, lesc->sc_reg, LEREG1_RDP, val);
}
static u_int16_t
@ -172,12 +121,10 @@ lerdcsr(sc, port)
struct lance_softc *sc;
u_int16_t port;
{
struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
u_int16_t val;
struct le_softc *lesc = (struct le_softc *)sc;
ler1->ler1_rap = port;
val = ler1->ler1_rdp;
return (val);
bus_space_write_2(lesc->sc_bustag, lesc->sc_reg, LEREG1_RAP, port);
return (bus_space_read_2(lesc->sc_bustag, lesc->sc_reg, LEREG1_RDP));
}
int
@ -209,7 +156,6 @@ leattach_obio(parent, self, aux)
struct obio4_attach_args *oba = &uoba->uoba_oba4;
struct le_softc *lesc = (struct le_softc *)self;
struct lance_softc *sc = &lesc->sc_am7990.lsc;
bus_space_handle_t bh;
bus_dma_segment_t seg;
int rseg;
/* XXX the following declarations should be elsewhere */
@ -219,13 +165,12 @@ leattach_obio(parent, self, aux)
lesc->sc_dmatag = oba->oba_dmatag;
if (obio_bus_map(oba->oba_bustag, oba->oba_paddr,
0, sizeof(struct lereg1),
0, 2 * sizeof(u_int16_t),
0, 0,
&bh) != 0) {
&lesc->sc_reg) != 0) {
printf("%s @ obio: cannot map registers\n", self->dv_xname);
return;
}
lesc->sc_r1 = (struct lereg1 *)bh;
if (oba->oba_bp != NULL &&
strcmp(oba->oba_bp->name, le_cd.cd_name) == 0 &&