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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB146C433EF for ; Thu, 24 Feb 2022 16:30:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229621AbiBXQaj (ORCPT ); Thu, 24 Feb 2022 11:30:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbiBXQah (ORCPT ); Thu, 24 Feb 2022 11:30:37 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E61A20C18B for ; Thu, 24 Feb 2022 08:29:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CGzygN9zmXKhz0Z67FMFNp2qiPseiFfA7FYjWGYAj+E=; b=1ymhgbw5dfFvnlQqfC9ZnBCaOR lkIdjqkkNrtMm8sC10LkAQYHiKXyZROj2DiuGflcljAlacCJzMHqFC+13OIZdN5xZhLAMT3j9AOZK o5stzYuB8lUiGSTivTDzFlD/5MOKx3zwXxVrzLnC6uD0goKQVQZ90g5t3U1AUJDDuekitPZQ9OXs3 eiOEwDm2D1Ix3NPsEDwdkMr7LDIhDERS6cMdWlU5npywBkiCx2xZzLhrqt0ivwUMj/aKHMNhg1hz4 f20/mB7c8yyHohs1Hxq+eESw9d/Dd+3J61DVCjVjxbl8hbDEByDBfCkjUBmfksvWIPSrfMf8UIbmP VIsPw7dA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:39188 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nNGmM-0004Cy-43; Thu, 24 Feb 2022 16:15:42 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1nNGmL-00AOjC-HP; Thu, 24 Feb 2022 16:15:41 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Vladimir Oltean Cc: Marek Beh__n , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Subject: [PATCH RFC net-next 6/6] net: dsa: sja1105: support switching between SGMII and 2500BASE-X MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Thu, 24 Feb 2022 16:15:41 +0000 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Vladimir Oltean suggests that sla1105 can support switching between SGMII and 2500BASE-X modes. Augment sja1105_phylink_get_caps() to fill in both interface modes if they can be supported. Signed-off-by: Russell King (Oracle) --- drivers/net/dsa/sja1105/sja1105_main.c | 28 +++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 5beef06d8ff7..36001b1d7968 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1396,6 +1396,7 @@ static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port, { struct sja1105_private *priv = ds->priv; struct sja1105_xmii_params_entry *mii; + phy_interface_t phy_mode; /* This driver does not make use of the speed, duplex, pause or the * advertisement in its mac_config, so it is safe to mark this driver @@ -1403,11 +1404,28 @@ static void sja1105_phylink_get_caps(struct dsa_switch *ds, int port, */ config->legacy_pre_march2020 = false; - /* The SJA1105 MAC programming model is through the static config - * (the xMII Mode table cannot be dynamically reconfigured), and - * we have to program that early. - */ - __set_bit(priv->phy_mode[port], config->supported_interfaces); + phy_mode = priv->phy_mode[port]; + if (phy_mode == PHY_INTERFACE_MODE_SGMII || + phy_mode == PHY_INTERFACE_MODE_2500BASEX) { + /* Changing the PHY mode on SERDES ports is possible and makes + * sense, because that is done through the XPCS. We allow + * changes between SGMII and 2500base-X (it is unknown whether + * 1000base-X is supported). + */ + if (priv->info->supports_sgmii[port]) + __set_bit(PHY_INTERFACE_MODE_SGMII, + config->supported_interfaces); + + if (priv->info->supports_2500basex[port]) + __set_bit(PHY_INTERFACE_MODE_2500BASEX, + config->supported_interfaces); + } else { + /* The SJA1105 MAC programming model is through the static + * config (the xMII Mode table cannot be dynamically + * reconfigured), and we have to program that early. + */ + __set_bit(phy_mode, config->supported_interfaces); + } /* The MAC does not support pause frames, and also doesn't * support half-duplex traffic modes. -- 2.30.2