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