openpic_iobus.c revision 177884
1139825Simp/*- 2124469Sgrehan * Copyright 2003 by Peter Grehan. All rights reserved. 3124469Sgrehan * 4124469Sgrehan * Redistribution and use in source and binary forms, with or without 5124469Sgrehan * modification, are permitted provided that the following conditions 6124469Sgrehan * are met: 7124469Sgrehan * 1. Redistributions of source code must retain the above copyright 8124469Sgrehan * notice, this list of conditions and the following disclaimer. 9124469Sgrehan * 2. Redistributions in binary form must reproduce the above copyright 10124469Sgrehan * notice, this list of conditions and the following disclaimer in the 11124469Sgrehan * documentation and/or other materials provided with the distribution. 12124469Sgrehan * 3. The name of the author may not be used to endorse or promote products 13124469Sgrehan * derived from this software without specific prior written permission. 14124469Sgrehan * 15124469Sgrehan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16124469Sgrehan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17124469Sgrehan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18124469Sgrehan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19124469Sgrehan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20124469Sgrehan * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21124469Sgrehan * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22124469Sgrehan * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23124469Sgrehan * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24124469Sgrehan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25124469Sgrehan * SUCH DAMAGE. 26124469Sgrehan * 27124469Sgrehan */ 28124469Sgrehan 29124469Sgrehan/* 30124469Sgrehan * The psim iobus attachment for the OpenPIC interrupt controller. 31124469Sgrehan */ 32124469Sgrehan 33124469Sgrehan#include <sys/cdefs.h> 34124469Sgrehan__FBSDID("$FreeBSD: head/sys/powerpc/psim/openpic_iobus.c 177884 2008-04-03 17:38:27Z marcel $"); 35124469Sgrehan 36124469Sgrehan#include <sys/param.h> 37124469Sgrehan#include <sys/systm.h> 38131102Sgrehan#include <sys/module.h> 39124469Sgrehan#include <sys/bus.h> 40124469Sgrehan#include <sys/conf.h> 41124469Sgrehan#include <sys/kernel.h> 42124469Sgrehan 43124469Sgrehan#include <dev/ofw/openfirm.h> 44124469Sgrehan 45124469Sgrehan#include <machine/bus.h> 46124469Sgrehan#include <machine/intr.h> 47124469Sgrehan#include <machine/intr_machdep.h> 48124469Sgrehan#include <machine/md_var.h> 49124469Sgrehan#include <machine/nexusvar.h> 50124469Sgrehan#include <machine/pio.h> 51124469Sgrehan#include <machine/resource.h> 52124469Sgrehan 53124469Sgrehan#include <vm/vm.h> 54124469Sgrehan#include <vm/pmap.h> 55124469Sgrehan 56124469Sgrehan#include <sys/rman.h> 57124469Sgrehan 58124469Sgrehan#include <machine/openpicvar.h> 59124469Sgrehan#include <powerpc/psim/iobusvar.h> 60124469Sgrehan 61124469Sgrehan#include "pic_if.h" 62124469Sgrehan 63124469Sgrehan/* 64171805Smarcel * PSIM IOBus interface 65124469Sgrehan */ 66124469Sgrehanstatic int openpic_iobus_probe(device_t); 67124469Sgrehan 68171805Smarcelstatic device_method_t openpic_iobus_methods[] = { 69124469Sgrehan /* Device interface */ 70171805Smarcel DEVMETHOD(device_probe, openpic_iobus_probe), 71171805Smarcel DEVMETHOD(device_attach, openpic_attach), 72124469Sgrehan 73124469Sgrehan /* PIC interface */ 74176918Smarcel DEVMETHOD(pic_config, openpic_config), 75171805Smarcel DEVMETHOD(pic_dispatch, openpic_dispatch), 76171805Smarcel DEVMETHOD(pic_enable, openpic_enable), 77171805Smarcel DEVMETHOD(pic_eoi, openpic_eoi), 78176208Smarcel DEVMETHOD(pic_ipi, openpic_ipi), 79171805Smarcel DEVMETHOD(pic_mask, openpic_mask), 80171805Smarcel DEVMETHOD(pic_unmask, openpic_unmask), 81124469Sgrehan 82124469Sgrehan { 0, 0 } 83124469Sgrehan}; 84124469Sgrehan 85171805Smarcelstatic driver_t openpic_iobus_driver = { 86124469Sgrehan "openpic", 87124469Sgrehan openpic_iobus_methods, 88171805Smarcel sizeof(struct openpic_softc) 89124469Sgrehan}; 90124469Sgrehan 91171805SmarcelDRIVER_MODULE(openpic, iobus, openpic_iobus_driver, openpic_devclass, 0, 0); 92124469Sgrehan 93124469Sgrehanstatic int 94124469Sgrehanopenpic_iobus_probe(device_t dev) 95124469Sgrehan{ 96177884Smarcel struct openpic_softc *sc; 97124469Sgrehan char *name; 98124469Sgrehan 99124469Sgrehan name = iobus_get_name(dev); 100124469Sgrehan if (strcmp(name, "interrupt-controller") != 0) 101171805Smarcel return (ENXIO); 102124469Sgrehan 103124469Sgrehan /* 104124469Sgrehan * The description was already printed out in the nexus 105124469Sgrehan * probe, so don't do it again here 106124469Sgrehan */ 107171805Smarcel device_set_desc(dev, OPENPIC_DEVSTR); 108177884Smarcel 109177884Smarcel sc = device_get_softc(dev); 110177884Smarcel sc->sc_psim = 1; 111177884Smarcel 112124469Sgrehan return (0); 113124469Sgrehan} 114