From patchwork Thu Oct 29 22:25:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 316016 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B75B2C4742C for ; Thu, 29 Oct 2020 22:25:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 598A921534 for ; Thu, 29 Oct 2020 22:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604010320; bh=3XTwgAa3BoI6bQchtn2eT/wund/GYOdEgOyRS1m8FS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=D2foVkKFB24gtHiUJWexGjhtRJ/TmKyGZlprcV8NoZ2HSGoSMuFdRKTb+EnQkgkvq utwaM78/xFnkTUsd5GjSCJNPXs1QBvspMIwgRa7A5SzjjFayus1fn9X/vKqW0masww WVnlNxsxoxEL1qC9HZG5jme3EpWUIS3eceO4ZNCM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725952AbgJ2WZT (ORCPT ); Thu, 29 Oct 2020 18:25:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:43750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725939AbgJ2WZQ (ORCPT ); Thu, 29 Oct 2020 18:25:16 -0400 Received: from dellmb.labs.office.nic.cz (nat-1.nic.cz [217.31.205.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 064FB21531; Thu, 29 Oct 2020 22:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604010316; bh=3XTwgAa3BoI6bQchtn2eT/wund/GYOdEgOyRS1m8FS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gwqyGXHO7k49mia3fIGGKAJiEuPZn3LW7EL3/dsWYCXu7IExT1whLvt3HroVVa4lt IhZcB8t1wV5IGvELmC43iY+gXs2Qp8yaNAU/byBJPzL0ruBzfidd8rHWi07NQHt33o fCTp2l8yP9aqkI0VH8Nb6NBSPSrQiAkoT0g9SRUs= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: netdev@vger.kernel.org Cc: davem@davemloft.net, =?utf-8?q?Marek_Beh=C3=BAn?= , Andrew Lunn , Russell King Subject: [PATCH net-next v2 2/5] net: phylink: allow attaching phy for SFP modules on 802.3z mode Date: Thu, 29 Oct 2020 23:25:06 +0100 Message-Id: <20201029222509.27201-3-kabel@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201029222509.27201-1-kabel@kernel.org> References: <20201029222509.27201-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some SFPs may contain an internal PHY which may in some cases want to connect with the host interface in 1000base-x/2500base-x mode. Do not fail if such PHY is being attached in one of these PHY interface modes. Signed-off-by: Marek BehĂșn Cc: Andrew Lunn Cc: Russell King Reviewed-by: Russell King --- drivers/net/phy/phylink.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 5d8c015bc9f2..705c49c37348 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1018,7 +1018,7 @@ static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy, { if (WARN_ON(pl->cfg_link_an_mode == MLO_AN_FIXED || (pl->cfg_link_an_mode == MLO_AN_INBAND && - phy_interface_mode_is_8023z(interface)))) + phy_interface_mode_is_8023z(interface) && !pl->sfp_bus))) return -EINVAL; if (pl->phydev) @@ -2069,9 +2069,6 @@ static int phylink_sfp_config(struct phylink *pl, u8 mode, phylink_an_mode_str(mode), phy_modes(config.interface), __ETHTOOL_LINK_MODE_MASK_NBITS, support); - if (phy_interface_mode_is_8023z(iface) && pl->phydev) - return -EINVAL; - changed = !linkmode_equal(pl->supported, support); if (changed) { linkmode_copy(pl->supported, support); From patchwork Thu Oct 29 22:25:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 316015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3506C4742C for ; Thu, 29 Oct 2020 22:25:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B4A5214F1 for ; Thu, 29 Oct 2020 22:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604010323; bh=C0AJ+ZLPZUyrlH7UNBZgTfeflDN7cswS0QlQC5XiO4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Bvlt9ncS+m9BlGgxsgXaPeyTtef7clhOuGMAd4FBw8Kx3Crlvi8Zu6JvCMVJ1mCiY pjnvq1ieQLM/Z2LHEt3e1ZrDdOMlVWm+7nK9N0mdVbgdbohKb3n/csEUuftnBlGWZD CRauMNHa0G7ZgZcF9lUIM2fU9OeSnBmf7RLIDfoQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725984AbgJ2WZW (ORCPT ); Thu, 29 Oct 2020 18:25:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:43796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725960AbgJ2WZU (ORCPT ); Thu, 29 Oct 2020 18:25:20 -0400 Received: from dellmb.labs.office.nic.cz (nat-1.nic.cz [217.31.205.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 18A02215A4; Thu, 29 Oct 2020 22:25:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604010319; bh=C0AJ+ZLPZUyrlH7UNBZgTfeflDN7cswS0QlQC5XiO4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TDut2KoDXnikYltsbuJZ0H9rBbFj4v9wFlCJcmdId9jQzEAq45Bsjiv8QX8p2PH4f G/h1Q5b89FJSKff2GuMkIp300/FDtt8fPkPMOTXdU3LO42h4rS2dyjW3VeI9gczxYf Cwq5AVulKsSGnygN0V47g/bnyfrYMk2RgeIbuIIU= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: netdev@vger.kernel.org Cc: davem@davemloft.net, =?utf-8?q?Marek_Beh=C3=BAn?= , Andrew Lunn , Russell King Subject: [PATCH net-next v2 4/5] net: phy: marvell10g: change MACTYPE if underlying MAC does not support it Date: Thu, 29 Oct 2020 23:25:08 +0100 Message-Id: <20201029222509.27201-5-kabel@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201029222509.27201-1-kabel@kernel.org> References: <20201029222509.27201-1-kabel@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org RollBall SFPs contain a Marvell 88X3310 PHY, but by default the MACTYPE is set to 10GBASE-R with Rate Matching. Some devices (for example those based on Armada 38x) only support up to 2500base-x SerDes modes. Change the PHY's MACTYPE to 4 (which means changing between 10gbase-r, 5gbase-r, 2500base-x ans SGMII depending on copper speed) if this is the case (which is infered from phydev->interface). Signed-off-by: Marek BehĂșn Cc: Andrew Lunn Cc: Russell King --- drivers/net/phy/marvell10g.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c index 1901ba277413..9e8e9aa66972 100644 --- a/drivers/net/phy/marvell10g.c +++ b/drivers/net/phy/marvell10g.c @@ -453,6 +453,33 @@ static bool mv3310_has_pma_ngbaset_quirk(struct phy_device *phydev) MV_PHY_ALASKA_NBT_QUIRK_MASK) == MV_PHY_ALASKA_NBT_QUIRK_REV; } +static int mv3310_select_mactype(struct phy_device *phydev) +{ + int mac_type, ret; + + /* On some devices the MAC does not support 10G mode, but may support + * lower modes, such as SGMII or 2500base-x. + * By changing MACTYPE of the PHY to 4 in this case, we ensure that + * the MAC will link with the PHY at least for these lower speeds. + */ + switch (phydev->interface) { + case PHY_INTERFACE_MODE_SGMII: + case PHY_INTERFACE_MODE_2500BASEX: + mac_type = 4; + break; + default: + return 0; + } + + ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL, + MV_V2_PORT_MAC_TYPE_MASK, mac_type); + if (ret <= 0) + return ret; + + return phy_modify_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL, + MV_V2_PORT_CTRL_SWRST, MV_V2_PORT_CTRL_SWRST); +} + static int mv3310_config_init(struct phy_device *phydev) { struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); @@ -474,6 +501,10 @@ static int mv3310_config_init(struct phy_device *phydev) if (err) return err; + err = mv3310_select_mactype(phydev); + if (err) + return err; + val = phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL); if (val < 0) return val;