From patchwork Fri Apr 22 07:35:02 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: 12822972 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 A6C9CC433F5 for ; Fri, 22 Apr 2022 07:48:28 +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=YKAENCOFKi/VcG6uIvPjXIQXfXXk16AVr5s/QT4oDqo=; b=QYa79aw0EL+c7S 14lVDuHHkMjwkMRdLeoIfJylih07g9iZVHvLDpvcGcgTR9+JDYRPhrSjsh2EPFW8vk3ctX+vAYSW/ qeGIUq7156fxqF62CdPROxEX2gfmX01J7w8kpVpl9LMfiFIEo8moNc7O8eDsCkq4UTcepL1+Xe+NT fO+oEb+KxjN/oKV50pf5Q81zwfGJABVm4tFSodpInv05aHzgxI9tT4JWJNyRO6MuUFPYZIINsTeq0 oJXJLDLj1qEVn2LinKBLozOYTYlVcDob9DonbhdzSIz2BKoU+BTxORV3fyKvMf26VHnA9jWw/Aolt 4T3MsWAlrbH84XzrrnDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nho0S-00Gxfi-I5; Fri, 22 Apr 2022 07:47:09 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhntP-00Gu5w-Q3 for linux-arm-kernel@lists.infradead.org; Fri, 22 Apr 2022 07:39:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650613191; x=1682149191; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ud1eKZ2w6i2EQsMUcCwNgZ6BRlq//P+NQjUhG6y063k=; b=fS41Nt6zwoL2xlJWictaXHQp52EXlhcZQ8/WYge4WFRQNO/p/GvnsmCg Cc2GLVYO2KZolJ+Tdm3XPhnJf/MEVEn0/wBBekPGm86m8+f9y2+lvctNR RI8qFiimyuYbjYHmIRMvydrWYx47nQZRwOtANvtW67NMXi28XQdn2G6DO 09AkDeDnApNzXY+YILXzIXC+ErY684x1XEqdn3hURzqvc8rlfGXjmiw65 hVNAC+Q6a6iG3kBbD0CKvA2CmT/ZdRkMQ+EkvV8nNlbOx8pu0GNtJzXrA q28csHkgfACofydf7MP3fFzkjm5pmwQdVmYJAmDugLCmY5NCzvhRXlK4n A==; X-IronPort-AV: E=McAfee;i="6400,9594,10324"; a="244534060" X-IronPort-AV: E=Sophos;i="5.90,281,1643702400"; d="scan'208";a="244534060" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2022 00:39:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,281,1643702400"; d="scan'208";a="648516321" Received: from p12hl98bong5.png.intel.com ([10.158.65.178]) by FMSMGA003.fm.intel.com with ESMTP; 22 Apr 2022 00:39:27 -0700 From: Ong Boon Leong To: Alexandre Torgue , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King , Paolo Abeni , "David S . Miller" , Jakub Kicinski , Maxime Coquelin , Alexandre Torgue , 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, Ong Boon Leong Subject: [PATCH net-next 1/4] net: pcs: xpcs: add CL37 1000BASE-X AN support Date: Fri, 22 Apr 2022 15:35:02 +0800 Message-Id: <20220422073505.810084-2-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220422073505.810084-1-boon.leong.ong@intel.com> References: <20220422073505.810084-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-20220422_003951_910958_70A6D9DE X-CRM114-Status: GOOD ( 21.37 ) 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. Tested-by: Emilio Riva Signed-off-by: Ong Boon Leong Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/net/pcs/pcs-xpcs.c | 174 ++++++++++++++++++++++++++++++++++- include/linux/pcs/pcs-xpcs.h | 3 +- 2 files changed, 173 insertions(+), 4 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 61418d4dc0c..7ba60944ba0 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, }; @@ -239,6 +252,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: @@ -774,6 +788,58 @@ 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) +{ + int ret, mdio_ctrl; + + /* For AN for 1000BASE-X mode, the settings are :- + * 1) VR_MII_MMD_CTRL Bit(12) [AN_ENABLE] = 0b (Disable C37 AN in case + * it is already enabled) + * 2) VR_MII_AN_CTRL Bit(2:1)[PCS_MODE] = 00b (1000BASE-X C37) + * 3) SR_MII_AN_ADV Bit(6)[FD] = 1b (Full Duplex) + * Note: Half Duplex is rarely used, so don't advertise. + * 4) VR_MII_MMD_CTRL Bit(12) [AN_ENABLE] = 1b (Enable C37 AN) + */ + 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; + + ret = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_ADVERTISE); + ret |= ADVERTISE_1000XFULL; + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MII_ADVERTISE, ret); + if (ret < 0) + return 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); + + return ret; +} + static int xpcs_config_2500basex(struct dw_xpcs *xpcs) { int ret; @@ -797,7 +863,7 @@ static int xpcs_config_2500basex(struct dw_xpcs *xpcs) } int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, - unsigned int mode) + unsigned int mode, const unsigned long *advertising) { const struct xpcs_compat *compat; int ret; @@ -819,6 +885,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) @@ -845,7 +917,7 @@ static int xpcs_config(struct phylink_pcs *pcs, unsigned int mode, { struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); - return xpcs_do_config(xpcs, interface, mode); + return xpcs_do_config(xpcs, interface, mode, advertising); } static int xpcs_get_state_c73(struct dw_xpcs *xpcs, @@ -866,7 +938,7 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs, state->link = 0; - return xpcs_do_config(xpcs, state->interface, MLO_AN_INBAND); + return xpcs_do_config(xpcs, state->interface, MLO_AN_INBAND, NULL); } if (state->an_enabled && xpcs_aneg_done_c73(xpcs, state, compat)) { @@ -923,6 +995,50 @@ 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; + + ret = xpcs_read(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL); + if (ret < 0) + return ret; + + if (ret & AN_CL37_EN) { + /* Reset link_state */ + state->link = false; + state->speed = SPEED_UNKNOWN; + state->duplex = DUPLEX_UNKNOWN; + state->pause = 0; + + lpa = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_LPA); + if (lpa < 0 || lpa & LPA_RFAULT) + return false; + + adv = xpcs_read(xpcs, MDIO_MMD_VEND2, MII_ADVERTISE); + if (adv < 0) + return false; + + if (lpa & ADVERTISE_1000XFULL && + adv & ADVERTISE_1000XFULL) { + state->speed = SPEED_1000; + state->duplex = DUPLEX_FULL; + state->link = true; + } + + /* Clear CL37 AN complete status */ + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_AN_INTR_STS, 0); + } else { + state->link = true; + state->speed = SPEED_1000; + state->duplex = DUPLEX_FULL; + state->pause = 0; + } + + return 0; +} + static void xpcs_get_state(struct phylink_pcs *pcs, struct phylink_link_state *state) { @@ -950,6 +1066,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; } @@ -985,6 +1108,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) { @@ -994,9 +1143,21 @@ 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); + ret |= BMCR_ANRESTART; + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1, ret); +} + static u32 xpcs_get_id(struct dw_xpcs *xpcs) { int ret; @@ -1062,6 +1223,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, @@ -1117,6 +1284,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 266eb26fb02..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; @@ -30,7 +31,7 @@ int xpcs_get_an_mode(struct dw_xpcs *xpcs, phy_interface_t interface); void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, phy_interface_t interface, int speed, int duplex); int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, - unsigned int mode); + unsigned int mode, const unsigned long *advertising); void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces); int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable); From patchwork Fri Apr 22 07:35:03 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: 12822985 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 EE919C433EF for ; Fri, 22 Apr 2022 07:48: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=douUtrH2hRc3CAFi5I5QX1IJ7IG+sLAQUzDK0RrSEKk=; b=VBqwTXM0qO8i/g 8nM+CVoLLsJ4E298FTau7grgABU5qpuTdDUwAzTuZUH4w2o6tieuNqdDhZ/hWH6qWfik/nOvBZkOr tgeJYHhmOR6fqoGx8B4a+RQTuzr3S6GJbRxgUn/vezOR2gV4lCmK5pjCXFKPN8AeIGqV9oOlWPtnS daR6YUpCr0yTWP80X4mEmjw2GNzTAtKOxlkxCgWFO1YXwTo3HMqyp5zl3CQ0pbS3Vzod6eVUtkFPJ ljauwvDcKNjPUzvmq3BDdX9lPpFbzTdTBE4P03nDlPLzsm7jlku5bP3KkkOCc67nfrcGY3WZcrT8X ngwmESYzTUxU2ji1Te8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nho0t-00GxtC-CQ; Fri, 22 Apr 2022 07:47:35 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhntR-00Gu8U-Q1 for linux-arm-kernel@lists.infradead.org; Fri, 22 Apr 2022 07:39:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650613193; x=1682149193; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6GcMHH6yUqex4pWxo8BLj/3zpi1O7XDEvvpDjCDkD0s=; b=lBQOc97wkEekbxpXH61ycyBLzbTAU9rWgxFLTbIIesVri0qrVXSG2KR4 yoCro7ht0FAlrqfZpOM/V5vKABNqGEO8Xp9vE4eR+dzk0dNtKNRMJR0wR JQgrunV6NwlFhmMK38Y4dNI8IQrUDzCHG4AmGwpAR/49JDZhpOKLAT6bO c2vLIpHo84Q8LGrdDWORXFN09fdfGCi93uDK70ZoktsLCjyllI8eAZPjq VTOS1IJZQ6ALSWulb4dSewThniYKhXLn/Xj7SgaqdVUhO/SqfEpBEx6FB pZnPQY8FLK4CINb3uhHGyWZwAaSImTqslFL1E2Qhzu3TUKV1mOkAPcUOO w==; X-IronPort-AV: E=McAfee;i="6400,9594,10324"; a="244534070" X-IronPort-AV: E=Sophos;i="5.90,281,1643702400"; d="scan'208";a="244534070" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2022 00:39:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,281,1643702400"; d="scan'208";a="648516336" Received: from p12hl98bong5.png.intel.com ([10.158.65.178]) by FMSMGA003.fm.intel.com with ESMTP; 22 Apr 2022 00:39:32 -0700 From: Ong Boon Leong To: Alexandre Torgue , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King , Paolo Abeni , "David S . Miller" , Jakub Kicinski , Maxime Coquelin , Alexandre Torgue , 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, Ong Boon Leong Subject: [PATCH net-next 2/4] net: stmmac: introduce PHY-less setup support Date: Fri, 22 Apr 2022 15:35:03 +0800 Message-Id: <20220422073505.810084-3-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220422073505.810084-1-boon.leong.ong@intel.com> References: <20220422073505.810084-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-20220422_003953_988396_EC221420 X-CRM114-Status: GOOD ( 16.79 ) 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 Certain platform uses PHY-less configuration whereby the MAC controller is connected to network switch chip directly over SGMII or 1000BASE-X. This patch prepares the stmmac driver to support PHY-less configuration described above. Tested-by: Emilio Riva Signed-off-by: Ong Boon Leong --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 +++++++++- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 +- include/linux/stmmac.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 57cb11abec8..4d39387bc48 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1142,11 +1142,18 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv) static int stmmac_init_phy(struct net_device *dev) { struct stmmac_priv *priv = netdev_priv(dev); + struct stmmac_mdio_bus_data *mdio_bus_data; struct device_node *node; - int ret; + int ret = 0; + mdio_bus_data = priv->plat->mdio_bus_data; node = priv->plat->phylink_node; + if (mdio_bus_data->phyless) { + netdev_info(priv->dev, "using PHY-less setup\n"); + goto phyless_setup; + } + if (node) ret = phylink_of_phy_connect(priv->phylink, node, 0); @@ -1166,6 +1173,7 @@ static int stmmac_init_phy(struct net_device *dev) ret = phylink_connect_phy(priv->phylink, phydev); } +phyless_setup: if (!priv->plat->pmt) { struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 9bc625fccca..16ce188697e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -490,7 +490,7 @@ int stmmac_mdio_register(struct net_device *ndev) if (priv->plat->has_xgmac) stmmac_xgmac2_mdio_read(new_bus, 0, MII_ADDR_C45); - if (priv->plat->phy_node || mdio_node) + if (priv->plat->phy_node || mdio_node || mdio_bus_data->phyless) goto bus_register_done; found = 0; diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index f8e8df25098..238d452ef43 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -82,6 +82,7 @@ struct stmmac_mdio_bus_data { unsigned int phy_mask; unsigned int has_xpcs; unsigned int xpcs_an_inband; + unsigned int phyless; int *irqs; int probed_phy_irq; bool needs_reset; From patchwork Fri Apr 22 07:35:04 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: 12822971 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 747DEC433F5 for ; Fri, 22 Apr 2022 07:47: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: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=DoHviP3d+hi/xbmO7L9APS6Q9nf6UZLOaoyJ7+HGO3c=; b=gjJ40r9DnM8vV5 sBN4GrR5zX6bqX0qJhZv6s9oN25kn3NEczMDnlNa9ipxdRxAHGjZ4FR40s/LBJMaDoWwDSbfcJmGT ofOq3l/zWxgwexguYPvoP8jOrG+hAMm2klmSOO0+FYZLJM6wOojWIrmOeFVnEZPqpPxTnEo5RRBE4 cBA4B0QZlAT7Ozap3j/pcss85Xfo+bWOr5HUDsDJZe28xcu9w5YbPpHFAVo9UXZ75KFhWGfDT1jd6 KhnBCWSTK919wyx38g2E9stph2zXSs+KULDnnbmU5fcPxPS0OIMKLRtvEE1QbCZwvur6kswsh21ku ir8e2vsOxROnz9stqeqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhnzf-00GxGL-0a; Fri, 22 Apr 2022 07:46:20 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhntR-00Gu5w-Qt for linux-arm-kernel@lists.infradead.org; Fri, 22 Apr 2022 07:39:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650613193; x=1682149193; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZAM//25jc969fXPpRmMZdTy2q65l1lpKHITyK900QMQ=; b=Nzyf03ftrIjzbLw3Fnwl+8pRPiyTWWJ4v9sbksDJryZA95tcf0Ri+BoF iaM5Rwr+6rFk7ptMy03nZsnELYpzz9qF9F+ylTYcxWJidmV4CBs5j93ho FW8iMtr4QQ7U/p3d3mkWe3aS4KSvPMb6cmO3Flr0gNz5KUtxW0W8abxza XF7nsFA92ZDSQx0yPvEgaP5Awc20dsURzIjaCRrTs1d7CeBsG6SbRMLOt 0E3IDhCyWibzSKUVGmDNvABxxX8yUXBTJv1pl9nakg2D/U+KvIwJdJg8A O1LPyvzfOETc2nzYao2zuVCHcu17812TC0GIK0YUhWyVboAzNTXM50s2E Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10324"; a="244534085" X-IronPort-AV: E=Sophos;i="5.90,281,1643702400"; d="scan'208";a="244534085" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2022 00:39:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,281,1643702400"; d="scan'208";a="648516342" Received: from p12hl98bong5.png.intel.com ([10.158.65.178]) by FMSMGA003.fm.intel.com with ESMTP; 22 Apr 2022 00:39:36 -0700 From: Ong Boon Leong To: Alexandre Torgue , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King , Paolo Abeni , "David S . Miller" , Jakub Kicinski , Maxime Coquelin , Alexandre Torgue , 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, Ong Boon Leong Subject: [PATCH net-next 3/4] stmmac: intel: prepare to support 1000BASE-X phy interface setting Date: Fri, 22 Apr 2022 15:35:04 +0800 Message-Id: <20220422073505.810084-4-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220422073505.810084-1-boon.leong.ong@intel.com> References: <20220422073505.810084-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-20220422_003953_931636_D8A1055F X-CRM114-Status: GOOD ( 12.95 ) 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. Tested-by: Emilio Riva 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 63754a9c4ba..265d39acdd0 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; } } @@ -561,7 +560,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 Apr 22 07:35:05 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: 12822986 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 E3B3AC433EF for ; Fri, 22 Apr 2022 07:49: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=j9hqz1lK8kegFnkob+VyU2slWr8CuDEy3TFsRKjswhk=; b=dKi6PR0YXtiZrK 46zXKlMcTQkPaVIC9Vju9rkj9RnhCO5UnwTJ4+ZI0bwJTw1DA3sNqXiI3yxCLU0nQdNLjY6nFsU3S UCqCgEgvr2rB56k/mogdHcVIcRfY0G57CsTkbZA8tcUgnPwNk1QinLAK2R5V9oTpTMshKVpJHli4a WCWCczxqPsTrdSo/NAu0ihbqkBjjvKDO5peCOhqOGgX4Y3ZE7+Jq0w0Pe2cj+3GSFdKO7dk98OPOR VFA44LuVx0T76DEQo25fsXWnucIza4hGSP9NHufdCtOeu/byLjSkEHvp1BaypaAjdTmze3MgFZXZs HK/bdNvslmq7IiFDM4VA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nho1O-00Gy6n-5s; Fri, 22 Apr 2022 07:48:07 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhntT-00Gu5w-A6 for linux-arm-kernel@lists.infradead.org; Fri, 22 Apr 2022 07:39:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650613195; x=1682149195; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nEPLMdPCwdmEFgscrfAJ4fkH252LE7MCcUu/Flr5Wyo=; b=SD9/S/n4R3glDD9N6qFUphzXrU0j5ncFl/olGewggySnYpMyhhRBS01u abgW132Q0giJJD53ryQn5hkMtTIJVASt7PP6SgPTLJ+/JcW/pkAcgDVDC Afbd2MDn32edBS1grrkban3gOF6H1hvjiA2PuMEeYAxAQAs6T5GsY92aF CyFxarYeByhw2lwIv4yO51fx8Liu9w+h9Rz/0bV4QbUtquRDhlXCZ+Ru1 dXlvyATiEH1ZNI0N9QYIUvv4x2B/QFG8oVJk1/g9zYhuica7zNDF7b6j+ CRcOkUykDOHG6QgSjLYffREi6/wYCIybfW62B/F/HzDdr8AdAjWIPX73B g==; X-IronPort-AV: E=McAfee;i="6400,9594,10324"; a="244534090" X-IronPort-AV: E=Sophos;i="5.90,281,1643702400"; d="scan'208";a="244534090" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2022 00:39:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,281,1643702400"; d="scan'208";a="648516353" Received: from p12hl98bong5.png.intel.com ([10.158.65.178]) by FMSMGA003.fm.intel.com with ESMTP; 22 Apr 2022 00:39:39 -0700 From: Ong Boon Leong To: Alexandre Torgue , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King , Paolo Abeni , "David S . Miller" , Jakub Kicinski , Maxime Coquelin , Alexandre Torgue , 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, Ong Boon Leong Subject: [PATCH net-next 4/4] stmmac: intel: introduce platform data phyless setting for Ericsson system Date: Fri, 22 Apr 2022 15:35:05 +0800 Message-Id: <20220422073505.810084-5-boon.leong.ong@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220422073505.810084-1-boon.leong.ong@intel.com> References: <20220422073505.810084-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-20220422_003955_506928_F9B7352B X-CRM114-Status: GOOD ( 14.33 ) 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 Certain platform wants specific GbE controller instance to be in PHY-less mode, i.e. to be used for 1000BASE-X connection for network switch. Tested-by: Emilio Riva Signed-off-by: Ong Boon Leong --- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 265d39acdd0..9c9577fc15d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -24,6 +24,8 @@ struct intel_priv_data { struct stmmac_pci_func_data { unsigned int func; int phy_addr; + phy_interface_t phy_interface; + unsigned int phyless; }; struct stmmac_pci_dmi_data { @@ -439,10 +441,65 @@ static void common_default_data(struct plat_stmmacenet_data *plat) plat->rx_queues_cfg[0].pkt_route = 0x0; } +static const struct stmmac_pci_func_data ericsson_phyless_func_data[] = { + { + .func = 2, + .phy_interface = PHY_INTERFACE_MODE_1000BASEX, + .phyless = true, + }, +}; + +static const struct stmmac_pci_dmi_data ericsson_phyless_dmi_data = { + .func = ericsson_phyless_func_data, + .nfuncs = ARRAY_SIZE(ericsson_phyless_func_data), +}; + +static const struct dmi_system_id intel_mgbe_pci_dmi[] = { + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Ericsson"), + DMI_MATCH(DMI_BOARD_NAME, "SMARC-SXEL"), + }, + .driver_data = (void *)&ericsson_phyless_dmi_data, + }, + {} +}; + +static bool stmmac_pci_find_phyless(struct pci_dev *pdev, + const struct dmi_system_id *dmi_list, + phy_interface_t *phy_interface, + unsigned int *phyless) +{ + const struct stmmac_pci_func_data *func_data; + const struct stmmac_pci_dmi_data *dmi_data; + const struct dmi_system_id *dmi_id; + int func = PCI_FUNC(pdev->devfn); + size_t n; + + dmi_id = dmi_first_match(dmi_list); + if (!dmi_id) + return false; + + dmi_data = dmi_id->driver_data; + func_data = dmi_data->func; + + for (n = 0; n < dmi_data->nfuncs; n++, func_data++) + if (func_data->func == func) { + *phy_interface = func_data->phy_interface; + *phyless = func_data->phyless; + return true; + } + + return false; +} + static int intel_mgbe_common_data(struct pci_dev *pdev, struct plat_stmmacenet_data *plat) { + phy_interface_t phy_interface; + unsigned int phyless; char clk_name[20]; + bool found; int ret; int i; @@ -559,6 +616,13 @@ 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; + found = stmmac_pci_find_phyless(pdev, intel_mgbe_pci_dmi, + &phy_interface, &phyless); + if (found) { + plat->mdio_bus_data->phyless = phyless; + plat->phy_interface = phy_interface; + } + /* Intel mgbe SGMII interface uses pcs-xcps */ if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII || plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) {