@@ -376,33 +376,46 @@ static void dwmac4_get_umac_addr(struct mac_device_info *hw,
376376 GMAC_ADDR_LOW (reg_n ));
377377}
378378
379- static void dwmac4_set_eee_mode (struct mac_device_info * hw ,
380- bool en_tx_lpi_clockgating )
379+ static int dwmac4_set_lpi_mode (struct mac_device_info * hw ,
380+ enum stmmac_lpi_mode mode ,
381+ bool en_tx_lpi_clockgating , u32 et )
381382{
382383 void __iomem * ioaddr = hw -> pcsr ;
383- u32 value ;
384+ u32 value , mask ;
384385
385- /* Enable the link status receive on RGMII, SGMII ore SMII
386- * receive path and instruct the transmit to enter in LPI
387- * state.
388- */
389- value = readl (ioaddr + GMAC4_LPI_CTRL_STATUS );
390- value |= GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA ;
386+ if (mode == STMMAC_LPI_DISABLE ) {
387+ value = 0 ;
388+ } else {
389+ value = LPI_CTRL_STATUS_LPIEN | LPI_CTRL_STATUS_LPITXA ;
391390
392- if (en_tx_lpi_clockgating )
393- value |= GMAC4_LPI_CTRL_STATUS_LPITCSE ;
391+ if (mode == STMMAC_LPI_TIMER ) {
392+ /* Return ERANGE if the timer is larger than the
393+ * register field.
394+ */
395+ if (et > STMMAC_ET_MAX )
396+ return - ERANGE ;
394397
395- writel ( value , ioaddr + GMAC4_LPI_CTRL_STATUS );
396- }
398+ /* Set the hardware LPI entry timer */
399+ writel ( et , ioaddr + GMAC4_LPI_ENTRY_TIMER );
397400
398- static void dwmac4_reset_eee_mode (struct mac_device_info * hw )
399- {
400- void __iomem * ioaddr = hw -> pcsr ;
401- u32 value ;
401+ /* Interpret a zero LPI entry timer to mean
402+ * immediate entry into LPI mode.
403+ */
404+ if (et )
405+ value |= LPI_CTRL_STATUS_LPIATE ;
406+ }
402407
403- value = readl (ioaddr + GMAC4_LPI_CTRL_STATUS );
404- value &= ~(GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA );
408+ if (en_tx_lpi_clockgating )
409+ value |= LPI_CTRL_STATUS_LPITCSE ;
410+ }
411+
412+ mask = LPI_CTRL_STATUS_LPIATE | LPI_CTRL_STATUS_LPIEN |
413+ LPI_CTRL_STATUS_LPITXA | LPI_CTRL_STATUS_LPITCSE ;
414+
415+ value |= readl (ioaddr + GMAC4_LPI_CTRL_STATUS ) & ~mask ;
405416 writel (value , ioaddr + GMAC4_LPI_CTRL_STATUS );
417+
418+ return 0 ;
406419}
407420
408421static void dwmac4_set_eee_pls (struct mac_device_info * hw , int link )
@@ -413,34 +426,13 @@ static void dwmac4_set_eee_pls(struct mac_device_info *hw, int link)
413426 value = readl (ioaddr + GMAC4_LPI_CTRL_STATUS );
414427
415428 if (link )
416- value |= GMAC4_LPI_CTRL_STATUS_PLS ;
429+ value |= LPI_CTRL_STATUS_PLS ;
417430 else
418- value &= ~GMAC4_LPI_CTRL_STATUS_PLS ;
431+ value &= ~LPI_CTRL_STATUS_PLS ;
419432
420433 writel (value , ioaddr + GMAC4_LPI_CTRL_STATUS );
421434}
422435
423- static void dwmac4_set_eee_lpi_entry_timer (struct mac_device_info * hw , u32 et )
424- {
425- void __iomem * ioaddr = hw -> pcsr ;
426- u32 value = et & STMMAC_ET_MAX ;
427- int regval ;
428-
429- /* Program LPI entry timer value into register */
430- writel (value , ioaddr + GMAC4_LPI_ENTRY_TIMER );
431-
432- /* Enable/disable LPI entry timer */
433- regval = readl (ioaddr + GMAC4_LPI_CTRL_STATUS );
434- regval |= GMAC4_LPI_CTRL_STATUS_LPIEN | GMAC4_LPI_CTRL_STATUS_LPITXA ;
435-
436- if (et )
437- regval |= GMAC4_LPI_CTRL_STATUS_LPIATE ;
438- else
439- regval &= ~GMAC4_LPI_CTRL_STATUS_LPIATE ;
440-
441- writel (regval , ioaddr + GMAC4_LPI_CTRL_STATUS );
442- }
443-
444436static void dwmac4_set_eee_timer (struct mac_device_info * hw , int ls , int tw )
445437{
446438 void __iomem * ioaddr = hw -> pcsr ;
@@ -849,17 +841,17 @@ static int dwmac4_irq_status(struct mac_device_info *hw,
849841 /* Clear LPI interrupt by reading MAC_LPI_Control_Status */
850842 u32 status = readl (ioaddr + GMAC4_LPI_CTRL_STATUS );
851843
852- if (status & GMAC4_LPI_CTRL_STATUS_TLPIEN ) {
844+ if (status & LPI_CTRL_STATUS_TLPIEN ) {
853845 ret |= CORE_IRQ_TX_PATH_IN_LPI_MODE ;
854846 x -> irq_tx_path_in_lpi_mode_n ++ ;
855847 }
856- if (status & GMAC4_LPI_CTRL_STATUS_TLPIEX ) {
848+ if (status & LPI_CTRL_STATUS_TLPIEX ) {
857849 ret |= CORE_IRQ_TX_PATH_EXIT_LPI_MODE ;
858850 x -> irq_tx_path_exit_lpi_mode_n ++ ;
859851 }
860- if (status & GMAC4_LPI_CTRL_STATUS_RLPIEN )
852+ if (status & LPI_CTRL_STATUS_RLPIEN )
861853 x -> irq_rx_path_in_lpi_mode_n ++ ;
862- if (status & GMAC4_LPI_CTRL_STATUS_RLPIEX )
854+ if (status & LPI_CTRL_STATUS_RLPIEX )
863855 x -> irq_rx_path_exit_lpi_mode_n ++ ;
864856 }
865857
@@ -1201,9 +1193,7 @@ const struct stmmac_ops dwmac4_ops = {
12011193 .pmt = dwmac4_pmt ,
12021194 .set_umac_addr = dwmac4_set_umac_addr ,
12031195 .get_umac_addr = dwmac4_get_umac_addr ,
1204- .set_eee_mode = dwmac4_set_eee_mode ,
1205- .reset_eee_mode = dwmac4_reset_eee_mode ,
1206- .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer ,
1196+ .set_lpi_mode = dwmac4_set_lpi_mode ,
12071197 .set_eee_timer = dwmac4_set_eee_timer ,
12081198 .set_eee_pls = dwmac4_set_eee_pls ,
12091199 .pcs_ctrl_ane = dwmac4_ctrl_ane ,
@@ -1245,9 +1235,7 @@ const struct stmmac_ops dwmac410_ops = {
12451235 .pmt = dwmac4_pmt ,
12461236 .set_umac_addr = dwmac4_set_umac_addr ,
12471237 .get_umac_addr = dwmac4_get_umac_addr ,
1248- .set_eee_mode = dwmac4_set_eee_mode ,
1249- .reset_eee_mode = dwmac4_reset_eee_mode ,
1250- .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer ,
1238+ .set_lpi_mode = dwmac4_set_lpi_mode ,
12511239 .set_eee_timer = dwmac4_set_eee_timer ,
12521240 .set_eee_pls = dwmac4_set_eee_pls ,
12531241 .pcs_ctrl_ane = dwmac4_ctrl_ane ,
@@ -1291,9 +1279,7 @@ const struct stmmac_ops dwmac510_ops = {
12911279 .pmt = dwmac4_pmt ,
12921280 .set_umac_addr = dwmac4_set_umac_addr ,
12931281 .get_umac_addr = dwmac4_get_umac_addr ,
1294- .set_eee_mode = dwmac4_set_eee_mode ,
1295- .reset_eee_mode = dwmac4_reset_eee_mode ,
1296- .set_eee_lpi_entry_timer = dwmac4_set_eee_lpi_entry_timer ,
1282+ .set_lpi_mode = dwmac4_set_lpi_mode ,
12971283 .set_eee_timer = dwmac4_set_eee_timer ,
12981284 .set_eee_pls = dwmac4_set_eee_pls ,
12991285 .pcs_ctrl_ane = dwmac4_ctrl_ane ,
0 commit comments