Skip to content

Commit 06dfcd4

Browse files
arinc9kuba-moo
authored andcommitted
net: dsa: mt7530: fix enabling EEE on MT7531 switch on all boards
The commit 40b5d2f ("net: dsa: mt7530: Add support for EEE features") brought EEE support but did not enable EEE on MT7531 switch MACs. EEE is enabled on MT7531 switch MACs by pulling the LAN2LED0 pin low on the board (bootstrapping), unsetting the EEE_DIS bit on the trap register, or setting the internal EEE switch bit on the CORE_PLL_GROUP4 register. Thanks to SkyLake Huang (黃啟澤) from MediaTek for providing information on the internal EEE switch bit. There are existing boards that were not designed to pull the pin low. Because of that, the EEE status currently depends on the board design. The EEE_DIS bit on the trap pertains to the LAN2LED0 pin which is usually used to control an LED. Once the bit is unset, the pin will be low. That will make the active low LED turn on. The pin is controlled by the switch PHY. It seems that the PHY controls the pin in the way that it inverts the pin state. That means depending on the wiring of the LED connected to LAN2LED0 on the board, the LED may be on without an active link. To not cause this unwanted behaviour whilst enabling EEE on all boards, set the internal EEE switch bit on the CORE_PLL_GROUP4 register. My testing on MT7531 shows a certain amount of traffic loss when EEE is enabled. That said, I haven't come across a board that enables EEE. So enable EEE on the switch MACs but disable EEE advertisement on the switch PHYs. This way, we don't change the behaviour of the majority of the boards that have this switch. The mediatek-ge PHY driver already disables EEE advertisement on the switch PHYs but my testing shows that it is somehow enabled afterwards. Disabling EEE advertisement before the PHY driver initialises keeps it off. With this change, EEE can now be enabled using ethtool. Fixes: 40b5d2f ("net: dsa: mt7530: Add support for EEE features") Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com> Tested-by: Daniel Golle <daniel@makrotopia.org> Reviewed-by: Daniel Golle <daniel@makrotopia.org> Link: https://lore.kernel.org/r/20240408-for-net-mt7530-fix-eee-for-mt7531-mt7988-v3-1-84fdef1f008b@arinc9.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 19fa4f2 commit 06dfcd4

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

drivers/net/dsa/mt7530.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,18 +2505,25 @@ mt7531_setup(struct dsa_switch *ds)
25052505
mt7530_rmw(priv, MT7531_GPIO_MODE0, MT7531_GPIO0_MASK,
25062506
MT7531_GPIO0_INTERRUPT);
25072507

2508-
/* Enable PHY core PLL, since phy_device has not yet been created
2509-
* provided for phy_[read,write]_mmd_indirect is called, we provide
2510-
* our own mt7531_ind_mmd_phy_[read,write] to complete this
2511-
* function.
2508+
/* Enable Energy-Efficient Ethernet (EEE) and PHY core PLL, since
2509+
* phy_device has not yet been created provided for
2510+
* phy_[read,write]_mmd_indirect is called, we provide our own
2511+
* mt7531_ind_mmd_phy_[read,write] to complete this function.
25122512
*/
25132513
val = mt7531_ind_c45_phy_read(priv, MT753X_CTRL_PHY_ADDR,
25142514
MDIO_MMD_VEND2, CORE_PLL_GROUP4);
2515-
val |= MT7531_PHY_PLL_BYPASS_MODE;
2515+
val |= MT7531_RG_SYSPLL_DMY2 | MT7531_PHY_PLL_BYPASS_MODE;
25162516
val &= ~MT7531_PHY_PLL_OFF;
25172517
mt7531_ind_c45_phy_write(priv, MT753X_CTRL_PHY_ADDR, MDIO_MMD_VEND2,
25182518
CORE_PLL_GROUP4, val);
25192519

2520+
/* Disable EEE advertisement on the switch PHYs. */
2521+
for (i = MT753X_CTRL_PHY_ADDR;
2522+
i < MT753X_CTRL_PHY_ADDR + MT7530_NUM_PHYS; i++) {
2523+
mt7531_ind_c45_phy_write(priv, i, MDIO_MMD_AN, MDIO_AN_EEE_ADV,
2524+
0);
2525+
}
2526+
25202527
mt7531_setup_common(ds);
25212528

25222529
/* Setup VLAN ID 0 for VLAN-unaware bridges */

drivers/net/dsa/mt7530.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ enum mt7531_clk_skew {
616616
#define RG_SYSPLL_DDSFBK_EN BIT(12)
617617
#define RG_SYSPLL_BIAS_EN BIT(11)
618618
#define RG_SYSPLL_BIAS_LPF_EN BIT(10)
619+
#define MT7531_RG_SYSPLL_DMY2 BIT(6)
619620
#define MT7531_PHY_PLL_OFF BIT(5)
620621
#define MT7531_PHY_PLL_BYPASS_MODE BIT(4)
621622

0 commit comments

Comments
 (0)