From patchwork Tue Apr 30 07:29:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13648423 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 D586FC41513 for ; Tue, 30 Apr 2024 07:30:32 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=r4Zvz4M7nhd2038M+mSonQRPPpL0EixLZZ2HYHJhtpA=; b=qkzdnJnXqgfMdM KSPfG7qLf7cW3BsF7KgolLiuyzi6ulNQj8sGn7tOwa8z1PKESPUZA44j2UtnLwrlj8mbQhIfaGRTe X3cztrp8qH66ni5zkJL6n6p5Whtx1p8LIibpgjiulqM3uKnTR9q1QABWazoxxMXWqaqMf95/MPmy/ Y7kHN1yZ0QL7yG/uWx2hut0Am+wu0NyysqRTk+KAXdv+IQtu1xHozhud64F9Nd08D9kd3xqgpnj12 +tDJUbJL3Ygr1kFbetyC/AXgJczgp5MsEueaYTk4MtJovoBFKW3R6jC8U93O2sKb7eX5FnQI70U5h TnlOTDDbcA+rrGZrAn0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1hwG-00000005R7o-10qs; Tue, 30 Apr 2024 07:30:08 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1hw5-00000005R2U-0vAw for linux-arm-kernel@bombadil.infradead.org; Tue, 30 Apr 2024 07:29:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=jCc/5DWJr0Wmss9ouvVqM9KULQkT2TgxRDjtMCmvwS4=; b=BhIX16yIVSH7OZx4DSwVCluUeA 2aX7JFrjtx4A0zvx3Px6G4oMmTDT9gviZD4Kp/Ub+7lpqIWk+jWyl5sAFEiZTnLMIGaQRe7uSJdyH Z1PnzyTlw72NtvVaoJuxZSaNnhYFVqihJs5kDpqWRiGg//id/FYwzdxT/i7bcEM/t8q5vuUjovrcT GDxqJybjfQBmvKN+SPieG/x0eQmCGnHhwxX2Pqudla42d3SJw1gYTEZnanpo98cXwBCpbDQsOFQyt zN5moVrbSns+j3CljhAo0ZqA09NE6NcIm6mGZATga/zCXkgCOobwvrRxibXLqsw+FDerzbbp+WYMV stp+11Hg==; Received: from relay1-d.mail.gandi.net ([217.70.183.193]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1hvx-0000000GqFz-3RBB for linux-arm-kernel@lists.infradead.org; Tue, 30 Apr 2024 07:29:53 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 5F098240002; Tue, 30 Apr 2024 07:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1714462148; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jCc/5DWJr0Wmss9ouvVqM9KULQkT2TgxRDjtMCmvwS4=; b=pAzY4EkjIuGARnGVvAgIDQ8cFa96R1aR/0FBMmGH0wAg9XCt29+nv+QwPoBRNRcvxDjRyP 3kftfVP8AnZ9r7v768bnOjFeLVzt/bNbvIq1kSFP3h1tOcgfK6QA5nHG/9yv+v4ftvy+Bw s7b1gybW1popET48vA9HOmukGVWregAlxbRNdmiXNC2Z0tHw1IYX61/LIVNMWjjiFJfYzh tVc7MsxzstZfij/xRn5D4u4thT5/opX0LMeALRtFlkzYbYAJrzg4ANqFsLrasoUPlh7rJb iVlgj50FHZJLoADkZW/shx9MLgw+u272By/mWEnzAc3knPdTGbuUITOGpzYzuQ== From: Romain Gantois Date: Tue, 30 Apr 2024 09:29:43 +0200 Subject: [PATCH net-next v5 3/7] net: stmmac: Make stmmac_xpcs_setup() generic to all PCS devices MIME-Version: 1.0 Message-Id: <20240430-rzn1-gmac1-v5-3-62f65a84f418@bootlin.com> References: <20240430-rzn1-gmac1-v5-0-62f65a84f418@bootlin.com> In-Reply-To: <20240430-rzn1-gmac1-v5-0-62f65a84f418@bootlin.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Russell King , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Serge Semin Cc: Thomas Petazzoni , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Romain Gantois X-Mailer: b4 0.13.0 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240430_082950_339761_DBF6836C X-CRM114-Status: GOOD ( 16.46 ) 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 From: Serge Semin A pcs_init() callback will be introduced to stmmac in a future patch. This new function will be called during the hardware initialization phase. Instead of separately initializing XPCS and PCS components, let's group all PCS-related hardware initialization logic in the current stmmac_xpcs_setup() function. Rename stmmac_xpcs_setup() to stmmac_pcs_setup() and move the conditional call to stmmac_xpcs_setup() inside the function itself. Signed-off-by: Serge Semin Co-developed-by: Romain Gantois Signed-off-by: Romain Gantois --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++---- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 28 ++++++++++++++--------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 7e0d727ed795b..f275f2fd91c3e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -360,7 +360,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_pcs_setup(struct net_device *ndev); void stmmac_pcs_clean(struct stmmac_priv *priv); void stmmac_set_ethtool_ops(struct net_device *netdev); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 2a55c5d07f6b8..72f4deda76407 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7754,11 +7754,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(priv->mii); - if (ret) - goto error_xpcs_setup; - } + ret = stmmac_pcs_setup(ndev); + if (ret) + goto error_pcs_setup; ret = stmmac_phy_setup(priv); if (ret) { @@ -7791,7 +7789,7 @@ int stmmac_dvr_probe(struct device *device, phylink_destroy(priv->phylink); error_phy_setup: stmmac_pcs_clean(priv); -error_xpcs_setup: +error_pcs_setup: 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 508bd39cbe2b3..af8ad9768da10 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -495,31 +495,37 @@ int stmmac_mdio_reset(struct mii_bus *bus) return 0; } -int stmmac_xpcs_setup(struct mii_bus *bus) +int stmmac_pcs_setup(struct net_device *ndev) { - struct net_device *ndev = bus->priv; struct stmmac_priv *priv; struct dw_xpcs *xpcs; + int ret = -ENODEV; int 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_mdiodev(bus, addr, mode); - if (IS_ERR(xpcs)) - continue; + if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { + /* Try to probe the XPCS by scanning all addresses */ + for (addr = 0; addr < PHY_MAX_ADDR; addr++) { + xpcs = xpcs_create_mdiodev(priv->mii, addr, mode); + if (IS_ERR(xpcs)) + continue; - priv->hw->xpcs = xpcs; - break; + ret = 0; + break; + } + } else { + return 0; } - if (!priv->hw->xpcs) { + if (ret) { dev_warn(priv->device, "No xPCS found\n"); - return -ENODEV; + return ret; } + priv->hw->xpcs = xpcs; + return 0; }