Date: Mon, 4 Jul 2022 16:40:01 GMT From: Mitchell Horne <mhorne@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 1da82ebe499a - stable/13 - if_dwc: recognize additional rgmii phy-modes Message-ID: <202207041640.264Ge1pJ042627@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=1da82ebe499aec5f505b23238a231f01e77a17c3 commit 1da82ebe499aec5f505b23238a231f01e77a17c3 Author: Mitchell Horne <mhorne@FreeBSD.org> AuthorDate: 2022-06-21 13:22:53 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> 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 <marentoy@protonmail.com> Reported by: Arie Bikker <src-2016@bikker.homeunix.net> 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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202207041640.264Ge1pJ042627>