Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: dp83822: add EDPD support for DP83826
@ 2026-12-01  6:49 Jie Gu
  2026-12-01  8:24 ` Maxime Chevallier
  0 siblings, 1 reply; 4+ messages in thread
From: Jie Gu @ 2026-12-01  6:49 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Russell King, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, netdev, Jie Gu

From: Jie Gu <jie.gu@leica-geosystems.com.cn>

The DP83826 supports Active Sleep, a link-down power-saving mode that
periodically transmits normal link pulses to detect a link partner.
Expose this mode through the ethtool energy-detect power-down tunable.

Program PHYSCR bits [14:12] to select Active Sleep while preserving
unrelated register fields. The transmit interval is fixed at 1400 ms,
so accept either that value or the default interval when enabling
EDPD. Reject other intervals and requests to disable pulse transmission.

Read the configured mode from hardware when querying the tunable.
Cache successful setting changes and restore them during PHY
initialization so they survive PHY resets and interface down/up cycles.

Leave EDPD disabled by default and register the tunable callbacks only
for DP83826 variants, leaving DP83822 and DP83825 unchanged.

Signed-off-by: Jie Gu <jie.gu@leica-geosystems.com.cn>
---
Tested with a TI DP83826 PHY on a downstream Linux 6.16-based kernel.

With the cable disconnected, measured board input power decreased by
approximately 0.11 W. With Active Sleep enabled on both endpoints,
link establishment and ping succeeded after cable insertion. The
observed link-up time was approximately 0.8 s.

Link recovery was also verified with a router with EEE enabled and
a switch with Green Ethernet or EEE enabled.

 drivers/net/phy/dp83822.c | 71 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
index d67ca7e4a7e7..d01221e74b0b 100644
--- a/drivers/net/phy/dp83822.c
+++ b/drivers/net/phy/dp83822.c
@@ -62,6 +62,9 @@
 /* PHYSCR Register Fields */
 #define DP83822_PHYSCR_INT_OE		BIT(0) /* Interrupt Output Enable */
 #define DP83822_PHYSCR_INTEN		BIT(1) /* Interrupt Enable */
+#define DP83826_PHYSCR_POWER_SAVE_MASK	GENMASK(14, 12)
+#define DP83826_PHYSCR_ACTIVE_SLEEP	(BIT(14) | BIT(13))
+#define DP83826_EDPD_TX_MSECS		1400
 
 /* MISR1 bits */
 #define DP83822_RX_ERR_HF_INT_EN	BIT(0)
@@ -203,6 +206,7 @@ struct dp83822_private {
 	u16 fx_sd_enable;
 	u8 cfg_dac_minus;
 	u8 cfg_dac_plus;
+	bool edpd_enabled;
 	struct ethtool_wolinfo wol;
 	bool set_gpio2_clk_out;
 	u32 gpio2_clk_out;
@@ -664,6 +668,67 @@ static int dp8382x_config_rmii_mode(struct phy_device *phydev)
 	return 0;
 }
 
+static int dp83826_config_edpd(struct phy_device *phydev, bool enable)
+{
+	return phy_modify(phydev, MII_DP83822_PHYSCR,
+			  DP83826_PHYSCR_POWER_SAVE_MASK,
+			  enable ? DP83826_PHYSCR_ACTIVE_SLEEP : 0);
+}
+
+static int dp83826_get_tunable(struct phy_device *phydev,
+			       struct ethtool_tunable *tuna, void *data)
+{
+	int val;
+
+	switch (tuna->id) {
+	case ETHTOOL_PHY_EDPD:
+		val = phy_read(phydev, MII_DP83822_PHYSCR);
+		if (val < 0)
+			return val;
+
+		if ((val & DP83826_PHYSCR_POWER_SAVE_MASK) ==
+		    DP83826_PHYSCR_ACTIVE_SLEEP)
+			*(u16 *)data = DP83826_EDPD_TX_MSECS;
+		else
+			*(u16 *)data = ETHTOOL_PHY_EDPD_DISABLE;
+		return 0;
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
+static int dp83826_set_tunable(struct phy_device *phydev,
+			       struct ethtool_tunable *tuna, const void *data)
+{
+	struct dp83822_private *dp83822 = phydev->priv;
+	bool enable;
+	int ret;
+
+	switch (tuna->id) {
+	case ETHTOOL_PHY_EDPD:
+		switch (*(const u16 *)data) {
+		case ETHTOOL_PHY_EDPD_DISABLE:
+			enable = false;
+			break;
+		case ETHTOOL_PHY_EDPD_DFLT_TX_MSECS:
+		case DP83826_EDPD_TX_MSECS:
+			enable = true;
+			break;
+		default:
+			return -EINVAL;
+		}
+
+		ret = dp83826_config_edpd(phydev, enable);
+		if (ret)
+			return ret;
+
+		dp83822->edpd_enabled = enable;
+		return 0;
+	default:
+		return -EOPNOTSUPP;
+	}
+}
+
 static int dp83826_config_init(struct phy_device *phydev)
 {
 	struct dp83822_private *dp83822 = phydev->priv;
@@ -714,6 +779,10 @@ static int dp83826_config_init(struct phy_device *phydev)
 			return ret;
 	}
 
+	ret = dp83826_config_edpd(phydev, dp83822->edpd_enabled);
+	if (ret)
+		return ret;
+
 	return dp83822_config_wol(phydev, &dp83822->wol);
 }
 
@@ -1225,6 +1294,8 @@ static int dp83822_led_hw_control_get(struct phy_device *phydev, u8 index,
 		.probe          = dp83826_probe,		\
 		.soft_reset	= dp83822_phy_reset,		\
 		.config_init	= dp83826_config_init,		\
+		.get_tunable = dp83826_get_tunable,		\
+		.set_tunable = dp83826_set_tunable,		\
 		.get_wol = dp83822_get_wol,			\
 		.set_wol = dp83822_set_wol,			\
 		.config_intr = dp83822_config_intr,		\
-- 
2.43.0


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

end of thread, other threads:[~2026-12-01 14:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  6:49 [PATCH net-next] net: phy: dp83822: add EDPD support for DP83826 Jie Gu
2026-12-01  8:24 ` Maxime Chevallier
2026-12-01 13:47   ` Andrew Lunn
2026-12-01 14:21     ` Maxime Chevallier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox