From: Gatien Chevallier <gatien.chevallier@foss.st.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Christophe Roullier <christophe.roullier@foss.st.com>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Simon Horman <horms@kernel.org>,
Tristram Ha <Tristram.Ha@microchip.com>,
Florian Fainelli <florian.fainelli@broadcom.com>
Cc: <netdev@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
Gatien Chevallier <gatien.chevallier@foss.st.com>
Subject: [PATCH net-next 3/4] net: phy: smsc: fix and improve WoL support
Date: Mon, 21 Jul 2025 13:14:45 +0200 [thread overview]
Message-ID: <20250721-wol-smsc-phy-v1-3-89d262812dba@foss.st.com> (raw)
In-Reply-To: <20250721-wol-smsc-phy-v1-0-89d262812dba@foss.st.com>
Add suspend()/resume() callbacks that do not shut down the PHY if the
WoL is supported and handle the WoL status flags.
If the WoL is supported by the PHY, indicate that the PHY device can
be a source of wake up for the platform. When setting the WoL
configuration, enable this capability.
Fixes: 8b305ee2a91c ("net: phy: smsc: add WoL support to LAN8740/LAN8742 PHYs")
Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
---
drivers/net/phy/smsc.c | 42 ++++++++++++++++++++++++++++++++++++++----
include/linux/smscphy.h | 2 ++
2 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index b6489da5cfcdfb405457058dc88575c0d84d259d..cf4e763907aefd2d725c734d3e0f2926128f770e 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -537,14 +537,45 @@ static int lan874x_set_wol(struct phy_device *phydev,
}
}
- rc = phy_write_mmd(phydev, MDIO_MMD_PCS, MII_LAN874X_PHY_MMD_WOL_WUCSR,
- val_wucsr);
+ /* Enable wakeup on PHY device if at least one WoL feature is configured */
+ device_set_wakeup_enable(&phydev->mdio.dev, !!(val_wucsr & MII_LAN874X_PHY_WOL_MASK));
+
+ rc = phy_write_mmd(phydev, MDIO_MMD_PCS, MII_LAN874X_PHY_MMD_WOL_WUCSR, val_wucsr);
if (rc < 0)
return rc;
return 0;
}
+static int smsc_phy_suspend(struct phy_device *phydev)
+{
+ if (!phydev->wol_enabled)
+ return genphy_suspend(phydev);
+
+ return 0;
+}
+
+static int smsc_phy_resume(struct phy_device *phydev)
+{
+ int rc;
+
+ if (!phydev->wol_enabled)
+ return genphy_resume(phydev);
+
+ rc = phy_read_mmd(phydev, MDIO_MMD_PCS, MII_LAN874X_PHY_MMD_WOL_WUCSR);
+ if (rc < 0)
+ return rc;
+
+ if (!(rc & MII_LAN874X_PHY_WOL_STATUS_MASK))
+ return 0;
+
+ dev_info(&phydev->mdio.dev, "Woke up from LAN event.\n");
+ rc = phy_write_mmd(phydev, MDIO_MMD_PCS, MII_LAN874X_PHY_MMD_WOL_WUCSR,
+ rc | MII_LAN874X_PHY_WOL_STATUS_MASK);
+
+ return rc;
+}
+
static int smsc_get_sset_count(struct phy_device *phydev)
{
return ARRAY_SIZE(smsc_hw_stats);
@@ -673,6 +704,9 @@ int smsc_phy_probe(struct phy_device *phydev)
phydev->priv = priv;
+ if (phydev->drv->set_wol)
+ device_set_wakeup_capable(&phydev->mdio.dev, true);
+
/* Make clk optional to keep DTB backward compatibility. */
refclk = devm_clk_get_optional_enabled_with_rate(dev, NULL,
50 * 1000 * 1000);
@@ -875,8 +909,8 @@ static struct phy_driver smsc_phy_driver[] = {
.set_wol = lan874x_set_wol,
.get_wol = lan874x_get_wol,
- .suspend = genphy_suspend,
- .resume = genphy_resume,
+ .suspend = smsc_phy_suspend,
+ .resume = smsc_phy_resume,
} };
module_phy_driver(smsc_phy_driver);
diff --git a/include/linux/smscphy.h b/include/linux/smscphy.h
index 1a6a851d2cf80d225bada7adeb79969e625964bd..cdf266960032609241afc8316da23f1c4834bfee 100644
--- a/include/linux/smscphy.h
+++ b/include/linux/smscphy.h
@@ -65,6 +65,8 @@ int smsc_phy_probe(struct phy_device *phydev);
#define MII_LAN874X_PHY_WOL_WUEN BIT(2)
#define MII_LAN874X_PHY_WOL_MPEN BIT(1)
#define MII_LAN874X_PHY_WOL_BCSTEN BIT(0)
+#define MII_LAN874X_PHY_WOL_MASK GENMASK(4, 0)
+#define MII_LAN874X_PHY_WOL_STATUS_MASK GENMASK(7, 4)
#define MII_LAN874X_PHY_WOL_FILTER_EN BIT(15)
#define MII_LAN874X_PHY_WOL_FILTER_MCASTTEN BIT(9)
--
2.35.3
next prev parent reply other threads:[~2025-07-21 13:12 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-21 11:14 [PATCH net-next 0/4] net: add WoL from PHY support for stm32mp135f-dk Gatien Chevallier
2025-07-21 11:14 ` [PATCH net-next 1/4] dt-bindings: net: document st,phy-wol property Gatien Chevallier
2025-07-21 11:30 ` Krzysztof Kozlowski
2025-07-21 12:10 ` Gatien CHEVALLIER
2025-07-21 12:16 ` Krzysztof Kozlowski
2025-07-21 12:54 ` Gatien CHEVALLIER
2025-07-21 13:18 ` Andrew Lunn
2025-07-21 15:56 ` Gatien CHEVALLIER
2025-07-21 17:07 ` Andrew Lunn
2025-07-21 18:08 ` Florian Fainelli
2025-07-22 9:08 ` Gatien CHEVALLIER
2025-07-22 13:40 ` Andrew Lunn
2025-07-22 20:20 ` Russell King (Oracle)
2025-07-22 20:30 ` Florian Fainelli
2025-07-22 20:59 ` Andrew Lunn
2025-07-22 21:39 ` Russell King (Oracle)
2025-07-22 22:00 ` Russell King (Oracle)
2025-07-22 22:57 ` Russell King (Oracle)
2025-07-23 14:02 ` Andrew Lunn
2025-07-23 14:23 ` Andrew Lunn
2025-07-23 18:13 ` Florian Fainelli
2025-07-23 8:50 ` Gatien CHEVALLIER
2025-07-23 8:53 ` Gatien CHEVALLIER
2025-07-23 9:25 ` Russell King (Oracle)
2025-07-23 9:20 ` Russell King (Oracle)
2025-07-23 14:35 ` Gatien CHEVALLIER
2025-07-22 9:13 ` Russell King (Oracle)
2025-07-22 7:32 ` Russell King (Oracle)
2025-07-22 9:10 ` Gatien CHEVALLIER
2025-07-21 11:14 ` [PATCH net-next 2/4] net: stmmac: stm32: add WoL from PHY support Gatien Chevallier
2025-07-21 11:14 ` Gatien Chevallier [this message]
2025-07-21 11:28 ` [PATCH net-next 3/4] net: phy: smsc: fix and improve WoL support Russell King (Oracle)
2025-07-21 12:23 ` Gatien CHEVALLIER
2025-07-21 13:26 ` Andrew Lunn
2025-07-21 14:19 ` Gatien CHEVALLIER
2025-07-21 14:23 ` Andrew Lunn
2025-07-21 11:14 ` [PATCH net-next 4/4] arm: dts: st: activate ETH1 WoL from PHY on stm32mp135f-dk Gatien Chevallier
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=20250721-wol-smsc-phy-v1-3-89d262812dba@foss.st.com \
--to=gatien.chevallier@foss.st.com \
--cc=Tristram.Ha@microchip.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=christophe.roullier@foss.st.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=florian.fainelli@broadcom.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).