aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e/82571.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000e/82571.c')
-rw-r--r--drivers/net/e1000e/82571.c264
1 files changed, 227 insertions, 37 deletions
diff --git a/drivers/net/e1000e/82571.c b/drivers/net/e1000e/82571.c
index a655beb69320..1397da118f0d 100644
--- a/drivers/net/e1000e/82571.c
+++ b/drivers/net/e1000e/82571.c
@@ -52,6 +52,7 @@
52 (ID_LED_DEF1_DEF2)) 52 (ID_LED_DEF1_DEF2))
53 53
54#define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000 54#define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000
55#define AN_RETRY_COUNT 5 /* Autoneg Retry Count value */
55#define E1000_BASE1000T_STATUS 10 56#define E1000_BASE1000T_STATUS 10
56#define E1000_IDLE_ERROR_COUNT_MASK 0xFF 57#define E1000_IDLE_ERROR_COUNT_MASK 0xFF
57#define E1000_RECEIVE_ERROR_COUNTER 21 58#define E1000_RECEIVE_ERROR_COUNTER 21
@@ -74,6 +75,11 @@ static bool e1000_check_mng_mode_82574(struct e1000_hw *hw);
74static s32 e1000_led_on_82574(struct e1000_hw *hw); 75static s32 e1000_led_on_82574(struct e1000_hw *hw);
75static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw); 76static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw);
76static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw); 77static void e1000_power_down_phy_copper_82571(struct e1000_hw *hw);
78static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw);
79static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw);
80static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw);
81static s32 e1000_set_d0_lplu_state_82574(struct e1000_hw *hw, bool active);
82static s32 e1000_set_d3_lplu_state_82574(struct e1000_hw *hw, bool active);
77 83
78/** 84/**
79 * e1000_init_phy_params_82571 - Init PHY func ptrs. 85 * e1000_init_phy_params_82571 - Init PHY func ptrs.
@@ -107,6 +113,10 @@ static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
107 case e1000_82574: 113 case e1000_82574:
108 case e1000_82583: 114 case e1000_82583:
109 phy->type = e1000_phy_bm; 115 phy->type = e1000_phy_bm;
116 phy->ops.acquire = e1000_get_hw_semaphore_82574;
117 phy->ops.release = e1000_put_hw_semaphore_82574;
118 phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82574;
119 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82574;
110 break; 120 break;
111 default: 121 default:
112 return -E1000_ERR_PHY; 122 return -E1000_ERR_PHY;
@@ -115,29 +125,36 @@ static s32 e1000_init_phy_params_82571(struct e1000_hw *hw)
115 125
116 /* This can only be done after all function pointers are setup. */ 126 /* This can only be done after all function pointers are setup. */
117 ret_val = e1000_get_phy_id_82571(hw); 127 ret_val = e1000_get_phy_id_82571(hw);
128 if (ret_val) {
129 e_dbg("Error getting PHY ID\n");
130 return ret_val;
131 }
118 132
119 /* Verify phy id */ 133 /* Verify phy id */
120 switch (hw->mac.type) { 134 switch (hw->mac.type) {
121 case e1000_82571: 135 case e1000_82571:
122 case e1000_82572: 136 case e1000_82572:
123 if (phy->id != IGP01E1000_I_PHY_ID) 137 if (phy->id != IGP01E1000_I_PHY_ID)
124 return -E1000_ERR_PHY; 138 ret_val = -E1000_ERR_PHY;
125 break; 139 break;
126 case e1000_82573: 140 case e1000_82573:
127 if (phy->id != M88E1111_I_PHY_ID) 141 if (phy->id != M88E1111_I_PHY_ID)
128 return -E1000_ERR_PHY; 142 ret_val = -E1000_ERR_PHY;
129 break; 143 break;
130 case e1000_82574: 144 case e1000_82574:
131 case e1000_82583: 145 case e1000_82583:
132 if (phy->id != BME1000_E_PHY_ID_R2) 146 if (phy->id != BME1000_E_PHY_ID_R2)
133 return -E1000_ERR_PHY; 147 ret_val = -E1000_ERR_PHY;
134 break; 148 break;
135 default: 149 default:
136 return -E1000_ERR_PHY; 150 ret_val = -E1000_ERR_PHY;
137 break; 151 break;
138 } 152 }
139 153
140 return 0; 154 if (ret_val)
155 e_dbg("PHY ID unknown: type = 0x%08x\n", phy->id);
156
157 return ret_val;
141} 158}
142 159
143/** 160/**
@@ -200,6 +217,17 @@ static s32 e1000_init_nvm_params_82571(struct e1000_hw *hw)
200 break; 217 break;
201 } 218 }
202 219
220 /* Function Pointers */
221 switch (hw->mac.type) {
222 case e1000_82574:
223 case e1000_82583:
224 nvm->ops.acquire = e1000_get_hw_semaphore_82574;
225 nvm->ops.release = e1000_put_hw_semaphore_82574;
226 break;
227 default:
228 break;
229 }
230
203 return 0; 231 return 0;
204} 232}
205 233
@@ -542,6 +570,146 @@ static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw)
542 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI); 570 swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
543 ew32(SWSM, swsm); 571 ew32(SWSM, swsm);
544} 572}
573/**
574 * e1000_get_hw_semaphore_82573 - Acquire hardware semaphore
575 * @hw: pointer to the HW structure
576 *
577 * Acquire the HW semaphore during reset.
578 *
579 **/
580static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw)
581{
582 u32 extcnf_ctrl;
583 s32 ret_val = 0;
584 s32 i = 0;
585
586 extcnf_ctrl = er32(EXTCNF_CTRL);
587 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
588 do {
589 ew32(EXTCNF_CTRL, extcnf_ctrl);
590 extcnf_ctrl = er32(EXTCNF_CTRL);
591
592 if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
593 break;
594
595 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
596
597 msleep(2);
598 i++;
599 } while (i < MDIO_OWNERSHIP_TIMEOUT);
600
601 if (i == MDIO_OWNERSHIP_TIMEOUT) {
602 /* Release semaphores */
603 e1000_put_hw_semaphore_82573(hw);
604 e_dbg("Driver can't access the PHY\n");
605 ret_val = -E1000_ERR_PHY;
606 goto out;
607 }
608
609out:
610 return ret_val;
611}
612
613/**
614 * e1000_put_hw_semaphore_82573 - Release hardware semaphore
615 * @hw: pointer to the HW structure
616 *
617 * Release hardware semaphore used during reset.
618 *
619 **/
620static void e1000_put_hw_semaphore_82573(struct e1000_hw *hw)
621{
622 u32 extcnf_ctrl;
623
624 extcnf_ctrl = er32(EXTCNF_CTRL);
625 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
626 ew32(EXTCNF_CTRL, extcnf_ctrl);
627}
628
629static DEFINE_MUTEX(swflag_mutex);
630
631/**
632 * e1000_get_hw_semaphore_82574 - Acquire hardware semaphore
633 * @hw: pointer to the HW structure
634 *
635 * Acquire the HW semaphore to access the PHY or NVM.
636 *
637 **/
638static s32 e1000_get_hw_semaphore_82574(struct e1000_hw *hw)
639{
640 s32 ret_val;
641
642 mutex_lock(&swflag_mutex);
643 ret_val = e1000_get_hw_semaphore_82573(hw);
644 if (ret_val)
645 mutex_unlock(&swflag_mutex);
646 return ret_val;
647}
648
649/**
650 * e1000_put_hw_semaphore_82574 - Release hardware semaphore
651 * @hw: pointer to the HW structure
652 *
653 * Release hardware semaphore used to access the PHY or NVM
654 *
655 **/
656static void e1000_put_hw_semaphore_82574(struct e1000_hw *hw)
657{
658 e1000_put_hw_semaphore_82573(hw);
659 mutex_unlock(&swflag_mutex);
660}
661
662/**
663 * e1000_set_d0_lplu_state_82574 - Set Low Power Linkup D0 state
664 * @hw: pointer to the HW structure
665 * @active: true to enable LPLU, false to disable
666 *
667 * Sets the LPLU D0 state according to the active flag.
668 * LPLU will not be activated unless the
669 * device autonegotiation advertisement meets standards of
670 * either 10 or 10/100 or 10/100/1000 at all duplexes.
671 * This is a function pointer entry point only called by
672 * PHY setup routines.
673 **/
674static s32 e1000_set_d0_lplu_state_82574(struct e1000_hw *hw, bool active)
675{
676 u16 data = er32(POEMB);
677
678 if (active)
679 data |= E1000_PHY_CTRL_D0A_LPLU;
680 else
681 data &= ~E1000_PHY_CTRL_D0A_LPLU;
682
683 ew32(POEMB, data);
684 return 0;
685}
686
687/**
688 * e1000_set_d3_lplu_state_82574 - Sets low power link up state for D3
689 * @hw: pointer to the HW structure
690 * @active: boolean used to enable/disable lplu
691 *
692 * The low power link up (lplu) state is set to the power management level D3
693 * when active is true, else clear lplu for D3. LPLU
694 * is used during Dx states where the power conservation is most important.
695 * During driver activity, SmartSpeed should be enabled so performance is
696 * maintained.
697 **/
698static s32 e1000_set_d3_lplu_state_82574(struct e1000_hw *hw, bool active)
699{
700 u16 data = er32(POEMB);
701
702 if (!active) {
703 data &= ~E1000_PHY_CTRL_NOND0A_LPLU;
704 } else if ((hw->phy.autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
705 (hw->phy.autoneg_advertised == E1000_ALL_NOT_GIG) ||
706 (hw->phy.autoneg_advertised == E1000_ALL_10_SPEED)) {
707 data |= E1000_PHY_CTRL_NOND0A_LPLU;
708 }
709
710 ew32(POEMB, data);
711 return 0;
712}
545 713
546/** 714/**
547 * e1000_acquire_nvm_82571 - Request for access to the EEPROM 715 * e1000_acquire_nvm_82571 - Request for access to the EEPROM
@@ -562,8 +730,6 @@ static s32 e1000_acquire_nvm_82571(struct e1000_hw *hw)
562 730
563 switch (hw->mac.type) { 731 switch (hw->mac.type) {
564 case e1000_82573: 732 case e1000_82573:
565 case e1000_82574:
566 case e1000_82583:
567 break; 733 break;
568 default: 734 default:
569 ret_val = e1000e_acquire_nvm(hw); 735 ret_val = e1000e_acquire_nvm(hw);
@@ -853,9 +1019,8 @@ static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)
853 **/ 1019 **/
854static s32 e1000_reset_hw_82571(struct e1000_hw *hw) 1020static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
855{ 1021{
856 u32 ctrl, extcnf_ctrl, ctrl_ext, icr; 1022 u32 ctrl, ctrl_ext;
857 s32 ret_val; 1023 s32 ret_val;
858 u16 i = 0;
859 1024
860 /* 1025 /*
861 * Prevent the PCI-E bus from sticking if there is no TLP connection 1026 * Prevent the PCI-E bus from sticking if there is no TLP connection
@@ -880,33 +1045,33 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
880 */ 1045 */
881 switch (hw->mac.type) { 1046 switch (hw->mac.type) {
882 case e1000_82573: 1047 case e1000_82573:
1048 ret_val = e1000_get_hw_semaphore_82573(hw);
1049 break;
883 case e1000_82574: 1050 case e1000_82574:
884 case e1000_82583: 1051 case e1000_82583:
885 extcnf_ctrl = er32(EXTCNF_CTRL); 1052 ret_val = e1000_get_hw_semaphore_82574(hw);
886 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
887
888 do {
889 ew32(EXTCNF_CTRL, extcnf_ctrl);
890 extcnf_ctrl = er32(EXTCNF_CTRL);
891
892 if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)
893 break;
894
895 extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;
896
897 msleep(2);
898 i++;
899 } while (i < MDIO_OWNERSHIP_TIMEOUT);
900 break; 1053 break;
901 default: 1054 default:
902 break; 1055 break;
903 } 1056 }
1057 if (ret_val)
1058 e_dbg("Cannot acquire MDIO ownership\n");
904 1059
905 ctrl = er32(CTRL); 1060 ctrl = er32(CTRL);
906 1061
907 e_dbg("Issuing a global reset to MAC\n"); 1062 e_dbg("Issuing a global reset to MAC\n");
908 ew32(CTRL, ctrl | E1000_CTRL_RST); 1063 ew32(CTRL, ctrl | E1000_CTRL_RST);
909 1064
1065 /* Must release MDIO ownership and mutex after MAC reset. */
1066 switch (hw->mac.type) {
1067 case e1000_82574:
1068 case e1000_82583:
1069 e1000_put_hw_semaphore_82574(hw);
1070 break;
1071 default:
1072 break;
1073 }
1074
910 if (hw->nvm.type == e1000_nvm_flash_hw) { 1075 if (hw->nvm.type == e1000_nvm_flash_hw) {
911 udelay(10); 1076 udelay(10);
912 ctrl_ext = er32(CTRL_EXT); 1077 ctrl_ext = er32(CTRL_EXT);
@@ -938,7 +1103,7 @@ static s32 e1000_reset_hw_82571(struct e1000_hw *hw)
938 1103
939 /* Clear any pending interrupt events. */ 1104 /* Clear any pending interrupt events. */
940 ew32(IMC, 0xffffffff); 1105 ew32(IMC, 0xffffffff);
941 icr = er32(ICR); 1106 er32(ICR);
942 1107
943 if (hw->mac.type == e1000_82571) { 1108 if (hw->mac.type == e1000_82571) {
944 /* Install any alternate MAC address into RAR0 */ 1109 /* Install any alternate MAC address into RAR0 */
@@ -1402,6 +1567,8 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1402 u32 rxcw; 1567 u32 rxcw;
1403 u32 ctrl; 1568 u32 ctrl;
1404 u32 status; 1569 u32 status;
1570 u32 txcw;
1571 u32 i;
1405 s32 ret_val = 0; 1572 s32 ret_val = 0;
1406 1573
1407 ctrl = er32(CTRL); 1574 ctrl = er32(CTRL);
@@ -1422,8 +1589,10 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1422 e1000_serdes_link_autoneg_progress; 1589 e1000_serdes_link_autoneg_progress;
1423 mac->serdes_has_link = false; 1590 mac->serdes_has_link = false;
1424 e_dbg("AN_UP -> AN_PROG\n"); 1591 e_dbg("AN_UP -> AN_PROG\n");
1592 } else {
1593 mac->serdes_has_link = true;
1425 } 1594 }
1426 break; 1595 break;
1427 1596
1428 case e1000_serdes_link_forced_up: 1597 case e1000_serdes_link_forced_up:
1429 /* 1598 /*
@@ -1431,8 +1600,10 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1431 * auto-negotiation in the TXCW register and disable 1600 * auto-negotiation in the TXCW register and disable
1432 * forced link in the Device Control register in an 1601 * forced link in the Device Control register in an
1433 * attempt to auto-negotiate with our link partner. 1602 * attempt to auto-negotiate with our link partner.
1603 * If the partner code word is null, stop forcing
1604 * and restart auto negotiation.
1434 */ 1605 */
1435 if (rxcw & E1000_RXCW_C) { 1606 if ((rxcw & E1000_RXCW_C) || !(rxcw & E1000_RXCW_CW)) {
1436 /* Enable autoneg, and unforce link up */ 1607 /* Enable autoneg, and unforce link up */
1437 ew32(TXCW, mac->txcw); 1608 ew32(TXCW, mac->txcw);
1438 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); 1609 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
@@ -1440,6 +1611,8 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1440 e1000_serdes_link_autoneg_progress; 1611 e1000_serdes_link_autoneg_progress;
1441 mac->serdes_has_link = false; 1612 mac->serdes_has_link = false;
1442 e_dbg("FORCED_UP -> AN_PROG\n"); 1613 e_dbg("FORCED_UP -> AN_PROG\n");
1614 } else {
1615 mac->serdes_has_link = true;
1443 } 1616 }
1444 break; 1617 break;
1445 1618
@@ -1495,6 +1668,7 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1495 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); 1668 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
1496 mac->serdes_link_state = 1669 mac->serdes_link_state =
1497 e1000_serdes_link_autoneg_progress; 1670 e1000_serdes_link_autoneg_progress;
1671 mac->serdes_has_link = false;
1498 e_dbg("DOWN -> AN_PROG\n"); 1672 e_dbg("DOWN -> AN_PROG\n");
1499 break; 1673 break;
1500 } 1674 }
@@ -1505,16 +1679,32 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)
1505 e_dbg("ANYSTATE -> DOWN\n"); 1679 e_dbg("ANYSTATE -> DOWN\n");
1506 } else { 1680 } else {
1507 /* 1681 /*
1508 * We have sync, and can tolerate one invalid (IV) 1682 * Check several times, if Sync and Config
1509 * codeword before declaring link down, so reread 1683 * both are consistently 1 then simply ignore
1510 * to look again. 1684 * the Invalid bit and restart Autoneg
1511 */ 1685 */
1512 udelay(10); 1686 for (i = 0; i < AN_RETRY_COUNT; i++) {
1513 rxcw = er32(RXCW); 1687 udelay(10);
1514 if (rxcw & E1000_RXCW_IV) { 1688 rxcw = er32(RXCW);
1515 mac->serdes_link_state = e1000_serdes_link_down; 1689 if ((rxcw & E1000_RXCW_IV) &&
1690 !((rxcw & E1000_RXCW_SYNCH) &&
1691 (rxcw & E1000_RXCW_C))) {
1692 mac->serdes_has_link = false;
1693 mac->serdes_link_state =
1694 e1000_serdes_link_down;
1695 e_dbg("ANYSTATE -> DOWN\n");
1696 break;
1697 }
1698 }
1699
1700 if (i == AN_RETRY_COUNT) {
1701 txcw = er32(TXCW);
1702 txcw |= E1000_TXCW_ANE;
1703 ew32(TXCW, txcw);
1704 mac->serdes_link_state =
1705 e1000_serdes_link_autoneg_progress;
1516 mac->serdes_has_link = false; 1706 mac->serdes_has_link = false;
1517 e_dbg("ANYSTATE -> DOWN\n"); 1707 e_dbg("ANYSTATE -> AN_PROG\n");
1518 } 1708 }
1519 } 1709 }
1520 } 1710 }
@@ -1897,7 +2087,7 @@ struct e1000_info e1000_82574_info = {
1897 | FLAG_HAS_AMT 2087 | FLAG_HAS_AMT
1898 | FLAG_HAS_CTRLEXT_ON_LOAD, 2088 | FLAG_HAS_CTRLEXT_ON_LOAD,
1899 .flags2 = FLAG2_CHECK_PHY_HANG, 2089 .flags2 = FLAG2_CHECK_PHY_HANG,
1900 .pba = 36, 2090 .pba = 32,
1901 .max_hw_frame_size = DEFAULT_JUMBO, 2091 .max_hw_frame_size = DEFAULT_JUMBO,
1902 .get_variants = e1000_get_variants_82571, 2092 .get_variants = e1000_get_variants_82571,
1903 .mac_ops = &e82571_mac_ops, 2093 .mac_ops = &e82571_mac_ops,
@@ -1914,7 +2104,7 @@ struct e1000_info e1000_82583_info = {
1914 | FLAG_HAS_SMART_POWER_DOWN 2104 | FLAG_HAS_SMART_POWER_DOWN
1915 | FLAG_HAS_AMT 2105 | FLAG_HAS_AMT
1916 | FLAG_HAS_CTRLEXT_ON_LOAD, 2106 | FLAG_HAS_CTRLEXT_ON_LOAD,
1917 .pba = 36, 2107 .pba = 32,
1918 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN, 2108 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
1919 .get_variants = e1000_get_variants_82571, 2109 .get_variants = e1000_get_variants_82571,
1920 .mac_ops = &e82571_mac_ops, 2110 .mac_ops = &e82571_mac_ops,