Skip to contentSkip to conversation

net: phy: micrel: additional clock handling

PATCH Applied Heiko Stuebner 4 participants 8 messages Dec 1, 2023 – Dec 4, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover net: phy: micrel: additional clock handling

Some Micrel phys define a specific rmii-ref clock (added in 2014) while the generic phy binding specifies an unnamed clock for ethernet phys.

This allows Micrel phys to use both, so as to keep the phys not using the named rmii-ref clock to conform to the generic binding while allowing them to enable a supplying clock, when the phy is not supplied by a dedicated oscillator.

Heiko Stuebner (2):
net: phy: micrel: use devm_clk_get_optional_enabled for the rmii-ref
clock
net: phy: micrel: allow usage of generic ethernet-phy clock

 drivers/net/phy/micrel.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/2 net: phy: micrel: use devm_clk_get_optional_enabled for the rmii-ref clock

From: Heiko Stuebner <[email protected]>

While the external clock input will most likely be enabled, it's not guaranteed and clk_get_rate in some suppliers will even just return valid results when the clock is running.

So use devm_clk_get_optional_enabled to retrieve and enable the clock in one go.

---
 drivers/net/phy/micrel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/micrel.c +1 -1
index 08e3915001c3..ec6a39dc9053 100644
@@ -2001,7 +2001,7 @@ static int kszphy_probe(struct phy_device *phydev)
 
 	kszphy_parse_led_mode(phydev);
 
-	clk = devm_clk_get(&phydev->mdio.dev, "rmii-ref");
+	clk = devm_clk_get_optional_enabled(&phydev->mdio.dev, "rmii-ref");
 	/* NOTE: clk may be NULL if building without CONFIG_HAVE_CLK */
 	if (!IS_ERR_OR_NULL(clk)) {
 		unsigned long rate = clk_get_rate(clk);
Signature · 1 line
2.39.2
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] net: phy: micrel: use devm_clk_get_optional_enabled for the rmii-ref clock

Quoted 10 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

While the external clock input will most likely be enabled, it's not guaranteed and clk_get_rate in some suppliers will even just return valid results when the clock is running.

So use devm_clk_get_optional_enabled to retrieve and enable the clock in one go.

Signature · 1 line
Florian
maintainer Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] net: phy: micrel: use devm_clk_get_optional_enabled for the rmii-ref clock

In reply to Heiko Stuebner
Quoted 10 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

While the external clock input will most likely be enabled, it's not guaranteed and clk_get_rate in some suppliers will even just return valid results when the clock is running.

So use devm_clk_get_optional_enabled to retrieve and enable the clock in one go.

Andrew

#4 lore raw

PATCH 2/2 net: phy: micrel: allow usage of generic ethernet-phy clock

In reply to Heiko Stuebner

From: Heiko Stuebner <[email protected]>

The generic ethernet-phy binding allows describing an external clock since commit 350b7a258f20 ("dt-bindings: net: phy: Document support for external PHY clk") for cases where the phy is not supplied by an oscillator but instead by a clock from the host system.

And the old named "rmii-ref" clock from 2014 is only specified for phys of the KSZ8021, KSZ8031, KSZ8081, KSZ8091 types.

So allow retrieving and enabling the optional generic clock on phys that do not provide a rmii-ref clock.

---
 drivers/net/phy/micrel.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/phy/micrel.c +5 -0
index ec6a39dc9053..9490849437c0 100644
@@ -2021,6 +2021,11 @@ static int kszphy_probe(struct phy_device *phydev)
 				   rate);
 			return -EINVAL;
 		}
+	} else if (!clk) {
+		/* unnamed clock from the generic ethernet-phy binding */
+		clk = devm_clk_get_optional_enabled(&phydev->mdio.dev, NULL);
+		if (IS_ERR(clk))
+			return PTR_ERR(clk);
 	}
 
 	if (ksz8041_fiber_mode(phydev))
Signature · 1 line
2.39.2
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] net: phy: micrel: allow usage of generic ethernet-phy clock

Quoted 7 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

The generic ethernet-phy binding allows describing an external clock since commit 350b7a258f20 ("dt-bindings: net: phy: Document support for external PHY clk") for cases where the phy is not supplied by an oscillator but instead by a clock from the host system.

Quoted 7 lines

And the old named "rmii-ref" clock from 2014 is only specified for phys of the KSZ8021, KSZ8031, KSZ8081, KSZ8091 types.

So allow retrieving and enabling the optional generic clock on phys that do not provide a rmii-ref clock.

Signature · 1 line
Florian
maintainer Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] net: phy: micrel: allow usage of generic ethernet-phy clock

In reply to Heiko Stuebner
Quoted 7 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

The generic ethernet-phy binding allows describing an external clock since commit 350b7a258f20 ("dt-bindings: net: phy: Document support for external PHY clk") for cases where the phy is not supplied by an oscillator but instead by a clock from the host system.

Quoted 7 lines

And the old named "rmii-ref" clock from 2014 is only specified for phys of the KSZ8021, KSZ8031, KSZ8081, KSZ8091 types.

So allow retrieving and enabling the optional generic clock on phys that do not provide a rmii-ref clock.

Andrew

#7 lore raw
In reply to Heiko Stuebner
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 9 lines · On Fri, 1 Dec 2023 16:01:29 +0100 you wrote:

Some Micrel phys define a specific rmii-ref clock (added in 2014) while the generic phy binding specifies an unnamed clock for ethernet phys.

This allows Micrel phys to use both, so as to keep the phys not using the named rmii-ref clock to conform to the generic binding while allowing them to enable a supplying clock, when the phy is not supplied by a dedicated oscillator.

[...]

Here is the summary with links:
- [1/2] net: phy: micrel: use devm_clk_get_optional_enabled for the rmii-ref clock

    https://git.kernel.org/netdev/net-next/c/985329462723
  - [2/2] net: phy: micrel: allow usage of generic ethernet-phy clock
    https://git.kernel.org/netdev/net-next/c/99ac4cbcc2a5

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html