aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern A. Zeeb <bz@FreeBSD.org>2022-07-02 21:10:00 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2022-07-03 22:19:40 +0000
commit11a7d5e5d906f691558e06d4bb93b892de31b446 (patch)
treea5409649eec378749344a5a6890b6f85f5494317
parent09cdf4878c621be4cd229fa88cdccdcdc8c101f7 (diff)
downloadsrc-11a7d5e5d906f691558e06d4bb93b892de31b446.tar.gz
src-11a7d5e5d906f691558e06d4bb93b892de31b446.zip
dwc3: improve debugging
Rather than hiding behind #if 0, hide the debugging behind DWC3_DEBUG so it can be turned on with a single define. Require bootverbose to print anything so we can still avoid spamming the console if DWC3_DEBUG is on. Harmonize the format string in snsp_dwc3_dump_regs() to always print the full register and also print the XHCI quirks. Call snsp_dwc3_dump_regs() twice, before and after generic XHCI attachment and initialisation as this may have an effect on the confirgumation state. Obtained from: an old debug patch MFC after: 2 weeks Reviewed by: mw Differential Revision: https://reviews.freebsd.org/D35700
-rw-r--r--sys/dev/usb/controller/dwc3.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/sys/dev/usb/controller/dwc3.c b/sys/dev/usb/controller/dwc3.c
index 4b5109291cc4..da64512af647 100644
--- a/sys/dev/usb/controller/dwc3.c
+++ b/sys/dev/usb/controller/dwc3.c
@@ -147,22 +147,33 @@ snps_dwc3_attach_xhci(device_t dev)
return (0);
}
-#if 0
+#ifdef DWC3_DEBUG
static void
-snsp_dwc3_dump_regs(struct snps_dwc3_softc *sc)
+snsp_dwc3_dump_regs(struct snps_dwc3_softc *sc, const char *msg)
{
+ struct xhci_softc *xsc;
uint32_t reg;
+ if (!bootverbose)
+ return;
+
+ device_printf(sc->dev, "%s: %s:\n", __func__, msg ? msg : "");
+
reg = DWC3_READ(sc, DWC3_GCTL);
- device_printf(sc->dev, "GCTL: %x\n", reg);
+ device_printf(sc->dev, "GCTL: %#012x\n", reg);
+ reg = DWC3_READ(sc, DWC3_GUCTL);
+ device_printf(sc->dev, "GUCTL: %#012x\n", reg);
reg = DWC3_READ(sc, DWC3_GUCTL1);
- device_printf(sc->dev, "GUCTL1: %x\n", reg);
+ device_printf(sc->dev, "GUCTL1: %#012x\n", reg);
reg = DWC3_READ(sc, DWC3_GUSB2PHYCFG0);
- device_printf(sc->dev, "GUSB2PHYCFG0: %x\n", reg);
+ device_printf(sc->dev, "GUSB2PHYCFG0: %#012x\n", reg);
reg = DWC3_READ(sc, DWC3_GUSB3PIPECTL0);
- device_printf(sc->dev, "GUSB3PIPECTL0: %x\n", reg);
+ device_printf(sc->dev, "GUSB3PIPECTL0: %#012x\n", reg);
reg = DWC3_READ(sc, DWC3_DCFG);
- device_printf(sc->dev, "DCFG: %x\n", reg);
+ device_printf(sc->dev, "DCFG: %#012x\n", reg);
+
+ xsc = &sc->sc;
+ device_printf(sc->dev, "xhci quirks: %#012x\n", xsc->sc_quirks);
}
#endif
@@ -384,10 +395,14 @@ snps_dwc3_attach(device_t dev)
snps_dwc3_configure_host(sc);
snps_dwc3_configure_phy(sc);
snps_dwc3_do_quirks(sc);
-#if 0
- snsp_dwc3_dump_regs(sc);
+
+#ifdef DWC3_DEBUG
+ snsp_dwc3_dump_regs(sc, "Pre XHCI init");
#endif
snps_dwc3_attach_xhci(dev);
+#ifdef DWC3_DEBUG
+ snsp_dwc3_dump_regs(sc, "Post XHCI init");
+#endif
return (0);
}