/* $NetBSD: sc_vme.c,v 1.19 2023/08/04 14:04:44 rin Exp $ */
/*-
* Copyright (c) 1996,2000,2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Adam Glass, David Jones, Gordon W. Ross, Jason R. Thorpe,
* Paul Kranenburg, and Matt Fredette.
*
* 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.
*
* 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.
*/
/*
* This file contains VME bus-dependent of the `sc' SCSI adapter.
* This hardware is frequently found on Sun 2, Sun 3, and Sun 4 machines.
*
* The SCSI machinery on this adapter is implemented by an Sun custom
* chipset, which is handled by the chipset driver in /sys/dev/ic/sunscpal.c
*/
/*
* This driver originated as an MD implementation for the `si' VME driver.
* The notes pertaining to that history are included below.
*
* David Jones wrote the initial version of this module for NetBSD/sun3,
* which included support for the VME adapter only. (no reselection).
*
* Gordon Ross added support for the Sun 3 OBIO adapter, and re-worked
* both the VME and OBIO code to support disconnect/reselect.
* (Required figuring out the hardware "features" noted above.)
*
* The autoconfiguration boilerplate came from Adam Glass.
*
* Jason R. Thorpe ported the autoconfiguration and VME portions to
* NetBSD/sparc, and added initial support for the 4/100 "SCSI Weird",
* a wacky OBIO variant of the VME SCSI-3. Many thanks to Chuck Cranor
* for lots of helpful tips and suggestions. Thanks also to Paul Kranenburg
* and Chris Torek for bits of insight needed along the way. Thanks to
* David Gilbert and Andrew Gillham who risked filesystem life-and-limb
* for the sake of testing. Andrew Gillham helped work out the bugs
* the 4/100 DMA code.
*/
/*
* If this is a VME SCSI board, we have to determine whether
* it is an "sc" (Sun2) or "si" (Sun3) SCSI board. This can
* be determined using the fact that the "sc" board occupies
* 4K bytes in VME space but the "si" board occupies 2K bytes.
*/
return vme_probe(ct, vme_addr + 0x801, 1, mod, VME_D8, NULL, 0) == 0;
}
/*
* Set up interrupts on the board.
*/
SUNSCPAL_WRITE_1(sc, sunscpal_intvec, va->ivector & 0xFF);
/* Do the common attach stuff. */
printf("%s", device_xname(self));
sunscpal_attach(sc, (device_cfdata(self)->cf_flags ?
device_cfdata(self)->cf_flags : sunsc_vme_options));
}
static int
sc_vme_intr(void *arg)
{
struct sunscpal_softc *sc = arg;
int claimed;
claimed = sunscpal_intr(sc);
#ifdef DEBUG
if (!claimed) {
printf("%s: spurious from SBC\n", __func__);
}
#endif
/* Yes, we DID cause this interrupt. */
claimed = 1;