@@ -38,20 +38,16 @@ static int mtk_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
38
38
const unsigned long * advertising ,
39
39
bool permit_pause_to_mac )
40
40
{
41
+ bool mode_changed = false, changed , use_an ;
41
42
struct mtk_pcs * mpcs = pcs_to_mtk_pcs (pcs );
42
43
unsigned int rgc3 , sgm_mode , bmcr ;
43
44
int advertise , link_timer ;
44
- bool changed , use_an ;
45
45
46
46
advertise = phylink_mii_c22_pcs_encode_advertisement (interface ,
47
47
advertising );
48
48
if (advertise < 0 )
49
49
return advertise ;
50
50
51
- link_timer = phylink_get_link_timer_ns (interface );
52
- if (link_timer < 0 )
53
- return link_timer ;
54
-
55
51
/* Clearing IF_MODE_BIT0 switches the PCS to BASE-X mode, and
56
52
* we assume that fixes it's speed at bitrate = line rate (in
57
53
* other words, 1000Mbps or 2500Mbps).
@@ -77,13 +73,16 @@ static int mtk_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
77
73
}
78
74
79
75
if (use_an ) {
80
- /* FIXME: Do we need to set AN_RESTART here? */
81
- bmcr = SGMII_AN_RESTART | SGMII_AN_ENABLE ;
76
+ bmcr = SGMII_AN_ENABLE ;
82
77
} else {
83
78
bmcr = 0 ;
84
79
}
85
80
86
81
if (mpcs -> interface != interface ) {
82
+ link_timer = phylink_get_link_timer_ns (interface );
83
+ if (link_timer < 0 )
84
+ return link_timer ;
85
+
87
86
/* PHYA power down */
88
87
regmap_update_bits (mpcs -> regmap , SGMSYS_QPHY_PWR_STATE_CTRL ,
89
88
SGMII_PHYA_PWD , SGMII_PHYA_PWD );
@@ -101,24 +100,25 @@ static int mtk_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
101
100
regmap_update_bits (mpcs -> regmap , mpcs -> ana_rgc3 ,
102
101
RG_PHY_SPEED_3_125G , rgc3 );
103
102
103
+ /* Setup the link timer */
104
+ regmap_write (mpcs -> regmap , SGMSYS_PCS_LINK_TIMER , link_timer / 2 / 8 );
105
+
104
106
mpcs -> interface = interface ;
107
+ mode_changed = true;
105
108
}
106
109
107
110
/* Update the advertisement, noting whether it has changed */
108
111
regmap_update_bits_check (mpcs -> regmap , SGMSYS_PCS_ADVERTISE ,
109
112
SGMII_ADVERTISE , advertise , & changed );
110
113
111
- /* Setup the link timer and QPHY power up inside SGMIISYS */
112
- regmap_write (mpcs -> regmap , SGMSYS_PCS_LINK_TIMER , link_timer / 2 / 8 );
113
-
114
114
/* Update the sgmsys mode register */
115
115
regmap_update_bits (mpcs -> regmap , SGMSYS_SGMII_MODE ,
116
116
SGMII_REMOTE_FAULT_DIS | SGMII_SPEED_DUPLEX_AN |
117
117
SGMII_IF_MODE_SGMII , sgm_mode );
118
118
119
119
/* Update the BMCR */
120
120
regmap_update_bits (mpcs -> regmap , SGMSYS_PCS_CONTROL_1 ,
121
- SGMII_AN_RESTART | SGMII_AN_ENABLE , bmcr );
121
+ SGMII_AN_ENABLE , bmcr );
122
122
123
123
/* Release PHYA power down state
124
124
* Only removing bit SGMII_PHYA_PWD isn't enough.
@@ -132,7 +132,7 @@ static int mtk_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
132
132
usleep_range (50 , 100 );
133
133
regmap_write (mpcs -> regmap , SGMSYS_QPHY_PWR_STATE_CTRL , 0 );
134
134
135
- return changed ;
135
+ return changed || mode_changed ;
136
136
}
137
137
138
138
static void mtk_pcs_restart_an (struct phylink_pcs * pcs )
0 commit comments