From patchwork Tue Dec 5 10:35:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13479907 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2DB48C4167B for ; Tue, 5 Dec 2023 10:37:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YjvjJeQASYDEgSdw66KnYp1TtBOCWuyMzhyNx0H3ONw=; b=cmRlpxp0NLGT61 x1F+XexmxviaYTvrgVxPo8/8CnWtvrFPyod6FD4vi6ndn6ZD7S65JhQZkQM0il7EhSXdcss7AGw7f IN9dOnJ+2kjwIMUE7wdO4GmkGmknLd/XuxnqUZsuEjl9/f5kGIBllj0TE7NyUsmYfigJOeFxEDWSv jNfQnqRxe6DrmxScf5Lr4wsQBl1p8wIgB2O6x1iSDcAHxERJiBPVBBd+P3eU9BsF/GtYYYk3xPkOd c9K+0fKBgbtnOL5v5JXQl++zsl9G1N4B0cgrs+rRx6CXuRTBzGZxmtfJxZ57naGH3vjOsl3bju7FM 7y2lNk1GvXHwyWLhG99g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rASn0-006zAz-2d; Tue, 05 Dec 2023 10:36:30 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rASmx-006z71-2H for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 10:36:29 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-50c0dbaf2baso229066e87.3 for ; Tue, 05 Dec 2023 02:36:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772583; x=1702377383; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WIQUz6kTrVuZdOXLZo+ge/Lp9pWSfj/oMDcXilwbtBU=; b=LpAroBuQ15JX9IZ/4S/dEUGGU+VtX24MKSl6XsgyG2h5OHsRCMP4zcX3Tp9p8NZEAL gF0qZaZgzjg16xCidTGe8D8A2z4W89eDKOiffpQfDKjrKucYnQOrYkmQVwfQw8I2iFu/ zY/zmx/3w8nu8MHjPtIBj8qGeMFP7ehVmQMk909ag8l5erFWTjz4m8wbX5CmdfcnehBI v/Ma7YaqYPXaT3Zunqg0jzM5tbCbPGm+6HvQj/SEDceK0jk/4PJR+wuhtKzt25iQ7xVm bg4k69mcdN64IuRUq3pjoYDU7ULQIgavzvgwWK7OGoH4mkR3aDBk+8pqpC9ftwGUdl8a 04vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772583; x=1702377383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WIQUz6kTrVuZdOXLZo+ge/Lp9pWSfj/oMDcXilwbtBU=; b=d/iSGxYKXQ9Gt0nv/HnAtkt3TlBJ3hYVi4riYbQHyJPYdvSS/w234i3vxVQHN8Akwb 6vI0arjFvSg6gMNuwvj5lWfgYBX561i1pi5JoGj0pRyGgeLOVv6UGmTUg9tBxu8NE1DI SRuK3mEc2ojoPTRWrkks3nP7/X01ISwdnjOfE25nOr9UZlgWr9Bq62Dn2DtVdKIIGIYI Ob1vO7/WWnWylqz+6RL8OnXdRpK723hfR8V/guURD1M5TDOG/UETpT4NSlXPFDGvmwah JB2S9XwsMRtvIVS5IVMBxGvsoupBV0ITI+UpQn/OoGvzrONttSjCh+GD7WZJUa0lECoW H5FQ== X-Gm-Message-State: AOJu0YybQi/UWG5EmtLvukq3uhcM6dXICgNuHLNNSJulA4/DJ1ywBOX8 To74G496+8oUG3326f56tu8= X-Google-Smtp-Source: AGHT+IGX6hxolloUWCXauP85aEGl4KFj8FADRPvac0Qo990dFIzZotJOwEw2Nm39AzLMj98ISD+EcQ== X-Received: by 2002:ac2:5a50:0:b0:50b:fea2:4cdc with SMTP id r16-20020ac25a50000000b0050bfea24cdcmr583327lfn.172.1701772582731; Tue, 05 Dec 2023 02:36:22 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id c10-20020ac25f6a000000b0050c0514fdf4sm146106lfc.127.2023.12.05.02.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:22 -0800 (PST) From: Serge Semin To: Andrew Lunn , Heiner Kallweit , Russell King , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Chevallier , Tomer Maimon , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Vladimir Oltean , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Serge Semin , openbmc@lists.ozlabs.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next 11/16] net: pcs: xpcs: Change xpcs_create_mdiodev() suffix to "byaddr" Date: Tue, 5 Dec 2023 13:35:32 +0300 Message-ID: <20231205103559.9605-12-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231205_023627_743763_2B2F74C4 X-CRM114-Status: GOOD ( 15.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The fwnode-based way of creating XPCS descriptor is about to be added. In order to have a function name distinguishable from the already implemented xpcs_create_mdiodev() method convert the later name to be xpcs_create_byaddr() which BTW better describes the method semantic in anyway. Signed-off-by: Serge Semin --- drivers/net/dsa/sja1105/sja1105_mdio.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 +- drivers/net/pcs/pcs-xpcs.c | 6 +++--- include/linux/pcs/pcs-xpcs.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c index 833e55e4b961..9101079e365d 100644 --- a/drivers/net/dsa/sja1105/sja1105_mdio.c +++ b/drivers/net/dsa/sja1105/sja1105_mdio.c @@ -409,7 +409,7 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv) priv->phy_mode[port] != PHY_INTERFACE_MODE_2500BASEX) continue; - xpcs = xpcs_create_mdiodev(bus, port, priv->phy_mode[port]); + xpcs = xpcs_create_byaddr(bus, port, priv->phy_mode[port]); if (IS_ERR(xpcs)) { rc = PTR_ERR(xpcs); goto out_pcs_free; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index fa9e7e7040b9..aa75e4f1e212 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -507,7 +507,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus) /* Try to probe the XPCS by scanning all addresses. */ for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - xpcs = xpcs_create_mdiodev(bus, addr, mode); + xpcs = xpcs_create_byaddr(bus, addr, mode); if (IS_ERR(xpcs)) continue; diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 183a37929b60..e376e255f1d3 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -1511,8 +1511,8 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, return ERR_PTR(ret); } -struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, - phy_interface_t interface) +struct dw_xpcs *xpcs_create_byaddr(struct mii_bus *bus, int addr, + phy_interface_t interface) { struct mdio_device *mdiodev; struct dw_xpcs *xpcs; @@ -1535,7 +1535,7 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, return xpcs; } -EXPORT_SYMBOL_GPL(xpcs_create_mdiodev); +EXPORT_SYMBOL_GPL(xpcs_create_byaddr); void xpcs_destroy(struct dw_xpcs *xpcs) { diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 53adbffb4c0a..b11bbb5e820a 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -73,8 +73,8 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces); int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable); -struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, - phy_interface_t interface); +struct dw_xpcs *xpcs_create_byaddr(struct mii_bus *bus, int addr, + phy_interface_t interface); void xpcs_destroy(struct dw_xpcs *xpcs); #endif /* __LINUX_PCS_XPCS_H */ From patchwork Tue Dec 5 10:35:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13479908 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8AC5EC4167B for ; Tue, 5 Dec 2023 10:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=27AYQWpuNGX/d3096UuqRbwPMPA0P/bnp3w7ZZVkWjs=; b=lVlLzRnk9Otb+4 ulactrUh50kJR4/1rQHGG/Np1rUQNTC34ES8LRa/ut9I0ZL9YdrGYOkY+RaKZc+2k8qWT1DnO1Qk5 GvwG/WaWFzAlQTwz7zDtWh8NrwFHp3GF++khp4K+rKuEe4RfvwJyg/I9TcbWVl6cKMdjwnk7RlSPY 5+oAwCfPCLi1Rapzgn4T1lTz23U2RYiOOANwiN2eGarm1KtCvS02nZd8B6/VTCYCVDOYaxpR9t0ys hfoJRdr5dNaqbE5tQAS4NMa17IPROaVaQKj2uMpzFSm1tNhU+FM5VUqZaqzv0WqXt3ChhiGGMI0A/ CU87ZUcenzcez8HRUmlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rASn2-006zCc-1i; Tue, 05 Dec 2023 10:36:32 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rASn0-006z8L-0b for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 10:36:31 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-50be24167efso3920136e87.3 for ; Tue, 05 Dec 2023 02:36:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772586; x=1702377386; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9/W7bRr2FIytmHTP+ve4vRfpj/k8/yIBrLP2P8LnNEk=; b=DEQpNzvYZ5tgiJX0u2hKqxLOMDfK4Ditvwhgfq4EpR3vSy+qtnoBqxxIYwWuVvT7id +0wEbzqwRq0gwG7oO1pMZ2LiBtXB1M/nIFJRxUYBjh9l6kBZ98hCGjeROiD04nsHY5VZ riDx+5RYBGl7cEvGUxXzIc2bywnUO/jEHqhm2IOwybHbD2EUfAl+c3jxBxdxL+qlTiGW jtNbU83oGsgNfsJH4EFBujkhaMtionmhLO01Af27u6hHjZp3/sBJhV6WudH2LY505dcD ZdwFZB8BqzyKQoV3CIcz3KA7itgXr4+o3K3E+8eZOi69uvG/poLqLv0p17nfpKnmLf6J fhLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772586; x=1702377386; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9/W7bRr2FIytmHTP+ve4vRfpj/k8/yIBrLP2P8LnNEk=; b=In5hFFliwQcTuv76kR7bPvZIhQ6/i61QmrtxbyHICOHa1OctVRIY1op9+oob0ZRm16 EE6frdvxhXos4U3au7ABnraLA4o9wbnm28Tndx5R0VKY+D77dDylWFhYeotcB6u6urBO xerPCGtmplSAjRW2w5//R2YEvQxI/06Ke8XkTBlsV4HZ1r/XDrRvl8WmLE1msD4rKRhI OTiQ+dPDLg+EhXSkxtJitKhZi+Kv9/rFQCibKv2skBZ1eiZzt8ZXWqbyfxLCUTuIx7xB mu9cHWhA4Aw5nV9o6SaOYQsjq3JMJRfvLo+eTPZQsRBxXRU4bZCUyl6cdfbD4gvFehdL YtTQ== X-Gm-Message-State: AOJu0Yw3H+QKmcCoO19CcDd+y3X+E9g7myMrgKARv13nPQ1bzEvFFITn DwhZduZmjI37qv/yw4O83jA= X-Google-Smtp-Source: AGHT+IES81scnB9OAc2hliG1AqfHqUzn12268APbl0b9mr/HfSY9+lceF3Al8CkH/xAT+wtxcOc+8g== X-Received: by 2002:a19:3848:0:b0:50c:4e7:87b8 with SMTP id d8-20020a193848000000b0050c04e787b8mr175943lfj.23.1701772586273; Tue, 05 Dec 2023 02:36:26 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id v8-20020ac25928000000b0050bf7a9c4adsm567335lfi.225.2023.12.05.02.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:25 -0800 (PST) From: Serge Semin To: Andrew Lunn , Heiner Kallweit , Russell King , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Chevallier , Tomer Maimon , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Serge Semin , openbmc@lists.ozlabs.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next 13/16] net: stmmac: intel: Register generic MDIO device Date: Tue, 5 Dec 2023 13:35:34 +0300 Message-ID: <20231205103559.9605-14-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231205_023630_225988_198FCA4E X-CRM114-Status: GOOD ( 17.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The DW XPCS driver has been updated to being bindable with the respective MDIO device registered during the MDIO bus probe procedure. As an example of using that feature let's convert the Intel mGBE low-level driver to registering the MDIO-device board info. Thus the registered DW XPCS device will be a subject of the fine-tunings performed during the MDIO-device probe procedures. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 60283543ffc8..7642c11abc59 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -4,6 +4,7 @@ #include #include +#include #include #include "dwmac-intel.h" #include "dwmac4.h" @@ -585,6 +586,28 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, /* Intel mgbe SGMII interface uses pcs-xcps */ if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII || plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) { + struct mdio_board_info *xpcs_info; + + xpcs_info = devm_kzalloc(&pdev->dev, + sizeof(*xpcs_info) + MII_BUS_ID_SIZE, + GFP_KERNEL); + if (!xpcs_info) { + ret = -ENOMEM; + goto err_alloc_info; + } + + xpcs_info->bus_id = (void *)xpcs_info + sizeof(*xpcs_info); + snprintf((char *)xpcs_info->bus_id, MII_BUS_ID_SIZE, + "stmmac-%x", plat->bus_id); + + snprintf(xpcs_info->modalias, MDIO_NAME_SIZE, "dwxpcs"); + + xpcs_info->mdio_addr = INTEL_MGBE_XPCS_ADDR; + + ret = mdiobus_register_board_info(xpcs_info, 1); + if (ret) + goto err_alloc_info; + plat->mdio_bus_data->has_xpcs = true; plat->mdio_bus_data->xpcs_an_inband = true; } @@ -600,7 +623,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, fwnode_handle_put(fixed_node); } - /* Ensure mdio bus scan skips intel serdes and pcs-xpcs */ + /* Ensure mdio bus PHY-scan skips intel serdes and pcs-xpcs */ plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR; plat->mdio_bus_data->phy_mask |= 1 << INTEL_MGBE_XPCS_ADDR; @@ -618,6 +641,12 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->msi_tx_base_vec = 1; return 0; + +err_alloc_info: + clk_disable_unprepare(clk); + clk_unregister_fixed_rate(clk); + + return ret; } static int ehl_common_data(struct pci_dev *pdev, From patchwork Tue Dec 5 10:35:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13479909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 489C9C10DCE for ; Tue, 5 Dec 2023 10:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3AUuMWzuzaFuupEXfGIbD8Oorifedw5ouE4/KTgOxZA=; b=JkMgZ/kZkKcSh8 jm+ZjBpqwMB6BJZdseLv4knffKoq5vt0o5C82Xx6VmqOWv/pNGm5S0Aduu8fV7WxdcBw3nndolUV5 pgty6guJgEkbTZffOoihjzdS1YZa458c5s7yrORnkNDTfsR6sM2eFSTSWo+HjbnE297449HNw7rdk MJjTb4UwauUKXGobrTSb9bH4MJjSINvo+rUT9IvixxNj5P+QMsCEC39jRdbQbKUH0JTZb2yKIRmFK 0Cq7pLJ9n4W++Pk4ISQQ+TDGvhnAAh1dzICpYwdBK1Ae8oCIyXf/qm0E4Feg6lD4dQqShR2V8bH/p QUDgmic5+jVDr7/+Qtmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rASn4-006zED-2d; Tue, 05 Dec 2023 10:36:34 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rASn1-006z9O-2f for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 10:36:33 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-50be10acaf9so3449267e87.1 for ; Tue, 05 Dec 2023 02:36:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772588; x=1702377388; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eSce1rQ1um+oY77DdZG8yrBJ6NEyKdJwNZU1ix0Nv7k=; b=JK+1zbOfZHAI28Tfy5tao7z/zE60coZbgmpc5mzNmlsNskxbqJr1dwM0Uc9rkiT45u lq4HzWRAV9ZMmINFeN1q0W1C/VJxVexc+Un3OdoTe0xS3cHxb5qTGfjMcM4eWI7Q5x7c Vc8u+VgJsCR/H1CNIx41CrP7fb617xJtfaSf9lnnLUigClEfF5YIkGElVZqVNNq7ry1C owVqCAODUa8gPAAEbeFNBk6xjnyg6ATL4+62a0Wz5U6iNdAWAR6uu1uQlrQQ3NqN+ANi NkjB//NZOPWTOch+o5Q3sVrqZ5IxEr3twQ98QRWqme2Mwg2+xTZOy7KN521Mz1XaLzXS zdvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772588; x=1702377388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eSce1rQ1um+oY77DdZG8yrBJ6NEyKdJwNZU1ix0Nv7k=; b=IfLIa2V63i75Q/JclHI1NzLLDoxs5kj36yqNhoimErLcbaS5yh1qU20ay8bNWJvC1N m0QzYyDl+RcQ6qmrtjBoQ9KCC/11hocJkelK4fSsnk01nGB7i2hmmHYvAbpEvtrJ+PAq rqodHjWo0auis+3htsE1Hc9f0jUzC0XIxuuFPAgH34Nfc2XU4mo5w0F3iKrfhHBTOy7l AvUyRVG3cRwQIXexVhVXakiMrJlV5bfJzffmG+MtuWSFKbw+bZEQDIkD6QPiKCS6dCAk 9V7DTZBY8AnDC0P5H2Oc+EEm2MIY/kF+VDUjdT+kAttq8z0suGx+yGauwDz/M3+HtZcw 6nnw== X-Gm-Message-State: AOJu0YyzpaJAU0smA68vw3XgK0AIV2RuAA2ipFAVXIu/GmxJQTQBvI/O qCLKFcTXpAVv056FrYnXtKg= X-Google-Smtp-Source: AGHT+IHCPdpPY0zKceA3SRi5ga/xIyMFSxmCiObH9MLWtgGsZTqmrUo8sVBhomQ2MmR96xpeV6v2vw== X-Received: by 2002:a05:6512:2809:b0:50b:f0a9:1e3e with SMTP id cf9-20020a056512280900b0050bf0a91e3emr834935lfb.3.1701772588437; Tue, 05 Dec 2023 02:36:28 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id x3-20020a056512046300b0050c0215a806sm185275lfd.83.2023.12.05.02.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:27 -0800 (PST) From: Serge Semin To: Andrew Lunn , Heiner Kallweit , Russell King , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Chevallier , Tomer Maimon , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Serge Semin , openbmc@lists.ozlabs.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next 14/16] net: stmmac: Pass netdev to XPCS setup function Date: Tue, 5 Dec 2023 13:35:35 +0300 Message-ID: <20231205103559.9605-15-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231205_023631_871268_D2D16EA3 X-CRM114-Status: GOOD ( 17.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It's possible to have the XPCS device accessible over a dedicated management interface which makes the XPCS device available over the MMIO space. In that case the management interface will be registered as a separate MDIO bus and the DW xGMAC device will be equipped with the "pcs-handle" property pointing to the XPCS device instead of auto-detecting it on the internal MDIO bus. In such configurations the SMA interface (embedded into the DW xGMAC MDIO interface) might be absent. Thus passing the MII bus interface handler to the stmmac_xpcs_setup() method won't let us reach the externally supplied XPCS device especially if the SMA bus isn't configured. Let's fix it by converting the stmmac_xpcs_setup(struct mii_bus *bus) prototype to stmmac_xpcs_setup(struct net_device *ndev). Note this is a preparation patch before adding the support of the XPCS devices specified via the "pcs-handle" property. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index cd7a9768de5f..d8a1c84880c5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -343,7 +343,7 @@ enum stmmac_state { int stmmac_mdio_unregister(struct net_device *ndev); int stmmac_mdio_register(struct net_device *ndev); int stmmac_mdio_reset(struct mii_bus *mii); -int stmmac_xpcs_setup(struct mii_bus *mii); +int stmmac_xpcs_setup(struct net_device *ndev); void stmmac_set_ethtool_ops(struct net_device *netdev); int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 3e50fd53a617..c3641db00f96 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7605,7 +7605,7 @@ int stmmac_dvr_probe(struct device *device, priv->plat->speed_mode_2500(ndev, priv->plat->bsp_priv); if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { - ret = stmmac_xpcs_setup(priv->mii); + ret = stmmac_xpcs_setup(ndev); if (ret) goto error_xpcs_setup; } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index aa75e4f1e212..e6133510e28d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -495,9 +495,8 @@ int stmmac_mdio_reset(struct mii_bus *bus) return 0; } -int stmmac_xpcs_setup(struct mii_bus *bus) +int stmmac_xpcs_setup(struct net_device *ndev) { - struct net_device *ndev = bus->priv; struct stmmac_priv *priv; struct dw_xpcs *xpcs; int mode, addr; @@ -507,7 +506,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus) /* Try to probe the XPCS by scanning all addresses. */ for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - xpcs = xpcs_create_byaddr(bus, addr, mode); + xpcs = xpcs_create_byaddr(priv->mii, addr, mode); if (IS_ERR(xpcs)) continue; From patchwork Tue Dec 5 10:35:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13479910 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43A71C4167B for ; Tue, 5 Dec 2023 10:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SOPrXLNltZHfXusOYKhtyE7O3uRSiwfeS0Yvc9QrSfM=; b=RvYiEx/1EDEn9R Fi8wMmdmeRxBqQb5yHP1rf1beIqHVq0pCRbimeESQhHBQ1+nu0S3qjsZpKTXXM/PBcQWDKicAbqSW MHtPwVcd7WHF5Exmk7cxVRNx9OYtRpEG3S3PYcZl47YmGorKfol7BpoTGuIiSaWWiGvLwZNEh4CaZ Awk7sbUfmPY+pAY/4sfj/n604LeeyQ7hvPPYj4wKRLPlbLDFtjjNxALDJhSkSpLEet3p6boy5wZpa pYM3R23tHpA+GMeiBtodzTw8YK2bLeKoHUItpCOpqEAYzGcPzHHpScaZSudTHy/uaX9jQZbkKdInF Mb+r8W4Wz7Qcp+zZNwEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rASn7-006zFt-1R; Tue, 05 Dec 2023 10:36:37 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rASn2-006zBI-37 for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 10:36:34 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-50be24167efso3920202e87.3 for ; Tue, 05 Dec 2023 02:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772590; x=1702377390; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KnWeBpfqtvqCDqeZAExTorADExkavt7pqbm3ec9WO1c=; b=HR4U6yZJ3UvRzxMNzHA49FphNW8irNlpvXoYEs2RW0rVNnSRo8HNEzc7jXjIi3gYH+ LKS17wudO8NODbESUrq1L1O/BwvGdP4UBRUYj/m72RlhsXSb2ql1ziKGfOaev5U9/Ygy EdRLAdEhW10JLuOUSrgLDIDdPmXDLV90p6Ztsk0mkG8bjGJ55cNG08Fg7YlGAeKMhDIS 4iPGMuNJRebPNqBbx4H+ByQFoKFiWrqZwxE/0fMyGhzA/zwRmB4DD4QaTpIboRRyb8HG vo29azRBm42SenFmgr1IIVrdtFGRYK6GPAwYM3J9aQ/twISA40s3E+IiDXUHpQIPaAHg I6Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772590; x=1702377390; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KnWeBpfqtvqCDqeZAExTorADExkavt7pqbm3ec9WO1c=; b=Dcu5BEFQIjNPkgVISRu4jSGELhd/dp/zaDJkBIrolBoLNdFjGpKxhTURN4nmncFDMF gUoJAPxzwN9zDH+AM24a5MYym8GNqzpabo5VQUZQIJiWy5BM110Nb7jwyqPhISvvOCiC e9mTjVE1CWnuGTjVF/wTsg1kNxFkV1IdioIku4d6lf3EaDIavUYBwlYaBjBFGV6uDs/a 9fVRaOxkvYLG7YQPbkvOT9xBVy/BgJe5ukFfvuFeUaLAjD7zdrxosjv/EIZXtIo+CIJC FKcajeap9rx9f8ziwsEUlX5sIyRG4o+h+qgXjQP6ShdokfCi51zB/N5sJyKXw+bkLJVo oYMQ== X-Gm-Message-State: AOJu0YyzM7ahMK24m/vQMqxmWBl7SXTSHPSvlArqF+nO1JTQsbl82AuW d9Py48fwWAruHXCZcA0vpvg= X-Google-Smtp-Source: AGHT+IFCUWZhdYHhKb8nG0l8H2uVfvXP7CMp59To4aI5jWsBTPXwOd7IoX4cD7Nlfspv3sfeyfBb1A== X-Received: by 2002:ac2:5f43:0:b0:50b:ccc1:201e with SMTP id 3-20020ac25f43000000b0050bccc1201emr1469322lfz.0.1701772590456; Tue, 05 Dec 2023 02:36:30 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id d19-20020a196b13000000b0050bf365e8c8sm679554lfa.63.2023.12.05.02.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:30 -0800 (PST) From: Serge Semin To: Andrew Lunn , Heiner Kallweit , Russell King , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Chevallier , Tomer Maimon , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Serge Semin , openbmc@lists.ozlabs.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next 15/16] net: stmmac: Add dedicated XPCS cleanup method Date: Tue, 5 Dec 2023 13:35:36 +0300 Message-ID: <20231205103559.9605-16-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231205_023633_010112_91A7D0C3 X-CRM114-Status: GOOD ( 16.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently the XPCS handler destruction is performed in the stmmac_mdio_unregister() method. It doesn't look well because the handler isn't originally created in the corresponding protagonist stmmac_mdio_unregister(), but in the stmmac_xpcs_setup() function. In order to have a bit more coherent MDIO and XPCS setup/cleanup procedures let's move the DW XPCS destruction to the dedicated stmmac_xpcs_clean() method. Note besides of that this change is a preparation to adding the PCS device supplied by means of the "pcs-handle" property. It's required since DW XPCS IP-core can be synthesized embedded into the chip with directly accessible CSRs. In that case the SMA interface can be absent so no corresponding MDIO bus will be registered. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++++- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 14 +++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index d8a1c84880c5..1709de519813 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -344,6 +344,7 @@ int stmmac_mdio_unregister(struct net_device *ndev); int stmmac_mdio_register(struct net_device *ndev); int stmmac_mdio_reset(struct mii_bus *mii); int stmmac_xpcs_setup(struct net_device *ndev); +void stmmac_xpcs_clean(struct net_device *ndev); void stmmac_set_ethtool_ops(struct net_device *netdev); int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index c3641db00f96..379552240ac9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7639,8 +7639,9 @@ int stmmac_dvr_probe(struct device *device, error_netdev_register: phylink_destroy(priv->phylink); -error_xpcs_setup: error_phy_setup: + stmmac_xpcs_clean(ndev); +error_xpcs_setup: if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); @@ -7682,6 +7683,9 @@ void stmmac_dvr_remove(struct device *dev) if (priv->plat->stmmac_rst) reset_control_assert(priv->plat->stmmac_rst); reset_control_assert(priv->plat->stmmac_ahb_rst); + + stmmac_xpcs_clean(ndev); + if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index e6133510e28d..101fa50c3c96 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -522,6 +522,17 @@ int stmmac_xpcs_setup(struct net_device *ndev) return 0; } +void stmmac_xpcs_clean(struct net_device *ndev) +{ + struct stmmac_priv *priv = netdev_priv(ndev); + + if (!priv->hw->xpcs) + return; + + xpcs_destroy(priv->hw->xpcs); + priv->hw->xpcs = NULL; +} + /** * stmmac_mdio_register * @ndev: net device structure @@ -674,9 +685,6 @@ int stmmac_mdio_unregister(struct net_device *ndev) if (!priv->mii) return 0; - if (priv->hw->xpcs) - xpcs_destroy(priv->hw->xpcs); - mdiobus_unregister(priv->mii); priv->mii->priv = NULL; mdiobus_free(priv->mii); From patchwork Tue Dec 5 10:35:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13479911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54C26C4167B for ; Tue, 5 Dec 2023 10:37:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZYmRrpGzctUx3fgYg6iIMOytmfkwouPg+VZlITp8elk=; b=Nng04RWPvGEhC0 /WOdjGgSPmNBuz7dbnoiK8YsMKr++93msVnnGvDc0bjgFUBlltHbtNZtVMvl/bwKVLkwJpVCsLDVR r/m7EWz9HI3tgHy3bJV1sLeL0Zk+AmPQMGsdhfdIYH6+LE/onNyKKT/f1WcRMYGgUlg82ZzfUkoQ8 snLVdpNV0s46f77wHhbqpZWy/YMvbSctHiq5nE4+HY4l0gs32PTdefvIPkI03tfDxZfAtF6GofF4s 8nSm5Pi6ftKiFfiYLv+M1v5ZuDJjyLcUKMH9I30sdTLIzQspOHsI6em+cbL3Djj9rPz7FEzushgMU DrIYVJ1h4p62SsXzyWfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rASn9-006zGm-0T; Tue, 05 Dec 2023 10:36:39 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rASn6-006zD0-0a for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 10:36:37 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c9ea37ac87so45173261fa.3 for ; Tue, 05 Dec 2023 02:36:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772592; x=1702377392; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KjKEFhPSgLN5vGtDlHZQvN1ZMYBQW2UNIHEU4iW11KA=; b=XGXAXLgMFfbOwimO1DJe7cmmzERJrTXL31eqmFAv8gj5rH0Vt9KEIWkpXrbkTGArhI fIIeQvYfA39eu2JV4zNBUFy36LBvSZp5Ls96RMbmFKWeE+OcY8fLCJBOo1CpbLAh/K56 suPcY3X2YLa5x34Ptmci/tiLJguV8+BmOjkWOW4RvJZ5Ubu9huWwddwEf9QIuqYSU+w6 mdhWcZ8BOYJWOFddd2EzPSS2Z/OdF3ACnyg3EpvVerd5Rl7lIuO+n4nzb4c8O1JjExcv gzp+ZuMaLsYZ4E6RNCjBMrMu/1IVl1uByGeL0WpaWVI0ceJSQKzL0256zskoELirdX5I jlWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772592; x=1702377392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KjKEFhPSgLN5vGtDlHZQvN1ZMYBQW2UNIHEU4iW11KA=; b=cyCp/WPmd+HStqT6lkSgWFv3rZtAEf0MiTgp9y4qFUNeklBBm5jtNVY1M+nPqwC0mo ZIdHCtOwwzRRhVE4kww4kKKE9PIVXH83dOQEaiLW6eLjWGtPN6jhLltOQcdbiIYzWPuV fNKegu7l4awHzOmFegm0giKf2lsHCgzyjmwHshwYB1yUszNwBIh8aXE6BtoiBJ4kA8Cn Q4cXGM93OfbghUIJfaeKiyBb2WdFGXo860Qgz+8UoALTekZ2z0Dw4ZtYRBcHDmaTERZk TS3KULalsyvEGdBuDLaM4f991AxKmQN/hINbUj3lgpM6xQWNuc4OuuuOgjGja0XRZRHg O7GA== X-Gm-Message-State: AOJu0YwJ4N48Su0GxCN/Tdb6d+8Vo4TM89tqdM08TFWuqR9eBBMHorMa owTxQHk8G2OrVqX9ufS58xk= X-Google-Smtp-Source: AGHT+IEV4/NEvKyiG2pISjXXhGEzBDyRRwcjqLkOq0cFAE1HY0eO+MjW4de0kYE72+xi26ZTN01x/w== X-Received: by 2002:a05:651c:85:b0:2ca:30a:8390 with SMTP id 5-20020a05651c008500b002ca030a8390mr1586235ljq.85.1701772592265; Tue, 05 Dec 2023 02:36:32 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id a21-20020a05651c031500b002c9e9c29670sm1153531ljp.47.2023.12.05.02.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:31 -0800 (PST) From: Serge Semin To: Andrew Lunn , Heiner Kallweit , Russell King , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Chevallier , Tomer Maimon , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Serge Semin , openbmc@lists.ozlabs.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH net-next 16/16] net: stmmac: Add externally detected DW XPCS support Date: Tue, 5 Dec 2023 13:35:37 +0300 Message-ID: <20231205103559.9605-17-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231205_023636_220726_E5E65842 X-CRM114-Status: GOOD ( 25.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org It's possible to have the DW XPCS device accessible over an external bus (external MDIO or DW XPCS management interface). Thus it will be futile to try to detect the device on the local SMA interface. Besides such platform setup isn't supported by the STMMAC driver anyway since the stmmac_mdio_bus_data instance might not be created and even if it is there is no code path which would set the stmmac_mdio_bus_data.has_xpcs flag thus activating the XPCS device setup. So in order to solve the denoted problem a pretty much standard approach is implemented: DT "pcs-handle" property is used to get the phandle referencing the DT-node describing the DW XPCS device; device node will be parsed by the xpcs_create_bynode() method implemented in the DW XPCS driver in a way as it's done for PHY-node; the node is used to find the MDIO-device instance, which in its turn will be used to create the XPCS descriptor. Note as a nice side effect of the provided change the conditional stmmac_xpcs_setup() method execution can be converted to the conditional statements implemented in the function itself. Thus the stmmac_open() will turn to look a bit simpler meanwhile stmmac_xpcs_setup() will provide the optional XPCS device semantic. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++--- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 34 ++++++++++++------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 379552240ac9..a33ba00d091d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7604,11 +7604,9 @@ int stmmac_dvr_probe(struct device *device, if (priv->plat->speed_mode_2500) priv->plat->speed_mode_2500(ndev, priv->plat->bsp_priv); - if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { - ret = stmmac_xpcs_setup(ndev); - if (ret) - goto error_xpcs_setup; - } + ret = stmmac_xpcs_setup(ndev); + if (ret) + goto error_xpcs_setup; ret = stmmac_phy_setup(priv); if (ret) { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 101fa50c3c96..b906be363b61 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -499,25 +499,33 @@ int stmmac_xpcs_setup(struct net_device *ndev) { struct stmmac_priv *priv; struct dw_xpcs *xpcs; - int mode, addr; + int ret, mode, addr; priv = netdev_priv(ndev); mode = priv->plat->phy_interface; - /* Try to probe the XPCS by scanning all addresses. */ - for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - xpcs = xpcs_create_byaddr(priv->mii, addr, mode); - if (IS_ERR(xpcs)) - continue; - - priv->hw->xpcs = xpcs; - break; + /* If PCS-node is specified use it to create the XPCS descriptor */ + if (fwnode_property_present(priv->plat->port_node, "pcs-handle")) { + xpcs = xpcs_create_bynode(priv->plat->port_node, mode); + ret = PTR_ERR_OR_ZERO(xpcs); + } else if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { + /* Try to probe the XPCS by scanning all addresses */ + for (ret = -ENODEV, addr = 0; addr < PHY_MAX_ADDR; addr++) { + xpcs = xpcs_create_byaddr(priv->mii, addr, mode); + if (IS_ERR(xpcs)) + continue; + + ret = 0; + break; + } + } else { + return 0; } - if (!priv->hw->xpcs) { - dev_warn(priv->device, "No xPCS found\n"); - return -ENODEV; - } + if (ret) + return dev_err_probe(priv->device, ret, "No xPCS found\n"); + + priv->hw->xpcs = xpcs; return 0; }