Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3416865pxb; Sun, 24 Oct 2021 01:31:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxM4tWWWvbbxwKhFxZa/tlj7b/3Rn0qrAft1TOzjyWqzq/IM/oS/TPfhV2BvP61Rx/2irEr X-Received: by 2002:a17:906:f41:: with SMTP id h1mr14099101ejj.255.1635064265420; Sun, 24 Oct 2021 01:31:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635064265; cv=none; d=google.com; s=arc-20160816; b=eBtH9dYP7MvO8XsKWTdD4233yZ4PsIDlNqmpUQuTZCfSRL3Z1c8c36I6AYveKUzhl3 RgROisAeQdziL1wq5yfXIxDACgb0U0rm/AW6fOeVh9ZFKva3DwGzfCkEm5hn2yKNKyXm FcuvtvXXF7Qu1kVezcXJ8+C8j1R8u8da28qv0xzxM6EOxYHLyNJ7sZTo1UKHKirCQYlX WKGa+hJjQhf9TxGu6C+FjG582FOlwa6FahPpFTxhAhyZnJK1cKVvBxLow65D7f9e6i4b TCWVdroRk9lsF8eLYsSi4xW3IRmSRX3k0FQDTin7y4RgO9Xi+i5HvbazZgWxyx5bkc5c htew== 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=w5/1xrZQCelKsEtJWvZLZk4AXONCuDkZPWMQPQV4UPEIdOZeYKR9ePXYjIV2BmDYxk oiYic5DWXBLHw6yOGuX00pMHQWJYenAu9Owkcth68Tf9kh4cVa/iLWdyY3FJ9iEsq5kH ZnjNv2GCeRQ5qjYqBXFpx0aplW63uefLzE31V/9fgl1WfNCCVWGqe1PHymwqLXpuXsiA 0dnkV6fQ6wvXCCX7frhtAKbzOs/kLJtqQu/1QU5N+j8jwOeT1xR9vGsUET0guWetdkLx K4jx8GCZ1ynZLKILKaCLLvpynH56AZkigFJz5b5xV9acxTS3plYtpn7k+hg6YpLIm5Rs 5rSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=uSIFya04; 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 h10si17163049edf.379.2021.10.24.01.30.15; Sun, 24 Oct 2021 01:31:05 -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=uSIFya04; 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 S231792AbhJXIal (ORCPT + 99 others); Sun, 24 Oct 2021 04:30:41 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:18899 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231664AbhJXIae (ORCPT ); Sun, 24 Oct 2021 04:30:34 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1635064094; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=+oajzsf1fl9Gw8kku/wIe9EdIdkDw2TeU2ygjiesPhQ=; b=uSIFya04FlBEoG1Gqcp2/LsYvtSGqo/vR3K4/6Q62mGHTe2/BQlrmOSIUxLcoyL1Vpv/xCaD 1mD3kmLF9MhgetqaCy9qyQ6ZCS1pn46vdpb19aG2YGNsFLT74SFbqNWS2jIdpdy+C9RNjyXc VBdASRReWKGa8/qCXa2IDOhvGZA= X-Mailgun-Sending-Ip: 69.72.43.7 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-n07.prod.us-west-2.postgun.com with SMTP id 6175191cdaa899cf748fa6ec (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sun, 24 Oct 2021 08:28:12 GMT Sender: luoj=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id E23CEC4361B; Sun, 24 Oct 2021 08:28:12 +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, URIBL_BLOCKED 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 3CA58C4360C; Sun, 24 Oct 2021 08:28:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 3CA58C4360C 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 v7 10/14] net: phy: add genphy_c45_fast_retrain Date: Sun, 24 Oct 2021 16:27:34 +0800 Message-Id: <20211024082738.849-11-luoj@codeaurora.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211024082738.849-1-luoj@codeaurora.org> References: <20211024082738.849-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