Lines Matching +full:usb +full:- +full:phy2

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
5 * Copyright (c) 2021-2022 Bjoern A. Zeeb <bz@FreeBSD.ORG>
47 #include <dev/usb/usb.h>
48 #include <dev/usb/usbdi.h>
50 #include <dev/usb/usb_core.h>
51 #include <dev/usb/usb_busdma.h>
52 #include <dev/usb/usb_process.h>
54 #include <dev/usb/usb_controller.h>
55 #include <dev/usb/usb_bus.h>
56 #include <dev/usb/controller/generic_xhci.h>
57 #include <dev/usb/controller/xhci.h>
58 #include <dev/usb/controller/dwc3/dwc3.h>
96 bus_space_write_4(_sc->bst, _sc->bsh, _off, _val)
98 bus_space_read_4(_sc->bst, _sc->bsh, _off)
107 USB_BUS_UNLOCK(&sc->sc_bus);
109 USB_BUS_LOCK(&sc->sc_bus);
110 usb_callout_reset(&sc->sc_callout, 1, (void *)&xhci_interrupt_poll, sc);
117 struct xhci_softc *sc = &snps_sc->sc;
120 sc->sc_io_res = snps_sc->mem_res;
121 sc->sc_io_tag = snps_sc->bst;
122 sc->sc_io_hdl = snps_sc->bsh;
123 sc->sc_io_size = rman_get_size(snps_sc->mem_res);
125 sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
127 if (sc->sc_irq_res == NULL) {
132 sc->sc_bus.bdev = device_add_child(dev, "usbus", DEVICE_UNIT_ANY);
133 if (sc->sc_bus.bdev == NULL) {
134 device_printf(dev, "Failed to add USB device\n");
138 device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
140 sprintf(sc->sc_vendor, "Synopsys");
141 device_set_desc(sc->sc_bus.bdev, "Synopsys");
144 err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
145 NULL, (driver_intr_t *)xhci_interrupt, sc, &sc->sc_intr_hdl);
148 sc->sc_intr_hdl = NULL;
159 usb_callout_init_mtx(&sc->sc_callout, &sc->sc_bus.bus_mtx, 0);
163 USB_BUS_LOCK(&sc->sc_bus);
165 USB_BUS_UNLOCK(&sc->sc_bus);
174 device_printf(sc->sc_bus.bdev, "trying to attach\n");
175 err = device_probe_and_attach(sc->sc_bus.bdev);
177 device_printf(dev, "Failed to initialize USB, with error %d\n", err);
194 device_printf(sc->dev, "%s: %s:\n", __func__, msg ? msg : "");
197 device_printf(sc->dev, "GCTL: %#012x\n", reg);
199 device_printf(sc->dev, "GUCTL: %#012x\n", reg);
201 device_printf(sc->dev, "GUCTL1: %#012x\n", reg);
203 device_printf(sc->dev, "GUSB2PHYCFG0: %#012x\n", reg);
205 device_printf(sc->dev, "GUSB3PIPECTL0: %#012x\n", reg);
207 device_printf(sc->dev, "DCFG: %#012x\n", reg);
209 xsc = &sc->sc;
210 device_printf(sc->dev, "xhci quirks: %#012x\n", xsc->sc_quirks);
227 device_printf(sc->dev, "hwparams[%d]: %#012x\n", i, reg);
235 uint32_t gctl, ghwp0, phy2, phy3;
243 phy2 = DWC3_READ(sc, DWC3_GUSB2PHYCFG0);
244 phy2 |= DWC3_GUSB2PHYCFG0_PHYSOFTRST;
247 phy2 &= ~DWC3_GUSB2PHYCFG0_SUSPENDUSB20;
248 DWC3_WRITE(sc, DWC3_GUSB2PHYCFG0, phy2);
259 phy2 &= ~DWC3_GUSB2PHYCFG0_PHYSOFTRST;
260 DWC3_WRITE(sc, DWC3_GUSB2PHYCFG0, phy2);
282 * host respond with a non-terminating retry ACK.
326 if (device_has_property(sc->dev, "snps,dis-u2-freeclk-exists-quirk"))
330 if (device_has_property(sc->dev, "snps,dis_u2_susphy_quirk"))
335 if (device_has_property(sc->dev, "snps,dis_enblslpm_quirk"))
342 if (device_has_property(sc->dev, "snps,dis-tx-ipgap-linecheck-quirk"))
347 if (device_has_property(sc->dev, "snps,dis-del-phy-power-chg-quirk"))
349 if (device_has_property(sc->dev, "snps,dis_rxdet_inp3_quirk"))
351 if (device_has_property(sc->dev, "snps,dis_u3_susphy_quirk"))
359 if ((sc->snpsid & 0xffff) <= 0x300a) {
360 xsc = &sc->sc;
361 xsc->sc_quirks |= XHCI_QUIRK_DISABLE_PORT_PED;
373 if (s == -1) {
400 sc->dev = dev;
403 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
405 if (sc->mem_res == NULL) {
409 sc->bst = rman_get_bustag(sc->mem_res);
410 sc->bsh = rman_get_bushandle(sc->mem_res);
412 sc->snpsid = DWC3_READ(sc, DWC3_GSNPSID);
413 sc->snpsversion = DWC3_VERSION(sc->snpsid);
414 sc->snpsrevision = DWC3_REVISION(sc->snpsid);
415 if (sc->snpsversion == DWC3_1_IP_ID ||
416 sc->snpsversion == DWC3_2_IP_ID) {
417 sc->snpsrevision = DWC3_READ(sc, DWC3_1_VER_NUMBER);
418 sc->snpsversion_type = DWC3_READ(sc, DWC3_1_VER_TYPE);
421 switch (sc->snpsversion) {
423 device_printf(sc->dev, "SNPS Version: DWC3 (%x %x)\n",
424 sc->snpsversion, sc->snpsrevision);
427 device_printf(sc->dev, "SNPS Version: DWC3.1 (%x %x %x)\n",
428 sc->snpsversion, sc->snpsrevision,
429 sc->snpsversion_type);
432 device_printf(sc->dev, "SNPS Version: DWC3.2 (%x %x %x)\n",
433 sc->snpsversion, sc->snpsrevision,
434 sc->snpsversion_type);
449 if (ofw_bus_is_compatible(dev, "rockchip,rk3328-dwc3") == 1 ||
450 ofw_bus_is_compatible(dev, "rockchip,rk3568-dwc3") == 1) {
451 if (clk_get_by_ofw_name(dev, node, "ref_clk", &sc->clk_ref) != 0)
453 if (clk_get_by_ofw_name(dev, node, "suspend_clk", &sc->clk_suspend) != 0)
455 if (clk_get_by_ofw_name(dev, node, "bus_clk", &sc->clk_bus) != 0)
459 if (sc->clk_ref != NULL) {
460 if (clk_enable(sc->clk_ref) != 0)
463 if (sc->clk_suspend != NULL) {
464 if (clk_enable(sc->clk_suspend) != 0)
467 if (sc->clk_bus != NULL) {
468 if (clk_enable(sc->clk_bus) != 0)
474 error = phy_get_by_ofw_name(dev, node, "usb2-phy", &usb2_phy);
477 error = phy_get_by_ofw_name(dev, node, "usb3-phy", &usb3_phy);
480 if (sc->snpsversion == DWC3_IP_ID) {
481 if (sc->snpsrevision >= 0x290A) {
512 if (sc->clk_ref != NULL)
513 clk_disable(sc->clk_ref);
514 if (sc->clk_suspend != NULL)
515 clk_disable(sc->clk_suspend);
516 if (sc->clk_bus != NULL)
517 clk_disable(sc->clk_bus);
536 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
619 MODULE_DEPEND(snps_dwc3_acpi, usb, 1, 1, 1);