]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: phy: micrel: add option to keep the preamble before sfd for KSZ9131
authorStefan Eichenberger <stefan.eichenberger@toradex.com>
Tue, 20 Jan 2026 20:30:03 +0000 (21:30 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 23 Jan 2026 02:27:32 +0000 (18:27 -0800)
If the PHY_F_KEEP_PREAMBLE_BEFORE_SFD flag is set in the
phy_device::dev_flags field, the preamble will be kept before the start
frame delimiter (SFD) on the KSZ9131 PHY. This flag is not officially
documented by Micrel. However, information provided by NXP and Micrel
indicates that this flag ensures the PHY sends the full preamble instead
of removing it. The full discussion can be found on the NXP forum:
https://community.nxp.com/t5/i-MX-Processors/iMX8MP-eqos-not-working-for-10base-t/m-p/2151032

Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20260120203905.23805-3-eichest@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/micrel.c

index 225d4adf28be416d2cf3378b08cf0a99ef6c50b5..b2a584b60bff1c5c56a1bce8f40c0b0b1ce4f7e4 100644 (file)
 #define LAN8814_CABLE_DIAG_VCT_DATA_MASK       GENMASK(7, 0)
 #define LAN8814_PAIR_BIT_SHIFT                 12
 
+/* KSZ9x31 remote loopback register */
+#define KSZ9x31_REMOTE_LOOPBACK                        0x11
+/* This is an undocumented bit of the KSZ9131RNX.
+ * It was reported by NXP in cooperation with Micrel.
+ */
+#define KSZ9x31_REMOTE_LOOPBACK_KEEP_PREAMBLE  BIT(2)
+#define KSZ9x31_REMOTE_LOOPBACK_EN             BIT(8)
+
 #define LAN8814_SKUS                           0xB
 
 #define LAN8814_WIRE_PAIR_MASK                 0xF
@@ -1500,7 +1508,11 @@ static int ksz9131_config_init(struct phy_device *phydev)
        if (ret < 0)
                return ret;
 
-       return 0;
+       if (phydev->dev_flags & PHY_F_KEEP_PREAMBLE_BEFORE_SFD)
+               ret = phy_modify(phydev, KSZ9x31_REMOTE_LOOPBACK, 0,
+                                KSZ9x31_REMOTE_LOOPBACK_KEEP_PREAMBLE);
+
+       return ret;
 }
 
 #define MII_KSZ9131_AUTO_MDIX          0x1C