2005-02-27 03:26:58 +03:00
|
|
|
/* $NetBSD: tcds.c,v 1.14 2005/02/27 00:27:49 perry Exp $ */
|
1998-05-25 03:41:42 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
1995-02-14 02:06:39 +03:00
|
|
|
|
|
|
|
/*
|
1996-04-12 10:07:05 +04:00
|
|
|
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
|
1995-02-14 02:06:39 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Keith Bostic, Chris G. Demetriou
|
2005-02-27 03:26:58 +03:00
|
|
|
*
|
1995-02-14 02:06:39 +03:00
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
2005-02-27 03:26:58 +03:00
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
1995-02-14 02:06:39 +03:00
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
2005-02-27 03:26:58 +03:00
|
|
|
*
|
1995-02-14 02:06:39 +03:00
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 09:26:09 +03:00
|
|
|
#include <sys/cdefs.h>
|
2005-02-27 03:26:58 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: tcds.c,v 1.14 2005/02/27 00:27:49 perry Exp $");
|
1997-04-07 02:31:45 +04:00
|
|
|
|
1995-02-14 02:06:39 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
2000-06-06 01:47:26 +04:00
|
|
|
#include <sys/malloc.h>
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-27 03:43:05 +04:00
|
|
|
#ifdef __alpha__
|
1995-02-14 02:06:39 +03:00
|
|
|
#include <machine/rpb.h>
|
1998-05-27 03:43:05 +04:00
|
|
|
#endif /* __alpha__ */
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
#include <dev/scsipi/scsi_all.h>
|
2000-07-04 06:22:08 +04:00
|
|
|
#include <dev/scsipi/scsipi_all.h>
|
|
|
|
#include <dev/scsipi/scsiconf.h>
|
1998-05-25 03:41:42 +04:00
|
|
|
|
|
|
|
#include <dev/ic/ncr53c9xvar.h>
|
|
|
|
|
2000-07-04 06:22:08 +04:00
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
#include <dev/tc/tcvar.h>
|
|
|
|
#include <dev/tc/tcdsreg.h>
|
|
|
|
#include <dev/tc/tcdsvar.h>
|
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
#include "locators.h"
|
|
|
|
|
1995-02-14 02:06:39 +03:00
|
|
|
struct tcds_softc {
|
|
|
|
struct device sc_dv;
|
1998-05-25 03:41:42 +04:00
|
|
|
bus_space_tag_t sc_bst;
|
|
|
|
bus_space_handle_t sc_bsh;
|
1998-05-27 03:43:05 +04:00
|
|
|
bus_dma_tag_t sc_dmat;
|
1995-12-20 03:40:21 +03:00
|
|
|
void *sc_cookie;
|
1998-05-25 03:41:42 +04:00
|
|
|
int sc_flags;
|
1995-12-20 03:40:21 +03:00
|
|
|
struct tcds_slotconfig sc_slots[2];
|
1995-02-14 02:06:39 +03:00
|
|
|
};
|
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
/* sc_flags */
|
|
|
|
#define TCDSF_BASEBOARD 0x01 /* baseboard on DEC 3000 */
|
1998-05-27 03:43:05 +04:00
|
|
|
#define TCDSF_FASTSCSI 0x02 /* supports Fast SCSI */
|
1998-05-25 03:41:42 +04:00
|
|
|
|
1995-02-14 02:06:39 +03:00
|
|
|
/* Definition of the driver for autoconfig. */
|
2005-02-04 05:10:35 +03:00
|
|
|
int tcdsmatch(struct device *, struct cfdata *, void *);
|
|
|
|
void tcdsattach(struct device *, struct device *, void *);
|
|
|
|
int tcdsprint(void *, const char *);
|
|
|
|
int tcdssubmatch(struct device *, struct cfdata *,
|
|
|
|
const locdesc_t *, void *);
|
1996-03-17 04:03:02 +03:00
|
|
|
|
2002-10-01 05:05:50 +04:00
|
|
|
CFATTACH_DECL(tcds, sizeof(struct tcds_softc),
|
2002-10-02 20:51:16 +04:00
|
|
|
tcdsmatch, tcdsattach, NULL, NULL);
|
1996-03-17 04:03:02 +03:00
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
/*static*/ int tcds_intr(void *);
|
|
|
|
/*static*/ int tcds_intrnull(void *);
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
struct tcds_device {
|
|
|
|
const char *td_name;
|
|
|
|
int td_flags;
|
|
|
|
} tcds_devices[] = {
|
1998-05-27 03:43:05 +04:00
|
|
|
#ifdef __alpha__
|
1998-05-25 03:41:42 +04:00
|
|
|
{ "PMAZ-DS ", TCDSF_BASEBOARD },
|
|
|
|
{ "PMAZ-FS ", TCDSF_BASEBOARD|TCDSF_FASTSCSI },
|
1998-05-27 03:43:05 +04:00
|
|
|
#endif /* __alpha__ */
|
1998-05-25 03:41:42 +04:00
|
|
|
{ "PMAZB-AA", 0 },
|
|
|
|
{ "PMAZC-AA", TCDSF_FASTSCSI },
|
|
|
|
{ NULL, 0 },
|
|
|
|
};
|
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
struct tcds_device *tcds_lookup(const char *);
|
|
|
|
void tcds_params(struct tcds_softc *, int, int *, int *);
|
1998-05-25 03:41:42 +04:00
|
|
|
|
|
|
|
struct tcds_device *
|
|
|
|
tcds_lookup(modname)
|
|
|
|
const char *modname;
|
|
|
|
{
|
|
|
|
struct tcds_device *td;
|
|
|
|
|
|
|
|
for (td = tcds_devices; td->td_name != NULL; td++)
|
|
|
|
if (strncmp(td->td_name, modname, TC_ROM_LLEN) == 0)
|
|
|
|
return (td);
|
|
|
|
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
1995-02-14 02:06:39 +03:00
|
|
|
int
|
1995-12-20 03:40:21 +03:00
|
|
|
tcdsmatch(parent, cfdata, aux)
|
1995-02-14 02:06:39 +03:00
|
|
|
struct device *parent;
|
1996-12-05 04:39:27 +03:00
|
|
|
struct cfdata *cfdata;
|
1995-12-20 03:40:21 +03:00
|
|
|
void *aux;
|
1995-02-14 02:06:39 +03:00
|
|
|
{
|
1996-04-12 05:31:43 +04:00
|
|
|
struct tc_attach_args *ta = aux;
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
return (tcds_lookup(ta->ta_modname) != NULL);
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tcdsattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct tcds_softc *sc = (struct tcds_softc *)self;
|
1996-04-12 05:31:43 +04:00
|
|
|
struct tc_attach_args *ta = aux;
|
1995-12-20 03:40:21 +03:00
|
|
|
struct tcdsdev_attach_args tcdsdev;
|
|
|
|
struct tcds_slotconfig *slotc;
|
1998-05-25 03:41:42 +04:00
|
|
|
struct tcds_device *td;
|
|
|
|
bus_space_handle_t sbsh[2];
|
2000-07-04 06:22:08 +04:00
|
|
|
int i, gpi2;
|
2000-06-06 01:47:26 +04:00
|
|
|
const struct evcnt *pevcnt;
|
2004-09-13 16:55:47 +04:00
|
|
|
int help[2];
|
|
|
|
locdesc_t *ldesc = (void *)help; /* XXX */
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
td = tcds_lookup(ta->ta_modname);
|
|
|
|
if (td == NULL)
|
|
|
|
panic("\ntcdsattach: impossible");
|
|
|
|
|
|
|
|
printf(": TurboChannel Dual SCSI");
|
|
|
|
if (td->td_flags & TCDSF_BASEBOARD)
|
1998-05-27 03:43:05 +04:00
|
|
|
printf(" (baseboard)");
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("\n");
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
sc->sc_flags = td->td_flags;
|
|
|
|
|
1998-05-27 03:43:05 +04:00
|
|
|
sc->sc_bst = ta->ta_memt;
|
|
|
|
sc->sc_dmat = ta->ta_dmat;
|
1998-05-25 05:14:38 +04:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
/*
|
|
|
|
* Map the device.
|
|
|
|
*/
|
|
|
|
if (bus_space_map(sc->sc_bst, ta->ta_addr,
|
|
|
|
(TCDS_SCSI1_OFFSET + 0x100), 0, &sc->sc_bsh)) {
|
|
|
|
printf("%s: unable to map device\n", sc->sc_dv.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now, slice off two subregions for the individual NCR SCSI chips.
|
|
|
|
*/
|
|
|
|
if (bus_space_subregion(sc->sc_bst, sc->sc_bsh, TCDS_SCSI0_OFFSET,
|
|
|
|
0x100, &sbsh[0]) ||
|
|
|
|
bus_space_subregion(sc->sc_bst, sc->sc_bsh, TCDS_SCSI1_OFFSET,
|
|
|
|
0x100, &sbsh[1])) {
|
|
|
|
printf("%s: unable to subregion SCSI chip space\n",
|
|
|
|
sc->sc_dv.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
sc->sc_cookie = ta->ta_cookie;
|
1995-02-14 02:06:39 +03:00
|
|
|
|
2000-06-06 01:47:26 +04:00
|
|
|
pevcnt = tc_intr_evcnt(parent, sc->sc_cookie);
|
1995-12-20 03:40:21 +03:00
|
|
|
tc_intr_establish(parent, sc->sc_cookie, TC_IPL_BIO, tcds_intr, sc);
|
1995-02-14 02:06:39 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* IMER apparently has some random (or, not so random, but still
|
|
|
|
* not useful) bits set in it when the system boots. Clear it.
|
|
|
|
*/
|
1998-05-25 03:41:42 +04:00
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_IMER, 0);
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
/* XXX Initial contents of CIR? */
|
|
|
|
|
1998-05-27 03:43:05 +04:00
|
|
|
/*
|
|
|
|
* Remember if GPI2 is set in the CIR; we'll need it later.
|
|
|
|
*/
|
|
|
|
gpi2 = (bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR) &
|
|
|
|
TCDS_CIR_GPI_2) != 0;
|
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
/*
|
2002-09-30 03:23:56 +04:00
|
|
|
* Set up the per-slot definitions for later use.
|
1995-12-20 03:40:21 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* fill in common information first */
|
|
|
|
for (i = 0; i < 2; i++) {
|
2001-08-22 09:00:27 +04:00
|
|
|
char *cp;
|
1995-12-20 03:40:21 +03:00
|
|
|
|
2001-08-22 09:00:27 +04:00
|
|
|
slotc = &sc->sc_slots[i];
|
1995-12-20 03:40:21 +03:00
|
|
|
bzero(slotc, sizeof *slotc); /* clear everything */
|
|
|
|
|
2001-08-22 09:00:27 +04:00
|
|
|
cp = slotc->sc_name;
|
|
|
|
snprintf(cp, sizeof(slotc->sc_name), "chip %d", i);
|
2000-06-06 01:47:26 +04:00
|
|
|
evcnt_attach_dynamic(&slotc->sc_evcnt, EVCNT_TYPE_INTR,
|
|
|
|
pevcnt, sc->sc_dv.dv_xname, cp);
|
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
slotc->sc_slot = i;
|
1998-05-25 03:41:42 +04:00
|
|
|
slotc->sc_bst = sc->sc_bst;
|
|
|
|
slotc->sc_bsh = sc->sc_bsh;
|
1995-12-20 03:40:21 +03:00
|
|
|
slotc->sc_intrhand = tcds_intrnull;
|
|
|
|
slotc->sc_intrarg = (void *)(long)i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* information for slot 0 */
|
|
|
|
slotc = &sc->sc_slots[0];
|
|
|
|
slotc->sc_resetbits = TCDS_CIR_SCSI0_RESET;
|
|
|
|
slotc->sc_intrmaskbits =
|
|
|
|
TCDS_IMER_SCSI0_MASK | TCDS_IMER_SCSI0_ENB;
|
|
|
|
slotc->sc_intrbits = TCDS_CIR_SCSI0_INT;
|
|
|
|
slotc->sc_dmabits = TCDS_CIR_SCSI0_DMAENA;
|
|
|
|
slotc->sc_errorbits = 0; /* XXX */
|
1998-05-25 03:41:42 +04:00
|
|
|
slotc->sc_sda = TCDS_SCSI0_DMA_ADDR;
|
|
|
|
slotc->sc_dic = TCDS_SCSI0_DMA_INTR;
|
|
|
|
slotc->sc_dud0 = TCDS_SCSI0_DMA_DUD0;
|
|
|
|
slotc->sc_dud1 = TCDS_SCSI0_DMA_DUD1;
|
1995-12-20 03:40:21 +03:00
|
|
|
|
|
|
|
/* information for slot 1 */
|
|
|
|
slotc = &sc->sc_slots[1];
|
|
|
|
slotc->sc_resetbits = TCDS_CIR_SCSI1_RESET;
|
|
|
|
slotc->sc_intrmaskbits =
|
|
|
|
TCDS_IMER_SCSI1_MASK | TCDS_IMER_SCSI1_ENB;
|
|
|
|
slotc->sc_intrbits = TCDS_CIR_SCSI1_INT;
|
|
|
|
slotc->sc_dmabits = TCDS_CIR_SCSI1_DMAENA;
|
|
|
|
slotc->sc_errorbits = 0; /* XXX */
|
1998-05-25 03:41:42 +04:00
|
|
|
slotc->sc_sda = TCDS_SCSI1_DMA_ADDR;
|
|
|
|
slotc->sc_dic = TCDS_SCSI1_DMA_INTR;
|
|
|
|
slotc->sc_dud0 = TCDS_SCSI1_DMA_DUD0;
|
|
|
|
slotc->sc_dud1 = TCDS_SCSI1_DMA_DUD1;
|
1995-12-20 03:40:21 +03:00
|
|
|
|
1995-03-08 03:38:44 +03:00
|
|
|
/* find the hardware attached to the TCDS ASIC */
|
1998-05-25 03:41:42 +04:00
|
|
|
for (i = 0; i < 2; i++) {
|
1998-05-27 03:43:05 +04:00
|
|
|
tcds_params(sc, i, &tcdsdev.tcdsda_id,
|
|
|
|
&tcdsdev.tcdsda_fast);
|
1998-05-25 05:14:38 +04:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
tcdsdev.tcdsda_bst = sc->sc_bst;
|
|
|
|
tcdsdev.tcdsda_bsh = sbsh[i];
|
2000-07-04 06:22:08 +04:00
|
|
|
tcdsdev.tcdsda_dmat = sc->sc_dmat;
|
1998-05-25 03:41:42 +04:00
|
|
|
tcdsdev.tcdsda_chip = i;
|
|
|
|
tcdsdev.tcdsda_sc = &sc->sc_slots[i];
|
1998-05-27 03:43:05 +04:00
|
|
|
/*
|
1999-09-22 07:32:42 +04:00
|
|
|
* Determine the chip frequency. TCDSF_FASTSCSI will be set
|
|
|
|
* for TC option cards. For baseboard chips, GPI2 is set, for a
|
1998-05-27 03:43:05 +04:00
|
|
|
* 25MHz clock, else a 40MHz clock.
|
|
|
|
*/
|
1999-09-22 07:32:42 +04:00
|
|
|
if ((sc->sc_flags & TCDSF_BASEBOARD && gpi2 == 0) ||
|
|
|
|
sc->sc_flags & TCDSF_FASTSCSI) {
|
1998-05-27 03:43:05 +04:00
|
|
|
tcdsdev.tcdsda_freq = 40000000;
|
|
|
|
tcdsdev.tcdsda_period = tcdsdev.tcdsda_fast ? 4 : 8;
|
1999-09-22 07:32:42 +04:00
|
|
|
} else {
|
|
|
|
tcdsdev.tcdsda_freq = 25000000;
|
|
|
|
tcdsdev.tcdsda_period = 5;
|
1998-05-27 03:43:05 +04:00
|
|
|
}
|
|
|
|
if (sc->sc_flags & TCDSF_BASEBOARD)
|
1998-05-25 03:41:42 +04:00
|
|
|
tcdsdev.tcdsda_variant = NCR_VARIANT_NCR53C94;
|
1998-05-27 03:43:05 +04:00
|
|
|
else
|
|
|
|
tcdsdev.tcdsda_variant = NCR_VARIANT_NCR53C96;
|
1995-12-20 03:40:21 +03:00
|
|
|
|
|
|
|
tcds_scsi_reset(tcdsdev.tcdsda_sc);
|
|
|
|
|
2004-09-13 16:55:47 +04:00
|
|
|
ldesc->len = 1;
|
|
|
|
ldesc->locs[TCDSCF_CHIP] = i;
|
|
|
|
|
|
|
|
config_found_sm_loc(self, "tcds", ldesc, &tcdsdev,
|
|
|
|
tcdsprint, tcdssubmatch);
|
1998-05-25 03:41:42 +04:00
|
|
|
#ifdef __alpha__
|
|
|
|
/*
|
|
|
|
* The second SCSI chip isn't present on the baseboard TCDS
|
|
|
|
* on the DEC Alpha 3000/300 series.
|
|
|
|
*/
|
|
|
|
if (sc->sc_flags & TCDSF_BASEBOARD &&
|
|
|
|
cputype == ST_DEC_3000_300)
|
|
|
|
break;
|
|
|
|
#endif /* __alpha__ */
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
int
|
2004-09-13 16:55:47 +04:00
|
|
|
tcdssubmatch(parent, cf, ldesc, aux)
|
1998-05-25 03:41:42 +04:00
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
2004-09-13 16:55:47 +04:00
|
|
|
const locdesc_t *ldesc;
|
1998-05-25 03:41:42 +04:00
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (cf->cf_loc[TCDSCF_CHIP] != TCDSCF_CHIP_DEFAULT &&
|
2004-09-13 16:55:47 +04:00
|
|
|
cf->cf_loc[TCDSCF_CHIP] != ldesc->locs[TCDSCF_CHIP])
|
1998-05-25 03:41:42 +04:00
|
|
|
return (0);
|
|
|
|
|
2002-09-27 07:17:40 +04:00
|
|
|
return (config_match(parent, cf, aux));
|
1998-05-25 03:41:42 +04:00
|
|
|
}
|
|
|
|
|
1995-02-14 02:06:39 +03:00
|
|
|
int
|
|
|
|
tcdsprint(aux, pnp)
|
|
|
|
void *aux;
|
1996-08-28 01:53:46 +04:00
|
|
|
const char *pnp;
|
1995-02-14 02:06:39 +03:00
|
|
|
{
|
1998-05-25 03:41:42 +04:00
|
|
|
struct tcdsdev_attach_args *tcdsdev = aux;
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
/* Only ASCs can attach to TCDSs; easy. */
|
1995-02-14 02:06:39 +03:00
|
|
|
if (pnp)
|
2003-01-01 03:10:15 +03:00
|
|
|
aprint_normal("asc at %s", pnp);
|
1998-05-25 03:41:42 +04:00
|
|
|
|
2003-01-01 03:10:15 +03:00
|
|
|
aprint_normal(" chip %d", tcdsdev->tcdsda_chip);
|
1998-05-25 03:41:42 +04:00
|
|
|
|
1995-02-14 02:06:39 +03:00
|
|
|
return (UNCONF);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-25 03:41:42 +04:00
|
|
|
tcds_intr_establish(tcds, slot, func, arg)
|
1995-12-20 03:40:21 +03:00
|
|
|
struct device *tcds;
|
1998-05-25 03:41:42 +04:00
|
|
|
int slot;
|
2005-02-04 05:10:35 +03:00
|
|
|
int (*func)(void *);
|
1998-05-25 03:41:42 +04:00
|
|
|
void *arg;
|
1995-02-14 02:06:39 +03:00
|
|
|
{
|
1995-12-20 03:40:21 +03:00
|
|
|
struct tcds_softc *sc = (struct tcds_softc *)tcds;
|
1995-03-08 03:38:44 +03:00
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
if (sc->sc_slots[slot].sc_intrhand != tcds_intrnull)
|
1998-05-25 03:41:42 +04:00
|
|
|
panic("tcds_intr_establish: chip %d twice", slot);
|
1995-03-08 03:38:44 +03:00
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
sc->sc_slots[slot].sc_intrhand = func;
|
|
|
|
sc->sc_slots[slot].sc_intrarg = arg;
|
|
|
|
tcds_scsi_reset(&sc->sc_slots[slot]);
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-25 03:41:42 +04:00
|
|
|
tcds_intr_disestablish(tcds, slot)
|
1995-12-20 03:40:21 +03:00
|
|
|
struct device *tcds;
|
1998-05-25 03:41:42 +04:00
|
|
|
int slot;
|
1995-02-14 02:06:39 +03:00
|
|
|
{
|
1995-12-20 03:40:21 +03:00
|
|
|
struct tcds_softc *sc = (struct tcds_softc *)tcds;
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
if (sc->sc_slots[slot].sc_intrhand == tcds_intrnull)
|
1998-05-25 03:41:42 +04:00
|
|
|
panic("tcds_intr_disestablish: chip %d missing intr",
|
1995-12-20 03:40:21 +03:00
|
|
|
slot);
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
sc->sc_slots[slot].sc_intrhand = tcds_intrnull;
|
1998-05-25 03:41:42 +04:00
|
|
|
sc->sc_slots[slot].sc_intrarg = (void *)(u_long)slot;
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
tcds_dma_enable(&sc->sc_slots[slot], 0);
|
|
|
|
tcds_scsi_enable(&sc->sc_slots[slot], 0);
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
tcds_intrnull(val)
|
|
|
|
void *val;
|
|
|
|
{
|
|
|
|
|
2002-09-27 19:35:29 +04:00
|
|
|
panic("tcds_intrnull: uncaught TCDS intr for chip %lu",
|
1995-12-20 03:40:21 +03:00
|
|
|
(u_long)val);
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1995-12-20 03:40:21 +03:00
|
|
|
tcds_scsi_reset(sc)
|
|
|
|
struct tcds_slotconfig *sc;
|
1995-02-14 02:06:39 +03:00
|
|
|
{
|
1998-05-25 03:41:42 +04:00
|
|
|
u_int32_t cir;
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
tcds_dma_enable(sc, 0);
|
|
|
|
tcds_scsi_enable(sc, 0);
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
cir = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
|
|
|
|
TCDS_CIR_CLR(cir, sc->sc_resetbits);
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR, cir);
|
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
DELAY(1);
|
1998-05-25 03:41:42 +04:00
|
|
|
|
|
|
|
cir = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
|
|
|
|
TCDS_CIR_SET(cir, sc->sc_resetbits);
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR, cir);
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
tcds_scsi_enable(sc, 1);
|
|
|
|
tcds_dma_enable(sc, 1);
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1995-12-20 03:40:21 +03:00
|
|
|
tcds_scsi_enable(sc, on)
|
|
|
|
struct tcds_slotconfig *sc;
|
|
|
|
int on;
|
1995-02-14 02:06:39 +03:00
|
|
|
{
|
1998-05-25 03:41:42 +04:00
|
|
|
u_int32_t imer;
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
imer = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_IMER);
|
|
|
|
|
|
|
|
if (on)
|
|
|
|
imer |= sc->sc_intrmaskbits;
|
1995-12-20 03:40:21 +03:00
|
|
|
else
|
1998-05-25 03:41:42 +04:00
|
|
|
imer &= ~sc->sc_intrmaskbits;
|
|
|
|
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_IMER, imer);
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1995-12-20 03:40:21 +03:00
|
|
|
tcds_dma_enable(sc, on)
|
|
|
|
struct tcds_slotconfig *sc;
|
|
|
|
int on;
|
1995-02-14 02:06:39 +03:00
|
|
|
{
|
1998-05-25 03:41:42 +04:00
|
|
|
u_int32_t cir;
|
|
|
|
|
|
|
|
cir = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
|
1995-02-14 02:06:39 +03:00
|
|
|
|
|
|
|
/* XXX Clear/set IOSLOT/PBS bits. */
|
2005-02-27 03:26:58 +03:00
|
|
|
if (on)
|
1998-05-25 03:41:42 +04:00
|
|
|
TCDS_CIR_SET(cir, sc->sc_dmabits);
|
1995-12-20 03:40:21 +03:00
|
|
|
else
|
1998-05-25 03:41:42 +04:00
|
|
|
TCDS_CIR_CLR(cir, sc->sc_dmabits);
|
|
|
|
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR, cir);
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-12-20 03:40:21 +03:00
|
|
|
tcds_scsi_isintr(sc, clear)
|
|
|
|
struct tcds_slotconfig *sc;
|
|
|
|
int clear;
|
1995-02-14 02:06:39 +03:00
|
|
|
{
|
1998-05-25 03:41:42 +04:00
|
|
|
u_int32_t cir;
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
cir = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
|
|
|
|
|
|
|
|
if ((cir & sc->sc_intrbits) != 0) {
|
1995-12-20 03:40:21 +03:00
|
|
|
if (clear) {
|
1998-05-25 03:41:42 +04:00
|
|
|
TCDS_CIR_CLR(cir, sc->sc_intrbits);
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR,
|
|
|
|
cir);
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
1995-12-20 03:40:21 +03:00
|
|
|
return (1);
|
|
|
|
} else
|
|
|
|
return (0);
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1995-12-20 03:40:21 +03:00
|
|
|
tcds_scsi_iserr(sc)
|
|
|
|
struct tcds_slotconfig *sc;
|
1995-02-14 02:06:39 +03:00
|
|
|
{
|
1998-05-25 03:41:42 +04:00
|
|
|
u_int32_t cir;
|
1995-02-14 02:06:39 +03:00
|
|
|
|
1998-05-25 03:41:42 +04:00
|
|
|
cir = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
|
|
|
|
return ((cir & sc->sc_errorbits) != 0);
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1998-05-25 03:41:42 +04:00
|
|
|
tcds_intr(arg)
|
|
|
|
void *arg;
|
1995-02-14 02:06:39 +03:00
|
|
|
{
|
1998-05-25 03:41:42 +04:00
|
|
|
struct tcds_softc *sc = arg;
|
|
|
|
u_int32_t ir, ir0;
|
1995-02-14 02:06:39 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* Copy and clear (gag!) the interrupts.
|
|
|
|
*/
|
1998-05-25 03:41:42 +04:00
|
|
|
ir = ir0 = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR);
|
|
|
|
TCDS_CIR_CLR(ir0, TCDS_CIR_ALLINTR);
|
|
|
|
bus_space_write_4(sc->sc_bst, sc->sc_bsh, TCDS_CIR, ir0);
|
1995-12-20 03:40:21 +03:00
|
|
|
tc_syncbus();
|
1995-02-14 02:06:39 +03:00
|
|
|
|
2000-06-06 01:47:26 +04:00
|
|
|
#define INCRINTRCNT(slot) sc->sc_slots[slot].sc_evcnt.ev_count++
|
1996-06-05 04:30:48 +04:00
|
|
|
|
1995-12-20 03:40:21 +03:00
|
|
|
#define CHECKINTR(slot) \
|
|
|
|
if (ir & sc->sc_slots[slot].sc_intrbits) { \
|
1996-06-05 04:30:48 +04:00
|
|
|
INCRINTRCNT(slot); \
|
1995-12-20 03:40:21 +03:00
|
|
|
(void)(*sc->sc_slots[slot].sc_intrhand) \
|
|
|
|
(sc->sc_slots[slot].sc_intrarg); \
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
1995-12-20 03:40:21 +03:00
|
|
|
CHECKINTR(0);
|
|
|
|
CHECKINTR(1);
|
1995-02-14 02:06:39 +03:00
|
|
|
#undef CHECKINTR
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
2005-02-27 03:26:58 +03:00
|
|
|
/*
|
1995-02-14 02:06:39 +03:00
|
|
|
* Interrupts not currently handled, but would like to know if they
|
|
|
|
* occur.
|
|
|
|
*
|
|
|
|
* XXX
|
|
|
|
* Don't know if we have to set the interrupt mask and enable bits
|
|
|
|
* in the IMER to allow some of them to happen?
|
|
|
|
*/
|
|
|
|
#define PRINTINTR(msg, bits) \
|
|
|
|
if (ir & bits) \
|
1998-05-25 03:41:42 +04:00
|
|
|
printf("%s: %s", sc->sc_dv.dv_xname, msg);
|
1995-02-14 02:06:39 +03:00
|
|
|
PRINTINTR("SCSI0 DREQ interrupt.\n", TCDS_CIR_SCSI0_DREQ);
|
|
|
|
PRINTINTR("SCSI1 DREQ interrupt.\n", TCDS_CIR_SCSI1_DREQ);
|
|
|
|
PRINTINTR("SCSI0 prefetch interrupt.\n", TCDS_CIR_SCSI0_PREFETCH);
|
|
|
|
PRINTINTR("SCSI1 prefetch interrupt.\n", TCDS_CIR_SCSI1_PREFETCH);
|
|
|
|
PRINTINTR("SCSI0 DMA error.\n", TCDS_CIR_SCSI0_DMA);
|
|
|
|
PRINTINTR("SCSI1 DMA error.\n", TCDS_CIR_SCSI1_DMA);
|
|
|
|
PRINTINTR("SCSI0 DB parity error.\n", TCDS_CIR_SCSI0_DB);
|
|
|
|
PRINTINTR("SCSI1 DB parity error.\n", TCDS_CIR_SCSI1_DB);
|
|
|
|
PRINTINTR("SCSI0 DMA buffer parity error.\n", TCDS_CIR_SCSI0_DMAB_PAR);
|
|
|
|
PRINTINTR("SCSI1 DMA buffer parity error.\n", TCDS_CIR_SCSI1_DMAB_PAR);
|
|
|
|
PRINTINTR("SCSI0 DMA read parity error.\n", TCDS_CIR_SCSI0_DMAR_PAR);
|
|
|
|
PRINTINTR("SCSI1 DMA read parity error.\n", TCDS_CIR_SCSI1_DMAR_PAR);
|
|
|
|
PRINTINTR("TC write parity error.\n", TCDS_CIR_TCIOW_PAR);
|
|
|
|
PRINTINTR("TC I/O address parity error.\n", TCDS_CIR_TCIOA_PAR);
|
|
|
|
#undef PRINTINTR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* The MACH source had this, with the comment:
|
|
|
|
* This is wrong, but machine keeps dying.
|
|
|
|
*/
|
|
|
|
DELAY(1);
|
1996-07-09 04:53:48 +04:00
|
|
|
|
|
|
|
return (1);
|
1995-02-14 02:06:39 +03:00
|
|
|
}
|
1998-05-25 05:14:38 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
tcds_params(sc, chip, idp, fastp)
|
|
|
|
struct tcds_softc *sc;
|
|
|
|
int chip, *idp, *fastp;
|
|
|
|
{
|
1998-05-27 03:43:05 +04:00
|
|
|
int id, fast;
|
1998-05-25 05:14:38 +04:00
|
|
|
u_int32_t ids;
|
|
|
|
|
|
|
|
#ifdef __alpha__
|
1999-11-08 06:00:32 +03:00
|
|
|
if (sc->sc_flags & TCDSF_BASEBOARD) {
|
1998-05-27 03:43:05 +04:00
|
|
|
extern u_int8_t dec_3000_scsiid[], dec_3000_scsifast[];
|
|
|
|
|
|
|
|
id = dec_3000_scsiid[chip];
|
|
|
|
fast = dec_3000_scsifast[chip];
|
1998-05-25 05:14:38 +04:00
|
|
|
} else
|
|
|
|
#endif /* __alpha__ */
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* SCSI IDs are stored in the EEPROM, along with whether or
|
|
|
|
* not the device is "fast". Chip 0 is the high nibble,
|
|
|
|
* chip 1 the low nibble.
|
|
|
|
*/
|
|
|
|
ids = bus_space_read_4(sc->sc_bst, sc->sc_bsh, TCDS_EEPROM_IDS);
|
|
|
|
if (chip == 0)
|
|
|
|
ids >>= 4;
|
|
|
|
|
1998-05-27 03:43:05 +04:00
|
|
|
id = ids & 0x7;
|
|
|
|
fast = ids & 0x8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id < 0 || id > 7) {
|
|
|
|
printf("%s: WARNING: bad SCSI ID %d for chip %d, using 7\n",
|
|
|
|
sc->sc_dv.dv_xname, id, chip);
|
|
|
|
id = 7;
|
1998-05-25 05:14:38 +04:00
|
|
|
}
|
|
|
|
|
1998-05-27 03:43:05 +04:00
|
|
|
if (fast)
|
|
|
|
printf("%s: fast mode set for chip %d\n",
|
1998-05-25 05:14:38 +04:00
|
|
|
sc->sc_dv.dv_xname, chip);
|
1998-05-27 03:43:05 +04:00
|
|
|
|
|
|
|
*idp = id;
|
|
|
|
*fastp = fast;
|
1998-05-25 05:14:38 +04:00
|
|
|
}
|