2023-06-05 15:47:49

by Detlev Casanova

[permalink] [raw]
Subject: [PATCH v4 0/3] net: phy: realtek: Support external PHY clock

Some PHYs can use an external clock that must be enabled before
communicating with them.

Changes since v3:
* Do not call genphy_suspend if WoL is enabled.
Changes since v2:
* Reword documentation commit message
Changes since v1:
* Remove the clock name as it is not guaranteed to be identical across
different PHYs
* Disable/Enable the clock when suspending/resuming




2023-06-05 15:49:54

by Detlev Casanova

[permalink] [raw]
Subject: [PATCH v4 3/3] net: phy: realtek: Disable clock on suspend

For PHYs that call rtl821x_probe() where an external clock can be
configured, make sure that the clock is disabled
when ->suspend() is called and enabled on resume.

The PHY_ALWAYS_CALL_SUSPEND is added to ensure that the suspend function
is actually always called.

Reviewed-by: Florian Fainelli <[email protected]>
Signed-off-by: Detlev Casanova <[email protected]>
---
drivers/net/phy/realtek.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index b13dd0b3c99e..894172a3e15f 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -426,10 +426,31 @@ static int rtl8211f_config_init(struct phy_device *phydev)
return genphy_soft_reset(phydev);
}

+static int rtl821x_suspend(struct phy_device *phydev)
+{
+ struct rtl821x_priv *priv = phydev->priv;
+ int ret = 0;
+
+ if (!phydev->wol_enabled) {
+ ret = genphy_suspend(phydev);
+
+ if (ret)
+ return ret;
+
+ clk_disable_unprepare(priv->clk);
+ }
+
+ return ret;
+}
+
static int rtl821x_resume(struct phy_device *phydev)
{
+ struct rtl821x_priv *priv = phydev->priv;
int ret;

+ if (!phydev->wol_enabled)
+ clk_prepare_enable(priv->clk);
+
ret = genphy_resume(phydev);
if (ret < 0)
return ret;
@@ -934,10 +955,11 @@ static struct phy_driver realtek_drvs[] = {
.read_status = rtlgen_read_status,
.config_intr = &rtl8211f_config_intr,
.handle_interrupt = rtl8211f_handle_interrupt,
- .suspend = genphy_suspend,
+ .suspend = rtl821x_suspend,
.resume = rtl821x_resume,
.read_page = rtl821x_read_page,
.write_page = rtl821x_write_page,
+ .flags = PHY_ALWAYS_CALL_SUSPEND,
}, {
PHY_ID_MATCH_EXACT(RTL_8211FVD_PHYID),
.name = "RTL8211F-VD Gigabit Ethernet",
@@ -946,10 +968,11 @@ static struct phy_driver realtek_drvs[] = {
.read_status = rtlgen_read_status,
.config_intr = &rtl8211f_config_intr,
.handle_interrupt = rtl8211f_handle_interrupt,
- .suspend = genphy_suspend,
+ .suspend = rtl821x_suspend,
.resume = rtl821x_resume,
.read_page = rtl821x_read_page,
.write_page = rtl821x_write_page,
+ .flags = PHY_ALWAYS_CALL_SUSPEND,
}, {
.name = "Generic FE-GE Realtek PHY",
.match_phy_device = rtlgen_match_phy_device,
--
2.39.3


2023-06-05 21:03:18

by Heiner Kallweit

[permalink] [raw]
Subject: Re: [PATCH v4 0/3] net: phy: realtek: Support external PHY clock

On 05.06.2023 17:40, Detlev Casanova wrote:
> Some PHYs can use an external clock that must be enabled before
> communicating with them.
>
> Changes since v3:
> * Do not call genphy_suspend if WoL is enabled.
> Changes since v2:
> * Reword documentation commit message
> Changes since v1:
> * Remove the clock name as it is not guaranteed to be identical across
> different PHYs
> * Disable/Enable the clock when suspending/resuming
>
>
Not a big thing, but if a v5 should be needed:
Please annotate the series properly as net-next (see netdev FAQ).


2023-06-07 09:18:35

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH v4 0/3] net: phy: realtek: Support external PHY clock

Hello:

This series was applied to netdev/net-next.git (main)
by David S. Miller <[email protected]>:

On Mon, 5 Jun 2023 11:40:07 -0400 you wrote:
> Some PHYs can use an external clock that must be enabled before
> communicating with them.
>
> Changes since v3:
> * Do not call genphy_suspend if WoL is enabled.
> Changes since v2:
> * Reword documentation commit message
> Changes since v1:
> * Remove the clock name as it is not guaranteed to be identical across
> different PHYs
> * Disable/Enable the clock when suspending/resuming

Here is the summary with links:
- [v4,1/3] net: phy: realtek: Add optional external PHY clock
https://git.kernel.org/netdev/net-next/c/7300c9b574cc
- [v4,2/3] dt-bindings: net: phy: Document support for external PHY clk
https://git.kernel.org/netdev/net-next/c/350b7a258f20
- [v4,3/3] net: phy: realtek: Disable clock on suspend
https://git.kernel.org/netdev/net-next/c/59e227e2894b

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html