1*a3609b82SAndrew Turner /*- 2*a3609b82SAndrew Turner * Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com> 3*a3609b82SAndrew Turner * Copyright (c) 2014 The FreeBSD Foundation 4*a3609b82SAndrew Turner * All rights reserved. 5*a3609b82SAndrew Turner * 6*a3609b82SAndrew Turner * This software was developed by SRI International and the University of 7*a3609b82SAndrew Turner * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 8*a3609b82SAndrew Turner * ("CTSRD"), as part of the DARPA CRASH research programme. 9*a3609b82SAndrew Turner * 10*a3609b82SAndrew Turner * Portions of this software were developed by Andrew Turner 11*a3609b82SAndrew Turner * under sponsorship from the FreeBSD Foundation. 12*a3609b82SAndrew Turner * 13*a3609b82SAndrew Turner * Redistribution and use in source and binary forms, with or without 14*a3609b82SAndrew Turner * modification, are permitted provided that the following conditions 15*a3609b82SAndrew Turner * are met: 16*a3609b82SAndrew Turner * 1. Redistributions of source code must retain the above copyright 17*a3609b82SAndrew Turner * notice, this list of conditions and the following disclaimer. 18*a3609b82SAndrew Turner * 2. Redistributions in binary form must reproduce the above copyright 19*a3609b82SAndrew Turner * notice, this list of conditions and the following disclaimer in the 20*a3609b82SAndrew Turner * documentation and/or other materials provided with the distribution. 21*a3609b82SAndrew Turner * 22*a3609b82SAndrew Turner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23*a3609b82SAndrew Turner * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24*a3609b82SAndrew Turner * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25*a3609b82SAndrew Turner * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 26*a3609b82SAndrew Turner * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27*a3609b82SAndrew Turner * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28*a3609b82SAndrew Turner * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29*a3609b82SAndrew Turner * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30*a3609b82SAndrew Turner * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31*a3609b82SAndrew Turner * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32*a3609b82SAndrew Turner * SUCH DAMAGE. 33*a3609b82SAndrew Turner */ 34*a3609b82SAndrew Turner 35*a3609b82SAndrew Turner /* 36*a3609b82SAndrew Turner * VirtIO MMIO interface. 37*a3609b82SAndrew Turner * This driver is heavily based on VirtIO PCI interface driver. 38*a3609b82SAndrew Turner */ 39*a3609b82SAndrew Turner 40*a3609b82SAndrew Turner #include "opt_acpi.h" 41*a3609b82SAndrew Turner 42*a3609b82SAndrew Turner #include <sys/cdefs.h> 43*a3609b82SAndrew Turner __FBSDID("$FreeBSD$"); 44*a3609b82SAndrew Turner 45*a3609b82SAndrew Turner #include <sys/param.h> 46*a3609b82SAndrew Turner #include <sys/systm.h> 47*a3609b82SAndrew Turner #include <sys/bus.h> 48*a3609b82SAndrew Turner #include <sys/kernel.h> 49*a3609b82SAndrew Turner #include <sys/module.h> 50*a3609b82SAndrew Turner 51*a3609b82SAndrew Turner #include <contrib/dev/acpica/include/acpi.h> 52*a3609b82SAndrew Turner #include <dev/acpica/acpivar.h> 53*a3609b82SAndrew Turner 54*a3609b82SAndrew Turner #include <dev/virtio/mmio/virtio_mmio.h> 55*a3609b82SAndrew Turner 56*a3609b82SAndrew Turner static int vtmmio_acpi_probe(device_t); 57*a3609b82SAndrew Turner 58*a3609b82SAndrew Turner static device_method_t vtmmio_acpi_methods[] = { 59*a3609b82SAndrew Turner /* Device interface. */ 60*a3609b82SAndrew Turner DEVMETHOD(device_probe, vtmmio_acpi_probe), 61*a3609b82SAndrew Turner 62*a3609b82SAndrew Turner DEVMETHOD_END 63*a3609b82SAndrew Turner }; 64*a3609b82SAndrew Turner 65*a3609b82SAndrew Turner DEFINE_CLASS_1(virtio_mmio, vtmmio_acpi_driver, vtmmio_acpi_methods, 66*a3609b82SAndrew Turner sizeof(struct vtmmio_softc), vtmmio_driver); 67*a3609b82SAndrew Turner 68*a3609b82SAndrew Turner static devclass_t vtmmio_acpi_devclass; 69*a3609b82SAndrew Turner 70*a3609b82SAndrew Turner DRIVER_MODULE(virtio_mmio, acpi, vtmmio_acpi_driver, vtmmio_acpi_devclass, 0,0); 71*a3609b82SAndrew Turner MODULE_DEPEND(virtio_mmio, acpi, 1, 1, 1); 72*a3609b82SAndrew Turner 73*a3609b82SAndrew Turner static int 74*a3609b82SAndrew Turner vtmmio_acpi_probe(device_t dev) 75*a3609b82SAndrew Turner { 76*a3609b82SAndrew Turner ACPI_HANDLE h; 77*a3609b82SAndrew Turner 78*a3609b82SAndrew Turner if ((h = acpi_get_handle(dev)) == NULL) 79*a3609b82SAndrew Turner return (ENXIO); 80*a3609b82SAndrew Turner 81*a3609b82SAndrew Turner if (!acpi_MatchHid(h, "LNRO0005")) 82*a3609b82SAndrew Turner return (ENXIO); 83*a3609b82SAndrew Turner 84*a3609b82SAndrew Turner device_set_desc(dev, "VirtIO MMIO adapter"); 85*a3609b82SAndrew Turner return (BUS_PROBE_DEFAULT); 86*a3609b82SAndrew Turner } 87