2012-10-27 21:17:22 +04:00
|
|
|
/* $NetBSD: cbiiisc.c,v 1.21 2012/10/27 17:17:28 chs Exp $ */
|
1999-03-08 01:16:19 +03: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.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. 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.
|
|
|
|
*
|
|
|
|
* @(#)dma.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1994,1998 Michael L. Hitch
|
|
|
|
*
|
|
|
|
* 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.
|
1999-03-08 01:16:19 +03:00
|
|
|
*
|
2004-03-28 22:59:39 +04:00
|
|
|
* 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.
|
1999-03-08 01:16:19 +03:00
|
|
|
*
|
|
|
|
* @(#)dma.c
|
|
|
|
*/
|
|
|
|
|
2002-01-28 12:56:43 +03:00
|
|
|
#include <sys/cdefs.h>
|
2012-10-27 21:17:22 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: cbiiisc.c,v 1.21 2012/10/27 17:17:28 chs Exp $");
|
2002-01-28 12:56:43 +03:00
|
|
|
|
1999-03-08 01:16:19 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
2010-12-20 03:25:23 +03:00
|
|
|
#include <sys/cpu.h>
|
2003-04-09 05:54:42 +04:00
|
|
|
|
1999-03-08 01:16:19 +03:00
|
|
|
#include <dev/scsipi/scsi_all.h>
|
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
|
|
|
#include <amiga/amiga/custom.h>
|
|
|
|
#include <amiga/amiga/cc.h>
|
|
|
|
#include <amiga/amiga/device.h>
|
|
|
|
#include <amiga/amiga/isr.h>
|
|
|
|
|
|
|
|
#define ARCH_720 /* This is for a 53c770 */
|
|
|
|
|
|
|
|
#include <amiga/dev/siopreg.h>
|
|
|
|
#include <amiga/dev/siopvar.h>
|
|
|
|
#include <amiga/dev/zbusvar.h>
|
2012-01-11 00:29:49 +04:00
|
|
|
#include <amiga/dev/p5busvar.h>
|
1999-03-08 01:16:19 +03:00
|
|
|
|
2012-10-27 21:17:22 +04:00
|
|
|
void cbiiiscattach(device_t, device_t, void *);
|
|
|
|
int cbiiiscmatch(device_t, cfdata_t, void *);
|
2002-01-26 16:40:52 +03:00
|
|
|
int cbiiisc_dmaintr(void *);
|
1999-03-08 01:16:19 +03:00
|
|
|
#ifdef DEBUG
|
2002-01-26 16:40:52 +03:00
|
|
|
void cbiiisc_dump(void);
|
1999-03-08 01:16:19 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#endif
|
|
|
|
|
2012-10-27 21:17:22 +04:00
|
|
|
CFATTACH_DECL_NEW(cbiiisc, sizeof(struct siop_softc),
|
2002-10-02 08:55:47 +04:00
|
|
|
cbiiiscmatch, cbiiiscattach, NULL, NULL);
|
1999-03-08 01:16:19 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* if we are a CyberStorm MK III SCSI
|
|
|
|
*/
|
|
|
|
int
|
2012-10-27 21:17:22 +04:00
|
|
|
cbiiiscmatch(device_t parent, cfdata_t cf, void *aux)
|
1999-03-08 01:16:19 +03:00
|
|
|
{
|
2012-01-11 00:29:49 +04:00
|
|
|
struct p5bus_attach_args *p5baa;
|
1999-03-08 01:16:19 +03:00
|
|
|
|
2012-10-27 21:17:22 +04:00
|
|
|
p5baa = aux;
|
2012-01-11 00:29:49 +04:00
|
|
|
|
|
|
|
if (strcmp(p5baa->p5baa_name, "cbiiisc") == 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
1999-03-08 01:16:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-10-27 21:17:22 +04:00
|
|
|
cbiiiscattach(device_t parent, device_t self, void *aux)
|
1999-03-08 01:16:19 +03:00
|
|
|
{
|
2012-10-27 21:17:22 +04:00
|
|
|
struct siop_softc *sc = device_private(self);
|
1999-03-08 01:16:19 +03:00
|
|
|
siop_regmap_p rp;
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipi_adapter *adapt = &sc->sc_adapter;
|
|
|
|
struct scsipi_channel *chan = &sc->sc_channel;
|
1999-03-08 01:16:19 +03:00
|
|
|
|
2012-01-11 00:29:49 +04:00
|
|
|
aprint_normal(": CyberStorm PPC/Mk-III SCSI host adapter\n");
|
1999-03-08 01:16:19 +03:00
|
|
|
|
2012-10-27 21:17:22 +04:00
|
|
|
sc->sc_dev = self;
|
1999-03-08 01:16:19 +03:00
|
|
|
sc->sc_siopp = rp = ztwomap(0xf40000);
|
1999-06-06 23:58:31 +04:00
|
|
|
/* siopng_dump_registers(sc); */
|
1999-03-08 01:16:19 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* CTEST7 = 00
|
|
|
|
*/
|
2006-03-09 02:46:22 +03:00
|
|
|
sc->sc_clock_freq = 50; /* Clock = 50 MHz >> */
|
1999-03-08 01:16:19 +03:00
|
|
|
sc->sc_ctest7 = 0x00;
|
|
|
|
sc->sc_dcntl = 0x20; /* XXX ?? */
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
/*
|
|
|
|
* Fill in the scsipi_adapter.
|
|
|
|
*/
|
|
|
|
memset(adapt, 0, sizeof(*adapt));
|
2012-10-27 21:17:22 +04:00
|
|
|
adapt->adapt_dev = self;
|
2001-04-25 21:53:04 +04:00
|
|
|
adapt->adapt_nchannels = 1;
|
|
|
|
adapt->adapt_openings = 7;
|
|
|
|
adapt->adapt_max_periph = 1;
|
|
|
|
adapt->adapt_request = siopng_scsipi_request;
|
|
|
|
adapt->adapt_minphys = siopng_minphys;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in the scsipi_channel.
|
|
|
|
*/
|
|
|
|
memset(chan, 0, sizeof(*chan));
|
|
|
|
chan->chan_adapter = adapt;
|
|
|
|
chan->chan_bustype = &scsi_bustype;
|
|
|
|
chan->chan_channel = 0;
|
|
|
|
chan->chan_ntargets = 16;
|
|
|
|
chan->chan_nluns = 8;
|
|
|
|
chan->chan_id = 7;
|
1999-03-08 01:16:19 +03:00
|
|
|
|
|
|
|
siopnginitialize(sc);
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
if (sc->sc_channel.chan_ntargets < 0)
|
1999-06-08 01:30:57 +04:00
|
|
|
return;
|
|
|
|
|
1999-03-08 01:16:19 +03:00
|
|
|
sc->sc_isr.isr_intr = cbiiisc_dmaintr;
|
|
|
|
sc->sc_isr.isr_arg = sc;
|
|
|
|
sc->sc_isr.isr_ipl = 2; /* ?? */
|
|
|
|
add_isr(&sc->sc_isr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* attach all scsi units on us
|
|
|
|
*/
|
2012-10-27 21:17:22 +04:00
|
|
|
config_found(self, chan, scsiprint);
|
1999-03-08 01:16:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2002-01-26 16:40:52 +03:00
|
|
|
cbiiisc_dmaintr(void *arg)
|
1999-03-08 01:16:19 +03:00
|
|
|
{
|
|
|
|
struct siop_softc *sc = arg;
|
|
|
|
siop_regmap_p rp;
|
|
|
|
int istat;
|
|
|
|
|
|
|
|
if (sc->sc_flags & SIOP_INTSOFF)
|
|
|
|
return (0); /* interrupts are not active */
|
|
|
|
rp = sc->sc_siopp;
|
2010-02-05 15:13:36 +03:00
|
|
|
amiga_membarrier();
|
1999-03-08 01:16:19 +03:00
|
|
|
istat = rp->siop_istat;
|
|
|
|
if ((istat & (SIOP_ISTAT_SIP | SIOP_ISTAT_DIP)) == 0)
|
|
|
|
return(0);
|
|
|
|
/*
|
|
|
|
* save interrupt status, DMA status, and SCSI status 0
|
|
|
|
* (may need to deal with stacked interrupts?)
|
|
|
|
*/
|
|
|
|
sc->sc_sist = rp->siop_sist;
|
|
|
|
sc->sc_istat = istat;
|
|
|
|
sc->sc_dstat = rp->siop_dstat;
|
2010-02-05 15:13:36 +03:00
|
|
|
amiga_membarrier();
|
1999-03-08 01:16:19 +03:00
|
|
|
siopngintr(sc);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
2002-01-26 16:40:52 +03:00
|
|
|
cbiiisc_dump(void)
|
1999-03-08 01:16:19 +03:00
|
|
|
{
|
|
|
|
extern struct cfdriver cbiiisc_cd;
|
2008-06-13 12:13:37 +04:00
|
|
|
struct siop_softc *sc;
|
1999-03-08 01:16:19 +03:00
|
|
|
int i;
|
|
|
|
|
2008-06-13 12:13:37 +04:00
|
|
|
for (i = 0; i < cbiiisc_cd.cd_ndevs; ++i) {
|
|
|
|
sc = device_lookup_private(&cbiiisc_cd, i);
|
|
|
|
if (sc != NULL)
|
|
|
|
siopng_dump(sc);
|
|
|
|
}
|
1999-03-08 01:16:19 +03:00
|
|
|
}
|
|
|
|
#endif
|