From: Luo Jie <luoj@codeaurora.org>
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 <luoj@codeaurora.org>
Subject: [PATCH v7 10/14] net: phy: add genphy_c45_fast_retrain
Date: Sun, 24 Oct 2021 16:27:34 +0800 [thread overview]
Message-ID: <20211024082738.849-11-luoj@codeaurora.org> (raw)
In-Reply-To: <20211024082738.849-1-luoj@codeaurora.org>
Add generic fast retrain auto-negotiation function for C45 PHYs.
Signed-off-by: Luo Jie <luoj@codeaurora.org>
---
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
next prev parent reply other threads:[~2021-10-24 8:28 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-24 8:27 [PATCH v7 0/14] net: phy: Add qca8081 ethernet phy driver Luo Jie
2021-10-24 8:27 ` [PATCH v7 01/14] net: phy: at803x: replace AT803X_DEVICE_ADDR with MDIO_MMD_PCS Luo Jie
2021-10-24 8:27 ` [PATCH v7 02/14] net: phy: at803x: use phy_modify() Luo Jie
2021-10-24 8:27 ` [PATCH v7 03/14] net: phy: at803x: improve the WOL feature Luo Jie
2021-10-24 18:29 ` Andrew Lunn
2021-10-24 8:27 ` [PATCH v7 04/14] net: phy: at803x: use GENMASK() for speed status Luo Jie
2021-10-24 8:27 ` [PATCH v7 05/14] net: phy: add qca8081 ethernet phy driver Luo Jie
2021-10-24 18:29 ` Andrew Lunn
2021-10-24 8:27 ` [PATCH v7 06/14] net: phy: add qca8081 read_status Luo Jie
2021-10-24 18:30 ` Andrew Lunn
2021-10-24 8:27 ` [PATCH v7 07/14] net: phy: add qca8081 get_features Luo Jie
2021-10-24 18:31 ` Andrew Lunn
2021-10-24 8:27 ` [PATCH v7 08/14] net: phy: add qca8081 config_aneg Luo Jie
2021-10-24 18:31 ` Andrew Lunn
2021-10-24 8:27 ` [PATCH v7 09/14] net: phy: add constants for fast retrain related register Luo Jie
2021-10-24 18:32 ` Andrew Lunn
2021-10-24 8:27 ` Luo Jie [this message]
2021-10-24 18:33 ` [PATCH v7 10/14] net: phy: add genphy_c45_fast_retrain Andrew Lunn
2021-10-24 8:27 ` [PATCH v7 11/14] net: phy: add qca8081 config_init Luo Jie
2021-10-24 18:34 ` Andrew Lunn
2021-10-24 8:27 ` [PATCH v7 12/14] net: phy: add qca8081 soft_reset and enable master/slave seed Luo Jie
2021-10-24 18:40 ` Andrew Lunn
2021-10-24 8:27 ` [PATCH v7 13/14] net: phy: adjust qca8081 master/slave seed value if link down Luo Jie
2021-10-24 18:41 ` Andrew Lunn
2021-10-24 8:27 ` [PATCH v7 14/14] net: phy: add qca8081 cdt feature Luo Jie
2021-10-24 18:43 ` Andrew Lunn
2021-10-25 13:10 ` [PATCH v7 0/14] net: phy: Add qca8081 ethernet phy driver patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211024082738.849-11-luoj@codeaurora.org \
--to=luoj@codeaurora.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=sricharan@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).