net: gem: Fix setting PCS auto-negotiation state
Subsystems (2)
PATCH 1/1 net: gem: Fix setting PCS auto-negotiation state
The code was trying to disable PCS auto-negotiation when a fixed-link node is present and enable it otherwise. However, the PCS registers were being written before the PCSSEL bit was set in the network configuration register, and it appears that in this state, PCS register writes are ignored. The result is that the intended change only took effect on the second network operation that was performed, since at that time PCSSEL is already enabled.
Fix the order of register writes so that PCS registers are only written to after the PCS is enabled.
--- drivers/net/zynq_gem.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/net/zynq_gem.c +17 -8
@@ -454,14 +454,6 @@ static int zynq_gem_init(struct udevice *dev) priv->int_pcs) { nwconfig |=ZYNQ_GEM_NWCFG_SGMII_ENBL |ZYNQ_GEM_NWCFG_PCS_SEL ; -#ifdef CONFIG_ARM64 -if (priv->phydev->phy_id !=PHY_FIXED_ID ) -writel (readl (®s->pcscntrl) |ZYNQ_GEM_PCS_CTL_ANEG_ENBL , - ®s->pcscntrl); -else -writel (readl (®s->pcscntrl) & ~ZYNQ_GEM_PCS_CTL_ANEG_ENBL , - ®s->pcscntrl); -#endif }switch (priv->phydev->speed) {
@@ -480,6 +472,23 @@ static int zynq_gem_init(struct udevice *dev)break ; } +#ifdef CONFIG_ARM64 +if (priv->interface ==PHY_INTERFACE_MODE_SGMII && + priv->int_pcs) { +/* +* Disable AN for fixed link configuration, enable otherwise. +* Must be written after PCS_SEL is set in nwconfig, +* otherwise writes will not take effect. +*/ +if (priv->phydev->phy_id !=PHY_FIXED_ID ) +writel (readl (®s->pcscntrl) |ZYNQ_GEM_PCS_CTL_ANEG_ENBL , + ®s->pcscntrl); +else +writel (readl (®s->pcscntrl) & ~ZYNQ_GEM_PCS_CTL_ANEG_ENBL , + ®s->pcscntrl); + } +#endif + ret =clk_set_rate (&priv->tx_clk, clk_rate);if (IS_ERR_VALUE (ret)) {dev_err (dev,"failed to set tx clock rate\n" );
Signature · 1 line
2.27.0
PATCH 1/1 net: gem: Fix setting PCS auto-negotiation state
Quoted 63 lines · Robert Hancock
The code was trying to disable PCS auto-negotiation when a fixed-link node is present and enable it otherwise. However, the PCS registers were being written before the PCSSEL bit was set in the network configuration register, and it appears that in this state, PCS register writes are ignored. The result is that the intended change only took effect on the second network operation that was performed, since at that time PCSSEL is already enabled.
Fix the order of register writes so that PCS registers are only written to after the PCS is enabled.
Fixes 26e62cc971 ("net: gem: Disable PCS autonegotiation in case of fixed-link")Signed-off-by Robert Hancock <[email protected]>--- drivers/net/zynq_gem.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)drivers/net/zynq_gem.c +17
-9@@ -454,14 +454,6 @@ static int zynq_gem_init(struct udevice *dev) priv->int_pcs) { nwconfig |=ZYNQ_GEM_NWCFG_SGMII_ENBL |ZYNQ_GEM_NWCFG_PCS_SEL ; -#ifdef CONFIG_ARM64 -if (priv->phydev->phy_id !=PHY_FIXED_ID ) -writel (readl (®s->pcscntrl) |ZYNQ_GEM_PCS_CTL_ANEG_ENBL , - ®s->pcscntrl); -else -writel (readl (®s->pcscntrl) & ~ZYNQ_GEM_PCS_CTL_ANEG_ENBL , - ®s->pcscntrl); -#endif }switch (priv->phydev->speed) {@@ -480,6 +472,23 @@ static int zynq_gem_init(struct udevice *dev)break ; } +#ifdef CONFIG_ARM64 +if (priv->interface ==PHY_INTERFACE_MODE_SGMII && + priv->int_pcs) { +/* +* Disable AN for fixed link configuration, enable otherwise. +* Must be written after PCS_SEL is set in nwconfig, +* otherwise writes will not take effect. +*/ +if (priv->phydev->phy_id !=PHY_FIXED_ID ) +writel (readl (®s->pcscntrl) |ZYNQ_GEM_PCS_CTL_ANEG_ENBL , + ®s->pcscntrl); +else +writel (readl (®s->pcscntrl) & ~ZYNQ_GEM_PCS_CTL_ANEG_ENBL , + ®s->pcscntrl); + } +#endif + ret =clk_set_rate (&priv->tx_clk, clk_rate);if (IS_ERR_VALUE (ret)) {dev_err (dev,"failed to set tx clock rate\n" ); --
Quoted 2 lines
2.27.0
PATCH 1/1 net: gem: Fix setting PCS auto-negotiation statee
In reply to Robert HancockQuoted 52 lines · Robert Hancock
The code was trying to disable PCS auto-negotiation when a fixed-link node is present and enable it otherwise. However, the PCS registers were being written before the PCSSEL bit was set in the network configuration register, and it appears that in this state, PCS register writes are ignored. The result is that the intended change only took effect on the second network operation that was performed, since at that time PCSSEL is already enabled.
Fix the order of register writes so that PCS registers are only written to after the PCS is enabled.
Fixes 26e62cc971 ("net: gem: Disable PCS autonegotiation in case of fixed-link")Signed-off-by Robert Hancock <[email protected]>--- drivers/net/zynq_gem.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)drivers/net/zynq_gem.c +10
-8@@ -454,14 +454,6 @@ static int zynq_gem_init(struct udevice *dev) priv->int_pcs) { nwconfig |=ZYNQ_GEM_NWCFG_SGMII_ENBL |ZYNQ_GEM_NWCFG_PCS_SEL ; -#ifdef CONFIG_ARM64 -if (priv->phydev->phy_id !=PHY_FIXED_ID ) -writel (readl (®s->pcscntrl) |ZYNQ_GEM_PCS_CTL_ANEG_ENBL , - ®s->pcscntrl); -else -writel (readl (®s->pcscntrl) & ~ZYNQ_GEM_PCS_CTL_ANEG_ENBL , - ®s->pcscntrl); -#endif }switch (priv->phydev->speed) {@@ -480,6 +472,23 @@ static int zynq_gem_init(struct udevice *dev)break ; } +#ifdef CONFIG_ARM64 +if (priv->interface ==PHY_INTERFACE_MODE_SGMII && + priv->int_pcs) { +/* +* Disable AN for fixed link configuration, enable otherwise. +* Must be written after PCS_SEL is set in nwconfig, +* otherwise writes will not take effect. +*/ +if (priv->phydev->phy_id !=PHY_FIXED_ID ) + writel(readl(®s->pcscntrl) | ZYNQ_GEM_PCS_CTL_ANEG_ENBL,
drivers/net/zynq_gem.c static int zynq_gem_init(struct udevice *dev) · line 494
Quoted 10 lines
drivers/net/zynq_gem.c +7
-0+ ®s->pcscntrl); + else + writel(readl(®s->pcscntrl) & ~ZYNQ_GEM_PCS_CTL_ANEG_ENBL, + ®s->pcscntrl); + } +#endif + ret =clk_set_rate (&priv->tx_clk, clk_rate);if (IS_ERR_VALUE (ret)) {dev_err (dev,"failed to set tx clock rate\n" );
Karthik/Ashok: Please retest it and reply.
Thanks,
Michal
PATCH 1/1 net: gem: Fix setting PCS auto-negotiation statee
Quoted 71 lines
-----Original Message-----
From: Michal Simek <[email protected]>
Sent: Monday, March 15, 2021 2:38 PM
To: Robert Hancock <[email protected]>; Michal Simek <[email protected]>; T Karthik Reddy <[email protected]>; Ashok Reddy Soma <[email protected]>
Cc: joe.hershberger at ni.com; rfried.dev at gmail.com; u-boot at lists.denx.de
Subject: Re: [PATCH] net: gem: Fix setting PCS auto-negotiation stateeQuoted 24 lines · Robert Hancock
The code was trying to disable PCS auto-negotiation when a fixed-link node is present and enable it otherwise. However, the PCS registers were being written before the PCSSEL bit was set in the network configuration register, and it appears that in this state, PCS register writes are ignored. The result is that the intended change only took effect on the second network operation that was performed, since at that time PCSSEL is already enabled.
Fix the order of register writes so that PCS registers are only written to after the PCS is enabled.
Fixes 26e62cc971 ("net: gem: Disable PCS autonegotiation in case offixed-link")
Signed-off-by Robert Hancock <[email protected]>--- drivers/net/zynq_gem.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)drivers/net/zynq_gem.c index renamed from drivers/net/zynq_gem.c +0
-0
baf06a2ad8..ff59982267100644drivers/net/zynq_gem.c static int zynq_gem_init(struct udevice *dev) · line 459
Quoted 6 lines
drivers/net/zynq_gem.c +0
-3@@ -454,14 +454,6 @@ static int zynq_gem_init(struct udevice *dev) priv->int_pcs) { nwconfig |=ZYNQ_GEM_NWCFG_SGMII_ENBL |ZYNQ_GEM_NWCFG_PCS_SEL ; -#ifdef CONFIG_ARM64 -if (priv->phydev->phy_id !=PHY_FIXED_ID ) - writel(readl(®s->pcscntrl) |
ZYNQ_GEM_PCS_CTL_ANEG_ENBL,drivers/net/zynq_gem.c static int zynq_gem_init(struct udevice *dev)
Quoted 3 lines
drivers/net/zynq_gem.c +0
-3- ®s->pcscntrl); - else - writel(readl(®s->pcscntrl) &~ZYNQ_GEM_PCS_CTL_ANEG_ENBL,
Quoted 9 lines
drivers/net/zynq_gem.c +0
-2- ®s->pcscntrl); -#endif }switch (priv->phydev->speed) {@@ -480,6 +472,23 @@ static int zynq_gem_init(struct udevice *dev)break ; }drivers/net/zynq_gem.c static int zynq_gem_init(struct udevice *dev) · line 484
Quoted 10 lines
drivers/net/zynq_gem.c +10
-0+#ifdef CONFIG_ARM64 +if (priv->interface ==PHY_INTERFACE_MODE_SGMII && + priv->int_pcs) { +/* +* Disable AN for fixed link configuration, enable otherwise. +* Must be written after PCS_SEL is set in nwconfig, +* otherwise writes will not take effect. +*/ +if (priv->phydev->phy_id !=PHY_FIXED_ID ) + writel(readl(®s->pcscntrl) |
ZYNQ_GEM_PCS_CTL_ANEG_ENBL,drivers/net/zynq_gem.c static int zynq_gem_init(struct udevice *dev)
Quoted 3 lines
drivers/net/zynq_gem.c +3
-0+ ®s->pcscntrl); + else + writel(readl(®s->pcscntrl) &~ZYNQ_GEM_PCS_CTL_ANEG_ENBL,
Quoted 10 lines
drivers/net/zynq_gem.c static int zynq_gem_init(struct udevice *dev) · line 494
Quoted 8 lines
drivers/net/zynq_gem.c +4
-0+ ®s->pcscntrl); + } +#endif + ret =clk_set_rate (&priv->tx_clk, clk_rate);if (IS_ERR_VALUE (ret)) {dev_err (dev,"failed to set tx clock rate\n" );Karthik/Ashok: Please retest it and reply.
Looks good.
Quoted 3 lines
Thanks,
Michal
Michal Simek
AppliedPATCH 1/1 net: gem: Fix setting PCS auto-negotiation state
In reply to Robert HancockQuoted 52 lines · Robert Hancock
The code was trying to disable PCS auto-negotiation when a fixed-link node is present and enable it otherwise. However, the PCS registers were being written before the PCSSEL bit was set in the network configuration register, and it appears that in this state, PCS register writes are ignored. The result is that the intended change only took effect on the second network operation that was performed, since at that time PCSSEL is already enabled.
Fix the order of register writes so that PCS registers are only written to after the PCS is enabled.
Fixes 26e62cc971 ("net: gem: Disable PCS autonegotiation in case of fixed-link")Signed-off-by Robert Hancock <[email protected]>--- drivers/net/zynq_gem.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)drivers/net/zynq_gem.c +10
-8@@ -454,14 +454,6 @@ static int zynq_gem_init(struct udevice *dev) priv->int_pcs) { nwconfig |=ZYNQ_GEM_NWCFG_SGMII_ENBL |ZYNQ_GEM_NWCFG_PCS_SEL ; -#ifdef CONFIG_ARM64 -if (priv->phydev->phy_id !=PHY_FIXED_ID ) -writel (readl (®s->pcscntrl) |ZYNQ_GEM_PCS_CTL_ANEG_ENBL , - ®s->pcscntrl); -else -writel (readl (®s->pcscntrl) & ~ZYNQ_GEM_PCS_CTL_ANEG_ENBL , - ®s->pcscntrl); -#endif }switch (priv->phydev->speed) {@@ -480,6 +472,23 @@ static int zynq_gem_init(struct udevice *dev)break ; } +#ifdef CONFIG_ARM64 +if (priv->interface ==PHY_INTERFACE_MODE_SGMII && + priv->int_pcs) { +/* +* Disable AN for fixed link configuration, enable otherwise. +* Must be written after PCS_SEL is set in nwconfig, +* otherwise writes will not take effect. +*/ +if (priv->phydev->phy_id !=PHY_FIXED_ID ) + writel(readl(®s->pcscntrl) | ZYNQ_GEM_PCS_CTL_ANEG_ENBL,
drivers/net/zynq_gem.c static int zynq_gem_init(struct udevice *dev) · line 494
Quoted 10 lines
drivers/net/zynq_gem.c +7
-0+ ®s->pcscntrl); + else + writel(readl(®s->pcscntrl) & ~ZYNQ_GEM_PCS_CTL_ANEG_ENBL, + ®s->pcscntrl); + } +#endif + ret =clk_set_rate (&priv->tx_clk, clk_rate);if (IS_ERR_VALUE (ret)) {dev_err (dev,"failed to set tx clock rate\n" );
Applied.
M