netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: phy: adin: clear the diag clock and set LINKING_EN during autoneg
@ 2020-10-21 13:51 Alexandru Ardelean
  2020-10-21 13:51 ` [PATCH 2/2] net: phy: adin: implement cable-test support Alexandru Ardelean
  2020-10-21 13:58 ` [PATCH 1/2] net: phy: adin: clear the diag clock and set LINKING_EN during autoneg Andrew Lunn
  0 siblings, 2 replies; 11+ messages in thread
From: Alexandru Ardelean @ 2020-10-21 13:51 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: alexaundru.ardelean, andrew, hkallweit1, linux, davem,
	ardeleanalex, kuba, Alexandru Ardelean

The LINKING_EN bit is always cleared during reset. Initially it was set
during the downshift setup, because it's in the same register as the
downshift retry count (PHY_CTRL1).

This change moves the handling of LINKING_EN from the downshift handler to
the autonegotiation handler. Also, during autonegotiation setup, the
diagnostics clock is cleared.

This is being done as a prequel to the cable-diagnostics patch. When the
cable diagnostics finishes, the PHY state machine goes back into the PHY_UP
state and the autonegotiation is restarted (or better said, the
autonegotiation handler is called).
During this call, the diagnostics clock should be disabled, and the
LINKING_EN bit set in the PHY_CTRL1 register.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/net/phy/adin.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c
index 5bc3926c52f0..619d36685b5d 100644
--- a/drivers/net/phy/adin.c
+++ b/drivers/net/phy/adin.c
@@ -23,6 +23,7 @@
 #define ADIN1300_PHY_CTRL1			0x0012
 #define   ADIN1300_AUTO_MDI_EN			BIT(10)
 #define   ADIN1300_MAN_MDIX_EN			BIT(9)
+#define   ADIN1300_DIAG_CLK_EN			BIT(2)
 
 #define ADIN1300_RX_ERR_CNT			0x0014
 
@@ -326,10 +327,9 @@ static int adin_set_downshift(struct phy_device *phydev, u8 cnt)
 		return -E2BIG;
 
 	val = FIELD_PREP(ADIN1300_DOWNSPEED_RETRIES_MSK, cnt);
-	val |= ADIN1300_LINKING_EN;
 
 	rc = phy_modify(phydev, ADIN1300_PHY_CTRL3,
-			ADIN1300_LINKING_EN | ADIN1300_DOWNSPEED_RETRIES_MSK,
+			ADIN1300_DOWNSPEED_RETRIES_MSK,
 			val);
 	if (rc < 0)
 		return rc;
@@ -560,6 +560,14 @@ static int adin_config_aneg(struct phy_device *phydev)
 {
 	int ret;
 
+	ret = phy_clear_bits(phydev, ADIN1300_PHY_CTRL1, ADIN1300_DIAG_CLK_EN);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_set_bits(phydev, ADIN1300_PHY_CTRL3, ADIN1300_LINKING_EN);
+	if (ret < 0)
+		return ret;
+
 	ret = adin_config_mdix(phydev);
 	if (ret)
 		return ret;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-10-21 16:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-21 13:51 [PATCH 1/2] net: phy: adin: clear the diag clock and set LINKING_EN during autoneg Alexandru Ardelean
2020-10-21 13:51 ` [PATCH 2/2] net: phy: adin: implement cable-test support Alexandru Ardelean
2020-10-21 14:08   ` Andrew Lunn
2020-10-21 14:16     ` Alexandru Ardelean
2020-10-21 14:28       ` Andrew Lunn
2020-10-21 14:46         ` Alexandru Ardelean
2020-10-21 13:58 ` [PATCH 1/2] net: phy: adin: clear the diag clock and set LINKING_EN during autoneg Andrew Lunn
2020-10-21 14:05   ` Alexandru Ardelean
2020-10-21 14:13     ` Andrew Lunn
2020-10-21 14:23       ` Alexandru Ardelean
2020-10-21 16:34         ` Andrew Lunn

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).