net: mtk_eth: an8855: fix packet loss and sync with Linux
Subsystems (2)
v2 cover net: mtk_eth: an8855: fix packet loss and sync with Linux
his patch series aligns the U-Boot Airoha AN8855 switch initialization code with the proposed Linux DSA driver [1], fixing several register configuration bugs and improving overall signal integrity.
[1] https://lore.kernel.org/all/[email protected]/
The current default U-Boot configuration leaves the SerDes with marginal drive characteristics. On some hardware iterations, this results in severe packet loss (50-60%) and timeouts during TFTP recovery. This drop occurs because of marginal signal integrity on the internal 2500Base-X link connecting the switch to the CPU.
By correcting a bitwise shift overlap, enabling link error recovery, and applying the proper TX FIR / RX CDR analog tuning parameters used in the proposed Linux driver, this series ensures a stable physical link between the CPU and switch across different boards.
These changes have been run-tested on the CMCC RAX3000ME and Xiaomi AX3000T, both featuring the AN8855 switch, confirming stable network operation and reliable gigabit TFTP recovery.
Changes in v2:
- Clarified in the cover letter that the referenced Linux driver is currently proposed/pending, and added a link to the patch series on lore.
- Added Fixes: tag to all three patches in the series.
- (Patch 3) Moved analog tuning parameters to the beginning of the init sequence, removed a redundant bitwise operation, and added a comment clarifying the 2500BASE-X values based on v1 review feedback.
Mikhail Zhilkin (3):
net: mtk_eth: an8855: fix bit collision in RX_CTRL_8 register
net: mtk_eth: an8855: sync link error recovery config with Linux
net: mtk_eth: an8855: sync SerDes tuning with Linux
drivers/net/mtk_eth/an8855.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/3 net: mtk_eth: an8855: fix bit collision in RX_CTRL_8 register
In an8855_port_sgmii_init(), the bitwise operations for the AN8855_RX_CTRL_8 register contain a shifting error. The code attempts to set a value at shift 16 (0x200 << 16), but subsequently applies a mask and value shifted by 14 (0xfff << 14). This creates a bitwise collision where the second operation overlaps and overwrites the bits configured by the first operation, resulting in unintended register values.
Fix the shift offset for the lower bits from 14 to 0 to prevent overlap and correctly apply the exact values used in the proposed Linux driver [1].
[1] https://lore.kernel.org/all/[email protected]/
---
Changes in v2:
- Dropped the unnecessary << 0 and parentheses based on review feedback.
- Changed "upstream" to "proposed" and added lore link.
- Added Fixes tag.
--- drivers/net/mtk_eth/an8855.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/mtk_eth/an8855.c +2 -2
@@ -627,8 +627,8 @@ static int an8855_port_sgmii_init(struct an8855_switch_priv *priv, u32 port)an8855_reg_read (priv,AN8855_RX_CTRL_8 , &val); val &= ~(0xfff <<16 ); val |= (0x200 <<16 ); - val &= ~(0x7fff <<14 ); - val |= (0xfff <<14 ); + val &= ~0x7fff ; + val |=0xfff ;an8855_reg_write (priv,AN8855_RX_CTRL_8 , val);/* Frequency memter */
Signature · 1 line
2.53.0
PATCH v2 2/3 net: mtk_eth: an8855: sync link error recovery config with Linux
In reply to Mikhail ZhilkinSync the Link Error Recovery configuration with the proposed Linux driver [1].
Currently, the U-Boot driver explicitly clears the AN8855_RG_LINK_ERRO_EN bit (bit 23) in the AN8855_RX_CTRL_26 register during SGMII initialization. Setting bit 23, while explicitly clearing bit 24, matches the Linux driver behavior. This allows the MAC/PCS to gracefully recover from momentary link errors on marginal hardware rather than dropping packets or the entire link.
[1] https://lore.kernel.org/all/[email protected]/
---
Changes in v2:
- Also cleared BIT(24) to exactly match the proposed Linux driver based on review feedback.
- Changed "upstream" to "proposed" and added lore link.
- Added Fixes tag.
--- drivers/net/mtk_eth/an8855.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/mtk_eth/an8855.c +2 -1
@@ -599,7 +599,8 @@ static int an8855_port_sgmii_init(struct an8855_switch_priv *priv, u32 port)an8855_reg_write (priv,AN8855_PLL_CTRL_0 , val);an8855_reg_read (priv,AN8855_RX_CTRL_26 , &val); - val &= ~BIT (23 ); + val |=BIT (23 ); + val &= ~BIT (24 ); val |=BIT (26 );an8855_reg_write (priv,AN8855_RX_CTRL_26 , val);
Signature · 1 line
2.53.0
PATCH v2 3/3 net: mtk_eth: an8855: sync SerDes tuning with Linux
In reply to Mikhail ZhilkinPort the TX FIR (TX Eye) and RX CDR (RX Jitter Tolerance) analog tuning parameters from the proposed Linux Airoha AN8855 DSA driver [1].
The default U-Boot configuration omits these register writes, leaving the SerDes with inferior default drive characteristics. On hardware iterations with minor silicon or trace variances, this marginal signal integrity leads to severe packet loss (50-60%) during TFTP recovery over the 2500Base-X link. Explicitly configuring AN8855_INTF_CTRL_10, AN8855_INTF_CTRL_11, and AN8855_RG_QP_CDR_LPF_BOT_LIM ensures a stable physical link across boards.
[1] https://lore.kernel.org/all/[email protected]/
---
Changes in v2:
- Changed "upstream" to "proposed" and added lore link to match cover letter.
- Added Fixes tag.
- Clarified in comments that TX FIR values are specifically for 2500BASE-X.
- Removed redundant bitwise OR with 0x00.
- Moved the analog tuning parameters to the beginning of an8855_port_sgmii_init() to match the proposed Linux driver.
--- drivers/net/mtk_eth/an8855.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/net/mtk_eth/an8855.c +24 -0
@@ -96,6 +96,8 @@#define AN8855_SS_LCPLL_TDC_PCW_1 (AN8855_QP_PMA_TOP_BASE + 0x248)#define AN8855_INTF_CTRL_8 (AN8855_QP_PMA_TOP_BASE + 0x320)#define AN8855_INTF_CTRL_9 (AN8855_QP_PMA_TOP_BASE + 0x324) +#define AN8855_INTF_CTRL_10 (AN8855_QP_PMA_TOP_BASE + 0x328) +#define AN8855_INTF_CTRL_11 (AN8855_QP_PMA_TOP_BASE + 0x32c)#define AN8855_PLL_CTRL_0 (AN8855_QP_PMA_TOP_BASE + 0x400)#define AN8855_PLL_CTRL_2 (AN8855_QP_PMA_TOP_BASE + 0x408)#define AN8855_PLL_CTRL_3 (AN8855_QP_PMA_TOP_BASE + 0x40c)
@@ -113,6 +115,7 @@#define AN8855_QP_ANA_CSR_BASE 0x1022f000#define AN8855_RG_QP_RX_DAC_EN (AN8855_QP_ANA_CSR_BASE + 0x00)#define AN8855_RG_QP_RXAFE_RESERVE (AN8855_QP_ANA_CSR_BASE + 0x04) +#define AN8855_RG_QP_CDR_LPF_BOT_LIM (AN8855_QP_ANA_CSR_BASE + 0x08)#define AN8855_RG_QP_CDR_LPF_MJV_LIM (AN8855_QP_ANA_CSR_BASE + 0x0c)#define AN8855_RG_QP_CDR_LPF_SETVALUE (AN8855_QP_ANA_CSR_BASE + 0x14)#define AN8855_RG_QP_CDR_PR_CKREF_DIV1 (AN8855_QP_ANA_CSR_BASE + 0x18)
@@ -434,6 +437,27 @@ static int an8855_port_sgmii_init(struct an8855_switch_priv *priv, u32 port)return -EINVAL ; } +/* TX FIR - improve TX EYE for 2500BASE-X */ +an8855_reg_read (priv,AN8855_INTF_CTRL_10 , &val); + val &= ~(0x1f <<24 ); + val |= (0x04 <<24 ); + val &= ~(0x1f <<16 ); + val |=BIT (29 ) |BIT (21 ); +an8855_reg_write (priv,AN8855_INTF_CTRL_10 , val); + +an8855_reg_read (priv,AN8855_INTF_CTRL_11 , &val); + val &= ~(0x3f <<0 ); + val |=BIT (6 ); +an8855_reg_write (priv,AN8855_INTF_CTRL_11 , val); + +/* RX CDR - improve RX Jitter Tolerance */ +an8855_reg_read (priv,AN8855_RG_QP_CDR_LPF_BOT_LIM , &val); + val &= ~(0x7 <<24 ); + val |= (0x5 <<24 ); + val &= ~(0x7 <<20 ); + val |= (0x5 <<20 ); +an8855_reg_write (priv,AN8855_RG_QP_CDR_LPF_BOT_LIM , val); +/* PLL */ an8855_reg_read (priv,AN8855_QP_DIG_MODE_CTRL_1 , &val); val &= ~(0x3 <<2 );
Signature · 1 line
2.53.0