Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp329263lqo; Fri, 10 May 2024 00:39:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXdEY7cWju8d4y0aQMUmTUsX12H9gmHfFmnlRxD5f2AwHGNsR+aipInMOw9QB11C6q4bR9LwabBgnbLvSwosAXxykfFVlpnchYeULSt6g== X-Google-Smtp-Source: AGHT+IEYA5aB4+pSlPMUkIHG8Fj7UI0Wh6/TxqSUY8hKbXtDpSISzGmE7M3qIJ6Zj3RfU1LtVp0B X-Received: by 2002:a05:6402:22d3:b0:572:a055:ac7 with SMTP id 4fb4d7f45d1cf-5734f785ceemr1128979a12.32.1715326777468; Fri, 10 May 2024 00:39:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715326777; cv=pass; d=google.com; s=arc-20160816; b=YtDyGPXVvCbyEKZlrQMItHkqwMeTWlRabCJzOtLgncQCrHi1FVk2PCus8HIbKQA4lC Ig/s7T5t9KjyNa1i1ENSD4APXrhgblhwl4fh5kXaS0DVU2V80BhK2YezWvOwUBNGm/fR 3fECMjHU21IjuwR8y2oI1aqqkGAwn1NmO8Xw6Ef8hQIvHI752lrF2g1dpcH67ly9AoDd x9iTZgZQESWoEL0stoYHxbzYcbnxbGc9fxSWEjHYDsWZnR1nu0xzKkLW5U3x55y2smQ/ 2hDLoALGoT174iucn7aH+z6Y7l/Qa5/FWxf0XQEX30RgICh/J1SLydIOcNxmzjrvIdQZ NpfA== 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=R70rkyRP1Hf1pp49vShPfEGxoK1eDHjp1Cs21gNxWro=; fh=iKbzTsM6Akj2X0N29umtxBSsa4Nmw1Zki5pbjnRyyYA=; b=vAqZVNRtXP7OtiqesFhUXBFlxyEm9IsrubHVjUs42Ibk2u+1hChEQiWoCKkhJt8Km8 UpUxtlZqLYjcGwE3wjW7kPtAZz+Fuh6qF/bBrEHhh4rTmP6ufOt3adWqlCyYLToZ5Iif E3IUrKswtU5ldPCTZrR8+EmL2E9PNBxLl1gWoTAxmHST20a6gqrD/GShUvcMeIiDyjdV q7G4NwRq00wQv1hmgSw41jkpuwauZRfXS1IBiiV9pTgk+n9oRZ6Xj0oxARhLNSqU4LLu g9qLd1+wL9SedP25PphoNSt+8yM/WV2COImbKOIKpEANURFyDge6mN9GhGxUvtKSLcCS XEdQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=heLlFnaM; 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-175408-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175408-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733beace92si1640636a12.89.2024.05.10.00.39.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 00:39:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175408-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=heLlFnaM; 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-175408-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175408-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 E12111F21E5C for ; Fri, 10 May 2024 07:39:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A7D1416D4D6; Fri, 10 May 2024 07:37:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="heLlFnaM" 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 A84B415FA62; Fri, 10 May 2024 07:37:42 +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=1715326665; cv=none; b=K4gKWXL1QADU+DN3vWWupkbob1VfOxO8wPVolYEuL3cRzICvA9fVjupjDfQnIo5laTzFmbDP729OWXNnDM8M3YioK8Wpb+Rl9RFROZYCQHC3N9IrZGg5gMzVbVAyfu+zwfR/pehEDvrQJpN/Q+P+CnyOnaLruOakHRJGIGVnasM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715326665; c=relaxed/simple; bh=q0ODQo1/fKkt5jwjA8LMTgrwpxwI3PEWS6up4ckYCN0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rBYfhiACOqWIALmF/AshpUXYL8FSHgrWqNN9MYPcrUk4CLTuN9hYRf6qRkpzDprA7jP3G1c4ofTmX9TwQQzOkQmHWkDobe1mObbfJWoP0GG8W3Ds2dOoMfMoYOg0+IEiA77tIgOIZoHqONdLRo5+vVl5iuI7Qi5VoWrq5NCYqqs= 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=heLlFnaM; 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 E6E0D240007; Fri, 10 May 2024 07:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1715326655; 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=R70rkyRP1Hf1pp49vShPfEGxoK1eDHjp1Cs21gNxWro=; b=heLlFnaMMiSW6jgN/C5enaGjr6fn6SrEoe5RGt8BIgAwJDNd+ln2EFWgjywe0FpYb00RAB +QUYBt4Kp8daKpNb8wruc/L75oaDtKLMIVkwaQWhbRgGYllWs8u9lhv9ut88SqaDDKzvwQ 96inZQ1FlFy5rd4MSDBQ+QDVu9y1RTU9KjJpWhd8q3v07OSOyzcEmfQTUMjnK2FN7Q2gMR U3ph/NWuTgprwVUMqKSJFkkkIoT9RcMPnnyZ8jby4bSny7+LA+mUXgl4CE9sQP6BeCvRvL VE+47LiVVWSHtWYDr8VdSKgRvlkttNcL9+0k8EoF0n5hWbHob1X3lIoNv8t/rA== From: Romain Gantois Date: Fri, 10 May 2024 09:38:10 +0200 Subject: [PATCH net-next v6 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: <20240510-rzn1-gmac1-v6-3-b63942be334c@bootlin.com> References: <20240510-rzn1-gmac1-v6-0-b63942be334c@bootlin.com> In-Reply-To: <20240510-rzn1-gmac1-v6-0-b63942be334c@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 badfe686a5702..ed38099ca7406 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 net_device *ndev); 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 0ac99c132733d..ef285b3c56ab9 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(ndev); -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 73ba9901a4439..778d79cdb2e6d 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