netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] net: phy: adin: Add flags to disable enhanced link detection
@ 2023-02-28 14:40 Ken Sloat
  2023-02-28 14:53 ` Andrew Lunn
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Ken Sloat @ 2023-02-28 14:40 UTC (permalink / raw)
  Cc: Ken Sloat, Michael Hennerich, Andrew Lunn, Heiner Kallweit,
	Russell King, David S. Miller, Jakub Kicinski, netdev,
	linux-kernel

Enhanced link detection is an ADI PHY feature that allows for earlier
detection of link down if certain signal conditions are met. This
feature is for the most part enabled by default on the PHY. This is
not suitable for all applications and breaks the IEEE standard as
explained in the ADI datasheet.

To fix this, add override flags to disable enhanced link detection
for 1000BASE-T and 100BASE-TX respectively by clearing any related
feature enable bits.

This new feature was tested on an ADIN1300 but according to the
datasheet applies equally for 100BASE-TX on the ADIN1200.

Signed-off-by: Ken Sloat <ken.s@variscite.com>
---
 drivers/net/phy/adin.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c
index da65215d19bb..8809f3e036a4 100644
--- a/drivers/net/phy/adin.c
+++ b/drivers/net/phy/adin.c
@@ -69,6 +69,15 @@
 #define ADIN1300_EEE_CAP_REG			0x8000
 #define ADIN1300_EEE_ADV_REG			0x8001
 #define ADIN1300_EEE_LPABLE_REG			0x8002
+#define ADIN1300_FLD_EN_REG				0x8E27
+#define   ADIN1300_FLD_PCS_ERR_100_EN			BIT(7)
+#define   ADIN1300_FLD_PCS_ERR_1000_EN			BIT(6)
+#define   ADIN1300_FLD_SLCR_OUT_STUCK_100_EN	BIT(5)
+#define   ADIN1300_FLD_SLCR_OUT_STUCK_1000_EN	BIT(4)
+#define   ADIN1300_FLD_SLCR_IN_ZDET_100_EN		BIT(3)
+#define   ADIN1300_FLD_SLCR_IN_ZDET_1000_EN		BIT(2)
+#define   ADIN1300_FLD_SLCR_IN_INVLD_100_EN		BIT(1)
+#define   ADIN1300_FLD_SLCR_IN_INVLD_1000_EN	BIT(0)
 #define ADIN1300_CLOCK_STOP_REG			0x9400
 #define ADIN1300_LPI_WAKE_ERR_CNT_REG		0xa000
 
@@ -508,6 +517,31 @@ static int adin_config_clk_out(struct phy_device *phydev)
 			      ADIN1300_GE_CLK_CFG_MASK, sel);
 }
 
+static int adin_config_fld_en(struct phy_device *phydev)
+{
+	struct device *dev = &phydev->mdio.dev;
+	int reg;
+
+	reg = phy_read_mmd(phydev, MDIO_MMD_VEND1, ADIN1300_FLD_EN_REG);
+	if (reg < 0)
+		return reg;
+
+	if (device_property_read_bool(dev, "adi,disable-fld-1000base-t"))
+		reg &= ~(ADIN1300_FLD_PCS_ERR_1000_EN |
+				 ADIN1300_FLD_SLCR_OUT_STUCK_1000_EN |
+				 ADIN1300_FLD_SLCR_IN_ZDET_1000_EN |
+				 ADIN1300_FLD_SLCR_IN_INVLD_1000_EN);
+
+	if (device_property_read_bool(dev, "adi,disable-fld-100base-tx"))
+		reg &= ~(ADIN1300_FLD_PCS_ERR_100_EN |
+				 ADIN1300_FLD_SLCR_OUT_STUCK_100_EN |
+				 ADIN1300_FLD_SLCR_IN_ZDET_100_EN |
+				 ADIN1300_FLD_SLCR_IN_INVLD_100_EN);
+
+	return phy_write_mmd(phydev, MDIO_MMD_VEND1,
+			     ADIN1300_FLD_EN_REG, reg);
+}
+
 static int adin_config_init(struct phy_device *phydev)
 {
 	int rc;
@@ -534,6 +568,10 @@ static int adin_config_init(struct phy_device *phydev)
 	if (rc < 0)
 		return rc;
 
+	rc = adin_config_fld_en(phydev);
+	if (rc < 0)
+		return rc;
+
 	phydev_dbg(phydev, "PHY is using mode '%s'\n",
 		   phy_modes(phydev->interface));
 
-- 
2.34.1


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

end of thread, other threads:[~2023-03-08 10:19 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-28 14:40 [PATCH v1] net: phy: adin: Add flags to disable enhanced link detection Ken Sloat
2023-02-28 14:53 ` Andrew Lunn
2023-02-28 15:13   ` Ken Sloat
2023-02-28 15:19     ` Andrew Lunn
2023-02-28 15:28       ` Ken Sloat
2023-02-28 15:35         ` Andrew Lunn
2023-03-01  3:31       ` Jakub Kicinski
2023-03-01 13:02         ` Andrew Lunn
2023-03-01 14:08           ` Ken Sloat
2023-02-28 15:09 ` Nuno Sá
2023-02-28 15:18   ` Ken Sloat
2023-02-28 18:49 ` [PATCH v2 1/2] net: phy: adin: Add flags to allow disabling of fast link down Ken Sloat
2023-02-28 18:49   ` [PATCH v2 2/2] dt-bindings: net: adin: Document bindings for fast link down disable Ken Sloat
2023-03-02  8:59     ` Krzysztof Kozlowski
2023-03-07 18:19       ` Ken Sloat
2023-03-08 10:19         ` Krzysztof Kozlowski
2023-03-01  7:33   ` [PATCH v2 1/2] net: phy: adin: Add flags to allow disabling of fast link down Nuno Sá
2023-03-01 12:32     ` Ken Sloat

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