Skip to contentSkip to conversation

net: zynq_gem: Clear stale speed bits in NWCFG before setting new ones

PATCH New Rafał Hibner 1 participant 1 message Apr 20

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

PATCH 1/1 net: zynq_gem: Clear stale speed bits in NWCFG before setting new ones

Commit ecba4380ad26 ("net: zynq_gem: Update the MDC clock divisor in the probe function") changed zynq_gem_init() from a direct register write to a read-modify-write pattern in order to preserve MDC clock divider bits. However, the old speed selection bits (SPEED100/SPEED1000) are never cleared before OR-ing in the new value.

When the PHY renegotiates at a different speed between successive calls to zynq_gem_init() (e.g. link flapping from 1 Gbps to 100 Mbps on a marginal cable), both SPEED100 and SPEED1000 end up set simultaneously in NWCFG. This confuses the GEM hardware and no frames are received.

Fix by explicitly clearing both speed bits before merging the new configuration, so only the currently negotiated speed is ever active.

Fixes ecba4380ad26 ("net: zynq_gem: Update the MDC clock divisor in the probe function")
---
 drivers/net/zynq_gem.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/zynq_gem.c +1 -0
index 407b022508c..f18458aee98 100644
@@ -612,6 +612,7 @@ static int zynq_gem_init(struct udevice *dev)
 		break;
 	}
 	nwcfg = readl(&regs->nwcfg);
+	nwcfg &= ~(ZYNQ_GEM_NWCFG_SPEED100 | ZYNQ_GEM_NWCFG_SPEED1000);
 	nwcfg |= nwconfig;
 	if (nwcfg)
 		writel(nwcfg, &regs->nwcfg);
Signature · 1 line
2.43.0