From nobody Thu Aug 11 14:53:19 2022 X-Original-To: dev-commits-src-branches@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 4M3VDH2d8kz4Y7MR; Thu, 11 Aug 2022 14:53:19 +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 4M3VDH28qfz3TQH; Thu, 11 Aug 2022 14:53:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660229599; 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=Vp4ej7BM6a7TN19HWSrhk/MI6LRqMdQJzKZcSssS93Y=; b=F5KyJhF5Jxs7LuV9oW1P0qWRlPvlr2xW3WrLzkh1DyfFHWPKPV7eIzxSElLpDYkWRiCDBY T0TxMekIneHhXJl3EgclcLrz10gtFyHveSSThyg3XYFY1PMmF7JjzkkMxW9WOKarGMbb9/ J+Kuin9fIE3W6mJQWmvPT6xq6ubt7xXmfjTWQGYxv6qP3h4TysqlALyhryPU+GPqSRTaaj D7Df27uZBGRFM9ZOiMgXsWA6Gug8PZZ/X6eiP3nmPORLQbkLajB28uALoV+KB8GW/D7mgS 7v4B+YSF72a0CWkYp25VWzwUc3M1g8KlOSGMHzQpOSzp1SMACBDM/ETLeoUB5A== 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 4M3VDH1GBpzw9B; Thu, 11 Aug 2022 14:53:19 +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 27BErJVZ032528; Thu, 11 Aug 2022 14:53:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27BErJ1L032527; Thu, 11 Aug 2022 14:53:19 GMT (envelope-from git) Date: Thu, 11 Aug 2022 14:53:19 GMT Message-Id: <202208111453.27BErJ1L032527@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: 2870cfc456fd - stable/12 - if_dwc: recognize additional rgmii phy-modes List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/12 X-Git-Reftype: branch X-Git-Commit: 2870cfc456fd8133ca6b22abf3aa53e25808f87b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660229599; 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=Vp4ej7BM6a7TN19HWSrhk/MI6LRqMdQJzKZcSssS93Y=; b=LwyWxVGk9zXDjmf3jeBxbQckdo4A9iuUWvhWwsLxxVqedZW1/N37GiZBljMbbTVsEO9ggQ xB6/p4SF0VjcrV6d7WXgolfjnw1sbmcsVIx5JBMH4nQiob25IQDQuh6UH0vTF0HPRFNPFK Q6qlNKlqfCJmClNPXDionFd7T7DWGih90gjzfTAAlQKdu/dEDq31OahkQOyFJaOcP7vRaY YfhQCiiXZAR9qQ2u+VzYQGi5xlDA8YlGFWHdYRcP8YXAuY7pPZgG21NBDLlPM9W8G6dA4E u7DBLOb+komTkleaEqRIrDbpvZmrJ5+K+NSfXdZMQLFNqs7vS5nhCiQFKpFd2g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660229599; a=rsa-sha256; cv=none; b=IELahkJ7vQxegbQua8xOWG1HVmR77yjG85zaZFrr0i3tXh/wDv3GPBL5mlRcpzmQNbaJ5F JN+eHWrqrh423m2DY7ZSroFYAnAVmvir0I8IppuczKK/YJdphRPbqLD6w5CUUYVu+lAWTE nuRCtAZtMQJS7VNdw1+M9smqeqkXU7ZtM2A4qxY+rwRTLbryITydgIjwMpsEJmw6lYghCl p1UgetLcx4LOfyXxEQatfSZi0OWjyHL0X9Odatdt+ZRUsxlnI4sJUecGgeaVmYxCfQ4SbF BCZ8wCBiB5YcAeMxIXEFep7kiUCQ1nETtjN791Ze4etvnkFLRYZkXJn3RBXGDQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=2870cfc456fd8133ca6b22abf3aa53e25808f87b commit 2870cfc456fd8133ca6b22abf3aa53e25808f87b Author: Mitchell Horne AuthorDate: 2022-06-21 13:22:53 +0000 Commit: Mitchell Horne CommitDate: 2022-08-11 14:52:03 +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 */