2000-03-06 06:08:32 +03:00
|
|
|
/* $NetBSD: asc_tc.c,v 1.14 2000/03/06 03:08:32 mhitch Exp $ */
|
1996-09-26 01:07:46 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1996 The Board of Trustees of The Leland Stanford
|
|
|
|
* Junior University. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose and without
|
|
|
|
* fee is hereby granted, provided that the above copyright
|
|
|
|
* notice appear in all copies. Stanford University
|
|
|
|
* makes no representations about the suitability of this
|
|
|
|
* software for any purpose. It is provided "as is" without
|
|
|
|
* express or implied warranty.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/device.h>
|
1999-04-20 10:48:58 +04:00
|
|
|
|
1996-09-26 01:07:46 +04:00
|
|
|
#include <dev/tc/tcvar.h>
|
|
|
|
#include <dev/tc/ioasicvar.h>
|
|
|
|
|
|
|
|
#include <pmax/dev/device.h> /* XXX */
|
|
|
|
#include <pmax/dev/scsi.h> /* XXX */
|
|
|
|
|
|
|
|
#include <pmax/dev/ascreg.h> /* XXX */
|
|
|
|
#include <dev/tc/ascvar.h>
|
|
|
|
|
|
|
|
/*XXX*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Autoconfiguration data for config.
|
|
|
|
*/
|
1997-07-21 09:39:02 +04:00
|
|
|
int asc_tc_match __P((struct device *, struct cfdata *, void *));
|
1996-09-26 01:07:46 +04:00
|
|
|
void asc_tc_attach __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
struct cfattach asc_tc_ca = {
|
|
|
|
sizeof(struct asc_softc), asc_tc_match, asc_tc_attach
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DMA callbacks
|
|
|
|
*/
|
|
|
|
|
1997-07-28 23:39:22 +04:00
|
|
|
static int
|
1996-09-26 01:07:46 +04:00
|
|
|
tc_dma_start __P((struct asc_softc *asc, struct scsi_state *state,
|
1997-07-28 23:39:22 +04:00
|
|
|
caddr_t cp, int flag, int len, int off));
|
1996-09-26 01:07:46 +04:00
|
|
|
|
|
|
|
static void
|
|
|
|
tc_dma_end __P((struct asc_softc *asc, struct scsi_state *state,
|
|
|
|
int flag));
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
asc_tc_match(parent, match, aux)
|
|
|
|
struct device *parent;
|
1997-07-21 09:39:02 +04:00
|
|
|
struct cfdata *match;
|
1996-09-26 01:07:46 +04:00
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct tc_attach_args *t = aux;
|
|
|
|
|
|
|
|
if (strncmp(t->ta_modname, "PMAZ-AA ", TC_ROM_LLEN))
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
asc_tc_attach(parent, self, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct device *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
register struct tc_attach_args *t = aux;
|
|
|
|
register asc_softc_t asc = (asc_softc_t) self;
|
1997-07-28 23:39:22 +04:00
|
|
|
u_char *buff;
|
|
|
|
int i, speed;
|
1996-09-26 01:07:46 +04:00
|
|
|
int unit;
|
|
|
|
|
|
|
|
unit = asc->sc_dev.dv_unit;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize hw descriptor, cache some pointers
|
|
|
|
*/
|
2000-02-11 04:32:42 +03:00
|
|
|
asc->regs = (asc_regmap_t *)(t->ta_addr + ASC_OFFSET_53C94);
|
1996-09-26 01:07:46 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up machine dependencies.
|
|
|
|
* (1) how to do dma
|
|
|
|
* (2) timing based on turbochannel frequency
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fall through for turbochannel option.
|
|
|
|
*/
|
2000-02-11 04:32:42 +03:00
|
|
|
asc->dmar = (volatile int *)(t->ta_addr + ASC_OFFSET_DMAR);
|
|
|
|
buff = (u_char *)(t->ta_addr + ASC_OFFSET_RAM);
|
1997-07-28 23:39:22 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Statically partition the DMA buffer between targets.
|
|
|
|
* This way we will eventually be able to attach/detach
|
|
|
|
* drives on-fly. And 18k/target is plenty for normal use.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Give each target its own DMA buffer region.
|
|
|
|
* We may want to try ping ponging buffers later.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < ASC_NCMD; i++)
|
|
|
|
asc->st[i].dmaBufAddr = buff + PER_TGT_DMA_SIZE * i;
|
|
|
|
|
1996-09-26 01:07:46 +04:00
|
|
|
asc->dma_start = tc_dma_start;
|
|
|
|
asc->dma_end = tc_dma_end;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now for timing. The 3max has a 25Mhz tb whereas the 3min and
|
|
|
|
* maxine are 12.5Mhz.
|
|
|
|
*/
|
1997-10-31 09:29:59 +03:00
|
|
|
printf(" (bus speed: %s MHz) ", t->ta_busspeed? "25" : "12.5");
|
1996-09-26 01:07:46 +04:00
|
|
|
|
|
|
|
switch (t->ta_busspeed) {
|
|
|
|
case TC_SPEED_25_MHZ:
|
|
|
|
speed = ASC_SPEED_25_MHZ;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1996-10-13 05:37:04 +04:00
|
|
|
printf(" (unknown TC speed, assuming 12.5MHz) ");
|
1996-09-26 01:07:46 +04:00
|
|
|
/* FALLTHROUGH*/
|
|
|
|
case TC_SPEED_12_5_MHZ:
|
|
|
|
speed = ASC_SPEED_12_5_MHZ;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
1997-07-28 23:39:22 +04:00
|
|
|
ascattach(asc, speed);
|
1996-09-26 01:07:46 +04:00
|
|
|
|
|
|
|
/* tie pseudo-slot to device */
|
|
|
|
tc_intr_establish(parent, t->ta_cookie, TC_IPL_BIO,
|
|
|
|
asc_intr, asc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DMA handling routines. For a turbochannel device, just set the dmar.
|
|
|
|
* For the I/O ASIC, handle the actual DMA interface.
|
|
|
|
*/
|
1997-07-28 23:39:22 +04:00
|
|
|
static int
|
|
|
|
tc_dma_start(asc, state, cp, flag, len, off)
|
1996-09-26 01:07:46 +04:00
|
|
|
asc_softc_t asc;
|
|
|
|
State *state;
|
|
|
|
caddr_t cp;
|
|
|
|
int flag;
|
1997-07-28 23:39:22 +04:00
|
|
|
int len;
|
|
|
|
int off;
|
1996-09-26 01:07:46 +04:00
|
|
|
{
|
|
|
|
|
1997-07-28 23:39:22 +04:00
|
|
|
if (len > PER_TGT_DMA_SIZE)
|
|
|
|
len = PER_TGT_DMA_SIZE;
|
1996-09-26 01:07:46 +04:00
|
|
|
if (flag == ASCDMA_WRITE)
|
1997-07-28 23:39:22 +04:00
|
|
|
bcopy(cp, state->dmaBufAddr + off, len);
|
|
|
|
if (flag == ASCDMA_WRITE)
|
|
|
|
*asc->dmar = ASC_DMAR_WRITE | ASC_DMA_ADDR(state->dmaBufAddr + off);
|
1996-09-26 01:07:46 +04:00
|
|
|
else
|
1997-07-28 23:39:22 +04:00
|
|
|
*asc->dmar = ASC_DMA_ADDR(state->dmaBufAddr + off);
|
|
|
|
return (len);
|
1996-09-26 01:07:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tc_dma_end(asc, state, flag)
|
|
|
|
asc_softc_t asc;
|
|
|
|
State *state;
|
|
|
|
int flag;
|
|
|
|
{
|
1997-07-28 23:39:22 +04:00
|
|
|
if (flag == ASCDMA_READ)
|
|
|
|
bcopy(state->dmaBufAddr, state->buf, state->dmalen);
|
1996-09-26 01:07:46 +04:00
|
|
|
}
|