From patchwork Fri Jun 10 03:29:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ong Boon Leong X-Patchwork-Id: 12876358 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 0159DC43334 for ; Fri, 10 Jun 2022 03:36:23 +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=khfoGk2igrM3YRXxGW+UHvm3OHtbkpQXSoRpF7paJTs=; b=DCJlk94dwoSfgN SufgeL4Mj+xMmiPUzJOoAauEmIcpKl2VxXJohE3G0dtmJchrPTglpaQXNP1RG4nMpTn8Dd6RxOHh3 F3DFVDBnwVtOOKBICiXk8kB5mOPY+Aj1dl59oR3WyadAZuVWReIgNj30ddGUTz5H5Kg/8IQNAOLOU gZz3dkQqJ2fXDe0r+knwh2nXlhDsUpQxrzRlkKXTrvMwv/ipubOl6ZcABPxBamIULd7ptlqg8Py/0 iUQ586iuUuGlh681M44ktW9mYvyw7MfF91oSB9spG3cTFF6f4nNOvyIXtIebcdRfRqyQBH9hXwd5k W+0qaL3vRYLvX1mxxmzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVQ5-005RbI-TG; Fri, 10 Jun 2022 03:34:46 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVPw-005RYQ-1t for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 03:34:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654832076; x=1686368076; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7k7HcB44rqwUtLS1IEz9qgWJASb6b1ZUMkYhi6CGeEg=; b=Ps87vWFjljssAky0uJF46SrUEKKiU9iqcwtWU3mASmrpEZVZVPatwZEC eTYnXhsXx4bjnYU4TzfgfRLgs+QPdTNihR70MPxU9+JodtaPMhRvbtWVQ T11vVrXSvQJJ6y2b9dCsfSItDmpqA2W2ak1jtHRwMvsVvXf/jhcN7k8FI Rz4OCLbYzil/BTJdUFPgnZphr3CgNIcorpqSSgRKPbTLjs4tRipIhYyX3 mB2x0idJ9DaqiM7B+Il/GcvdZyBhddjRSmflQJ/yiDcZniG3gqk0JSPHu rxwqleylxpRNMmf45Dr/KTEjecU1mr07lLcT8rnmNvTufVTHLVuDp37Z+ g==; X-IronPort-AV: E=McAfee;i="6400,9594,10373"; a="275024604" X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="275024604" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2022 20:34:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="585971598" Received: from p12hl98bong5.png.intel.com ([10.158.65.178]) by fmsmga007.fm.intel.com with ESMTP; 09 Jun 2022 20:34:29 -0700 From: Ong Boon Leong To: Alexandre Torgue , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King , Paolo Abeni , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Vladimir Oltean , Vivien Didelot , Florian Fainelli , Maxime Coquelin , Giuseppe Cavallaro Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Emilio Riva , Ong Boon Leong Subject: [PATCH net-next v2 1/6] net: dsa: sja1105: update xpcs_do_config additional input Date: Fri, 10 Jun 2022 11:29:36 +0800 Message-Id: <20220610032941.113690-2-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610032941.113690-1-boon.leong.ong@intel.com> References: <20220610032941.113690-1-boon.leong.ong@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_203436_167226_99D52D49 X-CRM114-Status: GOOD ( 12.07 ) 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 xpcs_do_config() is used for xpcs configuration without depending on advertising input, so set to NULL. Reported-by: kernel test robot Signed-off-by: Ong Boon Leong --- drivers/net/dsa/sja1105/sja1105_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 72b6fc1932b..b253e27bcfb 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -2330,7 +2330,7 @@ int sja1105_static_config_reload(struct sja1105_private *priv, else mode = MLO_AN_PHY; - rc = xpcs_do_config(xpcs, priv->phy_mode[i], mode); + rc = xpcs_do_config(xpcs, priv->phy_mode[i], mode, NULL); if (rc < 0) goto out; From patchwork Fri Jun 10 03:29:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ong Boon Leong X-Patchwork-Id: 12876359 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 54F26C433EF for ; Fri, 10 Jun 2022 03:36:25 +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=zlV9wLzXRonGyyW30aVdUZDhk8205TDGHUCoDsDH2mA=; b=cxNsfYBWRogm/A Wacdh0Mn1PaEBi6ZzoCRwoib7gvTpRYmSnmanVQxh3L7bQgKPadRaVgF0XMfnsM7WbbUoaqNFzXa4 kc8RoKfqXlA5P75lkqZaS0KZjEJ7WOlrbQFV22lZlvaotKuCw2Gj5K6qmtZTX69KSNKX2pOG7BPBv MP2NGS4FY+gG8Aj8eIWeFFCMblG5knHK/R8ssvNl+5D0UwMCphpk/FcKQ70XeS8BnlcqTGDbQOXSh sI5LHYC0ki/fUrAxz6AJAlAPYyxEbFLG5GPIW7hcImjOqlr27mGvWSorl+/SyWfkIPsGZ66DzPDPC qtrONH1kS+HR3AonDAgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVQF-005Re9-EF; Fri, 10 Jun 2022 03:34:55 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVQ0-005RYQ-QN for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 03:34:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654832080; x=1686368080; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YKMttFBPE2wCzfsgWycExPpf2Tu2U5inMYPLhQKTMdY=; b=D/W5y5rOoBalfnAachCN4jc0ysb9AHsiarSIdMxcYXG3DA34gC773OXS Kv4pwOOJwKDgtc4UdaF/mVCCN/7Wxh7fkLExLT2WqqQii9CtbXtwGa+4w E/XHrW2kLikhDhqHJBYTz303WD1xv7yHESRXXn8MrYkuSQX6M89DOTKX8 B8HPnv6BVOQBxL0VcuN1+vTANFQ8ktjLFyA8dfMUSZ+PWxfCTPEaDeD9/ 3sgK59vemDzFaMkDPXIG5eZTeh8mSfrjXZMnkTeal3bVTuBkxzRRo4kns p51C7/FIDvfyQoNUjJzCU3zJuUfSxlFf5EXM0Io4PLFtYOT9YyzmIjhmn Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10373"; a="275024610" X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="275024610" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2022 20:34:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="585971614" Received: from p12hl98bong5.png.intel.com ([10.158.65.178]) by fmsmga007.fm.intel.com with ESMTP; 09 Jun 2022 20:34:35 -0700 From: Ong Boon Leong To: Alexandre Torgue , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King , Paolo Abeni , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Vladimir Oltean , Vivien Didelot , Florian Fainelli , Maxime Coquelin , Giuseppe Cavallaro Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Emilio Riva , Ong Boon Leong Subject: [PATCH net-next v2 2/6] stmmac: intel: prepare to support 1000BASE-X phy interface setting Date: Fri, 10 Jun 2022 11:29:37 +0800 Message-Id: <20220610032941.113690-3-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610032941.113690-1-boon.leong.ong@intel.com> References: <20220610032941.113690-1-boon.leong.ong@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_203440_890760_A4A3854D X-CRM114-Status: GOOD ( 13.76 ) 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, intel_speed_mode_2500() redundantly fix-up phy_interface to PHY_INTERFACE_MODE_SGMII if the underlying controller is in 1000Mbps SGMII mode. The value of phy_interface has been initialized earlier. This patch removes such redundancy to prepare for setting 1000BASE-X mode for certain hardware platform configuration. Also update the intel_mgbe_common_data() to include 1000BASE-X setup. Signed-off-by: Ong Boon Leong --- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 38fe77d1035..675dfb89b76 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -251,7 +251,6 @@ static void intel_speed_mode_2500(struct net_device *ndev, void *intel_data) priv->plat->mdio_bus_data->xpcs_an_inband = false; } else { priv->plat->max_speed = 1000; - priv->plat->phy_interface = PHY_INTERFACE_MODE_SGMII; priv->plat->mdio_bus_data->xpcs_an_inband = true; } } @@ -562,7 +561,8 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->vlan_fail_q = plat->rx_queues_to_use - 1; /* Intel mgbe SGMII interface uses pcs-xcps */ - if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII) { + 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_an_inband = true; } From patchwork Fri Jun 10 03:29:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ong Boon Leong X-Patchwork-Id: 12876360 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 70664C43334 for ; Fri, 10 Jun 2022 03:36:50 +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=d13dh1gFeCn0V9MzyEB7S4m4SHz6TkS1JW6/ImYLUEk=; b=PTKZhpUWF6tLiT kHlkKcIVRf0mh+UC+GXJNkyJVG0fCHxRes3JmyEOEgmOBilN3Sh2U5idpzG5hdzB1o3sE4fMFy+9V tzvGJaxcCu0XT/a1Vho1S9SBEdoYSnwEyYeOJm+69WMomDmJrNxWzo3BDtUROP38UXTgOaV+pAKU6 58Me0Dwmx1mUcLm4abADgsthWagVnZSSJvKpUauiTCIiQ3VW5kvZ26sGZmEqEPOEHenn9MVYpp5rY oU7cXqJB63qe1lEXxLwbNAv7Jz3MD+siZLTa7iI5z0YSFSqDEYBBbvPyB96ocq4VGlXqUCgYQdQdr w/GdN+vNvL/eHBDjpnlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVQR-005RjC-26; Fri, 10 Jun 2022 03:35:07 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVQ4-005RYQ-Iq for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 03:34:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654832084; x=1686368084; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MXw/zChD1a8mVZCgKOqdhbMJAHYRSVeEBL3gFQMJIeA=; b=RAZL8HTHS1fQOUSosALshRjlWQovxWUPYLuHS0CfYvBc5ES3a3kh6fzc rASXRpOrfzRAelfKT2vfIr43xys/F0ICaNZM1ZRST/quOTmAMioa5Hf+M qouY0G1q5PnrRiGI6y2/nsqBS9T8U5f9a3zWSIalq91sMtpJAo01TaCuV fgi7MNbIGEyn6V5GrlBRQE6PXDdQbV95bisrIkItqybNuqEZD5in7+k4j 33VEMAq1DbmiJpkAU1F7xN2pfG0SFIsGhf/9Jh1hwKCt57yUM6qHV1BWW wWCXO86nwrtWs4sxqu5czgGyvbaFf4t7TiKKOkL0zoAAgkpDSPqbxl5Tv A==; X-IronPort-AV: E=McAfee;i="6400,9594,10373"; a="275024620" X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="275024620" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2022 20:34:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="585971626" Received: from p12hl98bong5.png.intel.com ([10.158.65.178]) by fmsmga007.fm.intel.com with ESMTP; 09 Jun 2022 20:34:40 -0700 From: Ong Boon Leong To: Alexandre Torgue , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King , Paolo Abeni , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Vladimir Oltean , Vivien Didelot , Florian Fainelli , Maxime Coquelin , Giuseppe Cavallaro Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Emilio Riva , Ong Boon Leong Subject: [PATCH net-next v2 3/6] net: pcs: xpcs: add CL37 1000BASE-X AN support Date: Fri, 10 Jun 2022 11:29:38 +0800 Message-Id: <20220610032941.113690-4-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610032941.113690-1-boon.leong.ong@intel.com> References: <20220610032941.113690-1-boon.leong.ong@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_203444_678037_16ACF4C1 X-CRM114-Status: GOOD ( 20.62 ) 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 For CL37 1000BASE-X AN, DW xPCS does not support C22 method but offers C45 vendor-specific MII MMD for programming. We also add the ability to disable Autoneg (through ethtool for certain network switch that supports 1000BASE-X (1000Mbps and Full-Duplex) but not Autoneg capability. v2: Fixes to issues spotted by Russell King in v1. Thanks! https://patchwork.kernel.org/comment/24826650/ Use phylink_mii_c22_pcs_encode_advertisement() and implement C45 MII ADV handling since IP only support C45 access. Tested-by: Emilio Riva Signed-off-by: Ong Boon Leong --- drivers/net/pcs/pcs-xpcs.c | 180 +++++++++++++++++++++++++++++++++++ include/linux/pcs/pcs-xpcs.h | 1 + 2 files changed, 181 insertions(+) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 48d81c40aab..5f75ad503ef 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -77,6 +77,14 @@ static const int xpcs_sgmii_features[] = { __ETHTOOL_LINK_MODE_MASK_NBITS, }; +static const int xpcs_1000basex_features[] = { + ETHTOOL_LINK_MODE_Pause_BIT, + ETHTOOL_LINK_MODE_Asym_Pause_BIT, + ETHTOOL_LINK_MODE_Autoneg_BIT, + ETHTOOL_LINK_MODE_1000baseX_Full_BIT, + __ETHTOOL_LINK_MODE_MASK_NBITS, +}; + static const int xpcs_2500basex_features[] = { ETHTOOL_LINK_MODE_Pause_BIT, ETHTOOL_LINK_MODE_Asym_Pause_BIT, @@ -102,6 +110,10 @@ static const phy_interface_t xpcs_sgmii_interfaces[] = { PHY_INTERFACE_MODE_SGMII, }; +static const phy_interface_t xpcs_1000basex_interfaces[] = { + PHY_INTERFACE_MODE_1000BASEX, +}; + static const phy_interface_t xpcs_2500basex_interfaces[] = { PHY_INTERFACE_MODE_2500BASEX, PHY_INTERFACE_MODE_MAX, @@ -112,6 +124,7 @@ enum { DW_XPCS_10GKR, DW_XPCS_XLGMII, DW_XPCS_SGMII, + DW_XPCS_1000BASEX, DW_XPCS_2500BASEX, DW_XPCS_INTERFACE_MAX, }; @@ -189,6 +202,16 @@ int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val) return mdiobus_c45_write(bus, addr, dev, reg, val); } +int xpcs_modify_changed(struct dw_xpcs *xpcs, int dev, u32 reg, + u16 mask, u16 set) +{ + u32 reg_addr = mdiobus_c45_addr(dev, reg); + struct mii_bus *bus = xpcs->mdiodev->bus; + int addr = xpcs->mdiodev->addr; + + return mdiobus_modify_changed(bus, addr, reg_addr, mask, set); +} + static int xpcs_read_vendor(struct dw_xpcs *xpcs, int dev, u32 reg) { return xpcs_read(xpcs, dev, DW_VENDOR | reg); @@ -237,6 +260,7 @@ static int xpcs_soft_reset(struct dw_xpcs *xpcs, break; case DW_AN_C37_SGMII: case DW_2500BASEX: + case DW_AN_C37_1000BASEX: dev = MDIO_MMD_VEND2; break; default: @@ -772,6 +796,68 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, unsigned int mode) return ret; } +static int xpcs_config_aneg_c37_1000basex(struct dw_xpcs *xpcs, unsigned int mode, + const unsigned long *advertising) +{ + phy_interface_t interface = PHY_INTERFACE_MODE_1000BASEX; + int ret, mdio_ctrl, adv; + bool changed = 0; + + /* According to Chap 7.12, to set 1000BASE-X C37 AN, AN must + * be disabled first:- + * 1) VR_MII_MMD_CTRL Bit(12)[AN_ENABLE] = 0b + * 2) VR_MII_AN_CTRL Bit(2:1)[PCS_MODE] = 00b (1000BASE-X C37) + */ + mdio_ctrl = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL); + if (mdio_ctrl < 0) + return mdio_ctrl; + + if (mdio_ctrl & AN_CL37_EN) { + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, + mdio_ctrl & ~AN_CL37_EN); + if (ret < 0) + return ret; + } + + ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL); + if (ret < 0) + return ret; + + ret &= ~DW_VR_MII_PCS_MODE_MASK; + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_CTRL, ret); + if (ret < 0) + return ret; + + /* Check for advertising changes and update the C45 MII ADV + * register accordingly. + */ + adv = phylink_mii_c22_pcs_encode_advertisement(interface, + advertising); + if (adv >= 0) { + ret = xpcs_modify_changed(xpcs, MDIO_MMD_VEND2, + MII_ADVERTISE, 0xffff, adv); + if (ret < 0) + return ret; + + changed = ret; + } + + /* Clear CL37 AN complete status */ + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); + if (ret < 0) + return ret; + + if (phylink_autoneg_inband(mode) && + linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, advertising)) { + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, + mdio_ctrl | AN_CL37_EN); + if (ret < 0) + return ret; + } + + return changed; +} + static int xpcs_config_2500basex(struct dw_xpcs *xpcs) { int ret; @@ -817,6 +903,12 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, if (ret) return ret; break; + case DW_AN_C37_1000BASEX: + ret = xpcs_config_aneg_c37_1000basex(xpcs, mode, + advertising); + if (ret) + return ret; + break; case DW_2500BASEX: ret = xpcs_config_2500basex(xpcs); if (ret) @@ -921,6 +1013,40 @@ static int xpcs_get_state_c37_sgmii(struct dw_xpcs *xpcs, return 0; } +static int xpcs_get_state_c37_1000basex(struct dw_xpcs *xpcs, + struct phylink_link_state *state) +{ + int lpa, adv; + int ret; + + if (state->an_enabled) { + /* Reset link state */ + state->link = false; + + lpa = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_LPA); + if (lpa < 0 || lpa & LPA_RFAULT) + return lpa; + + adv = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_ADVERTISE); + if (adv < 0) + return adv; + + if (lpa & ADVERTISE_1000XFULL && + adv & ADVERTISE_1000XFULL) { + state->link = true; + state->speed = SPEED_1000; + state->duplex = DUPLEX_FULL; + } + + /* Clear CL37 AN complete status */ + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); + if (ret < 0) + return ret; + } + + return 0; +} + static void xpcs_get_state(struct phylink_pcs *pcs, struct phylink_link_state *state) { @@ -948,6 +1074,13 @@ static void xpcs_get_state(struct phylink_pcs *pcs, ERR_PTR(ret)); } break; + case DW_AN_C37_1000BASEX: + ret = xpcs_get_state_c37_1000basex(xpcs, state); + if (ret) { + pr_err("xpcs_get_state_c37_1000basex returned %pe\n", + ERR_PTR(ret)); + } + break; default: return; } @@ -983,6 +1116,32 @@ static void xpcs_link_up_sgmii(struct dw_xpcs *xpcs, unsigned int mode, pr_err("%s: xpcs_write returned %pe\n", __func__, ERR_PTR(ret)); } +static void xpcs_link_up_1000basex(struct dw_xpcs *xpcs, int speed, + int duplex) +{ + int val, ret; + + switch (speed) { + case SPEED_1000: + val = BMCR_SPEED1000; + break; + case SPEED_100: + case SPEED_10: + default: + pr_err("%s: speed = %d\n", __func__, speed); + return; + } + + if (duplex == DUPLEX_FULL) + val |= BMCR_FULLDPLX; + else + pr_err("%s: half duplex not supported\n", __func__); + + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1, val); + if (ret) + pr_err("%s: xpcs_write returned %pe\n", __func__, ERR_PTR(ret)); +} + void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, phy_interface_t interface, int speed, int duplex) { @@ -992,9 +1151,23 @@ void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, return xpcs_config_usxgmii(xpcs, speed); if (interface == PHY_INTERFACE_MODE_SGMII) return xpcs_link_up_sgmii(xpcs, mode, speed, duplex); + if (interface == PHY_INTERFACE_MODE_1000BASEX) + return xpcs_link_up_1000basex(xpcs, speed, duplex); } EXPORT_SYMBOL_GPL(xpcs_link_up); +static void xpcs_an_restart(struct phylink_pcs *pcs) +{ + struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); + int ret; + + ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1); + if (ret >= 0) { + ret |= BMCR_ANRESTART; + xpcs_write(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1, ret); + } +} + static u32 xpcs_get_id(struct dw_xpcs *xpcs) { int ret; @@ -1060,6 +1233,12 @@ static const struct xpcs_compat synopsys_xpcs_compat[DW_XPCS_INTERFACE_MAX] = { .num_interfaces = ARRAY_SIZE(xpcs_sgmii_interfaces), .an_mode = DW_AN_C37_SGMII, }, + [DW_XPCS_1000BASEX] = { + .supported = xpcs_1000basex_features, + .interface = xpcs_1000basex_interfaces, + .num_interfaces = ARRAY_SIZE(xpcs_1000basex_interfaces), + .an_mode = DW_AN_C37_1000BASEX, + }, [DW_XPCS_2500BASEX] = { .supported = xpcs_2500basex_features, .interface = xpcs_2500basex_interfaces, @@ -1115,6 +1294,7 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = { .pcs_validate = xpcs_validate, .pcs_config = xpcs_config, .pcs_get_state = xpcs_get_state, + .pcs_an_restart = xpcs_an_restart, .pcs_link_up = xpcs_link_up, }; diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 37eb97cc228..d2da1e0b4a9 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -17,6 +17,7 @@ #define DW_AN_C73 1 #define DW_AN_C37_SGMII 2 #define DW_2500BASEX 3 +#define DW_AN_C37_1000BASEX 4 struct xpcs_id; From patchwork Fri Jun 10 03:29:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ong Boon Leong X-Patchwork-Id: 12876361 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 CBC3DC433EF for ; Fri, 10 Jun 2022 03:36:51 +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=/hAT+kHzDjSQCWpVZBYqIF/UGVGqsHljlPDnBlUBjYw=; b=sDXpif90v2htuN Tx8WPrGY7+j2tjcrZWZhUHa5QMwaqwkv0mG0r+77eUk9pTiUe10xZoXJlWtwEIb31akC4Rmx4IQ8x FPOx7SJ6vdAsVhvlY5rKbXut0KIQZJWnXZthi4OGNNJeHSRrfQ4jxwulF5JNp3atMx2lW8p8K2TmE WmUqvWFF8yfc0Ogps4jvi91OxIB1hZ3SZ68BYxSm9xoq2xMQqM3XSwiNIB/fjVnTgUpVQ0britePm 9EJQr1LwNksCSLAN5Jk5zK5GSSaf1pvczY+zpQf5LE4IV6yp32SiEShtbd9+a83sWY6LoFeY77cCP nrhcnRxmmyxDQGDfOW2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVQe-005Roz-W7; Fri, 10 Jun 2022 03:35:21 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVQK-005RgS-JP for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 03:35:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654832100; x=1686368100; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VsECB4rGQ9AOMk/R4KLPANHo0BZNISsxKzENHkPxCnY=; b=F8hVdcH8nww6GT8YbTuabm4n2Pf6LAmJBrwLkefOQ57pSmv36OA0s5Fl U2EwUs2CFk7aCbq1AlRg4+W5JCaybZ6BrFw2Z9gLhePg/8BZwdOR8Y3W3 mN14V9YepUF9FF7Io/UqPs6IuyAZEbIVJxfZS6YU+E72k/CKKQ+VmLpd7 BH0z+xQW/Cio0obs0h+Uj8F60lxFUemyHnqCOxY1qyv2htiRo+8VelpY4 +BVPHDiJTFM4uizYWYQshlOHqC8vMRdNB53yhvbikhxSBfjoKzNKnDI4H HIvZbdfw0ILHc0ykCFJ/hW3SlTM8v24dwB+wZGumxIPwKxIkB9B1hPV7x Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10373"; a="275024626" X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="275024626" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2022 20:34:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="585971638" Received: from p12hl98bong5.png.intel.com ([10.158.65.178]) by fmsmga007.fm.intel.com with ESMTP; 09 Jun 2022 20:34:44 -0700 From: Ong Boon Leong To: Alexandre Torgue , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King , Paolo Abeni , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Vladimir Oltean , Vivien Didelot , Florian Fainelli , Maxime Coquelin , Giuseppe Cavallaro Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Emilio Riva , Ong Boon Leong Subject: [PATCH net-next v2 4/6] net: phylink: unset ovr_an_inband if fixed-link is selected Date: Fri, 10 Jun 2022 11:29:39 +0800 Message-Id: <20220610032941.113690-5-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610032941.113690-1-boon.leong.ong@intel.com> References: <20220610032941.113690-1-boon.leong.ong@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_203500_722888_0894F084 X-CRM114-Status: GOOD ( 12.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 If "fixed-link" DT or ACPI _DSD subnode is selected, it should take precedence over the value of ovr_an_inband passed by MAC driver. Fixes: ab39385021d1 ("net: phylink: make phylink_parse_mode() support non-DT platform") Tested-by: Emilio Riva Signed-off-by: Ong Boon Leong --- drivers/net/phy/phylink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 066684b8091..566852815e0 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -609,8 +609,10 @@ static int phylink_parse_mode(struct phylink *pl, struct fwnode_handle *fwnode) const char *managed; dn = fwnode_get_named_child_node(fwnode, "fixed-link"); - if (dn || fwnode_property_present(fwnode, "fixed-link")) + if (dn || fwnode_property_present(fwnode, "fixed-link")) { pl->cfg_link_an_mode = MLO_AN_FIXED; + pl->config->ovr_an_inband = false; + } fwnode_handle_put(dn); if ((fwnode_property_read_string(fwnode, "managed", &managed) == 0 && From patchwork Fri Jun 10 03:29:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ong Boon Leong X-Patchwork-Id: 12876362 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 A20BCC433EF for ; Fri, 10 Jun 2022 03:37:20 +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=ZSASjqpvjLfcPfF0fcgmeTVwpdh9D9KXdOxs9wfbrCI=; b=jcLMRieS+m4Gmp pWMMs9P3elIvDSqZDZgavJtPZsiLSZEp4ksfLJGcnD15u6bHMa6qg6TOBrB9VAdMRvBIIhs1RTxFy IgzHOKN/xkxckNxc8/z9B3NbDk45KXlDxrLDTuq8l3Rh+RVVDzCRdjJ2JVNz0KuaJywHS1SBnG5sq gxRiwaPlahSaweFzoOAr4VsRrT4tD9J480gwA3Smhw3yCDX/KlwrCw2l8JiYl8FmytMm9pOk67XoJ bvlN97h5T7bII6en9pdY1uCVm8FHU3/dMpt2SMlpKF/RMBEHNPsCqCwHHqUVDVpO1VA0rCLFX+mWG Qf5Ab8Yn4La/WUai8tAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVR1-005RxK-Qc; Fri, 10 Jun 2022 03:35:44 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVQN-005RgS-8I for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 03:35:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654832103; x=1686368103; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5EE9Irt/xFP6OZxqCU9pzSV6Tdyhia7NhlBMrgRnlk4=; b=KlGIkHB/S8b1SS/AVmbeyV1moKDIBmXbR0uquEy9Kvpa3MGaZFOc0W01 3Qv2mw3tUohXS9ILbc+dPcZ/EIx9ipZK4YjEh2Lcikb480PYV1nTq5hbO L9rfAJSrhKzrw1xpzubRLCWB1wBjNadEKvx0ZeUseBkmJc0QbVQ9k3IEC NNz1tWPTKaavKR+63uUPvaaw1RQSAap+iAIxAtEkK687rZvUCGIWRUaVd RTimqTlcna52QHtkEvFUQHrFg+LbWjfSLZHeKZssjCGTDYV0oV4MQmvFl 5OQpHcKcKMppZi5PxPsbLxQBksxedH8Q+apfs3dAqwuMrxInLazxs6ll0 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10373"; a="275024656" X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="275024656" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2022 20:34:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="585971667" Received: from p12hl98bong5.png.intel.com ([10.158.65.178]) by fmsmga007.fm.intel.com with ESMTP; 09 Jun 2022 20:34:49 -0700 From: Ong Boon Leong To: Alexandre Torgue , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King , Paolo Abeni , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Vladimir Oltean , Vivien Didelot , Florian Fainelli , Maxime Coquelin , Giuseppe Cavallaro Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Emilio Riva , Ong Boon Leong Subject: [PATCH net-next v2 5/6] stmmac: intel: add phy-mode ACPI _DSD setting support Date: Fri, 10 Jun 2022 11:29:40 +0800 Message-Id: <20220610032941.113690-6-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610032941.113690-1-boon.leong.ong@intel.com> References: <20220610032941.113690-1-boon.leong.ong@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_203503_370837_59CA924B X-CRM114-Status: GOOD ( 13.53 ) 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, phy_interface for TSN controller instance is set based on its PCI Device ID. For SGMII PHY interface, phy_interface default to PHY_INTERFACE_MODE_SGMII. As C37 AN supports both SGMII and 1000BASE-X mode, we add support for 'phy-mode' ACPI _DSD for port-specific and customer platform specific customization. Thanks to Andrew Lunn's guidance in https://patchwork.kernel.org/comment/24827101/ Tested-by: Emilio Riva Signed-off-by: Ong Boon Leong --- drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 675dfb89b76..e5f3d7deec3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -442,6 +442,7 @@ static void common_default_data(struct plat_stmmacenet_data *plat) static int intel_mgbe_common_data(struct pci_dev *pdev, struct plat_stmmacenet_data *plat) { + struct fwnode_handle *fwnode; char clk_name[20]; int ret; int i; @@ -560,6 +561,20 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, /* Use the last Rx queue */ plat->vlan_fail_q = plat->rx_queues_to_use - 1; + /* For fixed-link setup, we allow phy-mode setting */ + fwnode = dev_fwnode(&pdev->dev); + if (fwnode) { + const char *phy_mode; + + if (!fwnode_property_read_string(fwnode, "phy-mode", + &phy_mode)) { + if (!strcmp(phy_mode, "sgmii")) + plat->phy_interface = PHY_INTERFACE_MODE_SGMII; + if (!strcmp(phy_mode, "1000base-x")) + plat->phy_interface = PHY_INTERFACE_MODE_1000BASEX; + } + } + /* Intel mgbe SGMII interface uses pcs-xcps */ if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII || plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) { From patchwork Fri Jun 10 03:29:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ong Boon Leong X-Patchwork-Id: 12876363 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 A08AFC433EF for ; Fri, 10 Jun 2022 03:37:37 +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=V7jmKMGAQwb2XywXtgMBQcvzMOOY2ZMh5JKuYwMulBw=; b=FYpoEX80A5HERw XZhHCyR2HfPd6M23XcakVcglke8PW5RfQq50VtGhlZ4X/+G6hSb8glMi+w7mtDkbZre1t2K5x5gcS UHRC0lbdOsGKHoPh5z/aqjUKsBKs5t1YRfafzlzfiYjF4c6RAsO0uBZqatd0yLTwvttECkaoHI6/v hIm5MUFcYHy8Tkb1RKv6rZeQLQzLpoxHm+ba/9hF8ifp9JchURAWRefIrJmQnfiRm4tZpg2jzLavb qQ1Om3mKiKnCZBxiNMFwDuYkpL5ZUkZ3l+BIQVB0zpWrru9eo+eaD2zavlhXjlS/tIuT0TeWAOYmO wpC3KlPWVyZ6S/GZdaGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVRN-005S6g-8j; Fri, 10 Jun 2022 03:36:05 +0000 Received: from mga11.intel.com ([192.55.52.93]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzVQO-005RiN-FT for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 03:35:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654832104; x=1686368104; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FJL02eXOJ6PqC8kbf/jCzhaldzTN2TIxSgiMk42PRXA=; b=JLvWwffxPl0z9+7zH61RMt38gDV/uxxrumFXvX+LaCOpVKFAoNQklb5d 6DctnY+PfO04cDyTJ8lVMft59BWU90/b3A+xKMQ5ycnl6SVtRmIWZfshu qyPGsAJxp0xjzOesbVAJARf2rvTFiXlSiDpJ0uxDfWL9t9U3qcAi2JpQu jQdekwUnSNhAUNrNda4afJcdOa2MXNfWmT44XexKYB+HZcEv6QH1GZL9u ot6zoRE/wN3TBWJNKl/+8m/mwyPtWiSIr7MedNLt5piCqxpA1hg+YYTYR qkAjP8CdNgk/x8kMquwx0ijIZQ1DJd6tMS4npRTRVsc4dKJczSWR6e/Oi A==; X-IronPort-AV: E=McAfee;i="6400,9594,10373"; a="275024680" X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="275024680" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2022 20:34:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,288,1647327600"; d="scan'208";a="585971700" Received: from p12hl98bong5.png.intel.com ([10.158.65.178]) by fmsmga007.fm.intel.com with ESMTP; 09 Jun 2022 20:34:53 -0700 From: Ong Boon Leong To: Alexandre Torgue , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King , Paolo Abeni , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Vladimir Oltean , Vivien Didelot , Florian Fainelli , Maxime Coquelin , Giuseppe Cavallaro Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Emilio Riva , Ong Boon Leong Subject: [PATCH net-next v2 6/6] net: stmmac: make mdio register skips PHY scanning for fixed-link Date: Fri, 10 Jun 2022 11:29:41 +0800 Message-Id: <20220610032941.113690-7-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220610032941.113690-1-boon.leong.ong@intel.com> References: <20220610032941.113690-1-boon.leong.ong@intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220609_203504_720663_145DC40F X-CRM114-Status: GOOD ( 15.71 ) 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 stmmac_mdio_register() lacks fixed-link consideration and only skip PHY scanning if it has done DT style PHY discovery. So, for DT or ACPI _DSD setting of fixed-link, the PHY scanning should not happen. Tested-by: Emilio Riva Signed-off-by: Ong Boon Leong --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 11 ++++++----- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 73cae2938f6..bc8edd88175 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1141,19 +1141,20 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv) */ static int stmmac_init_phy(struct net_device *dev) { + struct fwnode_handle *fwnode = of_fwnode_handle(priv->plat->phylink_node); struct stmmac_priv *priv = netdev_priv(dev); - struct device_node *node; int ret; - node = priv->plat->phylink_node; + if (!fwnode) + fwnode = dev_fwnode(priv->device); - if (node) - ret = phylink_of_phy_connect(priv->phylink, node, 0); + if (fwnode) + ret = phylink_fwnode_phy_connect(priv->phylink, fwnode, 0); /* Some DT bindings do not set-up the PHY handle. Let's try to * manually parse it */ - if (!node || ret) { + if (!fwnode || ret) { int addr = priv->plat->phy_addr; struct phy_device *phydev; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 03d3d1f7aa4..5f177ea8072 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -434,9 +434,11 @@ int stmmac_mdio_register(struct net_device *ndev) int err = 0; struct mii_bus *new_bus; struct stmmac_priv *priv = netdev_priv(ndev); + struct fwnode_handle *fwnode = of_fwnode_handle(priv->plat->phylink_node); struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data; struct device_node *mdio_node = priv->plat->mdio_node; struct device *dev = ndev->dev.parent; + struct fwnode_handle *fixed_node; int addr, found, max_addr; if (!mdio_bus_data) @@ -490,6 +492,18 @@ int stmmac_mdio_register(struct net_device *ndev) if (priv->plat->has_xgmac) stmmac_xgmac2_mdio_read(new_bus, 0, MII_ADDR_C45); + /* If fixed-link is set, skip PHY scanning */ + if (!fwnode) + fwnode = dev_fwnode(priv->device); + + if (fwnode) { + fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link"); + if (fixed_node) { + fwnode_handle_put(fixed_node); + goto bus_register_done; + } + } + if (priv->plat->phy_node || mdio_node) goto bus_register_done;