Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/usb/controller/dwc3_acpi.c
- This file was added.
/*- | |||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD | |||||
* | |||||
* Copyright (c) 2019 Emmanuel Vadot <manu@FreeBSD.Org> | |||||
* Copyright (c) 2021 Bjoern A. Zeeb <bz@FreeBSD.ORG> | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
* SUCH DAMAGE. | |||||
* | |||||
* $FreeBSD$ | |||||
* | |||||
*/ | |||||
#include <sys/cdefs.h> | |||||
__FBSDID("$FreeBSD$"); | |||||
#include "opt_acpi.h" | |||||
#include <sys/param.h> | |||||
#include <sys/systm.h> | |||||
#include <sys/bus.h> | |||||
#include <sys/rman.h> | |||||
#include <sys/condvar.h> | |||||
#include <sys/kernel.h> | |||||
#include <sys/module.h> | |||||
#include <sys/gpio.h> | |||||
#include <machine/bus.h> | |||||
#include <contrib/dev/acpica/include/acpi.h> | |||||
#include <contrib/dev/acpica/include/accommon.h> | |||||
#include <dev/acpica/acpivar.h> | |||||
#include <dev/usb/usb.h> | |||||
#include <dev/usb/usbdi.h> | |||||
#include <dev/usb/usb_core.h> | |||||
#include <dev/usb/usb_busdma.h> | |||||
#include <dev/usb/usb_process.h> | |||||
#include <dev/usb/usb_controller.h> | |||||
#include <dev/usb/usb_bus.h> | |||||
#include <dev/usb/controller/xhci.h> | |||||
#include <dev/usb/controller/dwc3.h> | |||||
#include "generic_xhci.h" | |||||
#define IS_DMA_32B 1 | |||||
struct snps_dwc3_acpi_softc { | |||||
struct snps_dwc3_common_softc csc; | |||||
}; | |||||
static char *dwc3_acpi_ids[] = { | |||||
"808622B7", | |||||
NULL | |||||
}; | |||||
static int | |||||
snps_dwc3_acpi_probe(device_t dev) | |||||
{ | |||||
int rc; | |||||
if (acpi_disabled("snps_dwc3")) | |||||
return (ENXIO); | |||||
rc = ACPI_ID_PROBE(device_get_parent(dev), dev, dwc3_acpi_ids, NULL); | |||||
if (rc > 0) | |||||
return (rc); | |||||
return (snps_dwc3_probe_common(dev)); | |||||
} | |||||
static int | |||||
snps_dwc3_acpi_attach(device_t dev) | |||||
{ | |||||
struct snps_dwc3_acpi_softc *sc; | |||||
struct snps_dwc3_common_softc *csc; | |||||
int rid = 0; | |||||
sc = device_get_softc(dev); | |||||
csc = &sc->csc; | |||||
csc->dev = dev; | |||||
csc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, | |||||
RF_ACTIVE); | |||||
if (csc->mem_res == NULL) { | |||||
device_printf(dev, "Failed to map memory\n"); | |||||
return (ENXIO); | |||||
} | |||||
csc->bst = rman_get_bustag(csc->mem_res); | |||||
csc->bsh = rman_get_bushandle(csc->mem_res); | |||||
if (bootverbose) | |||||
device_printf(dev, "snps id: %x\n", DWC3_READ(csc, DWC3_GSNPSID)); | |||||
snps_dwc3_reset(csc); | |||||
snps_dwc3_configure_host(csc); | |||||
snps_dwc3_do_quirks(csc); | |||||
#if 0 | |||||
snsp_dwc3_dump_regs(csc); | |||||
#endif | |||||
snps_dwc3_attach_xhci(csc); | |||||
return (0); | |||||
} | |||||
static device_method_t snps_dwc3_acpi_methods[] = { | |||||
/* Device interface */ | |||||
DEVMETHOD(device_probe, snps_dwc3_acpi_probe), | |||||
DEVMETHOD(device_attach, snps_dwc3_acpi_attach), | |||||
DEVMETHOD_END | |||||
}; | |||||
DEFINE_CLASS_1(xhci, snps_dwc3_acpi_driver, snps_dwc3_acpi_methods, | |||||
sizeof(struct snps_dwc3_acpi_softc), generic_xhci_driver); | |||||
static devclass_t snps_dwc3_acpi_devclass; | |||||
DRIVER_MODULE(snps_dwc3_acpi, acpi, snps_dwc3_acpi_driver, | |||||
snps_dwc3_acpi_devclass, 0, 0); | |||||
MODULE_DEPEND(snps_dwc3_acpi, usb, 1, 1, 1); |