xref: /freebsd-src/sys/dev/usb/controller/generic_xhci_acpi.c (revision 685dc743dc3b5645e34836464128e1c0558b404b)
1052073c3SEmmanuel Vadot /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3052073c3SEmmanuel Vadot  *
40b453151SVal Packett  * Copyright (c) 2019 Val Packett <val@packett.cool>
5052073c3SEmmanuel Vadot  *
6052073c3SEmmanuel Vadot  * Redistribution and use in source and binary forms, with or without
7052073c3SEmmanuel Vadot  * modification, are permitted provided that the following conditions
8052073c3SEmmanuel Vadot  * are met:
9052073c3SEmmanuel Vadot  * 1. Redistributions of source code must retain the above copyright
10052073c3SEmmanuel Vadot  *    notice, this list of conditions and the following disclaimer.
11052073c3SEmmanuel Vadot  * 2. Redistributions in binary form must reproduce the above copyright
12052073c3SEmmanuel Vadot  *    notice, this list of conditions and the following disclaimer in the
13052073c3SEmmanuel Vadot  *    documentation and/or other materials provided with the distribution.
14052073c3SEmmanuel Vadot  *
15052073c3SEmmanuel Vadot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16052073c3SEmmanuel Vadot  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17052073c3SEmmanuel Vadot  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18052073c3SEmmanuel Vadot  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19052073c3SEmmanuel Vadot  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20052073c3SEmmanuel Vadot  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21052073c3SEmmanuel Vadot  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22052073c3SEmmanuel Vadot  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23052073c3SEmmanuel Vadot  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24052073c3SEmmanuel Vadot  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25052073c3SEmmanuel Vadot  * SUCH DAMAGE.
26052073c3SEmmanuel Vadot  */
27052073c3SEmmanuel Vadot 
28052073c3SEmmanuel Vadot #include <sys/cdefs.h>
29052073c3SEmmanuel Vadot #include "opt_acpi.h"
30052073c3SEmmanuel Vadot 
31052073c3SEmmanuel Vadot #include <sys/param.h>
32052073c3SEmmanuel Vadot #include <sys/systm.h>
33052073c3SEmmanuel Vadot #include <sys/bus.h>
34052073c3SEmmanuel Vadot #include <sys/condvar.h>
35052073c3SEmmanuel Vadot #include <sys/kernel.h>
36052073c3SEmmanuel Vadot #include <sys/module.h>
37052073c3SEmmanuel Vadot 
38052073c3SEmmanuel Vadot #include <dev/usb/usb.h>
39052073c3SEmmanuel Vadot #include <dev/usb/usbdi.h>
40052073c3SEmmanuel Vadot 
41052073c3SEmmanuel Vadot #include <dev/usb/usb_core.h>
42052073c3SEmmanuel Vadot #include <dev/usb/usb_busdma.h>
43052073c3SEmmanuel Vadot #include <dev/usb/usb_process.h>
44052073c3SEmmanuel Vadot 
45052073c3SEmmanuel Vadot #include <dev/usb/usb_controller.h>
46052073c3SEmmanuel Vadot #include <dev/usb/usb_bus.h>
47052073c3SEmmanuel Vadot #include <dev/usb/controller/xhci.h>
48052073c3SEmmanuel Vadot 
49052073c3SEmmanuel Vadot #include <contrib/dev/acpica/include/acpi.h>
50052073c3SEmmanuel Vadot #include <dev/acpica/acpivar.h>
51052073c3SEmmanuel Vadot 
52052073c3SEmmanuel Vadot #include "generic_xhci.h"
53052073c3SEmmanuel Vadot 
548793196cSAndrew Turner static char *xhci_ids[] = {
558793196cSAndrew Turner 	"PNP0D10",
568793196cSAndrew Turner 	"PNP0D15",
578793196cSAndrew Turner 	NULL,
588793196cSAndrew Turner };
598793196cSAndrew Turner 
60052073c3SEmmanuel Vadot static int
generic_xhci_acpi_probe(device_t dev)61052073c3SEmmanuel Vadot generic_xhci_acpi_probe(device_t dev)
62052073c3SEmmanuel Vadot {
638793196cSAndrew Turner 	if (ACPI_ID_PROBE(device_get_parent(dev), dev, xhci_ids, NULL) >= 0)
64052073c3SEmmanuel Vadot 		return (ENXIO);
65052073c3SEmmanuel Vadot 
66052073c3SEmmanuel Vadot 	device_set_desc(dev, XHCI_HC_DEVSTR);
67052073c3SEmmanuel Vadot 
6876f3b8cbSBjoern A. Zeeb 	return (BUS_PROBE_GENERIC);
69052073c3SEmmanuel Vadot }
70052073c3SEmmanuel Vadot 
71052073c3SEmmanuel Vadot static device_method_t xhci_acpi_methods[] = {
72052073c3SEmmanuel Vadot 	/* Device interface */
73052073c3SEmmanuel Vadot 	DEVMETHOD(device_probe, generic_xhci_acpi_probe),
74052073c3SEmmanuel Vadot 
75052073c3SEmmanuel Vadot 	DEVMETHOD_END
76052073c3SEmmanuel Vadot };
77052073c3SEmmanuel Vadot 
78052073c3SEmmanuel Vadot DEFINE_CLASS_1(xhci, xhci_acpi_driver, xhci_acpi_methods,
79052073c3SEmmanuel Vadot     sizeof(struct xhci_softc), generic_xhci_driver);
80052073c3SEmmanuel Vadot 
81bc9372d7SJohn Baldwin DRIVER_MODULE(xhci, acpi, xhci_acpi_driver, 0, 0);
82052073c3SEmmanuel Vadot MODULE_DEPEND(xhci, usb, 1, 1, 1);
83