The xpcs_switch_interface_mode function was introduced to handle interface switching. According to the XPCS datasheet, a soft reset is required to initiate Clause 37 auto-negotiation when the XPCS switches interface modes. When the interface mode switches from 2500BASE-X to SGMII, re-initiating Clause 37 auto-negotiation is required for the SGMII interface mode to function properly.
Unified · Split
| @@ -602,12 +602,33 @@ static void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) · 601 unmodified lines | ||
| 602 | 602 | __set_bit(compat->interface, interfaces); |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | +static int xpcs_switch_interface_mode(struct dw_xpcs *xpcs, | |
| 606 | + phy_interface_t interface) | |
| 607 | +{ | |
| 608 | + int ret = 0; | |
| 609 | + | |
| 610 | + if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) { | |
| 611 | + ret = txgbe_xpcs_switch_mode(xpcs, interface); | |
| 612 | + } else if (xpcs->interface != interface) { | |
| 613 | + if (interface == PHY_INTERFACE_MODE_SGMII) | |
| 614 | + xpcs->need_reset = true; | |
| 615 | + xpcs->interface = interface; | |
| 616 | + } | |
| 617 | + | |
| 618 | + return ret; | |
| 619 | +} | |
| 620 | + | |
| 605 | 621 | static void xpcs_pre_config(struct phylink_pcs *pcs, phy_interface_t interface) |
| 606 | 622 | { |
| 607 | 623 | struct dw_xpcs *xpcs = phylink_pcs_to_xpcs(pcs); |
| 608 | 624 | const struct dw_xpcs_compat *compat; |
| 609 | 625 | int ret; |
| 610 | 626 | |
| 627 | + ret = xpcs_switch_interface_mode(xpcs, interface); | |
| 628 | + if (ret) | |
| 629 | + dev_err(&xpcs->mdiodev->dev, "switch interface failed: %pe\n", | |
| 630 | + ERR_PTR(ret)); | |
| 631 | + | |
| 611 | 632 | if (!xpcs->need_reset) |
| 612 | 633 | return; |
| 613 | 634 | |
| @@ -799,10 +820,6 @@ static int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, · 185 unmodified lines | ||
| 799 | 820 | return -ENODEV; |
| 800 | 821 | |
| 801 | 822 | if (xpcs->info.pma == WX_TXGBE_XPCS_PMA_10G_ID) { |
| 802 | − ret = txgbe_xpcs_switch_mode(xpcs, interface); | |
| 803 | − if (ret) | |
| 804 | − return ret; | |
| 805 | − | |
| 806 | 823 | /* Wangxun devices need backplane CL37 AN enabled for |
| 807 | 824 | * SGMII and 1000base-X |
| 808 | 825 | */ |