/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe.
*
* 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.
*/
/*
* Copyright (c) 1982, 1990, 1993
* 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. 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.
*
* @(#)fhpib.c 8.2 (Berkeley) 1/12/94
*/
/*
* Inline version of fhpibwait to be used in places where
* we don't worry about getting hung.
*/
#define FHPIBWAIT(hd, m) while (((hd)->hpib_intr & (m)) == 0) DELAY(1)
int dopriodma = 0; /* use high priority DMA */
int doworddma = 1; /* non-zero if we should attempt word DMA */
int doppollint = 1; /* use ppoll interrupts instead of watchdog */
int fhpibppolldelay = 50;
#endif
hd->hpib_cid = 0xFF;
DELAY(100);
hd->hpib_cmd = CT_8BIT;
hd->hpib_ar = AR_ARONC;
fhpibifc(hd);
hd->hpib_ie = IDS_IE;
hd->hpib_data = C_DCL;
DELAY(100000);
/*
* See if we can do word DMA.
* If so, we should be able to write and read back the appropos bit.
*/
hd->hpib_ie |= IDS_WDMA;
if (hd->hpib_ie & IDS_WDMA) {
hd->hpib_ie &= ~IDS_WDMA;
hs->sc_flags |= HPIBF_DMA16;
#ifdef DEBUG
if (fhpibdebug & FDB_DMA)
printf("fhpibtype: %s has word DMA\n",
device_xname(sc->sc_dev));
#endif
}
}
/*
* A DMA read can finish but the device can still be waiting (MAG-tape
* with more data than we're waiting for). This timeout routine
* takes care of that. Somehow, the thing gets hosed. For now, since
* this should be a very rare occurrence, we RESET it.
*/
static void
fhpibdmadone(void *arg)
{
struct hpibbus_softc *hs = arg;
struct fhpib_softc *sc = device_private(device_parent(hs->sc_dev));
int s = splbio();
/*
* XXX: this will have to change if we ever allow more than one
* pending operation per HP-IB.
*/
static void
fhpibppwatch(void *arg)
{
struct hpibbus_softc *hs = arg;
struct fhpib_softc *sc = device_private(device_parent(hs->sc_dev));
struct fhpibdevice *hd = sc->sc_regs;
int slave;