From patchwork Wed Jun 9 18:41:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 457382 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 359A3C48BCD for ; Wed, 9 Jun 2021 18:43:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EEDB613DC for ; Wed, 9 Jun 2021 18:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230059AbhFISpO (ORCPT ); Wed, 9 Jun 2021 14:45:14 -0400 Received: from mail-ej1-f54.google.com ([209.85.218.54]:33314 "EHLO mail-ej1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230027AbhFISpL (ORCPT ); Wed, 9 Jun 2021 14:45:11 -0400 Received: by mail-ej1-f54.google.com with SMTP id g20so39967974ejt.0 for ; Wed, 09 Jun 2021 11:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x54p5UC5lHeUMUMtJqvxKcSN6gEMtSjFo1/RRsSFRo8=; b=BgVCGp6zgD3SfsXLg79UlCqiyGm1sdGlXj9Z7pZ1QTomcMktWMDevt+x6CK+riJ/tQ oyFrO7T4jQW1d1xjCCnnnG7hLYkIHm9G9t4IOL18eAtsvTOzF/fOS7+5zyBQtDJIOuMI LXiiivNhqyADDJPNgQ/dAc7FXFIJ2l5V384KlSFGkzzEEyPmH28mYyxn/CZJqoRGTZhB 3gCUUxNkXa09tjYZMsKQ/VwajRhT9SooCNxgJUYVkQinnijd10cRzOybhkBeqVAdpnk+ Sg4w+YhMhTMhAhnOMhE1JcXRg2laesasDgypfckkE9sJUj8y6yd7eP73sNhoLPmpssfR nS6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x54p5UC5lHeUMUMtJqvxKcSN6gEMtSjFo1/RRsSFRo8=; b=NpImJjNZ+fqnssXGoUrM+n5EoXU8sHoSZNNNuBy8pRlJh8QJ0CL/IwyMeIFIVP2PjP RNPVGhcUik2q0aUy2BYE2hgy6YRyOR7vpmU+BG7572XWAm1IJmyAfgm7oCJRugkjjwu6 GGCub+Hwv3AowaDxV91qsCH1BDxYKTaJ81rJ+qZxhCo42+pH3lMxCFflNl/L0JPdMhIZ 3XXyGrAEZSW+VsqdFJjoqils9phXNdPKcWU3E4ZySG3fe97i1H5o1SQtwpxdWdpuarSw K+69RglnZzMwXtljpp5xoTWms86+TcvhlC1LnDtLJWothf/833NSfzzXyC+S8fT4jPHe O6GA== X-Gm-Message-State: AOAM531C78ijatQIe8qiN/uX42UqLUwHJPMI/ZvgUbRbTZE9kYw93K29 OVAIDrf/VxdQQjH6rVEsHpQ= X-Google-Smtp-Source: ABdhPJw/bsF3nCo3TrHtOFNVtGOHmhAvp+gm+pGvjAaYzus1s0zqZ2xcDnTZqNYKQ4ndaKw4Dh1qlw== X-Received: by 2002:a17:906:869a:: with SMTP id g26mr1178657ejx.94.1623264135473; Wed, 09 Jun 2021 11:42:15 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id oz11sm194935ejb.16.2021.06.09.11.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 11:42:15 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Wong Vee Khee , Ong Boon Leong , Michael Sit Wei Hong , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 03/13] net: stmmac: reduce indentation when calling stmmac_xpcs_setup Date: Wed, 9 Jun 2021 21:41:45 +0300 Message-Id: <20210609184155.921662-4-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609184155.921662-1-olteanv@gmail.com> References: <20210609184155.921662-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean There is no reason to embed an if within an if, we can just logically AND the two conditions. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 1c881ec8cd04..372673f9af30 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7002,12 +7002,10 @@ int stmmac_dvr_probe(struct device *device, if (priv->plat->speed_mode_2500) priv->plat->speed_mode_2500(ndev, priv->plat->bsp_priv); - if (priv->plat->mdio_bus_data) { - if (priv->plat->mdio_bus_data->has_xpcs) { - ret = stmmac_xpcs_setup(priv->mii); - if (ret) - goto error_xpcs_setup; - } + if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { + ret = stmmac_xpcs_setup(priv->mii); + if (ret) + goto error_xpcs_setup; } ret = stmmac_phy_setup(priv); From patchwork Wed Jun 9 18:41:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 457385 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 2050CC48BCF for ; Wed, 9 Jun 2021 18:42:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F23CE613E1 for ; Wed, 9 Jun 2021 18:42:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229874AbhFISoQ (ORCPT ); Wed, 9 Jun 2021 14:44:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbhFISoP (ORCPT ); Wed, 9 Jun 2021 14:44:15 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0CEEC06175F for ; Wed, 9 Jun 2021 11:42:19 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id r11so29632702edt.13 for ; Wed, 09 Jun 2021 11:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EsvBjtbO446jl1FbDgab+9xkWiJriO/2VRzw7NQw3e0=; b=G9ya+xsuiYD6ddjoL62f48/sJyTtk46AxYKhXLnnfqUfs2BmyZkTAry+ykfEgQu/NU GJU9GyTrRTqPhLleh2aTRVZOznfbJUhfSHRCcoj5iCFcfcQuAlG3WDJMptzO1bziNzEX HWAHRn81Y6OVzz0nXkVYkGTPUKWg53560Q+Zoer6LCzdNzcOvXGZVCGLSK9QBmp7Qc8Z +umQikXmdk1hRzHWy5nv0KxZ5QlccFhm67MY6fK4m9rI2Y7AjLgz1ADFjeHudBKcMsMH Zvjs2SaIxt6QuOOwqKwvof80f+3TrUOLuRa+ewqGBttjkJ5Lyuf0T8txdeKtEcRLEE5W YiRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EsvBjtbO446jl1FbDgab+9xkWiJriO/2VRzw7NQw3e0=; b=deuReicJvxNnicuDNuuCfdWD3Mnz8EeE2MMiJaP+0p6fH0YaONafg3OMH2EAcqqVL7 woC2nbeBKtIPdREtkolO7Bf8HtVCLpP2RuAF7EM9VPiZd9qDf3WojWyte3Opoq8/CG+1 CQcFagRrQY59HCwKkrb+b9aivpEF8Wl1cv5CJhsi+vHrIRzPacHGUXicUDrUpLUKwzBE sm3ic/gi6jx9GUwiay1+jUNj4NK2grKN/d6xub9tSyn/1ro8Gnyc8DYHzY1vo8gT2+FR 2szYJcNji9MHrai18tQHK5hOIt1bkZt3uZMRC0I9Up0F4k2tCHodhMs076+Kztkkda6f NWfQ== X-Gm-Message-State: AOAM5328NbX5ybrpK8ALl8y7s0t1v2ROLvfyYoknVVJa3u//iwG2pv7Z 7Wl84wEAF/ICmcTe2AxqE1o= X-Google-Smtp-Source: ABdhPJy8TKkJpcCNfSQsf4mPYsaQrYB3KXHDio4/9EBRN/DHBNkdZ9foIT4RmHDr2Wn4YnP4i08a1w== X-Received: by 2002:a05:6402:145a:: with SMTP id d26mr786028edx.151.1623264138486; Wed, 09 Jun 2021 11:42:18 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id oz11sm194935ejb.16.2021.06.09.11.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 11:42:18 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Wong Vee Khee , Ong Boon Leong , Michael Sit Wei Hong , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 05/13] net: pcs: xpcs: add support for sgmii with no inband AN Date: Wed, 9 Jun 2021 21:41:47 +0300 Message-Id: <20210609184155.921662-6-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609184155.921662-1-olteanv@gmail.com> References: <20210609184155.921662-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean In fixed-link use cases, the XPCS can disable the clause 37 in-band autoneg process, disable the "Automatic Speed Mode Change after CL37 AN" setting, and force operation in a speed dictated by management. Add support for this operating mode. Signed-off-by: Vladimir Oltean --- drivers/net/pcs/pcs-xpcs.c | 41 +++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 8ca7592b02ec..743b53734eeb 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -690,7 +690,7 @@ int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable) } EXPORT_SYMBOL_GPL(xpcs_config_eee); -static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs) +static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs, unsigned int mode) { int ret; @@ -726,7 +726,10 @@ static int xpcs_config_aneg_c37_sgmii(struct dw_xpcs *xpcs) if (ret < 0) return ret; - ret |= DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW; + if (phylink_autoneg_inband(mode)) + ret |= DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW; + else + ret &= ~DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW; return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL1, ret); } @@ -772,7 +775,7 @@ static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, } break; case DW_AN_C37_SGMII: - ret = xpcs_config_aneg_c37_sgmii(xpcs); + ret = xpcs_config_aneg_c37_sgmii(xpcs, mode); if (ret) return ret; break; @@ -905,6 +908,36 @@ static void xpcs_get_state(struct phylink_pcs *pcs, } } +static void xpcs_link_up_sgmii(struct dw_xpcs *xpcs, unsigned int mode, + int speed, int duplex) +{ + int val, ret; + + if (phylink_autoneg_inband(mode)) + return; + + switch (speed) { + case SPEED_1000: + val = BMCR_SPEED1000; + break; + case SPEED_100: + val = BMCR_SPEED100; + break; + case SPEED_10: + val = BMCR_SPEED10; + break; + default: + return; + } + + if (duplex == DUPLEX_FULL) + val |= BMCR_FULLDPLX; + + ret = xpcs_write(xpcs, MDIO_MMD_VEND2, MDIO_CTRL1, val); + if (ret) + pr_err("%s: xpcs_write returned %pe\n", __func__, ERR_PTR(ret)); +} + static void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, phy_interface_t interface, int speed, int duplex) { @@ -912,6 +945,8 @@ static void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, if (interface == PHY_INTERFACE_MODE_USXGMII) return xpcs_config_usxgmii(xpcs, speed); + if (interface == PHY_INTERFACE_MODE_SGMII) + return xpcs_link_up_sgmii(xpcs, mode, speed, duplex); } static u32 xpcs_get_id(struct dw_xpcs *xpcs) From patchwork Wed Jun 9 18:41:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 457380 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 563A2C48BDF for ; Wed, 9 Jun 2021 18:43:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3CDC4613AC for ; Wed, 9 Jun 2021 18:43:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230151AbhFISpY (ORCPT ); Wed, 9 Jun 2021 14:45:24 -0400 Received: from mail-ej1-f41.google.com ([209.85.218.41]:37545 "EHLO mail-ej1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbhFISpW (ORCPT ); Wed, 9 Jun 2021 14:45:22 -0400 Received: by mail-ej1-f41.google.com with SMTP id ce15so39901534ejb.4 for ; Wed, 09 Jun 2021 11:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eJOMwWkmACOVjOePCsgqeCByFG0o+AG6cYYoRpeib2s=; b=Y1bAIXtA7d23t7BzzQcah5uggKYj8oy+xhQ7wIUIA8oiVJZv1VN6LAwxFScl9GqYdl 2mjAWI1ZoGQj5jp8zxx8n+ysNI6mrrz/U6XR79/NyKo4KQlV4uFDatorspicItOMw4my 3dB8O9oRsIWGfgoSy6sogJCu+C6W+5cYHiv1YmRk20haR9guUfcHfuXBIJBuvPvb8ItL UxEU5grsaHroguR3KWF0e6l5zOwkVGHqugqn+fpD4hiQXQ2sPodgjLyD2WBArd6y76xL geDdLMZGJo28keR2ZN9Et/TsYci1BzexhnzP2r6ff+Z6gJB8rFwhnYO93qRv250ZagnV H4JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eJOMwWkmACOVjOePCsgqeCByFG0o+AG6cYYoRpeib2s=; b=JILPl1N8HRN2ixZap5NqzL6V6eK4gJPEmnKTQPTAGe7do/Ts3+bShO1TokoAUQS/3B eK59nxRO3HOz87Wn5eljG7xiJiLY5Cdl2bN8IC8l/e7EEH7rBkXoFgMOil6vHO5bk2vg ZWTqLG69615R7fW1tmmOblHLL2r+b9bySMc3jx6wTusOA1oUAWUb5k82JmZT0hRuo0Ui oPAfuna6BvZpiIPmsdGJxO6+tLjWATuCjCvtE5Nb3sO4D/r+tB2snCTVIOEqwLU3RX5t regpIsaT68PoMOOAkCxezQso93pbOeFZyIQ7zp1AwcQU40OrDp8/hUnVhjcqifU5tny8 q9zw== X-Gm-Message-State: AOAM532oCyMFUKWZvxgIAumb2tjvbC2Vy4HS0vzoZHkFPBpO1/HgSOBo /3NIjOXqORsw3BD2UchmDmc= X-Google-Smtp-Source: ABdhPJx12AdDmvxWJKZZUOoqy4RGvMsvYneUxfvkhVEiyU1p4JOgSohvtxjQS/XIhUxh/eXgio17Cg== X-Received: by 2002:a17:907:1112:: with SMTP id qu18mr1070040ejb.511.1623264139656; Wed, 09 Jun 2021 11:42:19 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id oz11sm194935ejb.16.2021.06.09.11.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 11:42:19 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Wong Vee Khee , Ong Boon Leong , Michael Sit Wei Hong , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 06/13] net: pcs: xpcs: also ignore phy id if it's all ones Date: Wed, 9 Jun 2021 21:41:48 +0300 Message-Id: <20210609184155.921662-7-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609184155.921662-1-olteanv@gmail.com> References: <20210609184155.921662-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean xpcs_get_id() searches multiple MMDs for a known PHY ID, starting with MDIO_MMD_PCS (3). However not all integrators might have implemented that MMD on their MDIO bus. For example, the NXP SJA1105 and SJA1110 switches only implement vendor-specific MMD 1 and 2. When there is nothing on an MDIO bus at a certain address, traditionally the bus returns 0xffff, which means that the bus remained in its default pull-up state for the duration of the MDIO transaction. The 0xffff value is widely used in drivers/net/phy/phy_device.c (see get_phy_c22_id for example) to denote a missing device. So it makes sense for the xpcs to ignore this value as well, and continue its search, eventually finding the proper PHY ID in the vendor-specific MMDs. Signed-off-by: Vladimir Oltean --- drivers/net/pcs/pcs-xpcs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 743b53734eeb..ecf5011977d3 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -965,8 +965,10 @@ static u32 xpcs_get_id(struct dw_xpcs *xpcs) if (ret < 0) return 0xffffffff; - /* If Device IDs are not all zeros, we found C73 AN-type device */ - if (id | ret) + /* If Device IDs are not all zeros or all ones, + * we found C73 AN-type device + */ + if ((id | ret) && (id | ret) != 0xffffffff) return id | ret; /* Next, search C37 PCS using Vendor-Specific MII MMD */ From patchwork Wed Jun 9 18:41:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 457384 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 0200FC48BCF for ; Wed, 9 Jun 2021 18:42:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDDCE613E3 for ; Wed, 9 Jun 2021 18:42:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229943AbhFISoV (ORCPT ); Wed, 9 Jun 2021 14:44:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbhFISoR (ORCPT ); Wed, 9 Jun 2021 14:44:17 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85276C061574 for ; Wed, 9 Jun 2021 11:42:22 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id l1so39933150ejb.6 for ; Wed, 09 Jun 2021 11:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jj1042usoUaQh/SdhL4YBrLAd/mZYkKZCKI2AfAJVps=; b=p5c3txWibIDWDliQFaREus1g0kSkgRIEqN01yfWz6wdlEN+LpTZlk0L94wf5zcAhKF 7Cf3iuB46AQxIxehzFefiWKNeYBDfNMDut0oFKaf8V8Fg+YlR6U452doOevqacL+FUpz Zulprg8SUNDLPca8YG1uTt3yldMEiTwWkl14O57AjsdmBf9aeLUNYu/O8Pmluk4bGjSH wzzyxzMsvmC7LbHLn56E/xLiVR7AUfUn/wTc/oFppOAl+71eAk5VrDNoFQ5fX2n9nAsg 3sMlje/iJjC1tdJF2w/n+JQQS65pMztGItWFy1frYUZXyRZ0qLhhy3YDoTvdTggA6BoN /QCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jj1042usoUaQh/SdhL4YBrLAd/mZYkKZCKI2AfAJVps=; b=Rd9gqzlzqSmDuVB2HFG+j4xb7j2JyHDp15BrfUG865fv+hNH1G5sC0yMHerHDrQ1dv alBe1HXjo+R+1e9je9HCjqDuctUy/VFU8cP0jtiwNCmyZ8ZkoQxzNCByKLX55SUaZLjj y4ihgZ+smmcolj+EAsddklqKhxZiqQhGkU1z/pzxLmdyUFYaDyIz1d1g1kIQbO9ntNnL Eb+SimsOWDCzllymmo9Uk0JAd85mazwLYzeixyIu/GkyYkb/CXTto7vCPzCrPgUV9PPS LX2KQPNeD36nrp8/ohJYzp3fxodBNfEVDp7/nPMgVsIIqCRw3kw4FSpCNhu1w0D/fTCt NmpA== X-Gm-Message-State: AOAM532flN7eAlGYwvIxnu/cJSY5SMuNvh3qk2eoUfjCyM0awBKdWDdq HGbmYRcdEHlNdg9dcXW99mo= X-Google-Smtp-Source: ABdhPJwneE+Frgm/M9lXs8nO35cC0R1vL3B7KjG45NkqaccJlqVEzU068ni07cXjKKyLXvP3AqU/xg== X-Received: by 2002:a17:906:e104:: with SMTP id gj4mr1176128ejb.350.1623264141003; Wed, 09 Jun 2021 11:42:21 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id oz11sm194935ejb.16.2021.06.09.11.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 11:42:20 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Wong Vee Khee , Ong Boon Leong , Michael Sit Wei Hong , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 07/13] net: pcs: xpcs: add support for NXP SJA1105 Date: Wed, 9 Jun 2021 21:41:49 +0300 Message-Id: <20210609184155.921662-8-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609184155.921662-1-olteanv@gmail.com> References: <20210609184155.921662-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean The NXP SJA1105 DSA switch integrates a Synopsys SGMII XPCS on port 4. The generic code works fine, except there is an integration issue which needs to be dealt with: in this switch, the XPCS is integrated with a PMA that has the TX lane polarity inverted by default (PLUS is MINUS, MINUS is PLUS). To obtain normal non-inverted behavior, the TX lane polarity must be inverted in the PCS, via the DIGITAL_CONTROL_2 register. We introduce a pma_config() method in xpcs_compat which is called by the phylink_pcs_config() implementation. Also, the NXP SJA1105 returns all zeroes in the PHY ID registers 2 and 3. We need to hack up an ad-hoc PHY ID (OUI is zero, device ID is 1) in order for the XPCS driver to recognize it. This PHY ID is added to the public include/linux/pcs/pcs-xpcs.h for that reason (for the sja1105 driver to be able to use it in a later patch). Signed-off-by: Vladimir Oltean --- MAINTAINERS | 1 + drivers/net/pcs/Makefile | 2 +- drivers/net/pcs/pcs-xpcs-nxp.c | 16 ++++++++++++++++ drivers/net/pcs/pcs-xpcs.c | 25 +++++++++++++++++++++++-- drivers/net/pcs/pcs-xpcs.h | 10 ++++++++++ include/linux/pcs/pcs-xpcs.h | 2 ++ 6 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 drivers/net/pcs/pcs-xpcs-nxp.c diff --git a/MAINTAINERS b/MAINTAINERS index 004c0d1e723d..c0ba005349fd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13209,6 +13209,7 @@ M: Vladimir Oltean L: linux-kernel@vger.kernel.org S: Maintained F: drivers/net/dsa/sja1105 +F: drivers/net/pcs/pcs-xpcs-nxp.c NXP TDA998X DRM DRIVER M: Russell King diff --git a/drivers/net/pcs/Makefile b/drivers/net/pcs/Makefile index c23146755972..d12b00e48358 100644 --- a/drivers/net/pcs/Makefile +++ b/drivers/net/pcs/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Linux PCS drivers -obj-$(CONFIG_PCS_XPCS) += pcs-xpcs.o +obj-$(CONFIG_PCS_XPCS) += pcs-xpcs.o pcs-xpcs-nxp.o obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o diff --git a/drivers/net/pcs/pcs-xpcs-nxp.c b/drivers/net/pcs/pcs-xpcs-nxp.c new file mode 100644 index 000000000000..51b2fc7d36a9 --- /dev/null +++ b/drivers/net/pcs/pcs-xpcs-nxp.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright 2021 NXP Semiconductors + */ +#include +#include "pcs-xpcs.h" + +/* In NXP SJA1105, the PCS is integrated with a PMA that has the TX lane + * polarity inverted by default (PLUS is MINUS, MINUS is PLUS). To obtain + * normal non-inverted behavior, the TX lane polarity must be inverted in the + * PCS, via the DIGITAL_CONTROL_2 register. + */ +int nxp_sja1105_sgmii_pma_config(struct dw_xpcs *xpcs) +{ + return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_DIG_CTRL2, + DW_VR_MII_DIG_CTRL2_TX_POL_INV); +} diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index ecf5011977d3..3b1baacfaf8f 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -117,6 +117,7 @@ struct xpcs_compat { const phy_interface_t *interface; int num_interfaces; int an_mode; + int (*pma_config)(struct dw_xpcs *xpcs); }; struct xpcs_id { @@ -168,7 +169,7 @@ static bool __xpcs_linkmode_supported(const struct xpcs_compat *compat, #define xpcs_linkmode_supported(compat, mode) \ __xpcs_linkmode_supported(compat, ETHTOOL_LINK_MODE_ ## mode ## _BIT) -static int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg) +int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg) { u32 reg_addr = mdiobus_c45_addr(dev, reg); struct mii_bus *bus = xpcs->mdiodev->bus; @@ -177,7 +178,7 @@ static int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg) return mdiobus_read(bus, addr, reg_addr); } -static int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val) +int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val) { u32 reg_addr = mdiobus_c45_addr(dev, reg); struct mii_bus *bus = xpcs->mdiodev->bus; @@ -788,6 +789,12 @@ static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, return -1; } + if (compat->pma_config) { + ret = compat->pma_config(xpcs); + if (ret) + return ret; + } + return 0; } @@ -1022,11 +1029,25 @@ static const struct xpcs_compat synopsys_xpcs_compat[DW_XPCS_INTERFACE_MAX] = { }, }; +static const struct xpcs_compat nxp_sja1105_xpcs_compat[DW_XPCS_INTERFACE_MAX] = { + [DW_XPCS_SGMII] = { + .supported = xpcs_sgmii_features, + .interface = xpcs_sgmii_interfaces, + .num_interfaces = ARRAY_SIZE(xpcs_sgmii_interfaces), + .an_mode = DW_AN_C37_SGMII, + .pma_config = nxp_sja1105_sgmii_pma_config, + }, +}; + static const struct xpcs_id xpcs_id_list[] = { { .id = SYNOPSYS_XPCS_ID, .mask = SYNOPSYS_XPCS_MASK, .compat = synopsys_xpcs_compat, + }, { + .id = NXP_SJA1105_XPCS_ID, + .mask = SYNOPSYS_XPCS_MASK, + .compat = nxp_sja1105_xpcs_compat, }, }; diff --git a/drivers/net/pcs/pcs-xpcs.h b/drivers/net/pcs/pcs-xpcs.h index 867537a68c63..3daf4276a158 100644 --- a/drivers/net/pcs/pcs-xpcs.h +++ b/drivers/net/pcs/pcs-xpcs.h @@ -60,10 +60,15 @@ /* EEE Mode Control Register */ #define DW_VR_MII_EEE_MCTRL0 0x8006 #define DW_VR_MII_EEE_MCTRL1 0x800b +#define DW_VR_MII_DIG_CTRL2 0x80e1 /* VR_MII_DIG_CTRL1 */ #define DW_VR_MII_DIG_CTRL1_MAC_AUTO_SW BIT(9) +/* VR_MII_DIG_CTRL2 */ +#define DW_VR_MII_DIG_CTRL2_TX_POL_INV BIT(4) +#define DW_VR_MII_DIG_CTRL2_RX_POL_INV BIT(0) + /* VR_MII_AN_CTRL */ #define DW_VR_MII_AN_CTRL_TX_CONFIG_SHIFT 3 #define DW_VR_MII_TX_CONFIG_MASK BIT(3) @@ -101,3 +106,8 @@ /* VR MII EEE Control 1 defines */ #define DW_VR_MII_EEE_TRN_LPI BIT(0) /* Transparent Mode Enable */ + +int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg); +int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val); + +int nxp_sja1105_sgmii_pma_config(struct dw_xpcs *xpcs); diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 4f1cdf6f3d4c..c594f7cdc304 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -10,6 +10,8 @@ #include #include +#define NXP_SJA1105_XPCS_ID 0x00000010 + /* AN mode */ #define DW_AN_C73 1 #define DW_AN_C37_SGMII 2 From patchwork Wed Jun 9 18:41:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 457379 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 B3D8AC48BCD for ; Wed, 9 Jun 2021 18:43:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D3B4613DF for ; Wed, 9 Jun 2021 18:43:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230040AbhFISp2 (ORCPT ); Wed, 9 Jun 2021 14:45:28 -0400 Received: from mail-ed1-f45.google.com ([209.85.208.45]:37688 "EHLO mail-ed1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230081AbhFISp0 (ORCPT ); Wed, 9 Jun 2021 14:45:26 -0400 Received: by mail-ed1-f45.google.com with SMTP id b11so29705030edy.4 for ; Wed, 09 Jun 2021 11:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Em2Aa6J9F9kVM3gPQWlF7kYj4x4JvyM78lJMl8Zig3o=; b=JoSVQVFTNTAEeYjHGzozM7gQyg24oygZV7KkZt7iI7GlIADiwfPTg6I7QYepOfOQNk aB6Hho0cd+sBAuXZoV2T5XcK9yqrKwUuv3tLSCZ8nt6eZcupa3+DZlck363CM42RiBo8 3vxnIIGXrdiDlgBXb1iuMzvZzdvioDtut273R2+I5oyRxhRQ1ycjUVJHbZfZ2IpdybHy EpkOieHxFz4ByGiRgTtTEmA0LSHf9V6qQoHgWuJ+o/ZUHkh5ntAsrhfkHvIfYPMeigKS idaDECsgD2Fft8wQR1LPA4jHfiUWAhHv+bVmy6HS8LnvN+X4aAOWVVBQYtn0Hj3vjLGW UTPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Em2Aa6J9F9kVM3gPQWlF7kYj4x4JvyM78lJMl8Zig3o=; b=f7dNE6K/wY1WTq1i7BZvHfUcBPV2AvZVDi0BQ9bviaOUqQIA3BXHi2rcBfPOVMY5SX CI9j+bbs9p38WyRoC8ZmwFNblbEdtyMd3U6ke8sQem7eBZiuAEG3R4CeP6n+e4jIDYP0 xbeSzsvlYpKrEL58hsE+vPVcvja26AHccUi9uc1/LaZLlfOl17lupgcxuSQHlYEzs/03 8TKjiG9gslBh6CbRw8TpCmlzEnIihERsaiANdLPRkQEstHvAdUQWC4cldW+Ly9Eej/K5 Ss/lHLIwH9eBk0iLoCU+wG7dn1B/FC11fQ+2/rSlhMNIePVmQ61AlSxz1Y4ZRm0P/upR ki9g== X-Gm-Message-State: AOAM53125ybTlqGnukvqZFsNfXcgsY5J24+pO3apZKvncHAAP7/O+fip kdaU9hTGP7J6n43WyRAVdFc= X-Google-Smtp-Source: ABdhPJw/5MfgzEKbAgmGT6YPTzNE8HTYTLO6hT0SrTjIkVUCJskE9HRcxvqZOxbPYLX/p9++tg5SXQ== X-Received: by 2002:a05:6402:612:: with SMTP id n18mr765642edv.83.1623264143511; Wed, 09 Jun 2021 11:42:23 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id oz11sm194935ejb.16.2021.06.09.11.42.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 11:42:23 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Wong Vee Khee , Ong Boon Leong , Michael Sit Wei Hong , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 09/13] net: pcs: xpcs: export xpcs_do_config and xpcs_link_up Date: Wed, 9 Jun 2021 21:41:51 +0300 Message-Id: <20210609184155.921662-10-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609184155.921662-1-olteanv@gmail.com> References: <20210609184155.921662-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean The sja1105 hardware has a quirk in that some changes require a switch reset, which loses all configuration. When the reset is initiated, everything needs to be reprogrammed, including the MACs and the PCS. This is currently done in sja1105_static_config_reload() - we manually call sja1105_adjust_port_config(), sja1105_sgmii_pcs_config() and sja1105_sgmii_pcs_force_speed() which are all internal functions. There is a desire for sja1105 to use the common xpcs driver, and that means that the equivalents of those functions, xpcs_do_config() and xpcs_link_up() respectively, will no longer be local functions. Forcing phylink to retrigger a resolve somehow, say by doing dev_close() followed by dev_open() is not really an option, because the CPU port might have a PCS as well, and there is no net device which we can close and reopen for that. Additionally, the dev_close/dev_open sequence might force a renegotiation of the copper-side link for SGMII ports connected to a PHY, and this is undesirable as well, because the switch reset is much quicker than a PHY autoneg, so we would have a lot more downtime. The only solution I see is for the sja1105 driver to keep doing what it's doing, and that means we need to export the equivalents from xpcs for sja1105_sgmii_pcs_config and sja1105_sgmii_pcs_force_speed, and call them directly in sja1105_static_config_reload(). This will be done during the conversion patch. Signed-off-by: Vladimir Oltean --- drivers/net/pcs/pcs-xpcs.c | 10 ++++++---- include/linux/pcs/pcs-xpcs.h | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index b66e46fc88dc..63fda3fc40aa 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -757,8 +757,8 @@ static int xpcs_config_2500basex(struct dw_xpcs *xpcs) return xpcs_write(xpcs, MDIO_MMD_VEND2, DW_VR_MII_MMD_CTRL, ret); } -static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, - unsigned int mode) +int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, + unsigned int mode) { const struct xpcs_compat *compat; int ret; @@ -797,6 +797,7 @@ static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, return 0; } +EXPORT_SYMBOL_GPL(xpcs_do_config); static int xpcs_config(struct phylink_pcs *pcs, unsigned int mode, phy_interface_t interface, @@ -945,8 +946,8 @@ 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(struct phylink_pcs *pcs, unsigned int mode, - phy_interface_t interface, int speed, int duplex) +void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, + phy_interface_t interface, int speed, int duplex) { struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); @@ -955,6 +956,7 @@ static void xpcs_link_up(struct phylink_pcs *pcs, unsigned int mode, if (interface == PHY_INTERFACE_MODE_SGMII) return xpcs_link_up_sgmii(xpcs, mode, speed, duplex); } +EXPORT_SYMBOL_GPL(xpcs_link_up); static u32 xpcs_get_id(struct dw_xpcs *xpcs) { diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index dae7dd8ac683..add077a81b21 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -27,6 +27,10 @@ struct dw_xpcs { }; 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); void xpcs_validate(struct dw_xpcs *xpcs, unsigned long *supported, struct phylink_link_state *state); int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, From patchwork Wed Jun 9 18:41:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 457383 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 0B75EC48BCD for ; Wed, 9 Jun 2021 18:42:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E32D2613DC for ; Wed, 9 Jun 2021 18:42:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230001AbhFISol (ORCPT ); Wed, 9 Jun 2021 14:44:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbhFISoj (ORCPT ); Wed, 9 Jun 2021 14:44:39 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E77CC061574 for ; Wed, 9 Jun 2021 11:42:30 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id ba2so27947227edb.2 for ; Wed, 09 Jun 2021 11:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uZ5jYvJRBU51BNg6a69WEodJQm6lb3/+UJF9RJja0Fg=; b=mu8F45cyczzhN1TgdHfy7mCvlZBFGpFmYh73p7qIhg6aUqYXkyg3OqiikPnnobttxz 6GLFsvq7Hq73UdiMVy4I7WM2V8lbbRxKjSGlZP6JryCKXebiAZcjRgOlBJaGltG7Y6ul 2BlI7zfnfI4j308G5e7TBvHMbDS+y9ZcEDtNScmK9jE/RHbNPaJphhc5ZraYPxU0c+cz LYXO73QEr7B3bi5xvAJK/QwM2L8cUgtctTJxgeL3MDoAPOjTaMGB7tXN6LZ2VWfFdgUL AtIc2xQTl7EVt3QVAoGKu7nfp2BIdtpr5NhF7v0HvAywP01dpD8kGHreN/RlCo7P57Ae abmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uZ5jYvJRBU51BNg6a69WEodJQm6lb3/+UJF9RJja0Fg=; b=mq/j5IW1R8Fn+sfXTCHhQACCCtCDBBP6JAjiE9b3nLq3OdTJsUmBJuypPZvmFjQfsL cjfqqToZVBePkbBbxmHow4tFo/vI7XQID1cD3zpinVjVSfEqy0otbQXMHAe1ZipAY7FG eWEqIbr4E9sivSZkLmiDMJrNeYq97uZdxyALBuxEwEdLPGuMJ/xTXoA+DML9pBvN9syY ZAoDEXgoIIgWqFmMvesakKk9qbyymBLcf3Jy1osDR19vrb8RJTf2EeLhHjB484iuTjGe DKG+EBUjzC2kqRKCSXYMUGe7Z/N0cZraRw0hDwWH8gUND1nelhTfSAqMSJkRIheMK4rT Xl6g== X-Gm-Message-State: AOAM530rnSueIlEXsfJMXuUTSSedU66JkxRQOUJKMCZK+XNtca1y59MM SAEopuyDroU2vp5bHcIX/ak= X-Google-Smtp-Source: ABdhPJxxloZB8yfL09mio37R7zdfws3rGTZaNVITCFVqHaItvTXrlj3XRmSLuA9gbA3i3fnH/D4qhA== X-Received: by 2002:a05:6402:48f:: with SMTP id k15mr792744edv.262.1623264148528; Wed, 09 Jun 2021 11:42:28 -0700 (PDT) Received: from localhost.localdomain ([188.26.52.84]) by smtp.gmail.com with ESMTPSA id oz11sm194935ejb.16.2021.06.09.11.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Jun 2021 11:42:28 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Wong Vee Khee , Ong Boon Leong , Michael Sit Wei Hong , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Coquelin , Heiner Kallweit , Russell King - ARM Linux admin , Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 13/13] net: dsa: sja1105: plug in support for 2500base-x Date: Wed, 9 Jun 2021 21:41:55 +0300 Message-Id: <20210609184155.921662-14-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609184155.921662-1-olteanv@gmail.com> References: <20210609184155.921662-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean The MAC treats 2500base-x same as SGMII (yay for that) except that it must be set to a different speed. Extend all places that check for SGMII to also check for 2500base-x. Also add the missing 2500base-x compatibility matrix entry for SJA1110D. Signed-off-by: Vladimir Oltean --- drivers/net/dsa/sja1105/sja1105_main.c | 19 ++++++++++++++++--- drivers/net/dsa/sja1105/sja1105_spi.c | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index aca243665f3b..a901803dbf02 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1046,6 +1046,9 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, case SPEED_1000: speed = priv->info->port_speed[SJA1105_SPEED_1000MBPS]; break; + case SPEED_2500: + speed = priv->info->port_speed[SJA1105_SPEED_2500MBPS]; + break; default: dev_err(dev, "Invalid speed %iMbps\n", speed_mbps); return -EINVAL; @@ -1060,6 +1063,8 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, */ if (priv->phy_mode[port] == PHY_INTERFACE_MODE_SGMII) mac[port].speed = priv->info->port_speed[SJA1105_SPEED_1000MBPS]; + else if (priv->phy_mode[port] == PHY_INTERFACE_MODE_2500BASEX) + mac[port].speed = priv->info->port_speed[SJA1105_SPEED_2500MBPS]; else mac[port].speed = speed; @@ -1172,6 +1177,10 @@ static void sja1105_phylink_validate(struct dsa_switch *ds, int port, if (mii->xmii_mode[port] == XMII_MODE_RGMII || mii->xmii_mode[port] == XMII_MODE_SGMII) phylink_set(mask, 1000baseT_Full); + if (priv->info->supports_2500basex[port]) { + phylink_set(mask, 2500baseT_Full); + phylink_set(mask, 2500baseX_Full); + } bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); bitmap_and(state->advertising, state->advertising, mask, @@ -1859,7 +1868,8 @@ int sja1105_static_config_reload(struct sja1105_private *priv, mac[i].speed); mac[i].speed = priv->info->port_speed[SJA1105_SPEED_AUTO]; - if (priv->phy_mode[i] == PHY_INTERFACE_MODE_SGMII) + if (priv->phy_mode[i] == PHY_INTERFACE_MODE_SGMII || + priv->phy_mode[i] == PHY_INTERFACE_MODE_2500BASEX) bmcr[i] = mdiobus_read(priv->mdio_pcs, i, reg_addr); } @@ -1914,7 +1924,8 @@ int sja1105_static_config_reload(struct sja1105_private *priv, if (rc < 0) goto out; - if (priv->phy_mode[i] != PHY_INTERFACE_MODE_SGMII) + if (priv->phy_mode[i] != PHY_INTERFACE_MODE_SGMII && + priv->phy_mode[i] != PHY_INTERFACE_MODE_2500BASEX) continue; if (bmcr[i] & BMCR_ANENABLE) @@ -1931,7 +1942,9 @@ int sja1105_static_config_reload(struct sja1105_private *priv, if (!phylink_autoneg_inband(mode)) { int speed = SPEED_UNKNOWN; - if (bmcr[i] & BMCR_SPEED1000) + if (priv->phy_mode[i] == PHY_INTERFACE_MODE_2500BASEX) + speed = SPEED_2500; + else if (bmcr[i] & BMCR_SPEED1000) speed = SPEED_1000; else if (bmcr[i] & BMCR_SPEED100) speed = SPEED_100; diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c index e6c2cb68fcc4..53c2213660a3 100644 --- a/drivers/net/dsa/sja1105/sja1105_spi.c +++ b/drivers/net/dsa/sja1105/sja1105_spi.c @@ -939,6 +939,8 @@ const struct sja1105_info sja1110d_info = { false, false, false, false, false, false}, .supports_sgmii = {false, true, true, true, true, false, false, false, false, false, false}, + .supports_2500basex = {false, false, false, true, true, + false, false, false, false, false, false}, .internal_phy = {SJA1105_NO_PHY, SJA1105_NO_PHY, SJA1105_NO_PHY, SJA1105_NO_PHY, SJA1105_NO_PHY, SJA1105_PHY_BASE_T1,