diff --git a/sys/dev/usb/controller/generic_xhci.c b/sys/dev/usb/controller/generic_xhci.c --- a/sys/dev/usb/controller/generic_xhci.c +++ b/sys/dev/usb/controller/generic_xhci.c @@ -61,7 +61,13 @@ #include "generic_xhci.h" +#if __SIZEOF_LONG__ == 8 +#define IS_DMA_32B 0 +#elif __SIZEOF_LONG__ == 4 #define IS_DMA_32B 1 +#else +#error unsupported long size +#endif int generic_xhci_attach(device_t dev) @@ -114,7 +120,8 @@ return (err); } - err = xhci_init(sc, dev, IS_DMA_32B); + err = xhci_init(sc, dev, + (sc->sc_quirks & XHCI_QUIRK_DMA_32B) == 0 ? IS_DMA_32B : 1); if (err != 0) { device_printf(dev, "Failed to init XHCI, with error %d\n", err); generic_xhci_detach(dev); diff --git a/sys/dev/usb/controller/generic_xhci_fdt.c b/sys/dev/usb/controller/generic_xhci_fdt.c --- a/sys/dev/usb/controller/generic_xhci_fdt.c +++ b/sys/dev/usb/controller/generic_xhci_fdt.c @@ -55,12 +55,16 @@ #include "generic_xhci.h" +/* Flags for the OFW compat data table */ +#define XHCI_FDT_MATCH 0x01 +#define XHCI_FDT_32BIT_DMA 0x02 /* Controller needs 32-bit DMA */ + static struct ofw_compat_data compat_data[] = { - {"marvell,armada-380-xhci", true}, - {"marvell,armada3700-xhci", true}, - {"marvell,armada-8k-xhci", true}, - {"generic-xhci", true}, - {NULL, false} + {"marvell,armada-380-xhci", XHCI_FDT_MATCH}, + {"marvell,armada3700-xhci", XHCI_FDT_MATCH}, + {"marvell,armada-8k-xhci", XHCI_FDT_MATCH}, + {"generic-xhci", XHCI_FDT_MATCH}, + {NULL, 0} }; static int @@ -81,14 +85,20 @@ static int generic_xhci_fdt_attach(device_t dev) { + struct xhci_softc *sc = device_get_softc(dev); phandle_t node; phy_t phy; + int flags; node = ofw_bus_get_node(dev); if (phy_get_by_ofw_property(dev, node, "usb-phy", &phy) == 0) if (phy_enable(phy) != 0) device_printf(dev, "Cannot enable phy\n"); + flags = ofw_bus_search_compatible(dev, compat_data)->ocd_data; + if ((flags & XHCI_FDT_32BIT_DMA) != 0) + sc->sc_quirks |= XHCI_QUIRK_DMA_32B; + return (generic_xhci_attach(dev)); } diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h --- a/sys/dev/usb/controller/xhci.h +++ b/sys/dev/usb/controller/xhci.h @@ -488,6 +488,7 @@ enum xhci_quirks { XHCI_QUIRK_DISABLE_PORT_PED = 0x00000001, + XHCI_QUIRK_DMA_32B = 0x00000002, }; struct xhci_softc {