From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: David Jander <david@protonic.nl>,
Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH] net: phy: dp83tg720: wake up PHYs in managed mode
Date: Wed, 12 Jun 2024 15:02:56 +0200 [thread overview]
Message-ID: <20240612130256.3587709-1-o.rempel@pengutronix.de> (raw)
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
next reply other threads:[~2024-06-12 13:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-12 13:02 Oleksij Rempel [this message]
2024-06-13 7:09 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240612130256.3587709-1-o.rempel@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=david@protonic.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox