/*-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),7071/* PIC interface */72DEVMETHOD(pic_config, openpic_config),73DEVMETHOD(pic_dispatch, openpic_dispatch),74DEVMETHOD(pic_enable, openpic_enable),75DEVMETHOD(pic_eoi, openpic_eoi),76DEVMETHOD(pic_ipi, openpic_ipi),77DEVMETHOD(pic_mask, openpic_mask),78DEVMETHOD(pic_unmask, openpic_unmask),79{ 0, 0 }80};8182static driver_t openpic_iobus_driver = {83"openpic",84openpic_iobus_methods,85sizeof(struct openpic_softc)86};8788DRIVER_MODULE(openpic, iobus, openpic_iobus_driver, 0, 0);8990static int91openpic_iobus_probe(device_t dev)92{93struct openpic_softc *sc;94char *name;9596name = iobus_get_name(dev);97if (strcmp(name, "interrupt-controller") != 0)98return (ENXIO);99100/*101* The description was already printed out in the nexus102* probe, so don't do it again here103*/104device_set_desc(dev, OPENPIC_DEVSTR);105106sc = device_get_softc(dev);107sc->sc_psim = 1;108109return (0);110}111112static int113openpic_iobus_attach(device_t dev)114{115116return (openpic_common_attach(dev, 0));117}118119120