git: bf7ce294145c - stable/13 - USB: dwc3: use device_{has,get}_property()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 18 Jul 2022 09:50:08 UTC
The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=bf7ce294145c6e5ee4b0459c889f618d1b728fea commit bf7ce294145c6e5ee4b0459c889f618d1b728fea Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2021-11-29 19:26:52 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2022-07-18 01:00:20 +0000 USB: dwc3: use device_{has,get}_property() Switch the driver to use device based functions which will work not only with FDT but also ACPI. While here make dr_mode a local variable as it is only used during probe and not needed later in the softc. Reviewed by: mw Differential Revision: https://reviews.freebsd.org/D33170 (cherry picked from commit b11f52f4db4420f69da537e5ed9b54b7c4fef093) --- sys/dev/usb/controller/dwc3.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/sys/dev/usb/controller/dwc3.c b/sys/dev/usb/controller/dwc3.c index d4422caf0fcd..c77f4bbc0f67 100644 --- a/sys/dev/usb/controller/dwc3.c +++ b/sys/dev/usb/controller/dwc3.c @@ -73,7 +73,6 @@ static struct ofw_compat_data compat_data[] = { struct snps_dwc3_softc { struct xhci_softc sc; device_t dev; - char dr_mode[16]; struct resource * mem_res; bus_space_tag_t bst; bus_space_handle_t bsh; @@ -244,39 +243,38 @@ snps_dwc3_do_quirks(struct snps_dwc3_softc *sc) uint32_t reg; reg = DWC3_READ(sc, DWC3_GUSB2PHYCFG0); - if (OF_hasprop(sc->node, "snps,dis-u2-freeclk-exists-quirk")) + if (device_has_property(sc->dev, "snps,dis-u2-freeclk-exists-quirk")) reg &= ~DWC3_GUSB2PHYCFG0_U2_FREECLK_EXISTS; else reg |= DWC3_GUSB2PHYCFG0_U2_FREECLK_EXISTS; - if (OF_hasprop(sc->node, "snps,dis_u2_susphy_quirk")) + if (device_has_property(sc->dev, "snps,dis_u2_susphy_quirk")) reg &= ~DWC3_GUSB2PHYCFG0_SUSPENDUSB20; else reg |= DWC3_GUSB2PHYCFG0_SUSPENDUSB20; - if (OF_hasprop(sc->node, "snps,dis_enblslpm_quirk")) + if (device_has_property(sc->dev, "snps,dis_enblslpm_quirk")) reg &= ~DWC3_GUSB2PHYCFG0_ENBLSLPM; else reg |= DWC3_GUSB2PHYCFG0_ENBLSLPM; - DWC3_WRITE(sc, DWC3_GUSB2PHYCFG0, reg); reg = DWC3_READ(sc, DWC3_GUCTL1); - if (OF_hasprop(sc->node, "snps,dis-tx-ipgap-linecheck-quirk")) + if (device_has_property(sc->dev, "snps,dis-tx-ipgap-linecheck-quirk")) reg |= DWC3_GUCTL1_TX_IPGAP_LINECHECK_DIS; DWC3_WRITE(sc, DWC3_GUCTL1, reg); reg = DWC3_READ(sc, DWC3_GUSB3PIPECTL0); - if (OF_hasprop(sc->node, "snps,dis-del-phy-power-chg-quirk")) + if (device_has_property(sc->dev, "snps,dis-del-phy-power-chg-quirk")) reg |= DWC3_GUSB3PIPECTL0_DELAYP1TRANS; - if (OF_hasprop(sc->node, "snps,dis_rxdet_inp3_quirk")) + if (device_has_property(sc->dev, "snps,dis_rxdet_inp3_quirk")) reg |= DWC3_GUSB3PIPECTL0_DISRXDETINP3; DWC3_WRITE(sc, DWC3_GUSB3PIPECTL0, reg); - } static int snps_dwc3_probe(device_t dev) { - struct snps_dwc3_softc *sc; + char dr_mode[16]; + ssize_t s; if (!ofw_bus_status_okay(dev)) return (ENXIO); @@ -284,11 +282,16 @@ snps_dwc3_probe(device_t dev) if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) return (ENXIO); - sc = device_get_softc(dev); - sc->node = ofw_bus_get_node(dev); - OF_getprop(sc->node, "dr_mode", sc->dr_mode, sizeof(sc->dr_mode)); - if (strcmp(sc->dr_mode, "host") != 0) { - device_printf(dev, "Only host mode is supported\n"); + s = device_get_property(dev, "dr_mode", dr_mode, sizeof(dr_mode), + DEVICE_PROP_BUFFER); + if (s == -1) { + device_printf(dev, "Cannot determine dr_mode\n"); + return (ENXIO); + } + if (strcmp(dr_mode, "host") != 0) { + device_printf(dev, + "Found dr_mode '%s' but only 'host' supported. s=%zd\n", + dr_mode, s); return (ENXIO); } @@ -318,6 +321,7 @@ snps_dwc3_attach(device_t dev) device_printf(dev, "snps id: %x\n", DWC3_READ(sc, DWC3_GSNPSID)); /* Get the phys */ + sc->node = ofw_bus_get_node(dev); phy_get_by_ofw_name(dev, sc->node, "usb2-phy", &sc->usb2_phy); phy_get_by_ofw_name(dev, sc->node, "usb3-phy", &sc->usb3_phy);