openpic_ofw.c revision 209639
1254721Semaste/*- 2254721Semaste * Copyright 2003 by Peter Grehan. All rights reserved. 3254721Semaste * 4254721Semaste * Redistribution and use in source and binary forms, with or without 5254721Semaste * modification, are permitted provided that the following conditions 6254721Semaste * are met: 7254721Semaste * 1. Redistributions of source code must retain the above copyright 8254721Semaste * notice, this list of conditions and the following disclaimer. 9254721Semaste * 2. Redistributions in binary form must reproduce the above copyright 10254721Semaste * notice, this list of conditions and the following disclaimer in the 11254721Semaste * documentation and/or other materials provided with the distribution. 12254721Semaste * 3. The name of the author may not be used to endorse or promote products 13254721Semaste * derived from this software without specific prior written permission. 14254721Semaste * 15254721Semaste * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16254721Semaste * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17254721Semaste * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18254721Semaste * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19254721Semaste * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20254721Semaste * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21254721Semaste * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22254721Semaste * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23254721Semaste * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24254721Semaste * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25254721Semaste * SUCH DAMAGE. 26254721Semaste * 27254721Semaste */ 28254721Semaste 29254721Semaste#include <sys/cdefs.h> 30254721Semaste__FBSDID("$FreeBSD: head/sys/powerpc/powermac/openpic_macio.c 209639 2010-07-02 02:17:39Z marcel $"); 31254721Semaste 32254721Semaste#include <sys/param.h> 33254721Semaste#include <sys/systm.h> 34254721Semaste#include <sys/module.h> 35254721Semaste#include <sys/bus.h> 36254721Semaste#include <sys/conf.h> 37254721Semaste#include <sys/kernel.h> 38254721Semaste 39254721Semaste#include <dev/ofw/ofw_bus.h> 40254721Semaste#include <dev/ofw/openfirm.h> 41254721Semaste 42254721Semaste#include <machine/bus.h> 43254721Semaste#include <machine/intr_machdep.h> 44254721Semaste#include <machine/md_var.h> 45254721Semaste#include <machine/pio.h> 46254721Semaste#include <machine/resource.h> 47254721Semaste 48254721Semaste#include <vm/vm.h> 49254721Semaste#include <vm/pmap.h> 50254721Semaste 51254721Semaste#include <sys/rman.h> 52254721Semaste 53254721Semaste#include <machine/openpicvar.h> 54254721Semaste 55254721Semaste#include "pic_if.h" 56254721Semaste 57254721Semaste/* 58254721Semaste * MacIO interface 59254721Semaste */ 60254721Semastestatic int openpic_macio_probe(device_t); 61254721Semastestatic uint32_t openpic_macio_id(device_t); 62254721Semaste 63254721Semastestatic device_method_t openpic_macio_methods[] = { 64254721Semaste /* Device interface */ 65254721Semaste DEVMETHOD(device_probe, openpic_macio_probe), 66254721Semaste DEVMETHOD(device_attach, openpic_attach), 67254721Semaste 68254721Semaste /* PIC interface */ 69254721Semaste DEVMETHOD(pic_bind, openpic_bind), 70254721Semaste DEVMETHOD(pic_config, openpic_config), 71254721Semaste DEVMETHOD(pic_dispatch, openpic_dispatch), 72254721Semaste DEVMETHOD(pic_enable, openpic_enable), 73254721Semaste DEVMETHOD(pic_eoi, openpic_eoi), 74254721Semaste DEVMETHOD(pic_ipi, openpic_ipi), 75254721Semaste DEVMETHOD(pic_mask, openpic_mask), 76254721Semaste DEVMETHOD(pic_unmask, openpic_unmask), 77254721Semaste DEVMETHOD(pic_id, openpic_macio_id), 78254721Semaste 79254721Semaste { 0, 0 }, 80254721Semaste}; 81254721Semaste 82254721Semastestatic driver_t openpic_macio_driver = { 83254721Semaste "openpic", 84254721Semaste openpic_macio_methods, 85254721Semaste sizeof(struct openpic_softc), 86254721Semaste}; 87254721Semaste 88254721SemasteDRIVER_MODULE(openpic, macio, openpic_macio_driver, openpic_devclass, 0, 0); 89254721Semaste 90254721Semastestatic int 91254721Semasteopenpic_macio_probe(device_t dev) 92254721Semaste{ 93254721Semaste const char *type = ofw_bus_get_type(dev); 94254721Semaste 95254721Semaste if (strcmp(type, "open-pic") != 0) 96254721Semaste return (ENXIO); 97254721Semaste 98254721Semaste device_set_desc(dev, OPENPIC_DEVSTR); 99254721Semaste return (0); 100254721Semaste} 101254721Semaste 102254721Semastestatic uint32_t 103254721Semasteopenpic_macio_id(device_t dev) 104254721Semaste{ 105254721Semaste return (ofw_bus_get_node(dev)); 106254721Semaste} 107254721Semaste 108254721Semaste