Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2350863pxb; Fri, 22 Oct 2021 20:29:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKaXpw/WanVPF7J3KJPUaGwidgX/2+VxcXAXE/+FqiKsY8nXPN33KZGaznZebBLOJoEdYy X-Received: by 2002:a05:6402:17c4:: with SMTP id s4mr5334019edy.253.1634959760573; Fri, 22 Oct 2021 20:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634959760; cv=none; d=google.com; s=arc-20160816; b=zeLtm6DzkC9K7nB+PVVoS5hQZxeD1z8oUVpMSwVTI62QD58pI+iLeDZuPdDHJXN+jD 36Dz+0FSAwGoBLs4WiW79PlU3+zPAGc/dkML0Wci+ubZxRZj3fNOUzR4J69+I6Ye3zj6 zRmOxmq0ElT9ARw3DMrff2D0jQCxsrw5MB3yiBd9pYGTnKKyCdYF9u2eMYe0+PYNAYc/ FQzF4A3fWtSggqsuVS6Qnwq+IXyKv9T9Gu8w39vpY2u1QyDFcRTRTs+/+s1xiKLNq/rO zRaaaQpCnq6dPusoiZ2MsylcS567w6X/fsdx4Y9xBUwgRe7vpwW7Y8POB5gd4fKLvu3j c7Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=+oajzsf1fl9Gw8kku/wIe9EdIdkDw2TeU2ygjiesPhQ=; b=qY3PWgXexthilxGEVlfzEBWt2AnPuylHRsar+Fjf3KEbWKcsGxcm0LJLaJxNmPrsW6 KjmOn5hzTaboQFOci/mXcizLQuOolXLrrCZKg/TE1dnTEZmNo+52rjaFvR6Pufja3jwu X0vgv4LQO4mb1WWaHTNXZ0Ka7nyNu0ooe2UuktSObkgxq+53Gx43KA+34TidNp7+zI59 jHBJQaHdzVWq4zbt9pH906jU8289Fp7qz1RF6rHMKJARkZ5J+POjh2zolheQCWkReVY/ JF8twmTWcymHQy9RkWJVEuH7Tw8PmI3+01X/+rBOhfSxWCPSJUS+acIXB9wz1gSRt5hA b0Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=idy04nX5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nc14si20907171ejc.589.2021.10.22.20.28.26; Fri, 22 Oct 2021 20:29:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=idy04nX5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbhJWD1i (ORCPT + 99 others); Fri, 22 Oct 2021 23:27:38 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:24270 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbhJWD1N (ORCPT ); Fri, 22 Oct 2021 23:27:13 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1634959495; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=+oajzsf1fl9Gw8kku/wIe9EdIdkDw2TeU2ygjiesPhQ=; b=idy04nX5MGw3657Nq34ZU5ZtDZOyrweG3Pt9zEv280reWGAGg2vk7VCtuErOHPNskdyGRJdi m10IQ/EzVND3ffUm8jzNuiYJOWymxFAwsUcCCHjZJyAF62y35r1QW+g788DoqiwuKrjfz6Zo UIe16rMG8DyoJjLg+Vp5av4GJAw= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n06.prod.us-east-1.postgun.com with SMTP id 6173808514914866fa39117c (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sat, 23 Oct 2021 03:24:53 GMT Sender: luoj=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 1D9B0C4360C; Sat, 23 Oct 2021 03:24:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from akronite-sh-dev02.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luoj) by smtp.codeaurora.org (Postfix) with ESMTPSA id CCED3C4360C; Sat, 23 Oct 2021 03:24:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org CCED3C4360C Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org From: Luo Jie To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sricharan@codeaurora.org, Luo Jie Subject: [PATCH v5 10/14] net: phy: add genphy_c45_fast_retrain Date: Sat, 23 Oct 2021 11:24:08 +0800 Message-Id: <20211023032412.30479-11-luoj@codeaurora.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211023032412.30479-1-luoj@codeaurora.org> References: <20211023032412.30479-1-luoj@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add generic fast retrain auto-negotiation function for C45 PHYs. Signed-off-by: Luo Jie --- drivers/net/phy/phy-c45.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/phy.h | 1 + 2 files changed, 35 insertions(+) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index c617dbcad6ea..b01180e1f578 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -611,6 +611,40 @@ int genphy_c45_loopback(struct phy_device *phydev, bool enable) } EXPORT_SYMBOL_GPL(genphy_c45_loopback); +/** + * genphy_c45_fast_retrain - configure fast retrain registers + * @phydev: target phy_device struct + * + * Description: If fast-retrain is enabled, we configure PHY as + * advertising fast retrain capable and THP Bypass Request, then + * enable fast retrain. If it is not enabled, we configure fast + * retrain disabled. + */ +int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable) +{ + int ret; + + if (!enable) + return phy_clear_bits_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_FSRT_CSR, + MDIO_PMA_10GBR_FSRT_ENABLE); + + if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->supported)) { + ret = phy_set_bits_mmd(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL, + MDIO_AN_10GBT_CTRL_ADVFSRT2_5G); + if (ret) + return ret; + + ret = phy_set_bits_mmd(phydev, MDIO_MMD_AN, MDIO_AN_CTRL2, + MDIO_AN_THP_BP2_5GT); + if (ret) + return ret; + } + + return phy_set_bits_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_FSRT_CSR, + MDIO_PMA_10GBR_FSRT_ENABLE); +} +EXPORT_SYMBOL_GPL(genphy_c45_fast_retrain); + struct phy_driver genphy_c45_driver = { .phy_id = 0xffffffff, .phy_id_mask = 0xffffffff, diff --git a/include/linux/phy.h b/include/linux/phy.h index 736e1d1a47c4..04e90423fa88 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1584,6 +1584,7 @@ int genphy_c45_config_aneg(struct phy_device *phydev); int genphy_c45_loopback(struct phy_device *phydev, bool enable); int genphy_c45_pma_resume(struct phy_device *phydev); int genphy_c45_pma_suspend(struct phy_device *phydev); +int genphy_c45_fast_retrain(struct phy_device *phydev, bool enable); /* Generic C45 PHY driver */ extern struct phy_driver genphy_c45_driver; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project