diff mbox series

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

Message ID 20231201150131.326766-3-heiko@sntech.de (mailing list archive)
State Accepted
Commit 99ac4cbcc2a50ecc86ffacc7b4b42ba4259a90d4
Delegated to: Netdev Maintainers
Headers show
Series net: phy: micrel: additional clock handling | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1115 this patch: 1115
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1142 this patch: 1142
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1142 this patch: 1142
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Heiko Stübner Dec. 1, 2023, 3:01 p.m. UTC
From: Heiko Stuebner <heiko.stuebner@cherry.de>

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.

Signed-off-by: Heiko Stuebner <heiko.stuebner@cherry.de>
---
 drivers/net/phy/micrel.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Florian Fainelli Dec. 1, 2023, 5:03 p.m. UTC | #1
On 12/1/23 07:01, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner@cherry.de>
> 
> 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.
> 
> Signed-off-by: Heiko Stuebner <heiko.stuebner@cherry.de>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Andrew Lunn Dec. 1, 2023, 10:21 p.m. UTC | #2
On Fri, Dec 01, 2023 at 04:01:31PM +0100, Heiko Stuebner wrote:
> From: Heiko Stuebner <heiko.stuebner@cherry.de>
> 
> 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.
> 
> Signed-off-by: Heiko Stuebner <heiko.stuebner@cherry.de>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
diff mbox series

Patch

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index ec6a39dc9053..9490849437c0 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -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))