@@ -137,6 +137,61 @@ static void dwmac4_get_umac_addr(struct mac_device_info *hw,
137137 GMAC_ADDR_LOW (reg_n ));
138138}
139139
140+ static void dwmac4_set_eee_mode (struct mac_device_info * hw )
141+ {
142+ void __iomem * ioaddr = hw -> pcsr ;
143+ u32 value ;
144+
145+ /* Enable the link status receive on RGMII, SGMII ore SMII
146+ * receive path and instruct the transmit to enter in LPI
147+ * state.
148+ */
149+ value = readl (ioaddr + GMAC4_LPI_CTRL_STATUS );
150+ value |= GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA ;
151+
152+ writel (value , ioaddr + GMAC4_LPI_CTRL_STATUS );
153+ }
154+
155+ static void dwmac4_reset_eee_mode (struct mac_device_info * hw )
156+ {
157+ void __iomem * ioaddr = hw -> pcsr ;
158+ u32 value ;
159+
160+ value = readl (ioaddr + GMAC4_LPI_CTRL_STATUS );
161+ value &= ~(GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA );
162+ writel (value , ioaddr + GMAC4_LPI_CTRL_STATUS );
163+ }
164+
165+ static void dwmac4_set_eee_pls (struct mac_device_info * hw , int link )
166+ {
167+ void __iomem * ioaddr = hw -> pcsr ;
168+ u32 value ;
169+
170+ value = readl (ioaddr + GMAC4_LPI_CTRL_STATUS );
171+
172+ if (link )
173+ value |= GMAC4_LPI_CTRL_STATUS_PLS ;
174+ else
175+ value &= ~GMAC4_LPI_CTRL_STATUS_PLS ;
176+
177+ writel (value , ioaddr + GMAC4_LPI_CTRL_STATUS );
178+ }
179+
180+ static void dwmac4_set_eee_timer (struct mac_device_info * hw , int ls , int tw )
181+ {
182+ void __iomem * ioaddr = hw -> pcsr ;
183+ int value = ((tw & 0xffff )) | ((ls & 0x7ff ) << 16 );
184+
185+ /* Program the timers in the LPI timer control register:
186+ * LS: minimum time (ms) for which the link
187+ * status from PHY should be ok before transmitting
188+ * the LPI pattern.
189+ * TW: minimum time (us) for which the core waits
190+ * after it has stopped transmitting the LPI pattern.
191+ */
192+ writel (value , ioaddr + GMAC4_LPI_TIMER_CTRL );
193+ }
194+
140195static void dwmac4_set_filter (struct mac_device_info * hw ,
141196 struct net_device * dev )
142197{
@@ -410,6 +465,10 @@ static const struct stmmac_ops dwmac4_ops = {
410465 .pmt = dwmac4_pmt ,
411466 .set_umac_addr = dwmac4_set_umac_addr ,
412467 .get_umac_addr = dwmac4_get_umac_addr ,
468+ .set_eee_mode = dwmac4_set_eee_mode ,
469+ .reset_eee_mode = dwmac4_reset_eee_mode ,
470+ .set_eee_timer = dwmac4_set_eee_timer ,
471+ .set_eee_pls = dwmac4_set_eee_pls ,
413472 .pcs_ctrl_ane = dwmac4_ctrl_ane ,
414473 .pcs_rane = dwmac4_rane ,
415474 .pcs_get_adv_lp = dwmac4_get_adv_lp ,
0 commit comments