From nobody Mon Jul 4 16:40:01 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 197431893F9A; Mon, 4 Jul 2022 16:40:02 +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 4LcBNx60jMz4SHf; Mon, 4 Jul 2022 16:40:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656952801; 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=pzEfnsEoqhJMs5WzMZnef9c+TQf+1FPPJ9AqVyXAR88=; b=o7FSYQ2cAgVOHYjXkJJtZUO4mLOeAmn8fWq5hc9FKXkqIpTedVm1jj7DanaNmwW17WYaOo oXQn8EgjyomU5zuBoyhYHMaV/P7eh5/hVrmHECMDkh4eGnZU/+gY9NCccZb5q1e6+nIxr3 E08iS7YclqnAKKeGpr/AwtyQoETuIGhpq1vQM0qUuMZlokqfpJhuxm9q7dTGAjtvc1hCwl cCuuPBbZz17uaBtCk4jarQtLkeNrbJq6QXR5eeGkoueYqzUbwV6q3z8oSqFfXEmHzn9wJu En1jn3r2Cy4a2tk2aguqKhJckwP7tiU4RFlWv+CId1QOyVgb+1cRSh1UIj7r+A== 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 A515214AF4; Mon, 4 Jul 2022 16:40:01 +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 264Ge1um042640; Mon, 4 Jul 2022 16:40:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 264Ge1pJ042627; Mon, 4 Jul 2022 16:40:01 GMT (envelope-from git) Date: Mon, 4 Jul 2022 16:40:01 GMT Message-Id: <202207041640.264Ge1pJ042627@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 1da82ebe499a - stable/13 - if_dwc: recognize additional rgmii phy-modes 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1da82ebe499aec5f505b23238a231f01e77a17c3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656952801; 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=pzEfnsEoqhJMs5WzMZnef9c+TQf+1FPPJ9AqVyXAR88=; b=b2n3RcqBltyM21Lazp4WAx5vYPbxZEqmOiX8a1CVUHWAlNjR6swr7G2leqA3+s99BspvIn fIMy9jqGNLcQWIAGk5BXHWyGQNWNDm1PJa3hK5Qi1OYlstQOkzTdSVTcbOBGe5R+8S8IbF T/X8rzC5NyoiHsg4wQBitkJhXHqtntmdrVD91D2XQnjQKWLlpHtP9CtfxthB/LWmiUnGze 13lUMeJZd8aD4clrUvI5tlIRZdnj75uSLu34Yp8YH7rj+TFayKx2piZe+gUn0U7AqKHbhX jrCMtGugN9EDLU2M1chEmqV8t9VROGBTrHb+fSQvklEwD2y5HJuz+p2UOGdmzA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656952801; a=rsa-sha256; cv=none; b=B1DnaKsyF/ds8GVFqru65XY7qEf3Bj1JXTbTHDmW4RLL+9zmk8TbIi1wRu+doRZwIn7LUN BjreCeCryjDkg0YnmZHxA3mzjryGQyNV/Taw0rMzj34WFJ27T1c8WFp8FRJ+fDCXRUrJjp 3WM+MfttpRR7OBXFVsWYnTfKzr+PM4Es/EQ9OrgI0Sdwmi67GbxH7qvBNIV/7nsuu8IjpE eehEhWwSc4EteiEGdtlNS0RIa65E1TNfdg6dfpYiA7GnQDBgaQSg9sVpFrvqiUFsP20YEq 5rWtHykYDbvABj1f8xwKhc/XBc0YleuKs2C3zWiv3S+aLKGVkBFheU2UBp1Flw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=1da82ebe499aec5f505b23238a231f01e77a17c3 commit 1da82ebe499aec5f505b23238a231f01e77a17c3 Author: Mitchell Horne AuthorDate: 2022-06-21 13:22:53 +0000 Commit: Mitchell Horne CommitDate: 2022-07-04 16:34:56 +0000 if_dwc: recognize additional rgmii phy-modes Per the reports, some Allwinner device trees now list the desired phy-mode as "rgmii-id". The manual string comparison fails to detect this, and we end up falling back to MII mode. Instead, select the clock name using the sc->phy_mode variable, which is set in the main attach function. The logic to actually handle rgmii-id mode delays will be added to the relevant PHY driver. PR: 261355, 264673 Reported by: Maren Reported by: Arie Bikker Reviewed by: manu MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35500 (cherry picked from commit 3428997cb398767655a5651b76eb177a56e4b00a) --- sys/arm/allwinner/aw_if_dwc.c | 55 +++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/sys/arm/allwinner/aw_if_dwc.c b/sys/arm/allwinner/aw_if_dwc.c index fa1742bfeaf3..caf4a7ec40dc 100644 --- a/sys/arm/allwinner/aw_if_dwc.c +++ b/sys/arm/allwinner/aw_if_dwc.c @@ -62,40 +62,43 @@ a20_if_dwc_probe(device_t dev) static int a20_if_dwc_init(device_t dev) { + struct dwc_softc *sc; const char *tx_parent_name; - char *phy_type; clk_t clk_tx, clk_tx_parent; regulator_t reg; - phandle_t node; int error; - node = ofw_bus_get_node(dev); + sc = device_get_softc(dev); /* Configure PHY for MII or RGMII mode */ - if (OF_getprop_alloc(node, "phy-mode", (void **)&phy_type)) { - error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", &clk_tx); - if (error != 0) { - device_printf(dev, "could not get tx clk\n"); - return (error); - } - - if (strcmp(phy_type, "rgmii") == 0) - tx_parent_name = "gmac_int_tx"; - else - tx_parent_name = "mii_phy_tx"; - - error = clk_get_by_name(dev, tx_parent_name, &clk_tx_parent); - if (error != 0) { - device_printf(dev, "could not get clock '%s'\n", - tx_parent_name); - return (error); - } + switch(sc->phy_mode) { + case PHY_MODE_RGMII: + tx_parent_name = "gmac_int_tx"; + break; + case PHY_MODE_MII: + tx_parent_name = "mii_phy_tx"; + break; + default: + device_printf(dev, "unsupported PHY connection type: %d", + sc->phy_mode); + return (ENXIO); + } - error = clk_set_parent_by_clk(clk_tx, clk_tx_parent); - if (error != 0) { - device_printf(dev, "could not set tx clk parent\n"); - return (error); - } + error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", &clk_tx); + if (error != 0) { + device_printf(dev, "could not get tx clk\n"); + return (error); + } + error = clk_get_by_name(dev, tx_parent_name, &clk_tx_parent); + if (error != 0) { + device_printf(dev, "could not get clock '%s'\n", + tx_parent_name); + return (error); + } + error = clk_set_parent_by_clk(clk_tx, clk_tx_parent); + if (error != 0) { + device_printf(dev, "could not set tx clk parent\n"); + return (error); } /* Enable PHY regulator if applicable */