Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1848618lqa; Tue, 30 Apr 2024 00:30:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpld1UCCmMrp49pPU3E9Gfp0pQiB2tv8TAwWogIz8pnpE600DBG5WzUupk4XXHuJzhvt8v/6gMA6NK9wubtREBPzmtM9vmYkka6U8Krw== X-Google-Smtp-Source: AGHT+IEO+SrW+Ldqdggmk3iJWY+j06dL2PkZH0Cl8HFtcRfcFZkQeHQkQNTi6dcaLEmKj6DVmRK2 X-Received: by 2002:a17:906:2313:b0:a58:c261:3e89 with SMTP id l19-20020a170906231300b00a58c2613e89mr7717248eja.31.1714462241641; Tue, 30 Apr 2024 00:30:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714462241; cv=pass; d=google.com; s=arc-20160816; b=bgzS3veTXk2xWyE6mqto6eWo1SS8dlwPPXHaFGzz2Hy8s+zIl4IT3H9frbC0Z9+1fh HdSI3rM65JMSfzdzvHSkpMsTOfg9N7I3esp/5Qler4RSXV3DMxr901yZZLOVrbt4Hc0F rt2L9BH9XHIsCLZGc5OWu1w1sXvVN2t1kAPp79esp86RrL0CH6NHn3ksxUI/EVCNLgob RZBUMA9xBhRbw+pWU2ioUn9N6NP26peuwkNED+ogACp1uLIoAIPR4AxZHWaxtDSab22S Az0ylwSwkMZviyVZiTFeueu/e4s3Pj6F1AaBIet7qCF9xu9yZX2mJGsgiHdYnDyTvMAQ PQTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=jCc/5DWJr0Wmss9ouvVqM9KULQkT2TgxRDjtMCmvwS4=; fh=iKbzTsM6Akj2X0N29umtxBSsa4Nmw1Zki5pbjnRyyYA=; b=GL8Hbj6bkAwjs2oe050phUrOCeiHFiuPdxP67erBfsePWXIuwiIJSCfFpulSy/+s5R vxKOtOhD66483ba1ReFz+BMN0dpCCwNxILTq7MkUKwvIa39c73/IptSXL3//Co7HJDfV Uuv5d5++KxmkAynbKFGXzgh7mk8PIMmDGictELTbbNtWS4iYLwrRLKMG8WpwzGGLLXmk 6MtmlG+SWg/2UbtFpwBGKJfuKmhkwrNw412vo4U6sITDsTH5jPs+j4Hrlx+YkxHQt+sP RK/nndhdTtvqgJ2pOUF/EUlbHUg6X++z2OKJtGFHv0OgaBdMEarBNlxwIs1hCmcSJeZm w1XA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=pAzY4Ekj; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-163472-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163472-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b5-20020a170906d10500b00a4721de23ffsi15423164ejz.855.2024.04.30.00.30.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 00:30:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163472-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=pAzY4Ekj; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-163472-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163472-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0FF621F2277B for ; Tue, 30 Apr 2024 07:30:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8892128828; Tue, 30 Apr 2024 07:29:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="pAzY4Ekj" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BB603BBE3; Tue, 30 Apr 2024 07:29:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714462153; cv=none; b=HaQqQ0QZLd7HXwzZeTzyDhUbbXc3WM2zkzPdOIUrcBRU55oteZyDxcYOwZTLPKUImQqOA751APQStg3duqEM4sie12aW96wQgULAPnpu6AAKWTW+mV5mheau4UJVL9PWMO1k9EZ47ibU+Itg0lue7T+tBRiSLtOYwK3Fn0lOmDY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714462153; c=relaxed/simple; bh=DPDVe3LFA+6CBx24SDwxAb8CpjYU1B/6sGWsr7qWW2s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WK4U1dVscWgTmGGqWzjQXAu/kO5zPUKw3LUjIF7oXn7H213ozhoA/qFsz35I0UICZ26TKgxPfJl6rIw1TZ/0rpPTFzJrnhtcgwrZWlma/fzfwx2MtXzpxDMqmiXY7n/JUQwEX9465zMQcHMSg39Ia+54pRBfpUOdfd2iBz+DLTw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=pAzY4Ekj; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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?q?Cl=C3=A9ment_L=C3=A9ger?= , 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 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; } -- 2.44.0