Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/usb/controller/generic_xhci.c
Show All 22 Lines | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * 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 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_bus.h" | #include "opt_acpi.h" | ||||
#include "opt_platform.h" | |||||
#include <sys/stdint.h> | #include <sys/stdint.h> | ||||
#include <sys/stddef.h> | #include <sys/stddef.h> | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
#include <sys/module.h> | #include <sys/module.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/condvar.h> | #include <sys/condvar.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/sx.h> | #include <sys/sx.h> | ||||
#include <sys/unistd.h> | #include <sys/unistd.h> | ||||
#include <sys/priv.h> | #include <sys/priv.h> | ||||
#include <sys/rman.h> | #include <sys/rman.h> | ||||
#ifdef FDT | |||||
#include <dev/ofw/ofw_bus.h> | #include <dev/ofw/ofw_bus.h> | ||||
#include <dev/ofw/ofw_bus_subr.h> | #include <dev/ofw/ofw_bus_subr.h> | ||||
#endif | |||||
#include <dev/usb/usb.h> | #include <dev/usb/usb.h> | ||||
#include <dev/usb/usbdi.h> | #include <dev/usb/usbdi.h> | ||||
#include <dev/usb/usb_core.h> | #include <dev/usb/usb_core.h> | ||||
#include <dev/usb/usb_busdma.h> | #include <dev/usb/usb_busdma.h> | ||||
#include <dev/usb/usb_process.h> | #include <dev/usb/usb_process.h> | ||||
#include <dev/usb/usb_util.h> | #include <dev/usb/usb_util.h> | ||||
#include <dev/usb/usb_controller.h> | #include <dev/usb/usb_controller.h> | ||||
#include <dev/usb/usb_bus.h> | #include <dev/usb/usb_bus.h> | ||||
#include <dev/usb/controller/xhci.h> | #include <dev/usb/controller/xhci.h> | ||||
#include <dev/usb/controller/xhcireg.h> | #include <dev/usb/controller/xhcireg.h> | ||||
#ifdef EXT_RESOURCES | #ifdef EXT_RESOURCES | ||||
#include <dev/extres/phy/phy.h> | #include <dev/extres/phy/phy.h> | ||||
#endif | #endif | ||||
#define XHCI_HC_DEVSTR "Marvell Integrated USB 3.0 controller" | #ifdef DEV_ACPI | ||||
#define XHCI_HC_VENDOR "Marvell" | #include <contrib/dev/acpica/include/acpi.h> | ||||
#include <dev/acpica/acpivar.h> | |||||
#endif | |||||
#define XHCI_HC_DEVSTR "Generic USB 3.0 controller" | |||||
#define XHCI_HC_VENDOR "Generic" | |||||
#define IS_DMA_32B 1 | #define IS_DMA_32B 1 | ||||
static device_attach_t xhci_attach; | static device_attach_t xhci_attach; | ||||
static device_detach_t xhci_detach; | static device_detach_t xhci_detach; | ||||
#ifdef FDT | |||||
static struct ofw_compat_data compat_data[] = { | static struct ofw_compat_data compat_data[] = { | ||||
{"marvell,armada-380-xhci", true}, | {"marvell,armada-380-xhci", true}, | ||||
{"marvell,armada3700-xhci", true}, | {"marvell,armada3700-xhci", true}, | ||||
{"marvell,armada-8k-xhci", true}, | {"marvell,armada-8k-xhci", true}, | ||||
{"generic-xhci", true}, | {"generic-xhci", true}, | ||||
{NULL, false} | {NULL, false} | ||||
}; | }; | ||||
static int | static int | ||||
xhci_probe(device_t dev) | xhci_fdt_probe(device_t dev) | ||||
{ | { | ||||
if (!ofw_bus_status_okay(dev)) | if (!ofw_bus_status_okay(dev)) | ||||
return (ENXIO); | return (ENXIO); | ||||
if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) | if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) | ||||
return (ENXIO); | return (ENXIO); | ||||
device_set_desc(dev, XHCI_HC_DEVSTR); | device_set_desc(dev, XHCI_HC_DEVSTR); | ||||
return (BUS_PROBE_DEFAULT); | return (BUS_PROBE_DEFAULT); | ||||
} | } | ||||
#endif | |||||
#ifdef DEV_ACPI | |||||
static int | static int | ||||
xhci_acpi_probe(device_t dev) | |||||
{ | |||||
ACPI_HANDLE h; | |||||
if ((h = acpi_get_handle(dev)) == NULL || | |||||
acpi_MatchHid(h, "PNP0D10") == ACPI_MATCHHID_NOMATCH) | |||||
return (ENXIO); | |||||
device_set_desc_copy(dev, XHCI_HC_DEVSTR); | |||||
return (BUS_PROBE_DEFAULT); | |||||
} | |||||
#endif | |||||
static int | |||||
xhci_attach(device_t dev) | xhci_attach(device_t dev) | ||||
{ | { | ||||
struct xhci_softc *sc = device_get_softc(dev); | struct xhci_softc *sc = device_get_softc(dev); | ||||
int err = 0, rid = 0; | int err = 0, rid = 0; | ||||
#ifdef EXT_RESOURCES | #ifdef EXT_RESOURCES | ||||
phandle_t node; | phandle_t node; | ||||
phy_t phy; | phy_t phy; | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | if (sc->sc_io_res != NULL) { | ||||
sc->sc_io_res = NULL; | sc->sc_io_res = NULL; | ||||
} | } | ||||
xhci_uninit(sc); | xhci_uninit(sc); | ||||
return (0); | return (0); | ||||
} | } | ||||
static device_method_t xhci_methods[] = { | #ifdef FDT | ||||
static device_method_t xhci_fdt_methods[] = { | |||||
/* Device interface */ | /* Device interface */ | ||||
DEVMETHOD(device_probe, xhci_probe), | DEVMETHOD(device_probe, xhci_fdt_probe), | ||||
DEVMETHOD(device_attach, xhci_attach), | DEVMETHOD(device_attach, xhci_attach), | ||||
DEVMETHOD(device_detach, xhci_detach), | DEVMETHOD(device_detach, xhci_detach), | ||||
DEVMETHOD(device_suspend, bus_generic_suspend), | DEVMETHOD(device_suspend, bus_generic_suspend), | ||||
DEVMETHOD(device_resume, bus_generic_resume), | DEVMETHOD(device_resume, bus_generic_resume), | ||||
DEVMETHOD(device_shutdown, bus_generic_shutdown), | DEVMETHOD(device_shutdown, bus_generic_shutdown), | ||||
DEVMETHOD_END | DEVMETHOD_END | ||||
}; | }; | ||||
static driver_t xhci_driver = { | static driver_t xhci_fdt_driver = { | ||||
"xhci", | "xhci", | ||||
xhci_methods, | xhci_fdt_methods, | ||||
sizeof(struct xhci_softc), | sizeof(struct xhci_softc), | ||||
}; | }; | ||||
static devclass_t xhci_devclass; | static devclass_t xhci_fdt_devclass; | ||||
DRIVER_MODULE(xhci, simplebus, xhci_driver, xhci_devclass, 0, 0); | DRIVER_MODULE(xhci_fdt, simplebus, xhci_fdt_driver, xhci_fdt_devclass, 0, 0); | ||||
MODULE_DEPEND(xhci, usb, 1, 1, 1); | MODULE_DEPEND(xhci_fdt, usb, 1, 1, 1); | ||||
#endif | |||||
#ifdef DEV_ACPI | |||||
static device_method_t xhci_acpi_methods[] = { | |||||
/* Device interface */ | |||||
DEVMETHOD(device_probe, xhci_acpi_probe), | |||||
DEVMETHOD(device_attach, xhci_attach), | |||||
DEVMETHOD(device_detach, xhci_detach), | |||||
DEVMETHOD(device_suspend, bus_generic_suspend), | |||||
DEVMETHOD(device_resume, bus_generic_resume), | |||||
DEVMETHOD(device_shutdown, bus_generic_shutdown), | |||||
DEVMETHOD_END | |||||
}; | |||||
static driver_t xhci_acpi_driver = { | |||||
"xhci", | |||||
xhci_acpi_methods, | |||||
sizeof(struct xhci_softc), | |||||
}; | |||||
static devclass_t xhci_acpi_devclass; | |||||
DRIVER_MODULE(xhci_acpi, acpi, xhci_acpi_driver, xhci_acpi_devclass, 0, 0); | |||||
MODULE_DEPEND(xhci_acpi, usb, 1, 1, 1); | |||||
#endif |