Skip to contentSkip to conversation

net: pcs: pcs-mtk-lynxi: fix bpi-r3 serdes configuration

RFC PATCH Superseded Frank Wunderlich 4 participants 7 messages Apr 9 – May 25

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 net: pcs: pcs-mtk-lynxi: fix bpi-r3 serdes configuration

From: Frank Wunderlich <[email protected]>

Commit 8871389da151 introduces common pcs dts properties which writes rx=normal,tx=normal polarity to register SGMSYS_QPHY_WRAP_CTRL of switch. This is initialized with tx-bit set and so change inverts polarity compared to before.

It looks like mt7531 has tx polarity inverted in hardware and set tx-bit by default to restore the normal polarity.

Till this patch the register write was only called when mediatek,pnswap property was set which cannot be done for switch because the fw-node param was always NULL from switch driver in the mtk_pcs_lynxi_create call.

Do not configure switch side like it's done before.

Fixes 8871389da151 ("net: pcs: pcs-mtk-lynxi: deprecate "mediatek,pnswap"")
---
 drivers/net/pcs/pcs-mtk-lynxi.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/pcs/pcs-mtk-lynxi.c +3 -0
index c12f8087af9b..a753bd88cbc2 100644
@@ -129,6 +129,9 @@ static int mtk_pcs_config_polarity(struct mtk_pcs_lynxi *mpcs,
 	unsigned int val = 0;
 	int ret;
 
+	if (!fwnode)
+		return 0;
+
 	if (fwnode_property_read_bool(fwnode, "mediatek,pnswap"))
 		default_pol = PHY_POL_INVERT;
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 37 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

Commit 8871389da151 introduces common pcs dts properties which writes rx=normal,tx=normal polarity to register SGMSYS_QPHY_WRAP_CTRL of switch. This is initialized with tx-bit set and so change inverts polarity compared to before.

It looks like mt7531 has tx polarity inverted in hardware and set tx-bit by default to restore the normal polarity.

Till this patch the register write was only called when mediatek,pnswap property was set which cannot be done for switch because the fw-node param was always NULL from switch driver in the mtk_pcs_lynxi_create call.

Do not configure switch side like it's done before.

Fixes 8871389da151 ("net: pcs: pcs-mtk-lynxi: deprecate "mediatek,pnswap"")
---
 drivers/net/pcs/pcs-mtk-lynxi.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/pcs/pcs-mtk-lynxi.c +3 -1
index c12f8087af9b..a753bd88cbc2 100644
@@ -129,6 +129,9 @@ static int mtk_pcs_config_polarity(struct mtk_pcs_lynxi *mpcs,
        unsigned int val = 0;
        int ret;
 
+       if (!fwnode)
+               return 0;
+
        if (fwnode_property_read_bool(fwnode, "mediatek,pnswap"))
                default_pol = PHY_POL_INVERT;
 
--
Quoted 2 lines

2.43.0

I notice Arınc, listed by ./scripts/get_maintainer.pl drivers/net/dsa/mt7530.c, and Felix, listed by ./scripts/get_maintainer.pl drivers/net/ethernet/mediatek/mtk_eth_soc.c, are not on CC. Maybe they have more info.

Only the switch port has a chance of having a non-zero default polarity setting? (coming from the efuse, if I understood this discussion properly)
https://lore.kernel.org/netdev/[email protected]/
The GMAC doesn't?

maintainer
#2 lore raw
Quoted 8 lines · Vladimir Oltean

I notice Arınc, listed by ./scripts/get_maintainer.pl drivers/net/dsa/mt7530.c, and Felix, listed by ./scripts/get_maintainer.pl drivers/net/ethernet/mediatek/mtk_eth_soc.c, are not on CC. Maybe they have more info.

Only the switch port has a chance of having a non-zero default polarity setting? (coming from the efuse, if I understood this discussion properly)
https://lore.kernel.org/netdev/[email protected]/
The GMAC doesn't?

Yes, vendor SDK uses DT mediatek,pnswap{,-rx,-tx} properties only for the SoC GMACs. For MT7531 there are **no** strap pins deciding the SerDes polarity, and also no software-way to override the defaults in the vendor SDK.

However, the MT7531 datasheet quite clearly states:
Register 000050EC QPHY_WRAP_CTRL -- QPHY wrapper control Reset value: 0x00000501

BIT 1 RX_BIT_POLARITY -- RX bit polarity control
1'b0: normal
1'b1: inverted

BIT 0 TX_BIT_POLARITY -- TX bit polarity control (TX default inversed in MT7531)
1'b0: normal
1'b1: inverted

Hence the best would be to just assume the documented default in the driver as well.

A quick register dump using the BPi-R3 confirms that this applies to *both* SerDes PCS on MT7531A (port 5 and port 6) equally, both read 0x00000501 after reset.

#3 lore raw
Quoted 27 lines · Daniel Golle
Quoted 8 lines · Vladimir Oltean

I notice Arınc, listed by ./scripts/get_maintainer.pl drivers/net/dsa/mt7530.c, and Felix, listed by ./scripts/get_maintainer.pl drivers/net/ethernet/mediatek/mtk_eth_soc.c, are not on CC. Maybe they have more info.

Only the switch port has a chance of having a non-zero default polarity setting? (coming from the efuse, if I understood this discussion properly)
https://lore.kernel.org/netdev/[email protected]/
The GMAC doesn't?

Yes, vendor SDK uses DT mediatek,pnswap{,-rx,-tx} properties only for the SoC GMACs. For MT7531 there are **no** strap pins deciding the SerDes polarity, and also no software-way to override the defaults in the vendor SDK.

However, the MT7531 datasheet quite clearly states:
Register 000050EC QPHY_WRAP_CTRL -- QPHY wrapper control Reset value: 0x00000501

BIT 1 RX_BIT_POLARITY -- RX bit polarity control
1'b0: normal
1'b1: inverted

BIT 0 TX_BIT_POLARITY -- TX bit polarity control (TX default inversed in MT7531)
1'b0: normal
1'b1: inverted

Quoted 6 lines

Hence the best would be to just assume the documented default in the driver as well.

A quick register dump using the BPi-R3 confirms that this applies to *both* SerDes PCS on MT7531A (port 5 and port 6) equally, both read 0x00000501 after reset.

OK. Excepting the DSA driver for MT7531 from polarity configuration based on lack of a fwnode for the PCS should be fine (for now, to address the regression).

Reviewed-by on v1 1/1
#4 lore raw
In reply to Frank Wunderlich
Quoted 14 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

Commit 8871389da151 introduces common pcs dts properties which writes rx=normal,tx=normal polarity to register SGMSYS_QPHY_WRAP_CTRL of switch. This is initialized with tx-bit set and so change inverts polarity compared to before.

It looks like mt7531 has tx polarity inverted in hardware and set tx-bit by default to restore the normal polarity.

Till this patch the register write was only called when mediatek,pnswap property was set which cannot be done for switch because the fw-node param was always NULL from switch driver in the mtk_pcs_lynxi_create call.

Quoted 5 lines

Do not configure switch side like it's done before.

Fixes 8871389da151 ("net: pcs: pcs-mtk-lynxi: deprecate "mediatek,pnswap"")

---

#5 lore raw

Am 2026-04-09 23:55, schrieb Vladimir Oltean:

Quoted 15 lines · Frank Wunderlich
Quoted 14 lines

From: Frank Wunderlich <[email protected]>

Commit 8871389da151 introduces common pcs dts properties which writes rx=normal,tx=normal polarity to register SGMSYS_QPHY_WRAP_CTRL of switch. This is initialized with tx-bit set and so change inverts polarity compared to before.

It looks like mt7531 has tx polarity inverted in hardware and set tx-bit by default to restore the normal polarity.

Till this patch the register write was only called when mediatek,pnswap property was set which cannot be done for switch because the fw-node param was always NULL from switch driver in the mtk_pcs_lynxi_create call.

Quoted 7 lines
Quoted 5 lines

Do not configure switch side like it's done before.

Fixes 8871389da151 ("net: pcs: pcs-mtk-lynxi: deprecate "mediatek,pnswap"")

---

Hi,

just a gentle ping as i still not see this in torvalds/master.

regards Frank

maintainer
#6 lore raw
Quoted 22 lines · On Mon, 25 May 2026 12:07:33 +0200 Frank Wunderlich (linux) wrote:

Am 2026-04-09 23:55, schrieb Vladimir Oltean:

Quoted 21 lines · Frank Wunderlich
Quoted 20 lines

From: Frank Wunderlich <[email protected]>

Commit 8871389da151 introduces common pcs dts properties which writes rx=normal,tx=normal polarity to register SGMSYS_QPHY_WRAP_CTRL of switch.
This is initialized with tx-bit set and so change inverts polarity compared to before.

It looks like mt7531 has tx polarity inverted in hardware and set tx-bit
by default to restore the normal polarity.

Till this patch the register write was only called when mediatek,pnswap
property was set which cannot be done for switch because the fw-node param
was always NULL from switch driver in the mtk_pcs_lynxi_create call.

Do not configure switch side like it's done before.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Fixes 8871389da151 ("net: pcs: pcs-mtk-lynxi: deprecate

"mediatek,pnswap"")

---

just a gentle ping as i still not see this in torvalds/master.

You posted it as RFC, patchwork treats RFC as "no action required". Since the posting is now >1mo old, please resend without the RFC tag?