@@ -2957,28 +2957,61 @@ static void mt753x_phylink_mac_link_up(struct phylink_config *config,
29572957 mcr |= PMCR_FORCE_RX_FC_EN ;
29582958 }
29592959
2960- if (mode == MLO_AN_PHY && phydev && phy_init_eee (phydev , false) >= 0 ) {
2961- switch (speed ) {
2962- case SPEED_1000 :
2963- case SPEED_2500 :
2964- mcr |= PMCR_FORCE_EEE1G ;
2965- break ;
2966- case SPEED_100 :
2967- mcr |= PMCR_FORCE_EEE100 ;
2968- break ;
2969- }
2970- }
2971-
29722960 mt7530_set (priv , MT753X_PMCR_P (dp -> index ), mcr );
29732961}
29742962
2963+ static void mt753x_phylink_mac_disable_tx_lpi (struct phylink_config * config )
2964+ {
2965+ struct dsa_port * dp = dsa_phylink_to_port (config );
2966+ struct mt7530_priv * priv = dp -> ds -> priv ;
2967+
2968+ mt7530_clear (priv , MT753X_PMCR_P (dp -> index ),
2969+ PMCR_FORCE_EEE1G | PMCR_FORCE_EEE100 );
2970+ }
2971+
2972+ static int mt753x_phylink_mac_enable_tx_lpi (struct phylink_config * config ,
2973+ u32 timer , bool tx_clock_stop )
2974+ {
2975+ struct dsa_port * dp = dsa_phylink_to_port (config );
2976+ struct mt7530_priv * priv = dp -> ds -> priv ;
2977+ u32 val ;
2978+
2979+ /* If the timer is zero, then set LPI_MODE_EN, which allows the
2980+ * system to enter LPI mode immediately rather than waiting for
2981+ * the LPI threshold.
2982+ */
2983+ if (!timer )
2984+ val = LPI_MODE_EN ;
2985+ else if (FIELD_FIT (LPI_THRESH_MASK , timer ))
2986+ val = FIELD_PREP (LPI_THRESH_MASK , timer );
2987+ else
2988+ val = LPI_THRESH_MASK ;
2989+
2990+ mt7530_rmw (priv , MT753X_PMEEECR_P (dp -> index ),
2991+ LPI_THRESH_MASK | LPI_MODE_EN , val );
2992+
2993+ mt7530_set (priv , MT753X_PMCR_P (dp -> index ),
2994+ PMCR_FORCE_EEE1G | PMCR_FORCE_EEE100 );
2995+
2996+ return 0 ;
2997+ }
2998+
29752999static void mt753x_phylink_get_caps (struct dsa_switch * ds , int port ,
29763000 struct phylink_config * config )
29773001{
29783002 struct mt7530_priv * priv = ds -> priv ;
3003+ u32 eeecr ;
29793004
29803005 config -> mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE ;
29813006
3007+ config -> lpi_capabilities = MAC_100FD | MAC_1000FD | MAC_2500FD ;
3008+
3009+ eeecr = mt7530_read (priv , MT753X_PMEEECR_P (port ));
3010+ /* tx_lpi_timer should be in microseconds. The time units for
3011+ * LPI threshold are unspecified.
3012+ */
3013+ config -> lpi_timer_default = FIELD_GET (LPI_THRESH_MASK , eeecr );
3014+
29823015 priv -> info -> mac_port_get_caps (ds , port , config );
29833016}
29843017
@@ -3088,18 +3121,9 @@ mt753x_setup(struct dsa_switch *ds)
30883121static int mt753x_set_mac_eee (struct dsa_switch * ds , int port ,
30893122 struct ethtool_keee * e )
30903123{
3091- struct mt7530_priv * priv = ds -> priv ;
3092- u32 set , mask = LPI_THRESH_MASK | LPI_MODE_EN ;
3093-
30943124 if (e -> tx_lpi_timer > 0xFFF )
30953125 return - EINVAL ;
30963126
3097- set = LPI_THRESH_SET (e -> tx_lpi_timer );
3098- if (!e -> tx_lpi_enabled )
3099- /* Force LPI Mode without a delay */
3100- set |= LPI_MODE_EN ;
3101- mt7530_rmw (priv , MT753X_PMEEECR_P (port ), mask , set );
3102-
31033127 return 0 ;
31043128}
31053129
@@ -3238,6 +3262,8 @@ static const struct phylink_mac_ops mt753x_phylink_mac_ops = {
32383262 .mac_config = mt753x_phylink_mac_config ,
32393263 .mac_link_down = mt753x_phylink_mac_link_down ,
32403264 .mac_link_up = mt753x_phylink_mac_link_up ,
3265+ .mac_disable_tx_lpi = mt753x_phylink_mac_disable_tx_lpi ,
3266+ .mac_enable_tx_lpi = mt753x_phylink_mac_enable_tx_lpi ,
32413267};
32423268
32433269const struct mt753x_info mt753x_table [] = {
0 commit comments