mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: phy: dp83tg720: wake up PHYs in managed mode
@ 2024-06-12 13:02 Oleksij Rempel
  2024-06-13  7:09 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Oleksij Rempel @ 2024-06-12 13:02 UTC (permalink / raw)
  To: barebox; +Cc: David Jander, Oleksij Rempel

From: David Jander <david@protonic.nl>

In case this PHY is bootstrapped for managed mode, we need to manually
wake it. Otherwise no link will be detected.

Signed-off-by: David Jander <david@protonic.nl>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/phy/dp83tg720.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/dp83tg720.c b/drivers/net/phy/dp83tg720.c
index 0571f4cb52..d57985539d 100644
--- a/drivers/net/phy/dp83tg720.c
+++ b/drivers/net/phy/dp83tg720.c
@@ -21,6 +21,11 @@
 #define DP83TG720S_PHY_RESET			0x1f
 #define DP83TG720S_HW_RESET			BIT(15)
 
+#define DP83TG720S_LPS_CFG3			0x18c
+/* Power modes are documented as bitfields but used as values */
+/* Power Mode 0 is Normal mode */
+#define DP83TG720S_LPS_CFG3_PWR_MODE_0		BIT(0)
+
 static int dp83tg720_config_rgmii_delay(struct phy_device *phydev)
 {
 	u16 rgmii_delay_mask;
@@ -54,6 +59,8 @@ static int dp83tg720_config_rgmii_delay(struct phy_device *phydev)
 
 static int dp83tg720_phy_init(struct phy_device *phydev)
 {
+	int ret = 0;
+
 	/* HW reset is needed to recover link if previous link was lost. SW
 	 * reset is not enough.
 	 */
@@ -62,10 +69,23 @@ static int dp83tg720_phy_init(struct phy_device *phydev)
 	phydev->supported = SUPPORTED_1000baseT_Full;
 	phydev->advertising = SUPPORTED_1000baseT_Full;
 
-	if (phy_interface_is_rgmii(phydev))
-		return dp83tg720_config_rgmii_delay(phydev);
+	/* According to the "DP83TG720R-Q1 1000BASE-T1 Automotive Ethernet PHY
+	 * datasheet (Rev. C)" - "T6.2 Post reset stabilization-time prior to
+	 * MDC preamble for register access is 1ms."
+	 */
+	mdelay(1);
 
-	return 0;
+	if (phy_interface_is_rgmii(phydev)) {
+		ret = dp83tg720_config_rgmii_delay(phydev);
+		if (ret)
+			return ret;
+	}
+
+	/* In case the PHY is bootstrapped in managed mode, we need to
+	 * wake it.
+	 */
+	return phy_write_mmd(phydev, MDIO_MMD_VEND2, DP83TG720S_LPS_CFG3,
+			     DP83TG720S_LPS_CFG3_PWR_MODE_0);
 }
 
 static int dp83tg720_read_status(struct phy_device *phydev)
-- 
2.39.2




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

* Re: [PATCH] net: phy: dp83tg720: wake up PHYs in managed mode
  2024-06-12 13:02 [PATCH] net: phy: dp83tg720: wake up PHYs in managed mode Oleksij Rempel
@ 2024-06-13  7:09 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-06-13  7:09 UTC (permalink / raw)
  To: barebox, Oleksij Rempel; +Cc: David Jander


On Wed, 12 Jun 2024 15:02:56 +0200, Oleksij Rempel wrote:
> In case this PHY is bootstrapped for managed mode, we need to manually
> wake it. Otherwise no link will be detected.
> 
> 

Applied, thanks!

[1/1] net: phy: dp83tg720: wake up PHYs in managed mode
      https://git.pengutronix.de/cgit/barebox/commit/?id=c9a2b7c74058 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2024-06-13  7:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-12 13:02 [PATCH] net: phy: dp83tg720: wake up PHYs in managed mode Oleksij Rempel
2024-06-13  7:09 ` Sascha Hauer

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