1995-04-10 17:08:28 +04:00
|
|
|
/* $NetBSD: ivsc.c,v 1.10 1995/04/10 13:08:54 mycroft Exp $ */
|
1994-10-26 05:01:24 +03:00
|
|
|
|
1994-05-08 09:52:54 +04:00
|
|
|
/*
|
1994-05-29 08:49:51 +04:00
|
|
|
* Copyright (c) 1994 Michael L. Hitch
|
1994-05-08 09:52:54 +04:00
|
|
|
* Copyright (c) 1982, 1990 The Regents of the University of California.
|
|
|
|
* 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 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.
|
|
|
|
*
|
|
|
|
* @(#)ivsdma.c
|
|
|
|
*/
|
1994-05-29 08:49:51 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <vm/vm.h> /* XXXX Kludge for IVS Vector - mlh */
|
|
|
|
#include <scsi/scsi_all.h>
|
|
|
|
#include <scsi/scsiconf.h>
|
|
|
|
#include <amiga/amiga/custom.h>
|
|
|
|
#include <amiga/amiga/device.h>
|
1995-02-12 22:18:33 +03:00
|
|
|
#include <amiga/amiga/isr.h>
|
1994-05-29 08:49:51 +04:00
|
|
|
#include <amiga/dev/scireg.h>
|
|
|
|
#include <amiga/dev/scivar.h>
|
1994-12-28 12:24:55 +03:00
|
|
|
#include <amiga/dev/zbusvar.h>
|
1994-05-29 08:49:51 +04:00
|
|
|
|
|
|
|
int ivscprint __P((void *auxp, char *));
|
|
|
|
void ivscattach __P((struct device *, struct device *, void *));
|
|
|
|
int ivscmatch __P((struct device *, struct cfdata *, void *));
|
|
|
|
|
1995-02-12 22:18:33 +03:00
|
|
|
int ivsc_intr __P((struct sci_softc *));
|
1994-05-29 08:49:51 +04:00
|
|
|
#ifdef notyet
|
|
|
|
int ivsc_dma_xfer_in __P((struct sci_softc *dev, int len,
|
|
|
|
register u_char *buf, int phase));
|
|
|
|
int ivsc_dma_xfer_out __P((struct sci_softc *dev, int len,
|
|
|
|
register u_char *buf, int phase));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct scsi_adapter ivsc_scsiswitch = {
|
|
|
|
sci_scsicmd,
|
|
|
|
sci_minphys,
|
|
|
|
0, /* no lun support */
|
|
|
|
0, /* no lun support */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct scsi_device ivsc_scsidev = {
|
|
|
|
NULL, /* use default error handler */
|
|
|
|
NULL, /* do not have a start functio */
|
|
|
|
NULL, /* have no async handler */
|
|
|
|
NULL, /* Use default done routine */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define QPRINTF
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
extern int sci_debug;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern int sci_data_wait;
|
|
|
|
|
|
|
|
struct cfdriver ivsccd = {
|
1994-12-01 20:24:23 +03:00
|
|
|
NULL, "ivsc", (cfmatch_t)ivscmatch, ivscattach,
|
1994-05-29 08:49:51 +04:00
|
|
|
DV_DULL, sizeof(struct sci_softc), NULL, 0 };
|
1994-05-08 09:52:54 +04:00
|
|
|
|
|
|
|
/*
|
1994-05-29 08:49:51 +04:00
|
|
|
* if this is an IVS board
|
1994-05-08 09:52:54 +04:00
|
|
|
*/
|
1994-05-29 08:49:51 +04:00
|
|
|
int
|
|
|
|
ivscmatch(pdp, cdp, auxp)
|
|
|
|
struct device *pdp;
|
|
|
|
struct cfdata *cdp;
|
|
|
|
void *auxp;
|
|
|
|
{
|
1994-12-28 12:24:55 +03:00
|
|
|
struct zbus_args *zap;
|
1994-05-08 09:52:54 +04:00
|
|
|
|
1994-05-29 08:49:51 +04:00
|
|
|
zap = auxp;
|
1994-05-08 09:52:54 +04:00
|
|
|
|
1994-05-29 08:49:51 +04:00
|
|
|
/*
|
|
|
|
* Check manufacturer and product id.
|
|
|
|
*/
|
|
|
|
if (zap->manid != 2112 || /* If manufacturer is IVS */
|
|
|
|
(zap->prodid != 52 && /* product = Trumpcard */
|
|
|
|
zap->prodid != 243)) /* product = Vector SCSI */
|
|
|
|
return(0); /* didn't match */
|
1995-02-12 22:18:33 +03:00
|
|
|
#if 0 /* shouldn't need this any more */
|
1994-05-29 08:49:51 +04:00
|
|
|
if (zap->prodid == 243) {
|
|
|
|
/*
|
|
|
|
* XXXX Ouch! board addresss isn't Zorro II or Zorro III!
|
|
|
|
* XXXX Kludge it up until I can do it better (MLH).
|
|
|
|
*
|
|
|
|
* XXXX pa 0x00f00000 shouldn't be used for anything
|
|
|
|
*/
|
1995-04-10 17:08:28 +04:00
|
|
|
if (pmap_extract(pmap_kernel(), (vm_offset_t) ztwomap(0x00f00000))
|
1994-10-06 23:34:25 +03:00
|
|
|
== 0x00f00000) {
|
1994-05-29 08:49:51 +04:00
|
|
|
physaccess(ztwomap(0x00f00000),zap->pa,
|
|
|
|
NBPG, PG_W|PG_CI);
|
1994-10-06 23:34:25 +03:00
|
|
|
zap->va = (void *) ztwomap(0x00f00000) +
|
|
|
|
((int)zap->pa & PGOFSET);
|
1994-05-29 08:49:51 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("IVS Vector: mapped to %x kva %x\n",
|
|
|
|
ztwomap(0x00f00000), zap->va);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("Unable to map IVS Vector SCSI\n");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
1995-02-12 22:18:33 +03:00
|
|
|
#endif
|
1994-05-29 08:49:51 +04:00
|
|
|
return(1);
|
|
|
|
}
|
1994-05-08 09:52:54 +04:00
|
|
|
|
|
|
|
void
|
1994-05-29 08:49:51 +04:00
|
|
|
ivscattach(pdp, dp, auxp)
|
|
|
|
struct device *pdp, *dp;
|
|
|
|
void *auxp;
|
|
|
|
{
|
|
|
|
volatile u_char *rp;
|
|
|
|
struct sci_softc *sc;
|
1994-12-28 12:24:55 +03:00
|
|
|
struct zbus_args *zap;
|
1994-05-29 08:49:51 +04:00
|
|
|
|
1994-06-13 12:12:30 +04:00
|
|
|
printf("\n");
|
|
|
|
|
1994-05-29 08:49:51 +04:00
|
|
|
zap = auxp;
|
|
|
|
|
|
|
|
sc = (struct sci_softc *)dp;
|
|
|
|
rp = zap->va + 0x40;
|
|
|
|
sc->sci_data = rp;
|
|
|
|
sc->sci_odata = rp;
|
|
|
|
sc->sci_icmd = rp + 2;
|
|
|
|
sc->sci_mode = rp + 4;
|
|
|
|
sc->sci_tcmd = rp + 6;
|
|
|
|
sc->sci_bus_csr = rp + 8;
|
|
|
|
sc->sci_sel_enb = rp + 8;
|
|
|
|
sc->sci_csr = rp + 10;
|
|
|
|
sc->sci_dma_send = rp + 10;
|
|
|
|
sc->sci_idata = rp + 12;
|
|
|
|
sc->sci_trecv = rp + 12;
|
|
|
|
sc->sci_iack = rp + 14;
|
|
|
|
sc->sci_irecv = rp + 14;
|
|
|
|
|
|
|
|
#ifdef notyet
|
|
|
|
sc->dma_xfer_in = ivsc_dma_xfer_in;
|
|
|
|
sc->dma_xfer_out = ivsc_dma_xfer_out;
|
|
|
|
#endif
|
|
|
|
|
1995-02-12 22:18:33 +03:00
|
|
|
sc->sc_isr.isr_intr = ivsc_intr;
|
|
|
|
sc->sc_isr.isr_arg = sc;
|
|
|
|
sc->sc_isr.isr_ipl = 2;
|
|
|
|
add_isr(&sc->sc_isr);
|
|
|
|
|
1994-05-29 08:49:51 +04:00
|
|
|
scireset(sc);
|
|
|
|
|
|
|
|
sc->sc_link.adapter_softc = sc;
|
1995-01-05 10:22:31 +03:00
|
|
|
sc->sc_link.adapter_target = 7;
|
1994-05-29 08:49:51 +04:00
|
|
|
sc->sc_link.adapter = &ivsc_scsiswitch;
|
|
|
|
sc->sc_link.device = &ivsc_scsidev;
|
1995-01-05 10:22:31 +03:00
|
|
|
sc->sc_link.openings = 1;
|
1994-05-29 08:49:51 +04:00
|
|
|
TAILQ_INIT(&sc->sc_xslist);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* attach all scsi units on us
|
|
|
|
*/
|
|
|
|
config_found(dp, &sc->sc_link, ivscprint);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* print diag if pnp is NULL else just extra
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
ivscprint(auxp, pnp)
|
|
|
|
void *auxp;
|
|
|
|
char *pnp;
|
|
|
|
{
|
|
|
|
if (pnp == NULL)
|
|
|
|
return(UNCONF);
|
|
|
|
return(QUIET);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef notyet
|
|
|
|
int
|
|
|
|
ivsc_dma_xfer_in (dev, len, buf, phase)
|
|
|
|
struct sci_softc *dev;
|
|
|
|
int len;
|
|
|
|
register u_char *buf;
|
|
|
|
int phase;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ivsc_dma_xfer_out (dev, len, buf, phase)
|
|
|
|
struct sci_softc *dev;
|
|
|
|
int len;
|
|
|
|
register u_char *buf;
|
|
|
|
int phase;
|
1994-05-08 09:52:54 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
1994-05-29 08:49:51 +04:00
|
|
|
|
|
|
|
int
|
1995-02-12 22:18:33 +03:00
|
|
|
ivsc_intr(dev)
|
1994-05-29 08:49:51 +04:00
|
|
|
struct sci_softc *dev;
|
1995-02-12 22:18:33 +03:00
|
|
|
{
|
1994-05-29 08:49:51 +04:00
|
|
|
u_char stat;
|
|
|
|
|
1995-02-12 22:18:33 +03:00
|
|
|
if ((*dev->sci_csr & SCI_CSR_INT) == 0)
|
|
|
|
return(0);
|
|
|
|
stat = *dev->sci_iack;
|
1994-05-29 08:49:51 +04:00
|
|
|
}
|