From nobody Thu Jun 23 18:15:59 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 D0848876377; Thu, 23 Jun 2022 18:16:00 +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 4LTT2m3d7sz3P2g; Thu, 23 Jun 2022 18:16:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656008160; 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=5IEZWM5bLcWhwH0ODN1WPfqPAl9oCoduOfNhwz2LgzQ=; b=EWxmyEui3mYvLax/Ed/JVnUWuLUm8iUEhNvgTQJJCmjb5yEP/ksP9BzxOEuOOCm2n69DQ4 qUiz+uskMWG80Ai7UavGjX5RwuG2sOougS2gPQyIkawamOPDnbTljNTZ4379n4yZHh7YLK QRFVigBKjQbkV9txeweaWwvGDmcgJ5DjdZGyDQJGGdGKigy/B6ax7lGHDUcUQluAuDMxsX jvG3vwCEevdSIDAmWtoIbREzHux23Ezgy4BFIVUNfGPzcjqXb7qN4ooy+eYbQ6Uga+wlOw d/E6VQUx8lPdVR69WorqOQUFOGqU5FrWPvHZnvTyUaNkmJYNAhlzHd07t4tg3w== 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 26E4920275; Thu, 23 Jun 2022 18:16:00 +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 25NIFxx9014752; Thu, 23 Jun 2022 18:15:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25NIFx1l014751; Thu, 23 Jun 2022 18:15:59 GMT (envelope-from git) Date: Thu, 23 Jun 2022 18:15:59 GMT Message-Id: <202206231815.25NIFx1l014751@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 3428997cb398 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 3428997cb398767655a5651b76eb177a56e4b00a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656008160; 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=5IEZWM5bLcWhwH0ODN1WPfqPAl9oCoduOfNhwz2LgzQ=; b=SmQV5pd4u00SQolAW+bvsy0cmsUF8mxdCN67O8YlSJTXwlJdRQ9R1xirfdXEoD2NuOrBcQ 0NBL/b2q9zGdPcnPtKGLLiCSr/n5mBrCioktwusBx6tKSTfACOtvpx4qf7vxp/H+EqAPYK 2RVksWeAQAzL/T/Utr8QLjJFRT5luDLkZ15bw5yJuwtQmdmqYDzrN/7iUdYo1zDXGGu5Eg +geoPvUJtRcqKOm0pXfIf8s2g+SklylukWctsWouh/BcPWW0V/jtNY2iSHjGtHLWa/gY1J B6khXzp8Hm208RrQc2t70amjvyLpEd0BB1ElbtXyfjG/rNSuaOxXt+SvZUfECw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656008160; a=rsa-sha256; cv=none; b=siAAQuDmm7lhIFswqr+4tRLXI8zwBWi4NKsnzaaEqc+mnbSatHuPH0cx659wwHYMTtn2Fw usgWC1BtwL7ime9i64GV+jjWyH1zFCEjc4V3OdB6hH41Gy6//qo7Ou4z+zVm6c4kW/Y8PT V+8n8OKlCiRBhZAF1JJjkVDsOP+0X21lth4PlrjkugjMx111Fp7jCCVjSS4HMQT0NKiaAi 2njgxI3ktI3oS2um3/F7krQpYziTlBx9GjmaC6eLSz41AxZ1wML/HpKyZkTMqTJzXd3rwB n8GHJGP+6Ubl+Lke9zJfwgGTZ4y1ERM5OzFQPDKWe0NUiqLlyLKRwb8Oa6OFZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=3428997cb398767655a5651b76eb177a56e4b00a commit 3428997cb398767655a5651b76eb177a56e4b00a Author: Mitchell Horne AuthorDate: 2022-06-21 13:22:53 +0000 Commit: Mitchell Horne CommitDate: 2022-06-23 18:15:10 +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 --- 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 98ff55c6755a..067afbdbd9c4 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 */