netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: phy: at803x: Improve hibernation support on start up
@ 2023-08-04 17:58 Marek Vasut
  2023-08-08  8:44 ` Wei Fang
  0 siblings, 1 reply; 32+ messages in thread
From: Marek Vasut @ 2023-08-04 17:58 UTC (permalink / raw)
  To: netdev
  Cc: Marek Vasut, David S. Miller, Andrew Lunn, Eric Dumazet,
	Heiner Kallweit, Jakub Kicinski, Oleksij Rempel, Paolo Abeni,
	Russell King, Wei Fang

Toggle hibernation mode OFF and ON to wake the PHY up and
make it generate clock on RX_CLK pin for about 10 seconds.
These clock are needed during start up by MACs like DWMAC
in NXP i.MX8M Plus to release their DMA from reset. After
the MAC has started up, the PHY can enter hibernation and
disable the RX_CLK clock, this poses no problem for the MAC.

Originally, this issue has been described by NXP in commit
9ecf04016c87 ("net: phy: at803x: add disable hibernation mode support")
but this approach fully disables the hibernation support and
takes away any power saving benefit. This patch instead makes
the PHY generate the clock on start up for 10 seconds, which
should be long enough for the EQoS MAC to release DMA from
reset.

Before this patch on i.MX8M Plus board with AR8031 PHY:
"
$ ifconfig eth1 up
[   25.576734] imx-dwmac 30bf0000.ethernet eth1: Register MEM_TYPE_PAGE_POOL RxQ-0
[   25.658916] imx-dwmac 30bf0000.ethernet eth1: PHY [stmmac-1:00] driver [Qualcomm Atheros AR8031/AR8033] (irq=38)
[   26.670276] imx-dwmac 30bf0000.ethernet: Failed to reset the dma
[   26.676322] imx-dwmac 30bf0000.ethernet eth1: stmmac_hw_setup: DMA engine initialization failed
[   26.685103] imx-dwmac 30bf0000.ethernet eth1: __stmmac_open: Hw setup failed
ifconfig: SIOCSIFFLAGS: Connection timed out
"

After this patch on i.MX8M Plus board with AR8031 PHY:
"
$ ifconfig eth1 up
[   19.419085] imx-dwmac 30bf0000.ethernet eth1: Register MEM_TYPE_PAGE_POOL RxQ-0
[   19.507380] imx-dwmac 30bf0000.ethernet eth1: PHY [stmmac-1:00] driver [Qualcomm Atheros AR8031/AR8033] (irq=38)
[   19.528464] imx-dwmac 30bf0000.ethernet eth1: No Safety Features support found
[   19.535769] imx-dwmac 30bf0000.ethernet eth1: IEEE 1588-2008 Advanced Timestamp supported
[   19.544302] imx-dwmac 30bf0000.ethernet eth1: registered PTP clock
[   19.552008] imx-dwmac 30bf0000.ethernet eth1: FPE workqueue start
[   19.558152] imx-dwmac 30bf0000.ethernet eth1: configuring for phy/rgmii-id link mode
"

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Oleksij Rempel <linux@rempel-privat.de>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Wei Fang <wei.fang@nxp.com>
Cc: netdev@vger.kernel.org
---
 drivers/net/phy/at803x.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 13c4121fa3092..8cb7b39c6cddc 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -986,6 +986,25 @@ static int at8031_pll_config(struct phy_device *phydev)
 static int at803x_hibernation_mode_config(struct phy_device *phydev)
 {
 	struct at803x_priv *priv = phydev->priv;
+	int ret;
+
+	/* Toggle hibernation mode OFF and ON to wake the PHY up and
+	 * make it generate clock on RX_CLK pin for about 10 seconds.
+	 * These clock are needed during start up by MACs like DWMAC
+	 * in NXP i.MX8M Plus to release their DMA from reset. After
+	 * the MAC has started up, the PHY can enter hibernation and
+	 * disable the RX_CLK clock, this poses no problem for the MAC.
+	 */
+	ret = at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL,
+				    AT803X_DEBUG_HIB_CTRL_PS_HIB_EN, 0);
+	if (ret < 0)
+		return ret;
+
+	ret = at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL,
+				    AT803X_DEBUG_HIB_CTRL_PS_HIB_EN,
+				    AT803X_DEBUG_HIB_CTRL_PS_HIB_EN);
+	if (ret < 0)
+		return ret;
 
 	/* The default after hardware reset is hibernation mode enabled. After
 	 * software reset, the value is retained.
-- 
2.40.1


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

end of thread, other threads:[~2023-12-15  8:26 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-04 17:58 [PATCH] net: phy: at803x: Improve hibernation support on start up Marek Vasut
2023-08-08  8:44 ` Wei Fang
2023-08-08 18:37   ` Marek Vasut
2023-08-09  2:27     ` Wei Fang
2023-08-09  4:36       ` Oleksij Rempel
2023-08-09  5:37         ` Wei Fang
2023-08-09  6:08           ` Oleksij Rempel
2023-08-09  8:43             ` Russell King (Oracle)
2023-08-10 10:30               ` Russell King (Oracle)
2023-12-14  8:13                 ` Romain Gantois
2023-12-14 10:46                   ` Marek Vasut
2023-12-14 16:49                   ` Russell King (Oracle)
2023-12-15  8:22                     ` Romain Gantois
2023-08-10  3:28             ` Wei Fang
2023-08-10  9:08               ` Russell King (Oracle)
2023-08-09 13:40           ` Andrew Lunn
2023-08-09 21:34             ` Marek Vasut
2023-08-09 22:06               ` Andrew Lunn
2023-08-10  0:49                 ` Marek Vasut
2023-08-10  4:32                   ` Oleksij Rempel
2023-08-10 10:10                     ` Russell King (Oracle)
2023-08-10 10:01                   ` Russell King (Oracle)
2023-08-10 10:34                     ` Russell King (Oracle)
2023-08-10 12:51                       ` Oleksij Rempel
2023-08-10 13:16                         ` Russell King (Oracle)
2023-08-10 13:49                           ` Andrew Lunn
2023-08-10 13:54                             ` Russell King (Oracle)
2023-08-10 14:23                               ` Andrew Lunn
2023-08-10 14:36                                 ` Russell King (Oracle)
2023-08-09 23:15               ` Russell King (Oracle)
2023-08-10 10:34                 ` Russell King (Oracle)
2023-08-10  3:38             ` Wei Fang

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