1*fe75646aSEmmanuel Vadot /*- 2*fe75646aSEmmanuel Vadot * SPDX-License-Identifier: BSD-2-Clause 3*fe75646aSEmmanuel Vadot * 4*fe75646aSEmmanuel Vadot * Copyright (c) 2019 Emmanuel Vadot <manu@FreeBSD.Org> 5*fe75646aSEmmanuel Vadot * Copyright (c) 2021-2022 Bjoern A. Zeeb <bz@FreeBSD.ORG> 6*fe75646aSEmmanuel Vadot * 7*fe75646aSEmmanuel Vadot * Redistribution and use in source and binary forms, with or without 8*fe75646aSEmmanuel Vadot * modification, are permitted provided that the following conditions 9*fe75646aSEmmanuel Vadot * are met: 10*fe75646aSEmmanuel Vadot * 1. Redistributions of source code must retain the above copyright 11*fe75646aSEmmanuel Vadot * notice, this list of conditions and the following disclaimer. 12*fe75646aSEmmanuel Vadot * 2. Redistributions in binary form must reproduce the above copyright 13*fe75646aSEmmanuel Vadot * notice, this list of conditions and the following disclaimer in the 14*fe75646aSEmmanuel Vadot * documentation and/or other materials provided with the distribution. 15*fe75646aSEmmanuel Vadot * 16*fe75646aSEmmanuel Vadot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17*fe75646aSEmmanuel Vadot * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*fe75646aSEmmanuel Vadot * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*fe75646aSEmmanuel Vadot * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20*fe75646aSEmmanuel Vadot * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*fe75646aSEmmanuel Vadot * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*fe75646aSEmmanuel Vadot * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*fe75646aSEmmanuel Vadot * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*fe75646aSEmmanuel Vadot * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*fe75646aSEmmanuel Vadot * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*fe75646aSEmmanuel Vadot * SUCH DAMAGE. 27*fe75646aSEmmanuel Vadot */ 28*fe75646aSEmmanuel Vadot 29*fe75646aSEmmanuel Vadot #include <sys/cdefs.h> 30*fe75646aSEmmanuel Vadot #include "opt_platform.h" 31*fe75646aSEmmanuel Vadot #include "opt_acpi.h" 32*fe75646aSEmmanuel Vadot 33*fe75646aSEmmanuel Vadot #include <sys/param.h> 34*fe75646aSEmmanuel Vadot #include <sys/systm.h> 35*fe75646aSEmmanuel Vadot #include <sys/bus.h> 36*fe75646aSEmmanuel Vadot #include <sys/rman.h> 37*fe75646aSEmmanuel Vadot #include <sys/condvar.h> 38*fe75646aSEmmanuel Vadot #include <sys/kernel.h> 39*fe75646aSEmmanuel Vadot #include <sys/module.h> 40*fe75646aSEmmanuel Vadot #include <sys/mutex.h> 41*fe75646aSEmmanuel Vadot #ifdef FDT 42*fe75646aSEmmanuel Vadot #include <sys/gpio.h> 43*fe75646aSEmmanuel Vadot #endif 44*fe75646aSEmmanuel Vadot 45*fe75646aSEmmanuel Vadot #include <machine/bus.h> 46*fe75646aSEmmanuel Vadot 47*fe75646aSEmmanuel Vadot #include <dev/usb/usb.h> 48*fe75646aSEmmanuel Vadot #include <dev/usb/usbdi.h> 49*fe75646aSEmmanuel Vadot 50*fe75646aSEmmanuel Vadot #include <dev/usb/usb_core.h> 51*fe75646aSEmmanuel Vadot #include <dev/usb/usb_busdma.h> 52*fe75646aSEmmanuel Vadot #include <dev/usb/usb_process.h> 53*fe75646aSEmmanuel Vadot 54*fe75646aSEmmanuel Vadot #include <dev/usb/usb_controller.h> 55*fe75646aSEmmanuel Vadot #include <dev/usb/usb_bus.h> 56*fe75646aSEmmanuel Vadot #include <dev/usb/controller/generic_xhci.h> 57*fe75646aSEmmanuel Vadot #include <dev/usb/controller/xhci.h> 58*fe75646aSEmmanuel Vadot #include <dev/usb/controller/dwc3/dwc3.h> 59*fe75646aSEmmanuel Vadot 60*fe75646aSEmmanuel Vadot #ifdef FDT 61*fe75646aSEmmanuel Vadot #include <dev/fdt/simplebus.h> 62*fe75646aSEmmanuel Vadot 63*fe75646aSEmmanuel Vadot #include <dev/fdt/fdt_common.h> 64*fe75646aSEmmanuel Vadot #include <dev/ofw/ofw_bus.h> 65*fe75646aSEmmanuel Vadot #include <dev/ofw/ofw_bus_subr.h> 66*fe75646aSEmmanuel Vadot #include <dev/ofw/ofw_subr.h> 67*fe75646aSEmmanuel Vadot 68*fe75646aSEmmanuel Vadot #include <dev/extres/clk/clk.h> 69*fe75646aSEmmanuel Vadot #include <dev/extres/phy/phy_usb.h> 70*fe75646aSEmmanuel Vadot #endif 71*fe75646aSEmmanuel Vadot 72*fe75646aSEmmanuel Vadot #ifdef DEV_ACPI 73*fe75646aSEmmanuel Vadot #include <contrib/dev/acpica/include/acpi.h> 74*fe75646aSEmmanuel Vadot #include <contrib/dev/acpica/include/accommon.h> 75*fe75646aSEmmanuel Vadot #include <dev/acpica/acpivar.h> 76*fe75646aSEmmanuel Vadot #endif 77*fe75646aSEmmanuel Vadot 78*fe75646aSEmmanuel Vadot struct snps_dwc3_softc { 79*fe75646aSEmmanuel Vadot struct xhci_softc sc; 80*fe75646aSEmmanuel Vadot device_t dev; 81*fe75646aSEmmanuel Vadot struct resource * mem_res; 82*fe75646aSEmmanuel Vadot bus_space_tag_t bst; 83*fe75646aSEmmanuel Vadot bus_space_handle_t bsh; 84*fe75646aSEmmanuel Vadot uint32_t snpsid; 85*fe75646aSEmmanuel Vadot uint32_t snpsversion; 86*fe75646aSEmmanuel Vadot uint32_t snpsrevision; 87*fe75646aSEmmanuel Vadot uint32_t snpsversion_type; 88*fe75646aSEmmanuel Vadot #ifdef FDT 89*fe75646aSEmmanuel Vadot clk_t clk_ref; 90*fe75646aSEmmanuel Vadot clk_t clk_suspend; 91*fe75646aSEmmanuel Vadot clk_t clk_bus; 92*fe75646aSEmmanuel Vadot #endif 93*fe75646aSEmmanuel Vadot }; 94*fe75646aSEmmanuel Vadot 95*fe75646aSEmmanuel Vadot #define DWC3_WRITE(_sc, _off, _val) \ 96*fe75646aSEmmanuel Vadot bus_space_write_4(_sc->bst, _sc->bsh, _off, _val) 97*fe75646aSEmmanuel Vadot #define DWC3_READ(_sc, _off) \ 98*fe75646aSEmmanuel Vadot bus_space_read_4(_sc->bst, _sc->bsh, _off) 99*fe75646aSEmmanuel Vadot 100*fe75646aSEmmanuel Vadot #define IS_DMA_32B 1 101*fe75646aSEmmanuel Vadot 102*fe75646aSEmmanuel Vadot static void 103*fe75646aSEmmanuel Vadot xhci_interrupt_poll(void *_sc) 104*fe75646aSEmmanuel Vadot { 105*fe75646aSEmmanuel Vadot struct xhci_softc *sc = _sc; 106*fe75646aSEmmanuel Vadot 107*fe75646aSEmmanuel Vadot USB_BUS_UNLOCK(&sc->sc_bus); 108*fe75646aSEmmanuel Vadot xhci_interrupt(sc); 109*fe75646aSEmmanuel Vadot USB_BUS_LOCK(&sc->sc_bus); 110*fe75646aSEmmanuel Vadot usb_callout_reset(&sc->sc_callout, 1, (void *)&xhci_interrupt_poll, sc); 111*fe75646aSEmmanuel Vadot } 112*fe75646aSEmmanuel Vadot 113*fe75646aSEmmanuel Vadot static int 114*fe75646aSEmmanuel Vadot snps_dwc3_attach_xhci(device_t dev) 115*fe75646aSEmmanuel Vadot { 116*fe75646aSEmmanuel Vadot struct snps_dwc3_softc *snps_sc = device_get_softc(dev); 117*fe75646aSEmmanuel Vadot struct xhci_softc *sc = &snps_sc->sc; 118*fe75646aSEmmanuel Vadot int err = 0, rid = 0; 119*fe75646aSEmmanuel Vadot 120*fe75646aSEmmanuel Vadot sc->sc_io_res = snps_sc->mem_res; 121*fe75646aSEmmanuel Vadot sc->sc_io_tag = snps_sc->bst; 122*fe75646aSEmmanuel Vadot sc->sc_io_hdl = snps_sc->bsh; 123*fe75646aSEmmanuel Vadot sc->sc_io_size = rman_get_size(snps_sc->mem_res); 124*fe75646aSEmmanuel Vadot 125*fe75646aSEmmanuel Vadot sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, 126*fe75646aSEmmanuel Vadot RF_SHAREABLE | RF_ACTIVE); 127*fe75646aSEmmanuel Vadot if (sc->sc_irq_res == NULL) { 128*fe75646aSEmmanuel Vadot device_printf(dev, "Failed to allocate IRQ\n"); 129*fe75646aSEmmanuel Vadot return (ENXIO); 130*fe75646aSEmmanuel Vadot } 131*fe75646aSEmmanuel Vadot 132*fe75646aSEmmanuel Vadot sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); 133*fe75646aSEmmanuel Vadot if (sc->sc_bus.bdev == NULL) { 134*fe75646aSEmmanuel Vadot device_printf(dev, "Failed to add USB device\n"); 135*fe75646aSEmmanuel Vadot return (ENXIO); 136*fe75646aSEmmanuel Vadot } 137*fe75646aSEmmanuel Vadot 138*fe75646aSEmmanuel Vadot device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); 139*fe75646aSEmmanuel Vadot 140*fe75646aSEmmanuel Vadot sprintf(sc->sc_vendor, "Synopsys"); 141*fe75646aSEmmanuel Vadot device_set_desc(sc->sc_bus.bdev, "Synopsys"); 142*fe75646aSEmmanuel Vadot 143*fe75646aSEmmanuel Vadot if (xhci_use_polling() == 0) { 144*fe75646aSEmmanuel Vadot err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, 145*fe75646aSEmmanuel Vadot NULL, (driver_intr_t *)xhci_interrupt, sc, &sc->sc_intr_hdl); 146*fe75646aSEmmanuel Vadot if (err != 0) { 147*fe75646aSEmmanuel Vadot device_printf(dev, "Failed to setup IRQ, %d\n", err); 148*fe75646aSEmmanuel Vadot sc->sc_intr_hdl = NULL; 149*fe75646aSEmmanuel Vadot return (err); 150*fe75646aSEmmanuel Vadot } 151*fe75646aSEmmanuel Vadot } 152*fe75646aSEmmanuel Vadot 153*fe75646aSEmmanuel Vadot err = xhci_init(sc, dev, IS_DMA_32B); 154*fe75646aSEmmanuel Vadot if (err != 0) { 155*fe75646aSEmmanuel Vadot device_printf(dev, "Failed to init XHCI, with error %d\n", err); 156*fe75646aSEmmanuel Vadot return (ENXIO); 157*fe75646aSEmmanuel Vadot } 158*fe75646aSEmmanuel Vadot 159*fe75646aSEmmanuel Vadot usb_callout_init_mtx(&sc->sc_callout, &sc->sc_bus.bus_mtx, 0); 160*fe75646aSEmmanuel Vadot 161*fe75646aSEmmanuel Vadot if (xhci_use_polling() != 0) { 162*fe75646aSEmmanuel Vadot device_printf(dev, "Interrupt polling at %dHz\n", hz); 163*fe75646aSEmmanuel Vadot USB_BUS_LOCK(&sc->sc_bus); 164*fe75646aSEmmanuel Vadot xhci_interrupt_poll(sc); 165*fe75646aSEmmanuel Vadot USB_BUS_UNLOCK(&sc->sc_bus); 166*fe75646aSEmmanuel Vadot } 167*fe75646aSEmmanuel Vadot 168*fe75646aSEmmanuel Vadot err = xhci_start_controller(sc); 169*fe75646aSEmmanuel Vadot if (err != 0) { 170*fe75646aSEmmanuel Vadot device_printf(dev, "Failed to start XHCI controller, with error %d\n", err); 171*fe75646aSEmmanuel Vadot return (ENXIO); 172*fe75646aSEmmanuel Vadot } 173*fe75646aSEmmanuel Vadot 174*fe75646aSEmmanuel Vadot device_printf(sc->sc_bus.bdev, "trying to attach\n"); 175*fe75646aSEmmanuel Vadot err = device_probe_and_attach(sc->sc_bus.bdev); 176*fe75646aSEmmanuel Vadot if (err != 0) { 177*fe75646aSEmmanuel Vadot device_printf(dev, "Failed to initialize USB, with error %d\n", err); 178*fe75646aSEmmanuel Vadot return (ENXIO); 179*fe75646aSEmmanuel Vadot } 180*fe75646aSEmmanuel Vadot 181*fe75646aSEmmanuel Vadot return (0); 182*fe75646aSEmmanuel Vadot } 183*fe75646aSEmmanuel Vadot 184*fe75646aSEmmanuel Vadot #ifdef DWC3_DEBUG 185*fe75646aSEmmanuel Vadot static void 186*fe75646aSEmmanuel Vadot snsp_dwc3_dump_regs(struct snps_dwc3_softc *sc, const char *msg) 187*fe75646aSEmmanuel Vadot { 188*fe75646aSEmmanuel Vadot struct xhci_softc *xsc; 189*fe75646aSEmmanuel Vadot uint32_t reg; 190*fe75646aSEmmanuel Vadot 191*fe75646aSEmmanuel Vadot if (!bootverbose) 192*fe75646aSEmmanuel Vadot return; 193*fe75646aSEmmanuel Vadot 194*fe75646aSEmmanuel Vadot device_printf(sc->dev, "%s: %s:\n", __func__, msg ? msg : ""); 195*fe75646aSEmmanuel Vadot 196*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GCTL); 197*fe75646aSEmmanuel Vadot device_printf(sc->dev, "GCTL: %#012x\n", reg); 198*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GUCTL); 199*fe75646aSEmmanuel Vadot device_printf(sc->dev, "GUCTL: %#012x\n", reg); 200*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GUCTL1); 201*fe75646aSEmmanuel Vadot device_printf(sc->dev, "GUCTL1: %#012x\n", reg); 202*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GUSB2PHYCFG0); 203*fe75646aSEmmanuel Vadot device_printf(sc->dev, "GUSB2PHYCFG0: %#012x\n", reg); 204*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GUSB3PIPECTL0); 205*fe75646aSEmmanuel Vadot device_printf(sc->dev, "GUSB3PIPECTL0: %#012x\n", reg); 206*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_DCFG); 207*fe75646aSEmmanuel Vadot device_printf(sc->dev, "DCFG: %#012x\n", reg); 208*fe75646aSEmmanuel Vadot 209*fe75646aSEmmanuel Vadot xsc = &sc->sc; 210*fe75646aSEmmanuel Vadot device_printf(sc->dev, "xhci quirks: %#012x\n", xsc->sc_quirks); 211*fe75646aSEmmanuel Vadot } 212*fe75646aSEmmanuel Vadot 213*fe75646aSEmmanuel Vadot static void 214*fe75646aSEmmanuel Vadot snps_dwc3_dump_ctrlparams(struct snps_dwc3_softc *sc) 215*fe75646aSEmmanuel Vadot { 216*fe75646aSEmmanuel Vadot const bus_size_t offs[] = { 217*fe75646aSEmmanuel Vadot DWC3_GHWPARAMS0, DWC3_GHWPARAMS1, DWC3_GHWPARAMS2, DWC3_GHWPARAMS3, 218*fe75646aSEmmanuel Vadot DWC3_GHWPARAMS4, DWC3_GHWPARAMS5, DWC3_GHWPARAMS6, DWC3_GHWPARAMS7, 219*fe75646aSEmmanuel Vadot DWC3_GHWPARAMS8, 220*fe75646aSEmmanuel Vadot }; 221*fe75646aSEmmanuel Vadot uint32_t reg; 222*fe75646aSEmmanuel Vadot int i; 223*fe75646aSEmmanuel Vadot 224*fe75646aSEmmanuel Vadot for (i = 0; i < nitems(offs); i++) { 225*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, offs[i]); 226*fe75646aSEmmanuel Vadot if (bootverbose) 227*fe75646aSEmmanuel Vadot device_printf(sc->dev, "hwparams[%d]: %#012x\n", i, reg); 228*fe75646aSEmmanuel Vadot } 229*fe75646aSEmmanuel Vadot } 230*fe75646aSEmmanuel Vadot #endif 231*fe75646aSEmmanuel Vadot 232*fe75646aSEmmanuel Vadot static void 233*fe75646aSEmmanuel Vadot snps_dwc3_reset(struct snps_dwc3_softc *sc) 234*fe75646aSEmmanuel Vadot { 235*fe75646aSEmmanuel Vadot uint32_t gctl, ghwp0, phy2, phy3; 236*fe75646aSEmmanuel Vadot 237*fe75646aSEmmanuel Vadot ghwp0 = DWC3_READ(sc, DWC3_GHWPARAMS0); 238*fe75646aSEmmanuel Vadot 239*fe75646aSEmmanuel Vadot gctl = DWC3_READ(sc, DWC3_GCTL); 240*fe75646aSEmmanuel Vadot gctl |= DWC3_GCTL_CORESOFTRESET; 241*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GCTL, gctl); 242*fe75646aSEmmanuel Vadot 243*fe75646aSEmmanuel Vadot phy2 = DWC3_READ(sc, DWC3_GUSB2PHYCFG0); 244*fe75646aSEmmanuel Vadot phy2 |= DWC3_GUSB2PHYCFG0_PHYSOFTRST; 245*fe75646aSEmmanuel Vadot if ((ghwp0 & DWC3_GHWPARAMS0_MODE_MASK) == 246*fe75646aSEmmanuel Vadot DWC3_GHWPARAMS0_MODE_DUALROLEDEVICE) 247*fe75646aSEmmanuel Vadot phy2 &= ~DWC3_GUSB2PHYCFG0_SUSPENDUSB20; 248*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GUSB2PHYCFG0, phy2); 249*fe75646aSEmmanuel Vadot 250*fe75646aSEmmanuel Vadot phy3 = DWC3_READ(sc, DWC3_GUSB3PIPECTL0); 251*fe75646aSEmmanuel Vadot phy3 |= DWC3_GUSB3PIPECTL0_PHYSOFTRST; 252*fe75646aSEmmanuel Vadot if ((ghwp0 & DWC3_GHWPARAMS0_MODE_MASK) == 253*fe75646aSEmmanuel Vadot DWC3_GHWPARAMS0_MODE_DUALROLEDEVICE) 254*fe75646aSEmmanuel Vadot phy3 &= ~DWC3_GUSB3PIPECTL0_SUSPENDUSB3; 255*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GUSB3PIPECTL0, phy3); 256*fe75646aSEmmanuel Vadot 257*fe75646aSEmmanuel Vadot DELAY(1000); 258*fe75646aSEmmanuel Vadot 259*fe75646aSEmmanuel Vadot phy2 &= ~DWC3_GUSB2PHYCFG0_PHYSOFTRST; 260*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GUSB2PHYCFG0, phy2); 261*fe75646aSEmmanuel Vadot 262*fe75646aSEmmanuel Vadot phy3 &= ~DWC3_GUSB3PIPECTL0_PHYSOFTRST; 263*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GUSB3PIPECTL0, phy3); 264*fe75646aSEmmanuel Vadot 265*fe75646aSEmmanuel Vadot gctl &= ~DWC3_GCTL_CORESOFTRESET; 266*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GCTL, gctl); 267*fe75646aSEmmanuel Vadot 268*fe75646aSEmmanuel Vadot } 269*fe75646aSEmmanuel Vadot 270*fe75646aSEmmanuel Vadot static void 271*fe75646aSEmmanuel Vadot snps_dwc3_configure_host(struct snps_dwc3_softc *sc) 272*fe75646aSEmmanuel Vadot { 273*fe75646aSEmmanuel Vadot uint32_t reg; 274*fe75646aSEmmanuel Vadot 275*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GCTL); 276*fe75646aSEmmanuel Vadot reg &= ~DWC3_GCTL_PRTCAPDIR_MASK; 277*fe75646aSEmmanuel Vadot reg |= DWC3_GCTL_PRTCAPDIR_HOST; 278*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GCTL, reg); 279*fe75646aSEmmanuel Vadot 280*fe75646aSEmmanuel Vadot /* 281*fe75646aSEmmanuel Vadot * Enable the Host IN Auto Retry feature, making the 282*fe75646aSEmmanuel Vadot * host respond with a non-terminating retry ACK. 283*fe75646aSEmmanuel Vadot * XXX If we ever support more than host mode this needs a dr_mode check. 284*fe75646aSEmmanuel Vadot */ 285*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GUCTL); 286*fe75646aSEmmanuel Vadot reg |= DWC3_GUCTL_HOST_AUTO_RETRY; 287*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GUCTL, reg); 288*fe75646aSEmmanuel Vadot } 289*fe75646aSEmmanuel Vadot 290*fe75646aSEmmanuel Vadot #ifdef FDT 291*fe75646aSEmmanuel Vadot static void 292*fe75646aSEmmanuel Vadot snps_dwc3_configure_phy(struct snps_dwc3_softc *sc, phandle_t node) 293*fe75646aSEmmanuel Vadot { 294*fe75646aSEmmanuel Vadot char *phy_type; 295*fe75646aSEmmanuel Vadot uint32_t reg; 296*fe75646aSEmmanuel Vadot int nphy_types; 297*fe75646aSEmmanuel Vadot 298*fe75646aSEmmanuel Vadot phy_type = NULL; 299*fe75646aSEmmanuel Vadot nphy_types = OF_getprop_alloc(node, "phy_type", (void **)&phy_type); 300*fe75646aSEmmanuel Vadot if (nphy_types <= 0) 301*fe75646aSEmmanuel Vadot return; 302*fe75646aSEmmanuel Vadot 303*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GUSB2PHYCFG0); 304*fe75646aSEmmanuel Vadot if (strncmp(phy_type, "utmi_wide", 9) == 0) { 305*fe75646aSEmmanuel Vadot reg &= ~(DWC3_GUSB2PHYCFG0_PHYIF | DWC3_GUSB2PHYCFG0_USBTRDTIM(0xf)); 306*fe75646aSEmmanuel Vadot reg |= DWC3_GUSB2PHYCFG0_PHYIF | 307*fe75646aSEmmanuel Vadot DWC3_GUSB2PHYCFG0_USBTRDTIM(DWC3_GUSB2PHYCFG0_USBTRDTIM_16BITS); 308*fe75646aSEmmanuel Vadot } else { 309*fe75646aSEmmanuel Vadot reg &= ~(DWC3_GUSB2PHYCFG0_PHYIF | DWC3_GUSB2PHYCFG0_USBTRDTIM(0xf)); 310*fe75646aSEmmanuel Vadot reg |= DWC3_GUSB2PHYCFG0_PHYIF | 311*fe75646aSEmmanuel Vadot DWC3_GUSB2PHYCFG0_USBTRDTIM(DWC3_GUSB2PHYCFG0_USBTRDTIM_8BITS); 312*fe75646aSEmmanuel Vadot } 313*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GUSB2PHYCFG0, reg); 314*fe75646aSEmmanuel Vadot OF_prop_free(phy_type); 315*fe75646aSEmmanuel Vadot } 316*fe75646aSEmmanuel Vadot #endif 317*fe75646aSEmmanuel Vadot 318*fe75646aSEmmanuel Vadot static void 319*fe75646aSEmmanuel Vadot snps_dwc3_do_quirks(struct snps_dwc3_softc *sc) 320*fe75646aSEmmanuel Vadot { 321*fe75646aSEmmanuel Vadot struct xhci_softc *xsc; 322*fe75646aSEmmanuel Vadot uint32_t ghwp0, reg; 323*fe75646aSEmmanuel Vadot 324*fe75646aSEmmanuel Vadot ghwp0 = DWC3_READ(sc, DWC3_GHWPARAMS0); 325*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GUSB2PHYCFG0); 326*fe75646aSEmmanuel Vadot if (device_has_property(sc->dev, "snps,dis-u2-freeclk-exists-quirk")) 327*fe75646aSEmmanuel Vadot reg &= ~DWC3_GUSB2PHYCFG0_U2_FREECLK_EXISTS; 328*fe75646aSEmmanuel Vadot else 329*fe75646aSEmmanuel Vadot reg |= DWC3_GUSB2PHYCFG0_U2_FREECLK_EXISTS; 330*fe75646aSEmmanuel Vadot if (device_has_property(sc->dev, "snps,dis_u2_susphy_quirk")) 331*fe75646aSEmmanuel Vadot reg &= ~DWC3_GUSB2PHYCFG0_SUSPENDUSB20; 332*fe75646aSEmmanuel Vadot else if ((ghwp0 & DWC3_GHWPARAMS0_MODE_MASK) == 333*fe75646aSEmmanuel Vadot DWC3_GHWPARAMS0_MODE_DUALROLEDEVICE) 334*fe75646aSEmmanuel Vadot reg |= DWC3_GUSB2PHYCFG0_SUSPENDUSB20; 335*fe75646aSEmmanuel Vadot if (device_has_property(sc->dev, "snps,dis_enblslpm_quirk")) 336*fe75646aSEmmanuel Vadot reg &= ~DWC3_GUSB2PHYCFG0_ENBLSLPM; 337*fe75646aSEmmanuel Vadot else 338*fe75646aSEmmanuel Vadot reg |= DWC3_GUSB2PHYCFG0_ENBLSLPM; 339*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GUSB2PHYCFG0, reg); 340*fe75646aSEmmanuel Vadot 341*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GUCTL1); 342*fe75646aSEmmanuel Vadot if (device_has_property(sc->dev, "snps,dis-tx-ipgap-linecheck-quirk")) 343*fe75646aSEmmanuel Vadot reg |= DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS; 344*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GUCTL1, reg); 345*fe75646aSEmmanuel Vadot 346*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GUSB3PIPECTL0); 347*fe75646aSEmmanuel Vadot if (device_has_property(sc->dev, "snps,dis-del-phy-power-chg-quirk")) 348*fe75646aSEmmanuel Vadot reg &= ~DWC3_GUSB3PIPECTL0_DELAYP1TRANS; 349*fe75646aSEmmanuel Vadot if (device_has_property(sc->dev, "snps,dis_rxdet_inp3_quirk")) 350*fe75646aSEmmanuel Vadot reg |= DWC3_GUSB3PIPECTL0_DISRXDETINP3; 351*fe75646aSEmmanuel Vadot if (device_has_property(sc->dev, "snps,dis_u3_susphy_quirk")) 352*fe75646aSEmmanuel Vadot reg &= ~DWC3_GUSB3PIPECTL0_SUSPENDUSB3; 353*fe75646aSEmmanuel Vadot else if ((ghwp0 & DWC3_GHWPARAMS0_MODE_MASK) == 354*fe75646aSEmmanuel Vadot DWC3_GHWPARAMS0_MODE_DUALROLEDEVICE) 355*fe75646aSEmmanuel Vadot reg |= DWC3_GUSB3PIPECTL0_SUSPENDUSB3; 356*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GUSB3PIPECTL0, reg); 357*fe75646aSEmmanuel Vadot 358*fe75646aSEmmanuel Vadot /* Port Disable does not work on <= 3.00a. Disable PORT_PED. */ 359*fe75646aSEmmanuel Vadot if ((sc->snpsid & 0xffff) <= 0x300a) { 360*fe75646aSEmmanuel Vadot xsc = &sc->sc; 361*fe75646aSEmmanuel Vadot xsc->sc_quirks |= XHCI_QUIRK_DISABLE_PORT_PED; 362*fe75646aSEmmanuel Vadot } 363*fe75646aSEmmanuel Vadot } 364*fe75646aSEmmanuel Vadot 365*fe75646aSEmmanuel Vadot static int 366*fe75646aSEmmanuel Vadot snps_dwc3_probe_common(device_t dev) 367*fe75646aSEmmanuel Vadot { 368*fe75646aSEmmanuel Vadot char dr_mode[16] = { 0 }; 369*fe75646aSEmmanuel Vadot ssize_t s; 370*fe75646aSEmmanuel Vadot 371*fe75646aSEmmanuel Vadot s = device_get_property(dev, "dr_mode", dr_mode, sizeof(dr_mode), 372*fe75646aSEmmanuel Vadot DEVICE_PROP_BUFFER); 373*fe75646aSEmmanuel Vadot if (s == -1) { 374*fe75646aSEmmanuel Vadot device_printf(dev, "Cannot determine dr_mode\n"); 375*fe75646aSEmmanuel Vadot return (ENXIO); 376*fe75646aSEmmanuel Vadot } 377*fe75646aSEmmanuel Vadot if (strcmp(dr_mode, "host") != 0) { 378*fe75646aSEmmanuel Vadot device_printf(dev, 379*fe75646aSEmmanuel Vadot "Found dr_mode '%s' but only 'host' supported. s=%zd\n", 380*fe75646aSEmmanuel Vadot dr_mode, s); 381*fe75646aSEmmanuel Vadot return (ENXIO); 382*fe75646aSEmmanuel Vadot } 383*fe75646aSEmmanuel Vadot 384*fe75646aSEmmanuel Vadot device_set_desc(dev, "Synopsys Designware DWC3"); 385*fe75646aSEmmanuel Vadot return (BUS_PROBE_DEFAULT); 386*fe75646aSEmmanuel Vadot } 387*fe75646aSEmmanuel Vadot 388*fe75646aSEmmanuel Vadot static int 389*fe75646aSEmmanuel Vadot snps_dwc3_common_attach(device_t dev, bool is_fdt) 390*fe75646aSEmmanuel Vadot { 391*fe75646aSEmmanuel Vadot struct snps_dwc3_softc *sc; 392*fe75646aSEmmanuel Vadot #ifdef FDT 393*fe75646aSEmmanuel Vadot phandle_t node; 394*fe75646aSEmmanuel Vadot phy_t usb2_phy, usb3_phy; 395*fe75646aSEmmanuel Vadot uint32_t reg; 396*fe75646aSEmmanuel Vadot #endif 397*fe75646aSEmmanuel Vadot int error, rid; 398*fe75646aSEmmanuel Vadot 399*fe75646aSEmmanuel Vadot sc = device_get_softc(dev); 400*fe75646aSEmmanuel Vadot sc->dev = dev; 401*fe75646aSEmmanuel Vadot 402*fe75646aSEmmanuel Vadot rid = 0; 403*fe75646aSEmmanuel Vadot sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, 404*fe75646aSEmmanuel Vadot RF_ACTIVE); 405*fe75646aSEmmanuel Vadot if (sc->mem_res == NULL) { 406*fe75646aSEmmanuel Vadot device_printf(dev, "Failed to map memory\n"); 407*fe75646aSEmmanuel Vadot return (ENXIO); 408*fe75646aSEmmanuel Vadot } 409*fe75646aSEmmanuel Vadot sc->bst = rman_get_bustag(sc->mem_res); 410*fe75646aSEmmanuel Vadot sc->bsh = rman_get_bushandle(sc->mem_res); 411*fe75646aSEmmanuel Vadot 412*fe75646aSEmmanuel Vadot sc->snpsid = DWC3_READ(sc, DWC3_GSNPSID); 413*fe75646aSEmmanuel Vadot sc->snpsversion = DWC3_VERSION(sc->snpsid); 414*fe75646aSEmmanuel Vadot sc->snpsrevision = DWC3_REVISION(sc->snpsid); 415*fe75646aSEmmanuel Vadot if (sc->snpsversion == DWC3_1_IP_ID || 416*fe75646aSEmmanuel Vadot sc->snpsversion == DWC3_2_IP_ID) { 417*fe75646aSEmmanuel Vadot sc->snpsrevision = DWC3_READ(sc, DWC3_1_VER_NUMBER); 418*fe75646aSEmmanuel Vadot sc->snpsversion_type = DWC3_READ(sc, DWC3_1_VER_TYPE); 419*fe75646aSEmmanuel Vadot } 420*fe75646aSEmmanuel Vadot if (bootverbose) { 421*fe75646aSEmmanuel Vadot switch (sc->snpsversion) { 422*fe75646aSEmmanuel Vadot case DWC3_IP_ID: 423*fe75646aSEmmanuel Vadot device_printf(sc->dev, "SNPS Version: DWC3 (%x %x)\n", 424*fe75646aSEmmanuel Vadot sc->snpsversion, sc->snpsrevision); 425*fe75646aSEmmanuel Vadot break; 426*fe75646aSEmmanuel Vadot case DWC3_1_IP_ID: 427*fe75646aSEmmanuel Vadot device_printf(sc->dev, "SNPS Version: DWC3.1 (%x %x %x)\n", 428*fe75646aSEmmanuel Vadot sc->snpsversion, sc->snpsrevision, 429*fe75646aSEmmanuel Vadot sc->snpsversion_type); 430*fe75646aSEmmanuel Vadot break; 431*fe75646aSEmmanuel Vadot case DWC3_2_IP_ID: 432*fe75646aSEmmanuel Vadot device_printf(sc->dev, "SNPS Version: DWC3.2 (%x %x %x)\n", 433*fe75646aSEmmanuel Vadot sc->snpsversion, sc->snpsrevision, 434*fe75646aSEmmanuel Vadot sc->snpsversion_type); 435*fe75646aSEmmanuel Vadot break; 436*fe75646aSEmmanuel Vadot } 437*fe75646aSEmmanuel Vadot } 438*fe75646aSEmmanuel Vadot #ifdef DWC3_DEBUG 439*fe75646aSEmmanuel Vadot snps_dwc3_dump_ctrlparams(sc); 440*fe75646aSEmmanuel Vadot #endif 441*fe75646aSEmmanuel Vadot 442*fe75646aSEmmanuel Vadot #ifdef FDT 443*fe75646aSEmmanuel Vadot if (!is_fdt) 444*fe75646aSEmmanuel Vadot goto skip_phys; 445*fe75646aSEmmanuel Vadot 446*fe75646aSEmmanuel Vadot node = ofw_bus_get_node(dev); 447*fe75646aSEmmanuel Vadot 448*fe75646aSEmmanuel Vadot /* Get the clocks if any */ 449*fe75646aSEmmanuel Vadot if (ofw_bus_is_compatible(dev, "rockchip,rk3328-dwc3") == 1 || 450*fe75646aSEmmanuel Vadot ofw_bus_is_compatible(dev, "rockchip,rk3568-dwc3") == 1) { 451*fe75646aSEmmanuel Vadot if (clk_get_by_ofw_name(dev, node, "ref_clk", &sc->clk_ref) != 0) 452*fe75646aSEmmanuel Vadot device_printf(dev, "Cannot get ref_clk\n"); 453*fe75646aSEmmanuel Vadot if (clk_get_by_ofw_name(dev, node, "suspend_clk", &sc->clk_suspend) != 0) 454*fe75646aSEmmanuel Vadot device_printf(dev, "Cannot get suspend_clk\n"); 455*fe75646aSEmmanuel Vadot if (clk_get_by_ofw_name(dev, node, "bus_clk", &sc->clk_bus) != 0) 456*fe75646aSEmmanuel Vadot device_printf(dev, "Cannot get bus_clk\n"); 457*fe75646aSEmmanuel Vadot } 458*fe75646aSEmmanuel Vadot 459*fe75646aSEmmanuel Vadot if (sc->clk_ref != NULL) { 460*fe75646aSEmmanuel Vadot if (clk_enable(sc->clk_ref) != 0) 461*fe75646aSEmmanuel Vadot device_printf(dev, "Cannot enable ref_clk\n"); 462*fe75646aSEmmanuel Vadot } 463*fe75646aSEmmanuel Vadot if (sc->clk_suspend != NULL) { 464*fe75646aSEmmanuel Vadot if (clk_enable(sc->clk_suspend) != 0) 465*fe75646aSEmmanuel Vadot device_printf(dev, "Cannot enable suspend_clk\n"); 466*fe75646aSEmmanuel Vadot } 467*fe75646aSEmmanuel Vadot if (sc->clk_bus != NULL) { 468*fe75646aSEmmanuel Vadot if (clk_enable(sc->clk_bus) != 0) 469*fe75646aSEmmanuel Vadot device_printf(dev, "Cannot enable bus_clk\n"); 470*fe75646aSEmmanuel Vadot } 471*fe75646aSEmmanuel Vadot 472*fe75646aSEmmanuel Vadot /* Get the phys */ 473*fe75646aSEmmanuel Vadot usb2_phy = usb3_phy = NULL; 474*fe75646aSEmmanuel Vadot error = phy_get_by_ofw_name(dev, node, "usb2-phy", &usb2_phy); 475*fe75646aSEmmanuel Vadot if (error == 0 && usb2_phy != NULL) 476*fe75646aSEmmanuel Vadot phy_enable(usb2_phy); 477*fe75646aSEmmanuel Vadot error = phy_get_by_ofw_name(dev, node, "usb3-phy", &usb3_phy); 478*fe75646aSEmmanuel Vadot if (error == 0 && usb3_phy != NULL) 479*fe75646aSEmmanuel Vadot phy_enable(usb3_phy); 480*fe75646aSEmmanuel Vadot if (sc->snpsversion == DWC3_IP_ID) { 481*fe75646aSEmmanuel Vadot if (sc->snpsrevision >= 0x290A) { 482*fe75646aSEmmanuel Vadot uint32_t hwparams3; 483*fe75646aSEmmanuel Vadot 484*fe75646aSEmmanuel Vadot hwparams3 = DWC3_READ(sc, DWC3_GHWPARAMS3); 485*fe75646aSEmmanuel Vadot if (DWC3_HWPARAMS3_SSPHY(hwparams3) == DWC3_HWPARAMS3_SSPHY_DISABLE) { 486*fe75646aSEmmanuel Vadot reg = DWC3_READ(sc, DWC3_GUCTL1); 487*fe75646aSEmmanuel Vadot if (bootverbose) 488*fe75646aSEmmanuel Vadot device_printf(dev, "Forcing USB2 clock only\n"); 489*fe75646aSEmmanuel Vadot reg |= DWC3_GUCTL1_DEV_FORCE_20_CLK_FOR_30_CLK; 490*fe75646aSEmmanuel Vadot DWC3_WRITE(sc, DWC3_GUCTL1, reg); 491*fe75646aSEmmanuel Vadot } 492*fe75646aSEmmanuel Vadot } 493*fe75646aSEmmanuel Vadot } 494*fe75646aSEmmanuel Vadot snps_dwc3_configure_phy(sc, node); 495*fe75646aSEmmanuel Vadot skip_phys: 496*fe75646aSEmmanuel Vadot #endif 497*fe75646aSEmmanuel Vadot 498*fe75646aSEmmanuel Vadot snps_dwc3_reset(sc); 499*fe75646aSEmmanuel Vadot snps_dwc3_configure_host(sc); 500*fe75646aSEmmanuel Vadot snps_dwc3_do_quirks(sc); 501*fe75646aSEmmanuel Vadot 502*fe75646aSEmmanuel Vadot #ifdef DWC3_DEBUG 503*fe75646aSEmmanuel Vadot snsp_dwc3_dump_regs(sc, "Pre XHCI init"); 504*fe75646aSEmmanuel Vadot #endif 505*fe75646aSEmmanuel Vadot error = snps_dwc3_attach_xhci(dev); 506*fe75646aSEmmanuel Vadot #ifdef DWC3_DEBUG 507*fe75646aSEmmanuel Vadot snsp_dwc3_dump_regs(sc, "Post XHCI init"); 508*fe75646aSEmmanuel Vadot #endif 509*fe75646aSEmmanuel Vadot 510*fe75646aSEmmanuel Vadot #ifdef FDT 511*fe75646aSEmmanuel Vadot if (error) { 512*fe75646aSEmmanuel Vadot if (sc->clk_ref != NULL) 513*fe75646aSEmmanuel Vadot clk_disable(sc->clk_ref); 514*fe75646aSEmmanuel Vadot if (sc->clk_suspend != NULL) 515*fe75646aSEmmanuel Vadot clk_disable(sc->clk_suspend); 516*fe75646aSEmmanuel Vadot if (sc->clk_bus != NULL) 517*fe75646aSEmmanuel Vadot clk_disable(sc->clk_bus); 518*fe75646aSEmmanuel Vadot } 519*fe75646aSEmmanuel Vadot #endif 520*fe75646aSEmmanuel Vadot return (error); 521*fe75646aSEmmanuel Vadot } 522*fe75646aSEmmanuel Vadot 523*fe75646aSEmmanuel Vadot #ifdef FDT 524*fe75646aSEmmanuel Vadot static struct ofw_compat_data compat_data[] = { 525*fe75646aSEmmanuel Vadot { "snps,dwc3", 1 }, 526*fe75646aSEmmanuel Vadot { NULL, 0 } 527*fe75646aSEmmanuel Vadot }; 528*fe75646aSEmmanuel Vadot 529*fe75646aSEmmanuel Vadot static int 530*fe75646aSEmmanuel Vadot snps_dwc3_fdt_probe(device_t dev) 531*fe75646aSEmmanuel Vadot { 532*fe75646aSEmmanuel Vadot 533*fe75646aSEmmanuel Vadot if (!ofw_bus_status_okay(dev)) 534*fe75646aSEmmanuel Vadot return (ENXIO); 535*fe75646aSEmmanuel Vadot 536*fe75646aSEmmanuel Vadot if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) 537*fe75646aSEmmanuel Vadot return (ENXIO); 538*fe75646aSEmmanuel Vadot 539*fe75646aSEmmanuel Vadot return (snps_dwc3_probe_common(dev)); 540*fe75646aSEmmanuel Vadot } 541*fe75646aSEmmanuel Vadot 542*fe75646aSEmmanuel Vadot static int 543*fe75646aSEmmanuel Vadot snps_dwc3_fdt_attach(device_t dev) 544*fe75646aSEmmanuel Vadot { 545*fe75646aSEmmanuel Vadot 546*fe75646aSEmmanuel Vadot return (snps_dwc3_common_attach(dev, true)); 547*fe75646aSEmmanuel Vadot } 548*fe75646aSEmmanuel Vadot 549*fe75646aSEmmanuel Vadot static device_method_t snps_dwc3_fdt_methods[] = { 550*fe75646aSEmmanuel Vadot /* Device interface */ 551*fe75646aSEmmanuel Vadot DEVMETHOD(device_probe, snps_dwc3_fdt_probe), 552*fe75646aSEmmanuel Vadot DEVMETHOD(device_attach, snps_dwc3_fdt_attach), 553*fe75646aSEmmanuel Vadot 554*fe75646aSEmmanuel Vadot DEVMETHOD_END 555*fe75646aSEmmanuel Vadot }; 556*fe75646aSEmmanuel Vadot 557*fe75646aSEmmanuel Vadot DEFINE_CLASS_1(snps_dwc3_fdt, snps_dwc3_fdt_driver, snps_dwc3_fdt_methods, 558*fe75646aSEmmanuel Vadot sizeof(struct snps_dwc3_softc), generic_xhci_driver); 559*fe75646aSEmmanuel Vadot 560*fe75646aSEmmanuel Vadot DRIVER_MODULE(snps_dwc3_fdt, simplebus, snps_dwc3_fdt_driver, 0, 0); 561*fe75646aSEmmanuel Vadot MODULE_DEPEND(snps_dwc3_fdt, xhci, 1, 1, 1); 562*fe75646aSEmmanuel Vadot #endif 563*fe75646aSEmmanuel Vadot 564*fe75646aSEmmanuel Vadot #ifdef DEV_ACPI 565*fe75646aSEmmanuel Vadot static char *dwc3_acpi_ids[] = { 566*fe75646aSEmmanuel Vadot "808622B7", /* This was an Intel PCI Vendor/Device ID used. */ 567*fe75646aSEmmanuel Vadot "PNP0D10", /* The generic XHCI PNP ID needing extra probe checks. */ 568*fe75646aSEmmanuel Vadot NULL 569*fe75646aSEmmanuel Vadot }; 570*fe75646aSEmmanuel Vadot 571*fe75646aSEmmanuel Vadot static int 572*fe75646aSEmmanuel Vadot snps_dwc3_acpi_probe(device_t dev) 573*fe75646aSEmmanuel Vadot { 574*fe75646aSEmmanuel Vadot char *match; 575*fe75646aSEmmanuel Vadot int error; 576*fe75646aSEmmanuel Vadot 577*fe75646aSEmmanuel Vadot if (acpi_disabled("snps_dwc3")) 578*fe75646aSEmmanuel Vadot return (ENXIO); 579*fe75646aSEmmanuel Vadot 580*fe75646aSEmmanuel Vadot error = ACPI_ID_PROBE(device_get_parent(dev), dev, dwc3_acpi_ids, &match); 581*fe75646aSEmmanuel Vadot if (error > 0) 582*fe75646aSEmmanuel Vadot return (ENXIO); 583*fe75646aSEmmanuel Vadot 584*fe75646aSEmmanuel Vadot /* 585*fe75646aSEmmanuel Vadot * If we found the Generic XHCI PNP ID we can only attach if we have 586*fe75646aSEmmanuel Vadot * some other means to identify the device as dwc3. 587*fe75646aSEmmanuel Vadot */ 588*fe75646aSEmmanuel Vadot if (strcmp(match, "PNP0D10") == 0) { 589*fe75646aSEmmanuel Vadot /* This is needed in SolidRun's HoneyComb. */ 590*fe75646aSEmmanuel Vadot if (device_has_property(dev, "snps,dis_rxdet_inp3_quirk")) 591*fe75646aSEmmanuel Vadot goto is_dwc3; 592*fe75646aSEmmanuel Vadot 593*fe75646aSEmmanuel Vadot return (ENXIO); 594*fe75646aSEmmanuel Vadot } 595*fe75646aSEmmanuel Vadot 596*fe75646aSEmmanuel Vadot is_dwc3: 597*fe75646aSEmmanuel Vadot return (snps_dwc3_probe_common(dev)); 598*fe75646aSEmmanuel Vadot } 599*fe75646aSEmmanuel Vadot 600*fe75646aSEmmanuel Vadot static int 601*fe75646aSEmmanuel Vadot snps_dwc3_acpi_attach(device_t dev) 602*fe75646aSEmmanuel Vadot { 603*fe75646aSEmmanuel Vadot 604*fe75646aSEmmanuel Vadot return (snps_dwc3_common_attach(dev, false)); 605*fe75646aSEmmanuel Vadot } 606*fe75646aSEmmanuel Vadot 607*fe75646aSEmmanuel Vadot static device_method_t snps_dwc3_acpi_methods[] = { 608*fe75646aSEmmanuel Vadot /* Device interface */ 609*fe75646aSEmmanuel Vadot DEVMETHOD(device_probe, snps_dwc3_acpi_probe), 610*fe75646aSEmmanuel Vadot DEVMETHOD(device_attach, snps_dwc3_acpi_attach), 611*fe75646aSEmmanuel Vadot 612*fe75646aSEmmanuel Vadot DEVMETHOD_END 613*fe75646aSEmmanuel Vadot }; 614*fe75646aSEmmanuel Vadot 615*fe75646aSEmmanuel Vadot DEFINE_CLASS_1(snps_dwc3_acpi, snps_dwc3_acpi_driver, snps_dwc3_acpi_methods, 616*fe75646aSEmmanuel Vadot sizeof(struct snps_dwc3_softc), generic_xhci_driver); 617*fe75646aSEmmanuel Vadot 618*fe75646aSEmmanuel Vadot DRIVER_MODULE(snps_dwc3_acpi, acpi, snps_dwc3_acpi_driver, 0, 0); 619*fe75646aSEmmanuel Vadot MODULE_DEPEND(snps_dwc3_acpi, usb, 1, 1, 1); 620*fe75646aSEmmanuel Vadot #endif 621