Extend asc driver to include support for the VS400/9x.

Add VS4000/9x support vsbus_dma.c
This commit is contained in:
matt 2000-04-23 16:38:52 +00:00
parent 59c8861b20
commit c10673838a
6 changed files with 97 additions and 53 deletions

View File

@ -1,11 +1,11 @@
# $NetBSD: GENERIC,v 1.63 2000/04/22 16:48:53 ragge Exp $
# $NetBSD: GENERIC,v 1.64 2000/04/23 16:38:52 matt Exp $
#
# GENERIC VAX configuration file; all supported devices.
#
include "arch/vax/conf/std.vax"
#ident "GENERIC-$Revision: 1.63 $"
#ident "GENERIC-$Revision: 1.64 $"
# Here are all different supported CPU types listed.
options "VAX8600"
@ -125,7 +125,8 @@ dz0 at vsbus0 csr 0x200a0000 # DC-367 DZ-11 lookalike ctlr
dz0 at vsbus0 csr 0x25000000 # VS4000/90 serial line
#hdc0 at vsbus0 csr 0x200c0000 # HDC9224 MFM/floppy ctlr
ncr0 at vsbus0 csr 0x200c0080 # VS2000/3100 SCSI-ctlr
asc0 at vsbus0 csr 0x200c0080 # VS4000 SCSI-ctlr
asc0 at vsbus0 csr 0x200c0080 # VS4000/60 (or VLC) SCSI-ctlr
asc0 at vsbus0 csr 0x26000080 # VS4000/90 SCSI-ctlr
ncr1 at vsbus0 csr 0x200c0180 # VS2000/3100 SCSI-ctlr
smg0 at vsbus0 csr 0x200f0000 # Small monochrome display ctlr.
#clr0 at vsbus0 csr 0x30000000 # 4- or 8-bitplans color graphics

View File

@ -1,4 +1,4 @@
/* $NetBSD: vsbus.h,v 1.11 2000/03/04 07:27:49 matt Exp $ */
/* $NetBSD: vsbus.h,v 1.12 2000/04/23 16:38:53 matt Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
@ -65,6 +65,7 @@ struct vsbus_attach_args {
#define NI_BASE 0x200e0000 /* LANCE CSRs */
#define NI_IOSIZE (128 * VAX_NBPG) /* IO address size */
#define KA49_SCSIMAP 0x27000000 /* KA49 SCSI SGMAP */
/*
* Small monochrome graphics framebuffer, present on all machines.
*/
@ -77,12 +78,13 @@ struct vsbus_softc {
u_char *sc_intclr; /* Clear interrupt register */
u_char *sc_intreq; /* Interrupt request register */
u_char sc_mask; /* Interrupts to enable after autoconf */
vaddr_t sc_vsregs; /* Where the VS_REGS are mapped */
struct vax_bus_dma_tag sc_dmatag;
struct vax_sgmap sc_sgmap;
};
#ifdef _KERNEL
void vsbus_dma_init __P((struct vsbus_softc *));
void vsbus_dma_init __P((struct vsbus_softc *, unsigned ptecnt));
u_char vsbus_setmask __P((int));
void vsbus_clrintr __P((int));
void vsbus_copytoproc __P((struct proc *, caddr_t, caddr_t, int));

View File

