From patchwork Sun Jun 2 14:36:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13682909 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 226DAC25B74 for ; Sun, 2 Jun 2024 14:37:18 +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=UmRv8LhB6lrfuize4jedwuuKsJOYYDGhTO2/0/wAxy4=; b=cCzp8HoV66VO3n JKfEeWStxFSo8myc2XBxLRdglX+Neoba8KeCQ/zPWOCwfhTQEO/3sgiT/anh/VKZG8EXuEOap5C29 wB2EA7raTKXnKYB1q25OKppm+WKXMnKx7Gzb7i14vZ4qV4PkEMcTIxbkmeKOsJ1TwldXu8YbFA4Td /MpyOALY27wVdpWNl3AgJOuRX5VuIQOggcb6feeTAhGjBydEMvNv+oeVSFd6uWtF9Esd+F5iaGg7J WgwgwCDYtjxWB2F4gYF0HwTMtSAwV0MxvL85J75laEl+3ccciUIv0AwZPecQn/eCH+n4BqyP8edzN Lhis5y8y4A88fJvBPMYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDmKY-0000000EQ5k-31wJ; Sun, 02 Jun 2024 14:37:06 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDmKW-0000000EQ3R-0qjE for linux-arm-kernel@lists.infradead.org; Sun, 02 Jun 2024 14:37:05 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-52965199234so3905286e87.2 for ; Sun, 02 Jun 2024 07:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717339021; x=1717943821; 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=7vjMvBNpGJ2YRY1Cb9nA1dqsGS8aAwxtGRodJv9KKVo=; b=PicHrIgei4+8iw9Ukqx2Idnh16yuTM5WpSf1JgHdkD3PzACfsnI5S2BTz/BDpE9Izj Z9EAZz++Wfo+9fdyImxjdRn1tditHVuZON4fEHaKjevW136F5ofKwo8+/fH0x+YIF4IW sFe1B9wItptrIYTxLXaBHwyNkOdltY/m+/1vZiz52drAHZ8RTucvpCsncs0vZCwtdm53 0aid+kPGlv3Uql2XKHIrHV/l5hvDA7v27zCostDtPv58PLQETJMJihZupGL8FH5Rw5Su vhB0UlUJ08FUYvXgn3EPLi9K1lCKPkmHiEzcp0/jVrlnitcVFqepGeLWDxb8J9jZxkwR xirw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717339021; x=1717943821; 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=7vjMvBNpGJ2YRY1Cb9nA1dqsGS8aAwxtGRodJv9KKVo=; b=JzNV87irgCuUb2dSiOY6tT2MumFFOSh4XMQketto6sQmMl3tDlV/b/NAdW57HoKEYp n4gSqxCvHznavba9eAcfODJqEjRStQ7psPuIH2hn4vemVxXspMoBiFgSgHzFll5S+Trx phUEdLFLh5q+kbgszMv11r5zrOuTpSZfZVgR3b6HzkDtrDUAlVwgbw+bPEUhwgYQ8pR6 YLJu6UZVbz9zyRsaaWxbYqeMh8WfuvcNoBIkvLYR3uCBbOgbp1ASfzMhR7fqL5a8qh9y w2AxaRSq2cld4VhtZjjCnBwzDN3aLgUB5QHnhMgPhgLtzhpJKUK8gU4HaSOR/xKObP8D aoqg== X-Forwarded-Encrypted: i=1; AJvYcCU3blohIcrP7yREFSnslZNNrs10SMRXSZXzsEsYLYNSzPleMTBYAlcWvTsWIs2YB2OIzxM88HHf9zF1HbSZ7FNec3xmmY4wo7XreFFEVJevzNKasjU= X-Gm-Message-State: AOJu0YyODqbqAuOe4gefzudI391N+JLtSEvHR9gI3KTDXj3nA2BDVikZ K+35OMv3qXE/S4JgMYQJRgBChF/bFqJ6G2Ts19M4bKbms2o6FhYL X-Google-Smtp-Source: AGHT+IF+Hex+g3j4f6h2pCksD9/xzuP9uZz4YvqyQTtFSMyXUw0x6Mqvz4SNvUNBrOtKz3gPvsNgXg== X-Received: by 2002:a05:6512:4c6:b0:52b:5f39:9221 with SMTP id 2adb3069b0e04-52b896f183fmr4063497e87.64.1717339021163; Sun, 02 Jun 2024 07:37:01 -0700 (PDT) Received: from localhost ([178.178.142.64]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52b98fb5c5asm152445e87.16.2024.06.02.07.37.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 07:37:00 -0700 (PDT) From: Serge Semin To: Andrew Lunn , Heiner Kallweit , Russell King , Alexandre Torgue , Jose Abreu , Jose Abreu , Vladimir Oltean , Florian Fainelli , Maxime Chevallier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Serge Semin , Sagar Cheluvegowda , Abhishek Chauhan , Andrew Halaney , Jiawen Wu , Mengyuan Lou , Tomer Maimon , 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 v2 09/10] net: stmmac: Create DW XPCS device with particular address Date: Sun, 2 Jun 2024 17:36:23 +0300 Message-ID: <20240602143636.5839-10-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240602143636.5839-1-fancer.lancer@gmail.com> References: <20240602143636.5839-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-20240602_073704_266252_C72FA61B X-CRM114-Status: GOOD ( 19.23 ) 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 only STMMAC platform driver using the DW XPCS code is the Intel mGBE device driver. (It can be determined by finding all the drivers having the stmmac_mdio_bus_data::has_xpcs flag set.) At the same time the low-level platform driver masks out the DW XPCS MDIO-address from being auto-detected as PHY by the MDIO subsystem core. Seeing the PCS MDIO ID is known the procedure of the DW XPCS device creation can be simplified by dropping the loop over all the MDIO IDs. From now the DW XPCS device descriptor will be created for the pre-defined MDIO-bus address. Note besides this shall speed up a bit the Intel mGBE probing. Signed-off-by: Serge Semin --- Changelog v2: - This is a new patch introduced on v2 stage of the review. --- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 15 ++++----------- include/linux/stmmac.h | 1 + 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 56649edb18cd..e60b7e955c35 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -586,6 +586,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII || plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) { plat->mdio_bus_data->has_xpcs = true; + plat->mdio_bus_data->xpcs_addr = INTEL_MGBE_XPCS_ADDR; plat->mdio_bus_data->default_an_inband = true; } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index aa43117134d3..807789d7309a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -499,8 +499,7 @@ int stmmac_pcs_setup(struct net_device *ndev) { struct dw_xpcs *xpcs = NULL; struct stmmac_priv *priv; - int ret = -ENODEV; - int mode, addr; + int addr, mode, ret; priv = netdev_priv(ndev); mode = priv->plat->phy_interface; @@ -509,15 +508,9 @@ int stmmac_pcs_setup(struct net_device *ndev) ret = priv->plat->pcs_init(priv); } else 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; - - ret = 0; - break; - } + addr = priv->plat->mdio_bus_data->xpcs_addr; + xpcs = xpcs_create_mdiodev(priv->mii, addr, mode); + ret = PTR_ERR_OR_ZERO(xpcs); } else { return 0; } diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index f337286623bb..a11b850d3672 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -83,6 +83,7 @@ struct stmmac_priv; struct stmmac_mdio_bus_data { unsigned int phy_mask; unsigned int has_xpcs; + unsigned int xpcs_addr; unsigned int default_an_inband; int *irqs; int probed_phy_irq; From patchwork Sun Jun 2 14:36:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Serge Semin X-Patchwork-Id: 13682910 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 EEC2FC27C4F for ; Sun, 2 Jun 2024 14:37:18 +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=MeHD9KEApNk63hX//GrH4qdYdG0r7yBgJ7CVaw0nFqI=; b=x5ZTG9Mi3tYFR6 iQ2j+C6WOKBgWmrhSJFy1oUPCVdKwWRPh6CFeQwftnvPhRL8jzgn4PAcWAl+Ps6D2MpRr3jtKlHs/ o/8Vd2L7emInzInuL218TFnKJRgaCAg0JWXCr5E5hEGvW1z1PBXU9utRXueX8AOXKNbnew1a7cJNT 2ZIx/GfPPi5m8NYBlmk5V6cz9itBQUw3ngbsSy0j/Y6CQGEa2GGnGfB0lAkDnBpe4VJ/NFmibu7nB UgIJcMExz1cGTuwhyW2Yw1IiJSYL4FWebi9FfVcpSol8csjzwf6ZjOvuXMydALgBx01veL6XcqofM xgv02y/+8Dla6CPn1uDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDmKZ-0000000EQ6X-2jhM; Sun, 02 Jun 2024 14:37:07 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDmKX-0000000EQ49-0WgZ for linux-arm-kernel@lists.infradead.org; Sun, 02 Jun 2024 14:37:06 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52b919d1fc0so780278e87.0 for ; Sun, 02 Jun 2024 07:37:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717339023; x=1717943823; 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=dU7sOuoCnE7DZBaFJYawXWXaLrHsBgPyxKdpukglgGI=; b=B55IQ7bQfnN3yrSpH2qgL9CfTTolNtVnpY+KwlBIx1U2liU8AkBR6TuvvfKipZE3OJ FzBoL/ljNMVybHXG5K9sAhWqzwYgyLLlcX1kq3v7jdxycNPwAf3dPGnXhtOMObcKAnmv Sc8CxdEcDfC3C/fD8HwqgUiDi5zmr3fC/qWVwoUcLE5wk/WYNeJnkLsHiVCNfkHi6Kiq SBwou/rxieNfstu3noYqk3NLEiZsk7uy+WZWxisSYlxUI/lmvC2AqLvdue/tck3RJTh7 slM+6cBa1lwEjTYVolnGp0d68lPFCL1DSPuCBlX3EmLiIuIVC4k1Q41tWNAuV7V5fkNJ pCFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717339023; x=1717943823; 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=dU7sOuoCnE7DZBaFJYawXWXaLrHsBgPyxKdpukglgGI=; b=O6/7yefsoUSOQ0aOYZksRCZ9ONI8Jv2v62ekXfUyN/Ed63akGPbM2gLbfeKeui1e+u KUGCWdCbauggDc9T19cMR6MSoElu1UZSO15m9+BPRVPNVWe3UYlmE8LcM+gx6u/bLVIk RPSZfHXEPD+VnrFW07qsMhrqb4+epl9uxOyOAi8AOl9m0vZrYr6qqxdxC1JuUche7135 B6CGwb8TvsZuyoyome+dcNsOnMirmOSgGiURSx6/ZcCj2RE0aoSO+UBCfpd+whxtEy1J KyZjEIjR03JX8SQZqoH/iW68sZuaJQRC4WwyH4KwGk5pJC1bsb1KaUpC5asqK7a1wYbs oYVA== X-Forwarded-Encrypted: i=1; AJvYcCX3vde5zgdIEMpvmgtTq8wmoRlqtdGLAonwyCVJzKCSfGc/zy8z49XEKoJgb/J04kL+aOF8w42uF1Ylm6S3X88b5WMKilNlWQhn7npAm2HCZtNiisQ= X-Gm-Message-State: AOJu0YxWxlxrcEUYNmWU8cVZGvpY7nJKL1utHosUP8Zi0Aj1ffOo4ysj 1+vgGlop+zz58XRXpCKQ6rx79IkrekZwnwMaNH4BBx7ngh2XK4UZ X-Google-Smtp-Source: AGHT+IGG30UwFOotd/0Zdrr/C30omiONtB0LV+xIFdYgqxXQLjQdJQlWg/j2uttrnvCHheKu72hvDg== X-Received: by 2002:a19:5f53:0:b0:52b:8912:2843 with SMTP id 2adb3069b0e04-52b89122a59mr1943524e87.32.1717339022871; Sun, 02 Jun 2024 07:37:02 -0700 (PDT) Received: from localhost ([178.178.142.64]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52b84d34b18sm966116e87.12.2024.06.02.07.37.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 07:37:02 -0700 (PDT) From: Serge Semin To: Andrew Lunn , Heiner Kallweit , Russell King , Alexandre Torgue , Jose Abreu , Jose Abreu , Vladimir Oltean , Florian Fainelli , Maxime Chevallier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin Cc: Serge Semin , Sagar Cheluvegowda , Abhishek Chauhan , Andrew Halaney , Jiawen Wu , Mengyuan Lou , Tomer Maimon , 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 v2 10/10] net: stmmac: Add DW XPCS specified via "pcs-handle" support Date: Sun, 2 Jun 2024 17:36:24 +0300 Message-ID: <20240602143636.5839-11-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240602143636.5839-1-fancer.lancer@gmail.com> References: <20240602143636.5839-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-20240602_073705_216791_1AF18D87 X-CRM114-Status: GOOD ( 15.89 ) 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 Recently the DW XPCS DT-bindings have been introduced and the DW XPCS driver has been altered to support the DW XPCS registered as a platform device. In order to have the DW XPCS DT-device accessed from the STMMAC driver let's alter the STMMAC PCS-setup procedure to support the "pcs-handle" property containing the phandle reference to the DW XPCS device DT-node. The respective fwnode will be then passed to the xpcs_create_fwnode() function which in its turn will create the DW XPCS descriptor utilized in the main driver for the PCS-related setups. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 807789d7309a..dc040051aa53 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -497,15 +497,22 @@ int stmmac_mdio_reset(struct mii_bus *bus) int stmmac_pcs_setup(struct net_device *ndev) { + struct fwnode_handle *devnode, *pcsnode; struct dw_xpcs *xpcs = NULL; struct stmmac_priv *priv; int addr, mode, ret; priv = netdev_priv(ndev); mode = priv->plat->phy_interface; + devnode = priv->plat->port_node; if (priv->plat->pcs_init) { ret = priv->plat->pcs_init(priv); + } else if (fwnode_property_present(devnode, "pcs-handle")) { + pcsnode = fwnode_find_reference(devnode, "pcs-handle", 0); + xpcs = xpcs_create_fwnode(pcsnode, mode); + fwnode_handle_put(pcsnode); + ret = PTR_ERR_OR_ZERO(xpcs); } else if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { addr = priv->plat->mdio_bus_data->xpcs_addr; @@ -515,10 +522,8 @@ int stmmac_pcs_setup(struct net_device *ndev) return 0; } - if (ret) { - dev_warn(priv->device, "No xPCS found\n"); - return ret; - } + if (ret) + return dev_err_probe(priv->device, ret, "No xPCS found\n"); priv->hw->xpcs = xpcs;