/*-
* Copyright (c) 1997, 1998, 1999 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) 1997 Michael Smith. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
/*
* Support for the "Frodo" (a.k.a. "Apollo Utility") chip found
* in HP Apollo 9000/4xx workstations, as well as 9000/382 controllers.
*/
/* Set interrupt polarities. */
FRODO_WRITE(sc, FRODO_PIO_IPR, 0x10);
/* ...and configure for edge triggering. */
FRODO_WRITE(sc, FRODO_PIO_IELR, 0xcf);
/*
* We defer hooking up our interrupt handler until
* a subdevice hooks up theirs.
*/
sc->sc_ih = NULL;
/* ... and attach subdevices. */
for (fd = frodo_subdevs; fd->fd_name != NULL; fd++) {
/*
* Skip the first serial port if we're not a 425e;
* it's mapped to the DCA at select code 9 on all
* other models.
*/
if (fd->fd_offset == FRODO_APCI_OFFSET(1) &&
mmuid != MMUID_425_E)
continue;
/*
* The mcclock is available only on a 425e.
*/
if (fd->fd_offset == FRODO_CALENDAR && mmuid != MMUID_425_E)
continue;
fa.fa_name = fd->fd_name;
fa.fa_bst = bst;
fa.fa_base = ia->ia_iobase;
fa.fa_offset = fd->fd_offset;
fa.fa_line = fd->fd_line;
config_found(self, &fa, frodoprint,
CFARGS(.submatch = frodosubmatch));
}
}
static int
frodosubmatch(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
{
struct frodo_attach_args *fa = aux;
if (cf->frodocf_offset != FRODO_UNKNOWN_OFFSET &&
cf->frodocf_offset != fa->fa_offset)
return 0;
/*
* If this is the first one, establish the frodo
* interrupt handler. If not, reestablish at a
* higher priority if necessary.
*/
if (ih == NULL || ih->ih_isrpri < isrpri) {
if (ih != NULL)
intr_disestablish(ih);
sc->sc_ih = intr_establish(frodointr, sc, sc->sc_ipl, isrpri);
}
static int
frodointr(void *arg)
{
struct frodo_softc *sc = arg;
struct frodo_interhand *fih;
int line, taken = 0;
/* Any interrupts pending? */
if (FRODO_GETPEND(sc) == 0)
return 0;
do {
/*
* Get pending interrupt; this also clears it for us.
*/
line = FRODO_IPEND(sc);
fih = &sc->sc_intr[line];
if (fih->ih_fn == NULL ||
(*fih->ih_fn)(fih->ih_arg) == 0)
printf("%s: spurious interrupt on line %d\n",
device_xname(sc->sc_dev), line);
if (taken++ > 100)
panic("frodointr: looping!");
} while (FRODO_GETPEND(sc) != 0);