]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: dsa: microchip: lan937x: Fix RGMII delay tuning
authorOleksij Rempel <o.rempel@pengutronix.de>
Fri, 14 Nov 2025 09:09:51 +0000 (10:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Dec 2025 21:12:37 +0000 (06:12 +0900)
commit 3ceb6ac2116ecda1c5d779bb73271479e70fccb4 upstream.

Correct RGMII delay application logic in lan937x_set_tune_adj().

The function was missing `data16 &= ~PORT_TUNE_ADJ` before setting the
new delay value. This caused the new value to be bitwise-OR'd with the
existing PORT_TUNE_ADJ field instead of replacing it.

For example, when setting the RGMII 2 TX delay on port 4, the
intended TUNE_ADJUST value of 0 (RGMII_2_TX_DELAY_2NS) was
incorrectly OR'd with the default 0x1B (from register value 0xDA3),
leaving the delay at the wrong setting.

This patch adds the missing mask to clear the field, ensuring the
correct delay value is written. Physical measurements on the RGMII TX
lines confirm the fix, showing the delay changing from ~1ns (before
change) to ~2ns.

While testing on i.MX 8MP showed this was within the platform's timing
tolerance, it did not match the intended hardware-characterized value.

Fixes: b19ac41faa3f ("net: dsa: microchip: apply rgmii tx and rx delay in phylink mac config")
Cc: stable@vger.kernel.org
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://patch.msgid.link/20251114090951.4057261-1-o.rempel@pengutronix.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/dsa/microchip/lan937x_main.c

index 338eff0818dfd258403a28affca6253d67e416fe..21424043f7d24583f89a36a0a7e7efff90128b2e 100644 (file)
@@ -328,6 +328,7 @@ static void lan937x_set_tune_adj(struct ksz_device *dev, int port,
        ksz_pread16(dev, port, reg, &data16);
 
        /* Update tune Adjust */
+       data16 &= ~PORT_TUNE_ADJ;
        data16 |= FIELD_PREP(PORT_TUNE_ADJ, val);
        ksz_pwrite16(dev, port, reg, data16);