@@ -2957,28 +2957,61 @@ static void mt753x_phylink_mac_link_up(struct phylink_config *config,
2957
2957
mcr |= PMCR_FORCE_RX_FC_EN ;
2958
2958
}
2959
2959
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
-
2972
2960
mt7530_set (priv , MT753X_PMCR_P (dp -> index ), mcr );
2973
2961
}
2974
2962
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
+
2975
2999
static void mt753x_phylink_get_caps (struct dsa_switch * ds , int port ,
2976
3000
struct phylink_config * config )
2977
3001
{
2978
3002
struct mt7530_priv * priv = ds -> priv ;
3003
+ u32 eeecr ;
2979
3004
2980
3005
config -> mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE ;
2981
3006
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
+
2982
3015
priv -> info -> mac_port_get_caps (ds , port , config );
2983
3016
}
2984
3017
@@ -3088,18 +3121,9 @@ mt753x_setup(struct dsa_switch *ds)
3088
3121
static int mt753x_set_mac_eee (struct dsa_switch * ds , int port ,
3089
3122
struct ethtool_keee * e )
3090
3123
{
3091
- struct mt7530_priv * priv = ds -> priv ;
3092
- u32 set , mask = LPI_THRESH_MASK | LPI_MODE_EN ;
3093
-
3094
3124
if (e -> tx_lpi_timer > 0xFFF )
3095
3125
return - EINVAL ;
3096
3126
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
-
3103
3127
return 0 ;
3104
3128
}
3105
3129
@@ -3238,6 +3262,8 @@ static const struct phylink_mac_ops mt753x_phylink_mac_ops = {
3238
3262
.mac_config = mt753x_phylink_mac_config ,
3239
3263
.mac_link_down = mt753x_phylink_mac_link_down ,
3240
3264
.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 ,
3241
3267
};
3242
3268
3243
3269
const struct mt753x_info mt753x_table [] = {
0 commit comments