Skip to contentSkip to conversation

net: phy: micrel_ksz90x1: workarounds for ksz9031 ERRATA

PATCH Superseded Max Merchel 1 participant 3 messages Dec 2, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 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 KSZ9031 with TQMa6 on MBa6 Baseboard.

KSZ9021 untested

Best regards,
Max
---

changes v2:
- [PATCH 1/2] net: phy: micrel_ksz90x1: disable asymmetric pause for KSZ9031
- implemented workaround as function
- integrate the workaround for KSZ9021
- add KSZ9021 to commit subject and message
- add references to linux commits
- remove unnecessary return 0
- [PATCH 2/2] net: phy: micrel_ksz90x1: support forced GIGE master for KSZ9031
- Change the variable order to a reverse Christmas tree layout

Markus Niebel (2):
net: phy: micrel_ksz90x1: disable asymmetric pause for KSZ9031 and

    KSZ9021

net: phy: micrel_ksz90x1: support forced GIGE master for KSZ9031

 drivers/net/phy/micrel_ksz90x1.c | 66 +++++++++++++++++++++++++++++++-
 1 file changed, 65 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/2 net: phy: micrel_ksz90x1: disable asymmetric pause for KSZ9031 and KSZ9021

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 KSZ9031 errata sheets: DS80000691D or DS80000692D.

Micrel KSZ9021 has no errata, but has the same issue with Asymmetric Pause. This patch apply the same workaround as the one for KSZ9031.

This follows linux implementation in commits
3aed3e2a143c ("net: phy: micrel: add Asym Pause workaround") 407d8098cb1a ("net: phy: micrel: add Asym Pause workaround for KSZ9021")

---
 drivers/net/phy/micrel_ksz90x1.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/net/phy/micrel_ksz90x1.c +29 -0
index a02dbe900b8..a669a5789b9 100644
@@ -217,6 +217,31 @@ static int ksz9031_center_flp_timing(struct phy_device *phydev)
 	return ret;
 }
 
+static void ksz90x1_workaround_asymmetric_pause(struct phy_device *phydev)
+{
+	u32 features = phydev->drv->features;
+
+	/* 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.
+	 *
+	 * The Errata Sheet is for ksz9031, but ksz9021 has the same issue
+	 *
+	 * Workaround:
+	 * Do not enable the Asymmetric Pause capability bit.
+	 */
+	features &= ~ADVERTISE_PAUSE_ASYM;
+
+	/* We force setting the Pause capability as the core will force the
+	 * Asymmetric Pause capability to 1 otherwise.
+	 */
+	features |= ADVERTISE_PAUSE_CAP;
+
+	/* update feature support and forward to advertised features */
+	phydev->supported = features;
+	phydev->advertising = phydev->supported;
+}
+
 /*
  * KSZ9021
  */
@@ -260,6 +285,8 @@ static int ksz9021_config(struct phy_device *phydev)
 	if (ret)
 		return ret;
 
+	ksz90x1_workaround_asymmetric_pause(phydev);
+
 	if (env_get("disable_giga"))
 		features &= ~(SUPPORTED_1000baseT_Half |
 		SUPPORTED_1000baseT_Full);
@@ -345,6 +372,8 @@ static int ksz9031_config(struct phy_device *phydev)
 	if (ret)
 		return ret;
 
+	ksz90x1_workaround_asymmetric_pause(phydev);
+
 	/* add an option to disable the gigabit feature of this PHY */
 	if (env_get("disable_giga")) {
 		unsigned features;
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/2 net: phy: micrel_ksz90x1: support forced GIGE master for KSZ9031

In reply to Max Merchel

From: 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 commit
e1b505a60366 ("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
index a669a5789b9..f357e0f1c77 100644
@@ -189,7 +189,10 @@ 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;
 	int i, ret = 0;
+	ofnode node;
 
 	for (i = 0; i < ARRAY_SIZE(ofcfg); i++) {
 		ret = ksz90x1_of_config_group(phydev, &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