openpic_iobus.c revision 176208
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 176208 2008-02-12 18:14:46Z 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 */ 74171805Smarcel DEVMETHOD(pic_dispatch, openpic_dispatch), 75171805Smarcel DEVMETHOD(pic_enable, openpic_enable), 76171805Smarcel DEVMETHOD(pic_eoi, openpic_eoi), 77176208Smarcel DEVMETHOD(pic_ipi, openpic_ipi), 78171805Smarcel DEVMETHOD(pic_mask, openpic_mask), 79171805Smarcel DEVMETHOD(pic_unmask, openpic_unmask), 80124469Sgrehan 81124469Sgrehan { 0, 0 } 82124469Sgrehan}; 83124469Sgrehan 84171805Smarcelstatic driver_t openpic_iobus_driver = { 85124469Sgrehan "openpic", 86124469Sgrehan openpic_iobus_methods, 87171805Smarcel sizeof(struct openpic_softc) 88124469Sgrehan}; 89124469Sgrehan 90171805SmarcelDRIVER_MODULE(openpic, iobus, openpic_iobus_driver, openpic_devclass, 0, 0); 91124469Sgrehan 92124469Sgrehanstatic int 93124469Sgrehanopenpic_iobus_probe(device_t dev) 94124469Sgrehan{ 95124469Sgrehan char *name; 96124469Sgrehan 97124469Sgrehan name = iobus_get_name(dev); 98124469Sgrehan if (strcmp(name, "interrupt-controller") != 0) 99171805Smarcel return (ENXIO); 100124469Sgrehan 101124469Sgrehan /* 102124469Sgrehan * The description was already printed out in the nexus 103124469Sgrehan * probe, so don't do it again here 104124469Sgrehan */ 105171805Smarcel device_set_desc(dev, OPENPIC_DEVSTR); 106124469Sgrehan return (0); 107124469Sgrehan} 108