net: phy: micrel_ksz90x1: workarounds for ksz9031 ERRATA
Subsystems (2)
cover net: phy: micrel_ksz90x1: workarounds for ksz9031 ERRATA
Hi all,
this series contains workarounds for ksz9031 ERRATA from the Silicon Errata Sheet (DS80000691D or DS80000692D).
Tested with TQMa6 on MBa6 Baseboard.
Best regards,
Max
Markus Niebel (2):
net: phy: micrel_ksz90x1: disable asymmetric pause for KSZ9031
net: phy: micrel_ksz90x1: support forced GIGE master for KSZ9031
drivers/net/phy/micrel_ksz90x1.c | 55 ++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 net: phy: micrel_ksz90x1: disable asymmetric pause for KSZ9031
From: Markus Niebel <[email protected]>
Disable the support due to chip errata and call genphy_config_aneg instead of genphy_config. For a complete describtion look at the errata sheets: DS80000691D or DS80000692D.
--- drivers/net/phy/micrel_ksz90x1.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/net/phy/micrel_ksz90x1.c +17 -1
@@ -336,6 +336,7 @@ static int ksz9031_phy_extwrite(struct phy_device *phydev, int addr,static int ksz9031_config (struct phy_device *phydev) { +unsigned int features = phydev->drv->features;int ret; ret =ksz9031_of_config (phydev);
@@ -371,7 +372,22 @@ static int ksz9031_config(struct phy_device *phydev)return 0 ; } -return genphy_config (phydev); +/* Silicon Errata Sheet (DS80000691D or DS80000692D): +* Whenever the device's Asymmetric Pause capability is set to 1, +* link-up may fail after a link-up to link-down transition. +* +* Workaround: +* Do not enable the Asymmetric Pause capability bit. +*/ + features &= ~ADVERTISE_PAUSE_ASYM ; +/* update feature support and forward to advertised features */ + phydev->supported = features; + phydev->advertising = phydev->supported; + +/* genphy_restart_aneg called from genphy_config_aneg */ +return genphy_config_aneg (phydev); + +return 0 ; }U_BOOT_PHY_DRIVER (ksz9031) = {
Signature · 1 line
2.43.0
Re: [PATCH 1/2] net: phy: micrel_ksz90x1: disable asymmetric pause for KSZ9031
Hi Max, Markus,
Quoted 6 lines · Max Merchel
From: Markus Niebel <[email protected]>
Disable the support due to chip errata and call
genphy_config_aneginstead ofgenphy_config. For a complete describtion look at the errata sheets: DS80000691D or DS80000692D.
Linux counterpart seems to be 3aed3e2a143c ("net: phy: micrel: add Asym Pause workaround"). It does seem to set an additional bit (ADVERTISE_PAUSE_CAP in U-Boot) but the explanation doesn't seem to apply to U-Boot.
Though another interesting commit is in the Linux tree as well, 407d8098cb1a ("net: phy: micrel: add Asym Pause workaround for KSZ9021"). I assume we need a similar fix in ksz9021_config()?
Quoted 11 lines
Signed-off-by Markus Niebel <[email protected]>Signed-off-by Max Merchel <[email protected]>--- drivers/net/phy/micrel_ksz90x1.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)drivers/net/phy/micrel_ksz90x1.c +0
-0
drivers/net/phy/micrel_ksz90x1.c static int ksz9031_phy_extwrite(struct phy_device *phydev, int addr, · line 339
Quoted 4 lines
drivers/net/phy/micrel_ksz90x1.c +1
-0@@ -336,6 +336,7 @@ static int ksz9031_phy_extwrite(struct phy_device *phydev, int addr,static int ksz9031_config (struct phy_device *phydev) { +unsigned int features = phydev->drv->features;
It's a u32 member, so we can simply use a u32 for the local variable.
This will be overshadowed by unsigned features in the if block, just remove the overshadowing variable and features = phydev->drv->features; in the if block since you'll already have set it.
Quoted 14 lines
drivers/net/phy/micrel_ksz90x1.c +6
-1int ret; ret =ksz9031_of_config (phydev);@@ -371,7 +372,22 @@ static int ksz9031_config(struct phy_device *phydev)return 0 ; } -return genphy_config (phydev); +/* Silicon Errata Sheet (DS80000691D or DS80000692D): +* Whenever the device's Asymmetric Pause capability is set to 1, +* link-up may fail after a link-up to link-down transition. +* +* Workaround: +* Do not enable the Asymmetric Pause capability bit.
drivers/net/phy/micrel_ksz90x1.c static int ksz9031_config(struct phy_device *phydev) · line 390
Quoted 10 lines
drivers/net/phy/micrel_ksz90x1.c +10
-0+*/ + features &= ~ADVERTISE_PAUSE_ASYM ; +/* update feature support and forward to advertised features */ + phydev->supported = features; + phydev->advertising = phydev->supported; + +/* genphy_restart_aneg called from genphy_config_aneg */ +return genphy_config_aneg (phydev); + +return 0 ;
Don't need the return 0 here as it won't be reached.
Is this errata only applicable if 1000BASE-T is supported? I couldn't find that in the doc but maybe I misread. In which case, we need the exact same logic in the if (env_get("disable_giga")) section I think?
Cheers,
Quentin
Re: [PATCH 1/2] net: phy: micrel_ksz90x1: disable asymmetric pause for KSZ9031
Am 24.11.25 um 17:31 schrieb Quentin Schulz:
Quoted 11 lines
Hi Max, Markus,
Quoted 6 lines · Max Merchel
From: Markus Niebel <[email protected]>
Disable the support due to chip errata and call
genphy_config_aneginstead ofgenphy_config. For a complete describtion look at the errata sheets: DS80000691D or DS80000692D.Linux counterpart seems to be
3aed3e2a143c("net: phy: micrel: add Asym Pause workaround"). It does seem to set an additional bit (ADVERTISE_PAUSE_CAPin U-Boot) but the explanation doesn't seem to apply to U-Boot.
I checked ADVERTISE_PAUSE_CAP in the code and ran tests on TQMa6-MBa6. Setting ADVERTISE_PAUSE_CAP isn't necessary for the workaround.
Quoted 2 lines
Though another interesting commit is in the Linux tree as well,
407d8098cb1a("net: phy: micrel: add Asym Pause workaround for KSZ9021"). I assume we need a similar fix inksz9021_config()?
I will integrate the workaround for KSZ9021 into the commit in V2 and add references to both Linux commits.
Quoted 6 lines
Quoted 6 lines
Signed-off-by Markus Niebel <[email protected]>Signed-off-by Max Merchel <[email protected]>---
drivers/net/phy/micrel_ksz90x1.c| 18 +++++++++++++++++-1 file changed, 17 insertions(+), 1 deletion(-)
Quoted 11 lines
drivers/net/phy/micrel_ksz90x1.c static int ksz9031_phy_extwrite(struct phy_device · line 339
Quoted 9 lines
drivers/net/phy/micrel_ksz90x1.c +1
-0@@ -336,6 +336,7 @@ static int ksz9031_phy_extwrite(struct phy_device *phydev, int addr, static int ksz9031_config(struct phy_device *phydev) { + unsigned int features = phydev->drv->features;It's a u32 member, so we can simply use a u32 for the local variable.
I've changed it in V2.
Quoted 19 lines
This will be overshadowed by unsigned features in the if block, just remove the overshadowing variable and features =
phydev->drv->features; in the if block since you'll already have set it.Quoted 16 lines
drivers/net/phy/micrel_ksz90x1.c +10
-1int ret; ret = ksz9031_of_config(phydev);@@ -371,7 +372,22 @@ static int ksz9031_config(struct phy_device *phydev) return 0; } - return genphy_config(phydev); + /* Silicon Errata Sheet (DS80000691D or DS80000692D): + * Whenever the device's Asymmetric Pause capability is set to 1, + * link-up may fail after a link-up to link-down transition. + * + * Workaround: + * Do not enable the Asymmetric Pause capability bit. + */ + features &= ~ADVERTISE_PAUSE_ASYM; + /* update feature support and forward to advertised features */ + phydev->supported = features;
Quoted 8 lines
drivers/net/phy/micrel_ksz90x1.c static int ksz9031_config(struct phy_device *phydev) · line 390
Quoted 6 lines
drivers/net/phy/micrel_ksz90x1.c +6
-0+ phydev->advertising = phydev->supported; + + /* genphy_restart_aneg called from genphy_config_aneg */ + return genphy_config_aneg(phydev); + + return 0;Don't need the return 0 here as it won't be reached.
I remove it.>
Quoted 1 line
Is this errata only applicable if 1000BASE-T is supported? I couldn't find that in the doc but maybe I misread. In which case, we need the exact same logic in the if (
env_get("disable_giga")) section I think?
I checked. It doesn't only apply to 1000BASE-T.
To use the workaround for KSZ9021 as well, it's implemented as a function and called before if (env_get("disable_giga")) for KSZ9031.
Quoted 3 lines
Cheers,
Quentin
I send V2
Signature · 7 lines
Best regards, Max TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany Amtsgericht München, HRB 105018 Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider http://www.tq-group.com/
PATCH 2/2 net: phy: micrel_ksz90x1: support forced GIGE master for KSZ9031
In reply to Max MerchelFrom: Markus Niebel <[email protected]>
The micrel KSZ9031 phy has a optional clock pin (CLK125_NDO) which can be used as reference clock for the MAC unit. The clock signal must meet the RGMII requirements to ensure the correct data transmission between the MAC and the PHY. The KSZ9031 phy does not fulfill the duty cycle requirement if the phy is configured as slave. For a complete describtion look at the errata sheets: DS80000691D or DS80000692D.
The errata sheet recommends to force the phy into master mode whenever there is a 1000Base-T link-up as work around. Only set the "micrel,force-master" property if you use the phy reference clock provided by CLK125_NDO pin as MAC reference clock in your application.
Attention: this workaround is only usable if the link partner can be configured to slave mode for 1000Base-T.
This follows linux implementation in commite1b505a60366 ("net: phy: micrel: add 125MHz reference clock workaround")
--- drivers/net/phy/micrel_ksz90x1.c | 37 +++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
drivers/net/phy/micrel_ksz90x1.c +36 -1
@@ -189,6 +189,9 @@ static int ksz9031_of_config(struct phy_device *phydev) { MII_KSZ9031_EXT_RGMII_TX_DATA_SKEW, 2, ksz90x1_txd_grp, 4 }, { MII_KSZ9031_EXT_RGMII_CLOCK_SKEW, 2, ksz9031_clk_grp, 2 }, }; +const unsigned int master =CTRL1000_CONFIG_MASTER |CTRL1000_MANUAL_CONFIG ; +struct udevice *dev = phydev->dev; +ofnode node;int i, ret =0 ;for (i =0 ; i <ARRAY_SIZE (ofcfg); i++) {
@@ -198,7 +201,39 @@ static int ksz9031_of_config(struct phy_device *phydev)return ret; } -return 0 ; + node = phydev->node; + +/* Look for a PHY node under the Ethernet node */ +if (!ofnode_valid (node)) + node =dev_read_subnode (dev,"ethernet-phy" ); + +/* No node found, look in the Ethernet node */ +if (!ofnode_valid (node)) + node =dev_ofnode (dev); + +/* Silicon Errata Sheet (DS80000691D or DS80000692D): +* When the device links in the 1000BASE-T slave mode only, +* the optional 125MHz reference output clock (CLK125_NDO) +* has wide duty cycle variation. +* +* The optional CLK125_NDO clock does not meet the RGMII +* 45/55 percent (min/max) duty cycle requirement and therefore +* cannot be used directly by the MAC side for clocking +* applications that have setup/hold time requirements on +* rising and falling clock edges. +* +* Workaround: +* Force the phy to be the master to receive a stable clock +* which meets the duty cycle requirement. +*/ +if (ofnode_read_bool (node,"micrel,force-master" )) { + ret =phy_modify (phydev,MDIO_DEVAD_NONE ,MII_CTRL1000 , + master |CTRL1000_PREFER_MASTER , master); +if (ret <0 ) +pr_err ("KSZ9031: error applying 'micrel,force-master'\n" ); + } + +return ret; }static int ksz9031_center_flp_timing (struct phy_device *phydev)
Signature · 1 line
2.43.0