From nobody Mon Jul 18 09:50:08 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 4LmcdY1J7fz4WtQ5; Mon, 18 Jul 2022 09:50:09 +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 4LmcdY0rmhz3D3Z; Mon, 18 Jul 2022 09:50:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658137809; 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=VJ4W53ZRTH593DdMi13lHDmNkYHhy/IRvk5rKsyFnm0=; b=XzCjITU04T5H5SRqNbswwvJxZrbvA4dohinwDZVkm1jsgX+RlTkHAvbPqGPrv0VkPqJgD7 1TWHOW2L+974IE1P0/R3BwUUKkxw26P6BQA250Rnlfs/RTqcM2D8An7udHSVRzVu8aIfvZ IqiZsdqP62LmxVAyjw4hqZaXwnPYadzUCQMORxTNmpq9gslTL4AW6PPGpI9ID7eB11rjzJ QweCnVwRRQu6ksGbFU45YOk8rN2N6EkZLVEZtmiTk2wOthCX6ZxN5VBa7a4TJyWEDNXJ2m c9xq+2Yma2D9xGe9Xwsa32f5be1Qj/6+I3L5GClrKwDjqMd8iacC0/zmdxhtcg== 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 4LmcdX6qLCzb2N; Mon, 18 Jul 2022 09:50:08 +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 26I9o8C5034140; Mon, 18 Jul 2022 09:50:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26I9o8Gk034137; Mon, 18 Jul 2022 09:50:08 GMT (envelope-from git) Date: Mon, 18 Jul 2022 09:50:08 GMT Message-Id: <202207180950.26I9o8Gk034137@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: bf7ce294145c - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: bf7ce294145c6e5ee4b0459c889f618d1b728fea Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658137809; 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=VJ4W53ZRTH593DdMi13lHDmNkYHhy/IRvk5rKsyFnm0=; b=O40dwwDQNbO9K0Y5Ogg0obec6eXN+ry29bhGdDOuzBWjMOidHDLo8BFLDvS9uy43pp+xIP BUc/zn0aJUqoedogYrJageeR5OjRv4HHx2t3kaXEWVwdLQ5rscVx27YgvFYrf3pK12nKs3 QOOPNWkJbWjoFSTdK9+FtvjlAVs8Q8ZaF/h+YduKCMRhGP48ZCZmPrXrSCpj9B3LOQAH8O 2MXQApU7iXUi2gHsTRhPyT497WId6N8N0H5hOE5Eq7bVUMoMsuiqiNHTVvFRWRH3LvoQlw 8u7cbEQEOICGKVHT/hAKNze8jpvyApvV4oxXtEgoDFgu+RUEaYY8/u4ToGNF8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658137809; a=rsa-sha256; cv=none; b=r7nOvCUhcRZ7Xp3UYRlPFu9PVvjX1R0fykJ36affFt0VnKDo/8xzKZYXMhuw+lcXMcFDzG WztWN4frKRV5s16AKcNO2r41yFU3zKdD9kVYemnmwqaWKZFzHPFEXySXcpt9vmB8M4EsBX 8DU9zGkewzAWF7JrgYvSdMgD1Hke0YUJcrYVrz4D+Eu1S+5gHxHUE2tmpupGRKso9+WLw+ QNbIpt2ZG0QJGNAV9fUZIOa1TBazYiyFhxrwAtnr1xAgZjjfa5bXycnberoH8jUCdl8vSh c91Bnd0BLkVDBkddUhcLoiK4VAYOok2YkEKBSAoxXEsl/1GOTAyUg9fvTtnYKA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=bf7ce294145c6e5ee4b0459c889f618d1b728fea commit bf7ce294145c6e5ee4b0459c889f618d1b728fea Author: Bjoern A. Zeeb AuthorDate: 2021-11-29 19:26:52 +0000 Commit: Bjoern A. Zeeb 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);