]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: zynq_gem: Clear stale speed bits in NWCFG before setting new ones
authorRafał Hibner <rafal.hibner@secom.com.pl>
Mon, 20 Apr 2026 07:46:40 +0000 (07:46 +0000)
committerMichal Simek <michal.simek@amd.com>
Thu, 23 Apr 2026 09:52:18 +0000 (11:52 +0200)
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")
Signed-off-by: Rafał Hibner <rafal.hibner@secom.com.pl>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/20260420074640.4036119-1-rafal.hibner@secom.com.pl
drivers/net/zynq_gem.c

index e3f9fd72d2fc5350a6a641319405eecec4eec14c..f570ae9ee73aaf3e4866d43a8dfd0aac64aea30a 100644 (file)
@@ -631,6 +631,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);