Lines Matching +full:rk3328 +full:- +full:dwc3
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
5 * Copyright (c) 2021-2022 Bjoern A. Zeeb <bz@FreeBSD.ORG>
57 #include <dev/usb/controller/dwc3/dwc3.h>
95 bus_space_write_4(_sc->bst, _sc->bsh, _off, _val)
97 bus_space_read_4(_sc->bst, _sc->bsh, _off)
106 USB_BUS_UNLOCK(&sc->sc_bus); in xhci_interrupt_poll()
108 USB_BUS_LOCK(&sc->sc_bus); in xhci_interrupt_poll()
109 usb_callout_reset(&sc->sc_callout, 1, (void *)&xhci_interrupt_poll, sc); in xhci_interrupt_poll()
116 struct xhci_softc *sc = &snps_sc->sc; in snps_dwc3_attach_xhci()
119 sc->sc_io_res = snps_sc->mem_res; in snps_dwc3_attach_xhci()
120 sc->sc_io_tag = snps_sc->bst; in snps_dwc3_attach_xhci()
121 sc->sc_io_hdl = snps_sc->bsh; in snps_dwc3_attach_xhci()
122 sc->sc_io_size = rman_get_size(snps_sc->mem_res); in snps_dwc3_attach_xhci()
124 sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, in snps_dwc3_attach_xhci()
126 if (sc->sc_irq_res == NULL) { in snps_dwc3_attach_xhci()
131 sc->sc_bus.bdev = device_add_child(dev, "usbus", DEVICE_UNIT_ANY); in snps_dwc3_attach_xhci()
132 if (sc->sc_bus.bdev == NULL) { in snps_dwc3_attach_xhci()
137 device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); in snps_dwc3_attach_xhci()
139 sprintf(sc->sc_vendor, "Synopsys"); in snps_dwc3_attach_xhci()
140 device_set_desc(sc->sc_bus.bdev, "Synopsys"); in snps_dwc3_attach_xhci()
143 err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, in snps_dwc3_attach_xhci()
144 NULL, (driver_intr_t *)xhci_interrupt, sc, &sc->sc_intr_hdl); in snps_dwc3_attach_xhci()
147 sc->sc_intr_hdl = NULL; in snps_dwc3_attach_xhci()
158 usb_callout_init_mtx(&sc->sc_callout, &sc->sc_bus.bus_mtx, 0); in snps_dwc3_attach_xhci()
162 USB_BUS_LOCK(&sc->sc_bus); in snps_dwc3_attach_xhci()
164 USB_BUS_UNLOCK(&sc->sc_bus); in snps_dwc3_attach_xhci()
173 device_printf(sc->sc_bus.bdev, "trying to attach\n"); in snps_dwc3_attach_xhci()
174 err = device_probe_and_attach(sc->sc_bus.bdev); in snps_dwc3_attach_xhci()
193 device_printf(sc->dev, "%s: %s:\n", __func__, msg ? msg : ""); in snsp_dwc3_dump_regs()
196 device_printf(sc->dev, "GCTL: %#012x\n", reg); in snsp_dwc3_dump_regs()
198 device_printf(sc->dev, "GUCTL: %#012x\n", reg); in snsp_dwc3_dump_regs()
200 device_printf(sc->dev, "GUCTL1: %#012x\n", reg); in snsp_dwc3_dump_regs()
202 device_printf(sc->dev, "GUSB2PHYCFG0: %#012x\n", reg); in snsp_dwc3_dump_regs()
204 device_printf(sc->dev, "GUSB3PIPECTL0: %#012x\n", reg); in snsp_dwc3_dump_regs()
206 device_printf(sc->dev, "DCFG: %#012x\n", reg); in snsp_dwc3_dump_regs()
208 xsc = &sc->sc; in snsp_dwc3_dump_regs()
209 device_printf(sc->dev, "xhci quirks: %#012x\n", xsc->sc_quirks); in snsp_dwc3_dump_regs()
226 device_printf(sc->dev, "hwparams[%d]: %#012x\n", i, reg); in snps_dwc3_dump_ctrlparams()
281 * host respond with a non-terminating retry ACK. in snps_dwc3_configure_host()
325 if (device_has_property(sc->dev, "snps,dis-u2-freeclk-exists-quirk")) in snps_dwc3_do_quirks()
329 if (device_has_property(sc->dev, "snps,dis_u2_susphy_quirk")) in snps_dwc3_do_quirks()
334 if (device_has_property(sc->dev, "snps,dis_enblslpm_quirk")) in snps_dwc3_do_quirks()
341 if (device_has_property(sc->dev, "snps,dis-tx-ipgap-linecheck-quirk")) in snps_dwc3_do_quirks()
346 if (device_has_property(sc->dev, "snps,dis-del-phy-power-chg-quirk")) in snps_dwc3_do_quirks()
348 if (device_has_property(sc->dev, "snps,dis_rxdet_inp3_quirk")) in snps_dwc3_do_quirks()
350 if (device_has_property(sc->dev, "snps,dis_u3_susphy_quirk")) in snps_dwc3_do_quirks()
358 if ((sc->snpsid & 0xffff) <= 0x300a) { in snps_dwc3_do_quirks()
359 xsc = &sc->sc; in snps_dwc3_do_quirks()
360 xsc->sc_quirks |= XHCI_QUIRK_DISABLE_PORT_PED; in snps_dwc3_do_quirks()
372 if (s == -1) { in snps_dwc3_probe_common()
383 device_set_desc(dev, "Synopsys Designware DWC3"); in snps_dwc3_probe_common()
399 sc->dev = dev; in snps_dwc3_common_attach()
402 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in snps_dwc3_common_attach()
404 if (sc->mem_res == NULL) { in snps_dwc3_common_attach()
408 sc->bst = rman_get_bustag(sc->mem_res); in snps_dwc3_common_attach()
409 sc->bsh = rman_get_bushandle(sc->mem_res); in snps_dwc3_common_attach()
411 sc->snpsid = DWC3_READ(sc, DWC3_GSNPSID); in snps_dwc3_common_attach()
412 sc->snpsversion = DWC3_VERSION(sc->snpsid); in snps_dwc3_common_attach()
413 sc->snpsrevision = DWC3_REVISION(sc->snpsid); in snps_dwc3_common_attach()
414 if (sc->snpsversion == DWC3_1_IP_ID || in snps_dwc3_common_attach()
415 sc->snpsversion == DWC3_2_IP_ID) { in snps_dwc3_common_attach()
416 sc->snpsrevision = DWC3_READ(sc, DWC3_1_VER_NUMBER); in snps_dwc3_common_attach()
417 sc->snpsversion_type = DWC3_READ(sc, DWC3_1_VER_TYPE); in snps_dwc3_common_attach()
420 switch (sc->snpsversion) { in snps_dwc3_common_attach()
422 device_printf(sc->dev, "SNPS Version: DWC3 (%x %x)\n", in snps_dwc3_common_attach()
423 sc->snpsversion, sc->snpsrevision); in snps_dwc3_common_attach()
426 device_printf(sc->dev, "SNPS Version: DWC3.1 (%x %x %x)\n", in snps_dwc3_common_attach()
427 sc->snpsversion, sc->snpsrevision, in snps_dwc3_common_attach()
428 sc->snpsversion_type); in snps_dwc3_common_attach()
431 device_printf(sc->dev, "SNPS Version: DWC3.2 (%x %x %x)\n", in snps_dwc3_common_attach()
432 sc->snpsversion, sc->snpsrevision, in snps_dwc3_common_attach()
433 sc->snpsversion_type); in snps_dwc3_common_attach()
448 if (ofw_bus_is_compatible(dev, "rockchip,rk3328-dwc3") == 1 || in snps_dwc3_common_attach()
449 ofw_bus_is_compatible(dev, "rockchip,rk3568-dwc3") == 1) { in snps_dwc3_common_attach()
450 if (clk_get_by_ofw_name(dev, node, "ref_clk", &sc->clk_ref) != 0) in snps_dwc3_common_attach()
452 if (clk_get_by_ofw_name(dev, node, "suspend_clk", &sc->clk_suspend) != 0) in snps_dwc3_common_attach()
454 if (clk_get_by_ofw_name(dev, node, "bus_clk", &sc->clk_bus) != 0) in snps_dwc3_common_attach()
458 if (sc->clk_ref != NULL) { in snps_dwc3_common_attach()
459 if (clk_enable(sc->clk_ref) != 0) in snps_dwc3_common_attach()
462 if (sc->clk_suspend != NULL) { in snps_dwc3_common_attach()
463 if (clk_enable(sc->clk_suspend) != 0) in snps_dwc3_common_attach()
466 if (sc->clk_bus != NULL) { in snps_dwc3_common_attach()
467 if (clk_enable(sc->clk_bus) != 0) in snps_dwc3_common_attach()
473 error = phy_get_by_ofw_name(dev, node, "usb2-phy", &usb2_phy); in snps_dwc3_common_attach()
476 error = phy_get_by_ofw_name(dev, node, "usb3-phy", &usb3_phy); in snps_dwc3_common_attach()
479 if (sc->snpsversion == DWC3_IP_ID) { in snps_dwc3_common_attach()
480 if (sc->snpsrevision >= 0x290A) { in snps_dwc3_common_attach()
511 if (sc->clk_ref != NULL) in snps_dwc3_common_attach()
512 clk_disable(sc->clk_ref); in snps_dwc3_common_attach()
513 if (sc->clk_suspend != NULL) in snps_dwc3_common_attach()
514 clk_disable(sc->clk_suspend); in snps_dwc3_common_attach()
515 if (sc->clk_bus != NULL) in snps_dwc3_common_attach()
516 clk_disable(sc->clk_bus); in snps_dwc3_common_attach()
524 { "snps,dwc3", 1 },
535 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) in snps_dwc3_fdt_probe()
585 * some other means to identify the device as dwc3. in snps_dwc3_acpi_probe()