mirror-linux/drivers/net/phy
Wei Fang 25c6a5ab15 net: phy: micrel: Dynamically control external clock of KSZ PHY
On the i.MX6ULL-14x14-EVK board, enet1_ref and enet2_ref are used as the
clock sources for two external KSZ PHYs. However, after closing the two
FEC ports, the clk_enable_count of the enet1_ref and enet2_ref clocks is
not 0. The root cause is that since the commit 9853294627 ("net: phy:
micrel: use devm_clk_get_optional_enabled for the rmii-ref clock"), the
external clock of KSZ PHY has been enabled when the PHY driver probes,
and it can only be disabled when the PHY driver is removed. This causes
the clock to continue working when the system is suspended or the network
port is down.

Although Heiko explained in the commit message that the patch was because
some clock suppliers need to enable the clock to get the valid clock rate
, it seems that the simple fix is to disable the clock after getting the
clock rate to solve the current problem. This is indeed true, but we need
to admit that Heiko's patch has been applied for more than a year, and we
cannot guarantee whether there are platforms that only enable rmii-ref in
the KSZ PHY driver during this period. If this is the case, disabling
rmii-ref will cause RMII on these platforms to not work.

Secondly, commit 99ac4cbcc2 ("net: phy: micrel: allow usage of generic
ethernet-phy clock") just simply enables the generic clock permanently,
which seems like the generic clock may only be enabled in the PHY driver.
If we simply disable the generic clock, RMII may not work. If we keep it
as it is, the platform using the generic clock will have the same problem
as the i.MX6ULL platform.

To solve this problem, the clock is enabled when phy_driver::resume() is
called, and the clock is disabled when phy_driver::suspend() is called.
Since phy_driver::resume() and phy_driver::suspend() are not called in
pairs, an additional clk_enable flag is added. When phy_driver::suspend()
is called, the clock is disabled only if clk_enable is true. Conversely,
when phy_driver::resume() is called, the clock is enabled if clk_enable
is false.

The changes that introduced the problem were only a few lines, while the
current fix is about a hundred lines, which seems out of proportion, but
it is necessary because kszphy_probe() is used by multiple KSZ PHYs and
we need to fix all of them.

Fixes: 9853294627 ("net: phy: micrel: use devm_clk_get_optional_enabled for the rmii-ref clock")
Fixes: 99ac4cbcc2 ("net: phy: micrel: allow usage of generic ethernet-phy clock")
Signed-off-by: Wei Fang <wei.fang@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20241217063500.1424011-1-wei.fang@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-12-19 17:29:20 -08:00
..
aquantia net: phy: avoid undefined behavior in *_led_polarity_set() 2024-12-18 16:50:23 -08:00
mediatek net: phy: mediatek: add MT7530 & MT7531's PHY ID macros 2024-11-13 13:06:04 +00:00
mscc net: phy: use ethtool string helpers 2024-11-03 11:07:46 -08:00
qcom net: phy: use ethtool string helpers 2024-11-03 11:07:46 -08:00
Kconfig net: phy: mediatek: Re-organize MediaTek ethernet phy drivers 2024-11-13 13:06:04 +00:00
Makefile net: phy: mediatek: Re-organize MediaTek ethernet phy drivers 2024-11-13 13:06:04 +00:00
adin.c net: phy: use ethtool string helpers 2024-11-03 11:07:46 -08:00
adin1100.c
air_en8811h.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
amd.c
ax88796b.c
ax88796b_rust.rs rust: net::phy unified read/write API for C22 and C45 registers 2024-08-30 10:27:35 +01:00
bcm-cygnus.c
bcm-phy-lib.c net: phy: broadcom: use genphy_c45_an_config_eee_aneg in bcm_config_lre_aneg 2024-11-07 20:31:06 -08:00
bcm-phy-lib.h net: phy: bcm-phy-lib: Implement BroadR-Reach link modes 2024-07-14 20:38:35 -07:00
bcm-phy-ptp.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
bcm7xxx.c
bcm63xx.c
bcm87xx.c
bcm54140.c
bcm84881.c net: phy: bcm84881: Fix some error handling paths 2024-10-04 16:19:00 -07:00
broadcom.c net: phy: bcm-phy-lib: Implement BroadR-Reach link modes 2024-07-14 20:38:35 -07:00
cicada.c
cortina.c
davicom.c
dp83tc811.c
dp83td510.c phy: dp83td510: Utilize ALCD for cable length measurement when link is active 2024-08-26 09:33:58 -07:00
dp83tg720.c net: phy: dp83tg720: Add cable testing support 2024-08-16 10:16:26 -07:00
dp83640.c net: Add struct kernel_ethtool_ts_info 2024-07-15 08:02:26 -07:00
dp83640_reg.h
dp83822.c net: phy: dp83822: Configure RMII mode on DP83825 devices 2024-10-31 15:42:58 +01:00
dp83848.c net: phy: ti: add PHY_RST_AFTER_CLK_EN flag 2024-11-05 17:46:03 -08:00
dp83867.c
dp83869.c net: phy: dp83869: fix status reporting for 1000base-x autonegotiation 2024-11-14 19:11:03 -08:00
et1011c.c
fixed_phy.c
icplus.c net: phy: use ethtool string helpers 2024-11-03 11:07:46 -08:00
intel-xway.c net: phy: avoid undefined behavior in *_led_polarity_set() 2024-12-18 16:50:23 -08:00
linkmode.c
lxt.c
marvell-88q2xxx.c net: phy: marvell-88q2xxx: Enable auto negotiation for mv88q2110 2024-10-08 18:18:16 -07:00
marvell-88x2222.c net: phy: add helpers to handle sfp phy connect/disconnect 2024-08-23 13:04:34 +01:00
marvell.c net: phy: use ethtool string helpers 2024-11-03 11:07:46 -08:00
marvell10g.c net: phy: add helpers to handle sfp phy connect/disconnect 2024-08-23 13:04:34 +01:00
mdio-boardinfo.c
mdio-boardinfo.h
mdio-open-alliance.h
mdio_bus.c driver core: have match() callback in struct bus_type take a const * 2024-07-03 15:16:54 +02:00
mdio_device.c driver core: have match() callback in struct bus_type take a const * 2024-07-03 15:16:54 +02:00
mdio_devres.c
meson-gxl.c
micrel.c net: phy: micrel: Dynamically control external clock of KSZ PHY 2024-12-19 17:29:20 -08:00
microchip.c net: phy: microchip: Reset LAN88xx PHY to ensure clean link state on LAN7800/7850 2024-12-02 18:56:41 -08:00
microchip_t1.c net: phy: microchip_t1: Clause-45 PHY loopback support for LAN887x 2024-11-15 15:22:10 -08:00
microchip_t1s.c net: phy: microchip_t1s: configure collision detection based on PLCA mode 2024-10-11 15:54:40 -07:00
mii_timestamper.c
motorcomm.c net: phy: Add driver for Motorcomm yt8821 2.5G ethernet phy 2024-09-05 15:21:12 +02:00
mxl-gpy.c net: phy: avoid undefined behavior in *_led_polarity_set() 2024-12-18 16:50:23 -08:00
national.c
ncn26000.c
nxp-c45-tja11xx-macsec.c
nxp-c45-tja11xx.c net: phy: use ethtool string helpers 2024-11-03 11:07:46 -08:00
nxp-c45-tja11xx.h net: phy: c45-tja11xx: add support for outputting RMII reference clock 2024-10-15 10:44:52 +02:00
nxp-cbtx.c net: phy: use ethtool string helpers 2024-11-03 11:07:46 -08:00
nxp-tja11xx.c
open_alliance_helpers.c phy: Add Open Alliance helpers for the PHY framework 2024-08-16 10:16:26 -07:00
open_alliance_helpers.h phy: Add Open Alliance helpers for the PHY framework 2024-08-16 10:16:26 -07:00
phy-c45.c net: phy: fix phy_ethtool_set_eee() incorrectly enabling LPI 2024-11-28 09:26:13 +01:00
phy-core.c net: phy: convert eee_broken_modes to a linkmode bitmap 2024-11-14 18:01:37 -08:00
phy.c net: phy: fix phy_ethtool_set_eee() incorrectly enabling LPI 2024-11-28 09:26:13 +01:00
phy_device.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-11-19 13:56:02 +01:00
phy_led_triggers.c
phy_link_topology.c net: phy: Introduce ethernet link topology representation 2024-08-23 13:04:34 +01:00
phylink.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-11-14 11:29:15 -08:00
qsemi.c
qt2025.rs net: phy: qt2025: Fix warning: unused import DeviceId 2024-10-02 17:44:00 -07:00
realtek.c net: phy: realtek: add RTL8125D-internal PHY 2024-10-20 11:06:47 -05:00
rockchip.c
sfp-bus.c net: sfp: Add helper to return the SFP bus name 2024-08-23 13:04:34 +01:00
sfp.c net: sfp: change quirks for Alcatel Lucent G-010S-P 2024-10-21 10:33:22 +02:00
sfp.h
smsc.c net: phy: smsc: use devm_clk_get_optional_enabled_with_rate() 2024-10-08 15:36:28 -07:00
spi_ks8995.c
ste10Xp.c
stubs.c
swphy.c
swphy.h
teranetics.c
uPD60620.c
vitesse.c net: phy: vitesse: implement MDI-X configuration in vsc73xx 2024-08-27 14:26:49 -07:00
xilinx_gmii2rgmii.c