@ -1,4 +1,4 @@
/* $NetBSD: asc_vsbus.c,v 1.10 2000/04/18 21:25:31 matt Exp $ */
/* $NetBSD: asc_vsbus.c,v 1.11 2000/04/23 16:38:54 matt Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -40,7 +40,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: asc_vsbus.c,v 1.10 2000/04/18 21:25:31 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: asc_vsbus.c,v 1.11 2000/04/23 16:38:54 matt Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -76,6 +76,8 @@ struct asc_vsbus_softc {
struct ncr53c9x_softc sc_ncr53c9x; /* Must be first */
bus_space_tag_t sc_bst; /* bus space tag */
bus_space_handle_t sc_bsh; /* bus space handle */
bus_space_handle_t sc_dirh; /* scsi direction handle */
bus_space_handle_t sc_adrh; /* scsi address handle */
bus_space_handle_t sc_ncrh; /* ncr bus space handle */
bus_dma_tag_t sc_dmat; /* bus dma tag */
bus_dmamap_t sc_dmamap;
@ -89,8 +91,10 @@ struct asc_vsbus_softc {
unsigned long sc_xfers;
};
#define ASC_REG_ADR 0x0000
#define ASC_REG_DIR 0x000C
#define ASC_REG_KA46_ADR 0x0000
#define ASC_REG_KA46_DIR 0x000C
#define ASC_REG_KA49_ADR 0x0004
#define ASC_REG_KA49_DIR 0x0008
#define ASC_REG_NCR 0x0080
#define ASC_REG_END 0x00B0
@ -147,7 +151,7 @@ asc_vsbus_match( struct device *parent, struct cfdata *cf, void *aux)
if (vax_boardtype != VAX_BTYP_46
&& vax_boardtype != VAX_BTYP_48
/* && vax_boardtype != VAX_BTYP_49 */)
&& vax_boardtype != VAX_BTYP_49)
return 0;
ncr_regs = (volatile u_int8_t *) va->va_addr;
@ -203,6 +207,34 @@ asc_vsbus_attach(struct device *parent, struct device *self, void *aux)
printf(": failed to map ncr registers: error=%d\n", error);
return;
}
if (vax_boardtype == VAX_BTYP_46 || vax_boardtype == VAX_BTYP_48) {
error = bus_space_subregion(asc->sc_bst, asc->sc_bsh,
ASC_REG_KA46_ADR, sizeof(u_int32_t), &asc->sc_adrh);
if (error) {
printf(": failed to map adr register: error=%d\n",
error);
return;
}
error = bus_space_subregion(asc->sc_bst, asc->sc_bsh,
ASC_REG_KA46_DIR, sizeof(u_int32_t), &asc->sc_dirh);
if (error) {
printf(": failed to map dir register: error=%d\n",
error);
return;
}
} else {
/* This is a gross and disgusting kludge but it'll
* save a bunch of ugly code. Unlike the VS4000/60,
* the SCSI Address and direction registers are not
* near the SCSI NCR registers and are inside the
* block of general VAXstation registers. So we grab
* them from there and knowing the internals of the
* bus_space implementation, we cast to bus_space_handles.
*/
struct vsbus_softc *vsc = (struct vsbus_softc *) parent;
asc->sc_adrh = (bus_space_handle_t) (vsc->sc_vsregs + ASC_REG_KA49_ADR);
asc->sc_dirh = (bus_space_handle_t) (vsc->sc_vsregs + ASC_REG_KA49_DIR);
}
error = bus_dmamap_create(asc->sc_dmat, ASC_MAXXFERSIZE, 1,
ASC_MAXXFERSIZE, 0, BUS_DMA_NOWAIT, &asc->sc_dmamap);
@ -398,9 +430,9 @@ asc_vsbus_dma_setup(struct ncr53c9x_softc *sc, caddr_t *addr, size_t *len,
asc->sc_flags & ASC_FROMMEMORY
? BUS_DMASYNC_PREWRITE
: BUS_DMASYNC_PREREAD);
bus_space_write_4(asc->sc_bst, asc->sc_bsh, ASC_REG_ADR,
bus_space_write_4(asc->sc_bst, asc->sc_adrh, 0,
asc->sc_dmamap->dm_segs[0].ds_addr);
bus_space_write_4(asc->sc_bst, asc->sc_bsh, ASC_REG_DIR,
bus_space_write_4(asc->sc_bst, asc->sc_dirh, 0,
asc->sc_flags & ASC_FROMMEMORY);
asc->sc_flags |= ASC_MAPLOADED;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ze_vsbus.c,v 1.2 2000/01/24 02:40:35 matt Exp $ */
/* $NetBSD: if_ze_vsbus.c,v 1.3 2000/04/23 16:38:54 matt Exp $ */
/*
* Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved.
*
@ -104,6 +104,7 @@ zeattach(parent, self, aux)
{
struct ze_softc *sc = (struct ze_softc *)self;
struct vsbus_attach_args *va = aux;
extern struct vax_bus_dma_tag vax_bus_dma_tag;
int *ea, i;
/*
@ -111,7 +112,7 @@ zeattach(parent, self, aux)
*/
sc->sc_ioh = vax_map_physmem(SGECADDR, 1);
sc->sc_iot = 0; /* :-) */
sc->sc_dmat = va->va_dmat;
sc->sc_dmat = &vax_bus_dma_tag;
sc->sc_intvec = SGECVEC;
scb_vecalloc(va->va_cvec, (void (*)(void *)) sgec_intr, sc, SCB_ISTACK);

View File

@ -1,4 +1,4 @@
/* $NetBSD: vsbus.c,v 1.23 2000/03/08 23:50:51 matt Exp $ */
/* $NetBSD: vsbus.c,v 1.24 2000/04/23 16:38:54 matt Exp $ */
/*
* Copyright (c) 1996, 1999 Ludd, University of Lule}, Sweden.
* All rights reserved.
@ -132,7 +132,6 @@ vsbus_attach(parent, self, aux)
void *aux;
{
struct vsbus_softc *sc = (void *)self;
vaddr_t temp;
printf("\n");
@ -141,28 +140,29 @@ vsbus_attach(parent, self, aux)
switch (vax_boardtype) {
#if VAX49
case VAX_BTYP_49:
temp = vax_map_physmem(0x25c00000, 1);
sc->sc_intreq = (char *)temp + 12;
sc->sc_intclr = (char *)temp + 12;
sc->sc_intmsk = (char *)temp + 8;
#if 0
vsbus_dma_init(sc); /* not yet */
#endif
sc->sc_vsregs = vax_map_physmem(0x25c00000, 1);
sc->sc_intreq = (char *)sc->sc_vsregs + 12;
sc->sc_intclr = (char *)sc->sc_vsregs + 12;
sc->sc_intmsk = (char *)sc->sc_vsregs + 8;
vsbus_dma_init(sc, 8192);
break;
#endif
#if VAX46 || VAX48
case VAX_BTYP_48:
case VAX_BTYP_46:
vsbus_dma_init(sc);
/* FALL THROUGH */
sc->sc_vsregs = vax_map_physmem(VS_REGS, 1);
sc->sc_intreq = (char *)sc->sc_vsregs + 15;
sc->sc_intclr = (char *)sc->sc_vsregs + 15;
sc->sc_intmsk = (char *)sc->sc_vsregs + 12;
vsbus_dma_init(sc, 32768);
#endif
default:
temp = vax_map_physmem(VS_REGS, 1);
sc->sc_intreq = (char *)temp + 15;
sc->sc_intclr = (char *)temp + 15;
sc->sc_intmsk = (char *)temp + 12;
sc->sc_vsregs = vax_map_physmem(VS_REGS, 1);
sc->sc_intreq = (char *)sc->sc_vsregs + 15;
sc->sc_intclr = (char *)sc->sc_vsregs + 15;
sc->sc_intmsk = (char *)sc->sc_vsregs + 12;
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: vsbus_dma.c,v 1.3 2000/03/07 00:07:16 matt Exp $ */
/* $NetBSD: vsbus_dma.c,v 1.4 2000/04/23 16:38:54 matt Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -48,6 +48,7 @@
#define _VAX_BUS_DMA_PRIVATE
#include <machine/bus.h>
#include <machine/cpu.h>
#include <machine/sid.h>
#include <machine/sgmap.h>
#include <machine/vsbus.h>
@ -74,14 +75,15 @@ static void vsbus_bus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
bus_size_t, int));
void
vsbus_dma_init(sc)
vsbus_dma_init(sc, ptecnt)
struct vsbus_softc *sc;
unsigned ptecnt;
{
bus_dma_tag_t t;
bus_dma_segment_t segs[1];
struct pte *pte;
int nsegs, error;
vaddr_t vs_regs;
unsigned mapsize = ptecnt * sizeof(struct pte);
/*
* Initialize the DMA tag used for sgmap-mapped DMA.
@ -89,7 +91,7 @@ vsbus_dma_init(sc)
t = &sc->sc_dmatag;
t->_cookie = sc;
t->_wbase = 0;
t->_wsize = 16*1024*1024;
t->_wsize = ptecnt * VAX_NBPG;
t->_boundary = 0;
t->_sgmap = &sc->sc_sgmap;
t->_dmamap_create = vsbus_bus_dmamap_create_sgmap;
@ -107,28 +109,34 @@ vsbus_dma_init(sc)
t->_dmamem_unmap = _bus_dmamem_unmap;
t->_dmamem_mmap = _bus_dmamem_mmap;
if (vax_boardtype == VAX_BTYP_46 || vax_boardtype == VAX_BTYP_48) {
/*
* Allocate and map the VS4000 scatter gather map.
*/
error = bus_dmamem_alloc(t, 0x20000, 0x20000, 0x20000,
error = bus_dmamem_alloc(t, mapsize, mapsize, mapsize,
segs, 1, &nsegs, BUS_DMA_NOWAIT);
if (error) {
panic("vsbus_dma_init: error allocating memory for hw sgmap"
": error=%d", error);
panic("vsbus_dma_init: error allocating memory for "
"hw sgmap: error=%d", error);
}
error = bus_dmamem_map(t, segs, nsegs, 0x20000,
error = bus_dmamem_map(t, segs, nsegs, mapsize,
(caddr_t *) &pte, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
if (error) {
panic("vsbus_dma_init: error mapping memory for hw sgmap"
": error=%d", error);
panic("vsbus_dma_init: error mapping memory for "
"hw sgmap: error=%d", error);
}
printf("%s: 32K entry DMA SGMAP at PA 0x%lx (VA %p)\n",
sc->sc_dev.dv_xname, segs->ds_addr, pte);
memset(pte, 0, 0x20000);
vs_regs = vax_map_physmem(VS_REGS, 1);
*(int *) (vs_regs + 8) = segs->ds_addr; /* set MAP BASE 0x2008008 */
vax_unmap_physmem(vs_regs, 1);
memset(pte, 0, mapsize);
*(int *) (sc->sc_vsregs + 8) = segs->ds_addr; /* set MAP BASE 0x2008008 */
} else {
pte = (struct pte *) vax_map_physmem(KA49_SCSIMAP, mapsize / VAX_NBPG);
for (; ptecnt > 0; ) {
((u_int32_t *) pte)[--ptecnt] = 0;
}
segs->ds_addr = KA49_SCSIMAP;
}
printf("%s: %uK entry DMA SGMAP at PA 0x%lx (VA %p)\n",
sc->sc_dev.dv_xname, ptecnt / 1024, segs->ds_addr, pte);
/*
* Initialize the SGMAP.