/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright 2003 by Peter Grehan. All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13* 3. The name of the author may not be used to endorse or promote products14* derived from this software without specific prior written permission.15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR17* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES18* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.19* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,20* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,21* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED23* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,24* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*28*/2930/*31* The psim iobus attachment for the OpenPIC interrupt controller.32*/3334#include <sys/param.h>35#include <sys/systm.h>36#include <sys/module.h>37#include <sys/bus.h>38#include <sys/conf.h>39#include <sys/kernel.h>4041#include <dev/ofw/openfirm.h>4243#include <machine/bus.h>44#include <machine/intr_machdep.h>45#include <machine/md_var.h>46#include <machine/pio.h>47#include <machine/resource.h>4849#include <vm/vm.h>50#include <vm/pmap.h>5152#include <sys/rman.h>5354#include <machine/openpicreg.h>55#include <machine/openpicvar.h>56#include <powerpc/psim/iobusvar.h>5758#include "pic_if.h"5960/*61* PSIM IOBus interface62*/63static int openpic_iobus_probe(device_t);64static int openpic_iobus_attach(device_t);6566static device_method_t openpic_iobus_methods[] = {67/* Device interface */68DEVMETHOD(device_probe, openpic_iobus_probe),69DEVMETHOD(device_attach, openpic_iobus_attach),7071DEVMETHOD_END72};7374DEFINE_CLASS_1(openpic, openpic_iobus_driver, openpic_iobus_methods,75sizeof(struct openpic_softc), openpic_class);7677DRIVER_MODULE(openpic, iobus, openpic_iobus_driver, 0, 0);7879static int80openpic_iobus_probe(device_t dev)81{82struct openpic_softc *sc;83char *name;8485name = iobus_get_name(dev);86if (strcmp(name, "interrupt-controller") != 0)87return (ENXIO);8889/*90* The description was already printed out in the nexus91* probe, so don't do it again here92*/93device_set_desc(dev, OPENPIC_DEVSTR);9495sc = device_get_softc(dev);96sc->sc_psim = 1;9798return (0);99}100101static int102openpic_iobus_attach(device_t dev)103{104105return (openpic_common_attach(dev, 0));106}107108109