net: phy: dp83822: Fix RGMII TX delay configuration
Subsystems (3)
PATCH v3 1/1 net: phy: dp83822: Fix RGMII TX delay configuration
The logic for enabling the TX clock shift is inverse of enabling the RX clock shift. The TX clock shift is disabled when DP83822_TX_CLK_SHIFT is set. Correct the current behavior and always write the delay configuration to ensure consistent delay settings regardless of bootloader configuration.
Reference: https://www.ti.com/lit/ds/symlink/dp83822i.pdf p. 69
---
Changes in v3:
- Revert changes involving DP83822_RGMII_MODE_EN
- Rebase on net-next
Changes in v2:
- Further cleanup of RGMII configuration
- Check for errors setting DP83822_RGMII_MODE_EN
--- drivers/net/phy/dp83822.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-)
drivers/net/phy/dp83822.c +20 -17
@@ -402,7 +402,7 @@ static int dp83822_config_init(struct phy_device *phydev) {struct dp83822_private *dp83822 = phydev->priv;struct device *dev = &phydev->mdio.dev; -int rgmii_delay; +int rgmii_delay =0 ;s32 rx_int_delay;s32 tx_int_delay;int err =0 ;
@@ -412,30 +412,33 @@ static int dp83822_config_init(struct phy_device *phydev) rx_int_delay =phy_get_internal_delay (phydev, dev,NULL ,0 , true); -if (rx_int_delay <=0 ) - rgmii_delay =0 ; -else - rgmii_delay =DP83822_RX_CLK_SHIFT ; +/* Set DP83822_RX_CLK_SHIFT to enable rx clk internal delay */ +if (rx_int_delay >0 ) + rgmii_delay |=DP83822_RX_CLK_SHIFT ; tx_int_delay =phy_get_internal_delay (phydev, dev,NULL ,0 , false); + +/* Set DP83822_TX_CLK_SHIFT to disable tx clk internal delay */ if (tx_int_delay <=0 ) - rgmii_delay &= ~DP83822_TX_CLK_SHIFT ; -else rgmii_delay |=DP83822_TX_CLK_SHIFT ; -if (rgmii_delay) { - err =phy_set_bits_mmd (phydev,DP83822_DEVADDR , -MII_DP83822_RCSR , rgmii_delay); -if (err) -return err; - } + err =phy_modify_mmd (phydev,DP83822_DEVADDR ,MII_DP83822_RCSR , +DP83822_RX_CLK_SHIFT |DP83822_TX_CLK_SHIFT , rgmii_delay); +if (err) +return err; + + err =phy_set_bits_mmd (phydev,DP83822_DEVADDR , +MII_DP83822_RCSR ,DP83822_RGMII_MODE_EN ); -phy_set_bits_mmd (phydev,DP83822_DEVADDR , -MII_DP83822_RCSR ,DP83822_RGMII_MODE_EN ); +if (err) +return err; }else { -phy_clear_bits_mmd (phydev,DP83822_DEVADDR , -MII_DP83822_RCSR ,DP83822_RGMII_MODE_EN ); + err =phy_clear_bits_mmd (phydev,DP83822_DEVADDR , +MII_DP83822_RCSR ,DP83822_RGMII_MODE_EN ); + +if (err) +return err; }if (dp83822->fx_enabled) {
Signature · 1 line
2.43.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 5 Mar 2024 12:06:08 +0100 you wrote:
The logic for enabling the TX clock shift is inverse of enabling the RX clock shift. The TX clock shift is disabled when
DP83822_TX_CLK_SHIFTis set. Correct the current behavior and always write the delay configuration to ensure consistent delay settings regardless of bootloader configuration.Reference: https://www.ti.com/lit/ds/symlink/dp83822i.pdf p. 69
[...]
Here is the summary with links:
- [net-next,v3] net: phy: dp83822: Fix RGMII TX delay configuration
https://git.kernel.org/netdev/net/c/c8a5c731fd12
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html