From nobody Tue Jun 28 13:04:21 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5A02586F271; Tue, 28 Jun 2022 13:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LXPts25bVz3rp4; Tue, 28 Jun 2022 13:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656421461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KJZR1/SG78cQvyZsXpuHeMqJB2UEr616tWeE0amUMzA=; b=LhjhwE2fVlGpJ+zngn0FDYSKiijIteUTqbn7TOnYGe9JuZc16Aw9IANKxRW5xVGdS52kSY qMVKoZO3r1ZncywrR5llj94c7AbyFUBejy9Cb220iGv+S26vyZ8q9asmNhZPReKSg5M56u 6yi0qfKgbQkqacsi09WFIFK6kPNzE0scIGpnbjtuAqRo/jbStYGgMglWnk3fPeC22EJ+OJ Lwj+SFEH8rcvN97MokQaor/ZuwfIyvTDQ+NrttNzzV/k2+pPnfEzpXA2NJLmzMx4pIClAM jCWBH2NmLJS+tYwTjV8ZPcmY2jqvt3u2hhXIxHgjIHk5rAdzkdiVg+/m8IZWQw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 27D3B1D7F2; Tue, 28 Jun 2022 13:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25SD4LjU050831; Tue, 28 Jun 2022 13:04:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25SD4LNr050830; Tue, 28 Jun 2022 13:04:21 GMT (envelope-from git) Date: Tue, 28 Jun 2022 13:04:21 GMT Message-Id: <202206281304.25SD4LNr050830@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: b11f52f4db44 - main - USB: dwc3: use device_{has,get}_property() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b11f52f4db4420f69da537e5ed9b54b7c4fef093 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656421461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KJZR1/SG78cQvyZsXpuHeMqJB2UEr616tWeE0amUMzA=; b=iZ9lG9yVWBkDSzKYZVAKPT5ZSIImemniJzcZCJqNE9WTts0rOCaBi44y4KLdBIOMjcA5bT KykNHMVT52Cie+uKouGEGwgY1nfKHqAthy7aUBsss6ZdwrVZVfAb9V+L/J1Y+00Ff2Djg0 qJUH1n85xMQej2vmbWgNkAGacUkCwzOtVXGtW/aSqPkcY0SsZ4gl+wKGp1+I1P9vysF6tW T2xQe9epMaxuVJyuS9oqa33BsEFpP/jyXQ5ugNSKMcDfqLXiSMpczPehVw6eoh7kLvAiry GhQ8nqVYIuUcpPik8dGlphTg/2676BqR7pRaAs5erAkDfTaFzxL6Vva4sVt4Ig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656421461; a=rsa-sha256; cv=none; b=bdygBWjkF/lA8+nZ3rr4dV5VKVj99wDzXf3AUtsZjIfay5sFKz1UXN8nMjJ7lyycvXMTFY hVw69Zn5srQMXaGScZvfZITRd3WMUOz5wPtwo1EE7G5TiOe3Npcg8K8BQoVuaud+rdJbZA uxo6gyjYvq0xLsKCPerdXNADNd5GbrFeylPCdcMjzK2+8emdAciMmWRa1UxLveN4Xrs/Ww XS1Z20msW/DshtlFcK9t7+nivl+A+5sfRPAaiN6qbjoeKvz6wj4SWUTnNlVDKDaoaQhJM8 eqg6Q/TOZvcupzgSHbI40wsHnzNxsul+Ga3i3StpqhGNgCPOaorXSFRGtgfe+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=b11f52f4db4420f69da537e5ed9b54b7c4fef093 commit b11f52f4db4420f69da537e5ed9b54b7c4fef093 Author: Bjoern A. Zeeb AuthorDate: 2021-11-29 19:26:52 +0000 Commit: Bjoern A. Zeeb CommitDate: 2022-06-28 13:02:11 +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. MFC after: 2 weeks Reviewed by: mw Differential Revision: https://reviews.freebsd.org/D33170 --- 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 9847afb952eb..a3c84b40101a 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);