aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000e/lib.c')
-rw-r--r--drivers/net/e1000e/lib.c186
1 files changed, 137 insertions, 49 deletions
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index 0fd4eb5ac5fb..dd8ab05b5590 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 2
3 Intel PRO/1000 Linux driver 3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2010 Intel Corporation. 4 Copyright(c) 1999 - 2011 Intel Corporation.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License, 7 under the terms and conditions of the GNU General Public License,
@@ -144,7 +144,7 @@ void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value)
144 * @hw: pointer to the HW structure 144 * @hw: pointer to the HW structure
145 * @rar_count: receive address registers 145 * @rar_count: receive address registers
146 * 146 *
147 * Setups the receive address registers by setting the base receive address 147 * Setup the receive address registers by setting the base receive address
148 * register to the devices MAC address and clearing all the other receive 148 * register to the devices MAC address and clearing all the other receive
149 * address registers to 0. 149 * address registers to 0.
150 **/ 150 **/
@@ -493,9 +493,8 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
493 * different link partner. 493 * different link partner.
494 */ 494 */
495 ret_val = e1000e_config_fc_after_link_up(hw); 495 ret_val = e1000e_config_fc_after_link_up(hw);
496 if (ret_val) { 496 if (ret_val)
497 e_dbg("Error configuring flow control\n"); 497 e_dbg("Error configuring flow control\n");
498 }
499 498
500 return ret_val; 499 return ret_val;
501} 500}
@@ -534,7 +533,7 @@ s32 e1000e_check_for_fiber_link(struct e1000_hw *hw)
534 mac->autoneg_failed = 1; 533 mac->autoneg_failed = 1;
535 return 0; 534 return 0;
536 } 535 }
537 e_dbg("NOT RXing /C/, disable AutoNeg and force link.\n"); 536 e_dbg("NOT Rx'ing /C/, disable AutoNeg and force link.\n");
538 537
539 /* Disable auto-negotiation in the TXCW register */ 538 /* Disable auto-negotiation in the TXCW register */
540 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE)); 539 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
@@ -557,7 +556,7 @@ s32 e1000e_check_for_fiber_link(struct e1000_hw *hw)
557 * and disable forced link in the Device Control register 556 * and disable forced link in the Device Control register
558 * in an attempt to auto-negotiate with our link partner. 557 * in an attempt to auto-negotiate with our link partner.
559 */ 558 */
560 e_dbg("RXing /C/, enable AutoNeg and stop forcing link.\n"); 559 e_dbg("Rx'ing /C/, enable AutoNeg and stop forcing link.\n");
561 ew32(TXCW, mac->txcw); 560 ew32(TXCW, mac->txcw);
562 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); 561 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
563 562
@@ -599,7 +598,7 @@ s32 e1000e_check_for_serdes_link(struct e1000_hw *hw)
599 mac->autoneg_failed = 1; 598 mac->autoneg_failed = 1;
600 return 0; 599 return 0;
601 } 600 }
602 e_dbg("NOT RXing /C/, disable AutoNeg and force link.\n"); 601 e_dbg("NOT Rx'ing /C/, disable AutoNeg and force link.\n");
603 602
604 /* Disable auto-negotiation in the TXCW register */ 603 /* Disable auto-negotiation in the TXCW register */
605 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE)); 604 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE));
@@ -622,7 +621,7 @@ s32 e1000e_check_for_serdes_link(struct e1000_hw *hw)
622 * and disable forced link in the Device Control register 621 * and disable forced link in the Device Control register
623 * in an attempt to auto-negotiate with our link partner. 622 * in an attempt to auto-negotiate with our link partner.
624 */ 623 */
625 e_dbg("RXing /C/, enable AutoNeg and stop forcing link.\n"); 624 e_dbg("Rx'ing /C/, enable AutoNeg and stop forcing link.\n");
626 ew32(TXCW, mac->txcw); 625 ew32(TXCW, mac->txcw);
627 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); 626 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU));
628 627
@@ -801,9 +800,9 @@ static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw)
801 * The possible values of the "fc" parameter are: 800 * The possible values of the "fc" parameter are:
802 * 0: Flow control is completely disabled 801 * 0: Flow control is completely disabled
803 * 1: Rx flow control is enabled (we can receive pause frames, 802 * 1: Rx flow control is enabled (we can receive pause frames,
804 * but not send pause frames). 803 * but not send pause frames).
805 * 2: Tx flow control is enabled (we can send pause frames but we 804 * 2: Tx flow control is enabled (we can send pause frames but we
806 * do not support receiving pause frames). 805 * do not support receiving pause frames).
807 * 3: Both Rx and Tx flow control (symmetric) are enabled. 806 * 3: Both Rx and Tx flow control (symmetric) are enabled.
808 */ 807 */
809 switch (hw->fc.current_mode) { 808 switch (hw->fc.current_mode) {
@@ -869,7 +868,7 @@ static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw)
869 * milliseconds even if the other end is doing it in SW). 868 * milliseconds even if the other end is doing it in SW).
870 */ 869 */
871 for (i = 0; i < FIBER_LINK_UP_LIMIT; i++) { 870 for (i = 0; i < FIBER_LINK_UP_LIMIT; i++) {
872 msleep(10); 871 usleep_range(10000, 20000);
873 status = er32(STATUS); 872 status = er32(STATUS);
874 if (status & E1000_STATUS_LU) 873 if (status & E1000_STATUS_LU)
875 break; 874 break;
@@ -931,7 +930,7 @@ s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw)
931 930
932 ew32(CTRL, ctrl); 931 ew32(CTRL, ctrl);
933 e1e_flush(); 932 e1e_flush();
934 msleep(1); 933 usleep_range(1000, 2000);
935 934
936 /* 935 /*
937 * For these adapters, the SW definable pin 1 is set when the optics 936 * For these adapters, the SW definable pin 1 is set when the optics
@@ -1032,9 +1031,9 @@ s32 e1000e_force_mac_fc(struct e1000_hw *hw)
1032 * The possible values of the "fc" parameter are: 1031 * The possible values of the "fc" parameter are:
1033 * 0: Flow control is completely disabled 1032 * 0: Flow control is completely disabled
1034 * 1: Rx flow control is enabled (we can receive pause 1033 * 1: Rx flow control is enabled (we can receive pause
1035 * frames but not send pause frames). 1034 * frames but not send pause frames).
1036 * 2: Tx flow control is enabled (we can send pause frames 1035 * 2: Tx flow control is enabled (we can send pause frames
1037 * frames but we do not receive pause frames). 1036 * frames but we do not receive pause frames).
1038 * 3: Both Rx and Tx flow control (symmetric) is enabled. 1037 * 3: Both Rx and Tx flow control (symmetric) is enabled.
1039 * other: No other values should be possible at this point. 1038 * other: No other values should be possible at this point.
1040 */ 1039 */
@@ -1136,7 +1135,8 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1136 ret_val = e1e_rphy(hw, PHY_AUTONEG_ADV, &mii_nway_adv_reg); 1135 ret_val = e1e_rphy(hw, PHY_AUTONEG_ADV, &mii_nway_adv_reg);
1137 if (ret_val) 1136 if (ret_val)
1138 return ret_val; 1137 return ret_val;
1139 ret_val = e1e_rphy(hw, PHY_LP_ABILITY, &mii_nway_lp_ability_reg); 1138 ret_val =
1139 e1e_rphy(hw, PHY_LP_ABILITY, &mii_nway_lp_ability_reg);
1140 if (ret_val) 1140 if (ret_val)
1141 return ret_val; 1141 return ret_val;
1142 1142
@@ -1181,7 +1181,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1181 * of pause frames. In this case, we had to advertise 1181 * of pause frames. In this case, we had to advertise
1182 * FULL flow control because we could not advertise Rx 1182 * FULL flow control because we could not advertise Rx
1183 * ONLY. Hence, we must now check to see if we need to 1183 * ONLY. Hence, we must now check to see if we need to
1184 * turn OFF the TRANSMISSION of PAUSE frames. 1184 * turn OFF the TRANSMISSION of PAUSE frames.
1185 */ 1185 */
1186 if (hw->fc.requested_mode == e1000_fc_full) { 1186 if (hw->fc.requested_mode == e1000_fc_full) {
1187 hw->fc.current_mode = e1000_fc_full; 1187 hw->fc.current_mode = e1000_fc_full;
@@ -1189,7 +1189,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)
1189 } else { 1189 } else {
1190 hw->fc.current_mode = e1000_fc_rx_pause; 1190 hw->fc.current_mode = e1000_fc_rx_pause;
1191 e_dbg("Flow Control = " 1191 e_dbg("Flow Control = "
1192 "RX PAUSE frames only.\r\n"); 1192 "Rx PAUSE frames only.\r\n");
1193 } 1193 }
1194 } 1194 }
1195 /* 1195 /*
@@ -1385,7 +1385,7 @@ s32 e1000e_get_auto_rd_done(struct e1000_hw *hw)
1385 while (i < AUTO_READ_DONE_TIMEOUT) { 1385 while (i < AUTO_READ_DONE_TIMEOUT) {
1386 if (er32(EECD) & E1000_EECD_AUTO_RD) 1386 if (er32(EECD) & E1000_EECD_AUTO_RD)
1387 break; 1387 break;
1388 msleep(1); 1388 usleep_range(1000, 2000);
1389 i++; 1389 i++;
1390 } 1390 }
1391 1391
@@ -1496,9 +1496,8 @@ s32 e1000e_setup_led_generic(struct e1000_hw *hw)
1496{ 1496{
1497 u32 ledctl; 1497 u32 ledctl;
1498 1498
1499 if (hw->mac.ops.setup_led != e1000e_setup_led_generic) { 1499 if (hw->mac.ops.setup_led != e1000e_setup_led_generic)
1500 return -E1000_ERR_CONFIG; 1500 return -E1000_ERR_CONFIG;
1501 }
1502 1501
1503 if (hw->phy.media_type == e1000_media_type_fiber) { 1502 if (hw->phy.media_type == e1000_media_type_fiber) {
1504 ledctl = er32(LEDCTL); 1503 ledctl = er32(LEDCTL);
@@ -1531,12 +1530,12 @@ s32 e1000e_cleanup_led_generic(struct e1000_hw *hw)
1531} 1530}
1532 1531
1533/** 1532/**
1534 * e1000e_blink_led - Blink LED 1533 * e1000e_blink_led_generic - Blink LED
1535 * @hw: pointer to the HW structure 1534 * @hw: pointer to the HW structure
1536 * 1535 *
1537 * Blink the LEDs which are set to be on. 1536 * Blink the LEDs which are set to be on.
1538 **/ 1537 **/
1539s32 e1000e_blink_led(struct e1000_hw *hw) 1538s32 e1000e_blink_led_generic(struct e1000_hw *hw)
1540{ 1539{
1541 u32 ledctl_blink = 0; 1540 u32 ledctl_blink = 0;
1542 u32 i; 1541 u32 i;
@@ -1979,15 +1978,15 @@ static s32 e1000_ready_nvm_eeprom(struct e1000_hw *hw)
1979{ 1978{
1980 struct e1000_nvm_info *nvm = &hw->nvm; 1979 struct e1000_nvm_info *nvm = &hw->nvm;
1981 u32 eecd = er32(EECD); 1980 u32 eecd = er32(EECD);
1982 u16 timeout = 0;
1983 u8 spi_stat_reg; 1981 u8 spi_stat_reg;
1984 1982
1985 if (nvm->type == e1000_nvm_eeprom_spi) { 1983 if (nvm->type == e1000_nvm_eeprom_spi) {
1984 u16 timeout = NVM_MAX_RETRY_SPI;
1985
1986 /* Clear SK and CS */ 1986 /* Clear SK and CS */
1987 eecd &= ~(E1000_EECD_CS | E1000_EECD_SK); 1987 eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
1988 ew32(EECD, eecd); 1988 ew32(EECD, eecd);
1989 udelay(1); 1989 udelay(1);
1990 timeout = NVM_MAX_RETRY_SPI;
1991 1990
1992 /* 1991 /*
1993 * Read "Status Register" repeatedly until the LSB is cleared. 1992 * Read "Status Register" repeatedly until the LSB is cleared.
@@ -2088,8 +2087,6 @@ s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
2088 if (ret_val) 2087 if (ret_val)
2089 return ret_val; 2088 return ret_val;
2090 2089
2091 msleep(10);
2092
2093 while (widx < words) { 2090 while (widx < words) {
2094 u8 write_opcode = NVM_WRITE_OPCODE_SPI; 2091 u8 write_opcode = NVM_WRITE_OPCODE_SPI;
2095 2092
@@ -2133,12 +2130,125 @@ s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
2133 } 2130 }
2134 } 2131 }
2135 2132
2136 msleep(10); 2133 usleep_range(10000, 20000);
2137 nvm->ops.release(hw); 2134 nvm->ops.release(hw);
2138 return 0; 2135 return 0;
2139} 2136}
2140 2137
2141/** 2138/**
2139 * e1000_read_pba_string_generic - Read device part number
2140 * @hw: pointer to the HW structure
2141 * @pba_num: pointer to device part number
2142 * @pba_num_size: size of part number buffer
2143 *
2144 * Reads the product board assembly (PBA) number from the EEPROM and stores
2145 * the value in pba_num.
2146 **/
2147s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num,
2148 u32 pba_num_size)
2149{
2150 s32 ret_val;
2151 u16 nvm_data;
2152 u16 pba_ptr;
2153 u16 offset;
2154 u16 length;
2155
2156 if (pba_num == NULL) {
2157 e_dbg("PBA string buffer was null\n");
2158 ret_val = E1000_ERR_INVALID_ARGUMENT;
2159 goto out;
2160 }
2161
2162 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
2163 if (ret_val) {
2164 e_dbg("NVM Read Error\n");
2165 goto out;
2166 }
2167
2168 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &pba_ptr);
2169 if (ret_val) {
2170 e_dbg("NVM Read Error\n");
2171 goto out;
2172 }
2173
2174 /*
2175 * if nvm_data is not ptr guard the PBA must be in legacy format which
2176 * means pba_ptr is actually our second data word for the PBA number
2177 * and we can decode it into an ascii string
2178 */
2179 if (nvm_data != NVM_PBA_PTR_GUARD) {
2180 e_dbg("NVM PBA number is not stored as string\n");
2181
2182 /* we will need 11 characters to store the PBA */
2183 if (pba_num_size < 11) {
2184 e_dbg("PBA string buffer too small\n");
2185 return E1000_ERR_NO_SPACE;
2186 }
2187
2188 /* extract hex string from data and pba_ptr */
2189 pba_num[0] = (nvm_data >> 12) & 0xF;
2190 pba_num[1] = (nvm_data >> 8) & 0xF;
2191 pba_num[2] = (nvm_data >> 4) & 0xF;
2192 pba_num[3] = nvm_data & 0xF;
2193 pba_num[4] = (pba_ptr >> 12) & 0xF;
2194 pba_num[5] = (pba_ptr >> 8) & 0xF;
2195 pba_num[6] = '-';
2196 pba_num[7] = 0;
2197 pba_num[8] = (pba_ptr >> 4) & 0xF;
2198 pba_num[9] = pba_ptr & 0xF;
2199
2200 /* put a null character on the end of our string */
2201 pba_num[10] = '\0';
2202
2203 /* switch all the data but the '-' to hex char */
2204 for (offset = 0; offset < 10; offset++) {
2205 if (pba_num[offset] < 0xA)
2206 pba_num[offset] += '0';
2207 else if (pba_num[offset] < 0x10)
2208 pba_num[offset] += 'A' - 0xA;
2209 }
2210
2211 goto out;
2212 }
2213
2214 ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length);
2215 if (ret_val) {
2216 e_dbg("NVM Read Error\n");
2217 goto out;
2218 }
2219
2220 if (length == 0xFFFF || length == 0) {
2221 e_dbg("NVM PBA number section invalid length\n");
2222 ret_val = E1000_ERR_NVM_PBA_SECTION;
2223 goto out;
2224 }
2225 /* check if pba_num buffer is big enough */
2226 if (pba_num_size < (((u32)length * 2) - 1)) {
2227 e_dbg("PBA string buffer too small\n");
2228 ret_val = E1000_ERR_NO_SPACE;
2229 goto out;
2230 }
2231
2232 /* trim pba length from start of string */
2233 pba_ptr++;
2234 length--;
2235
2236 for (offset = 0; offset < length; offset++) {
2237 ret_val = e1000_read_nvm(hw, pba_ptr + offset, 1, &nvm_data);
2238 if (ret_val) {
2239 e_dbg("NVM Read Error\n");
2240 goto out;
2241 }
2242 pba_num[offset * 2] = (u8)(nvm_data >> 8);
2243 pba_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF);
2244 }
2245 pba_num[offset * 2] = '\0';
2246
2247out:
2248 return ret_val;
2249}
2250
2251/**
2142 * e1000_read_mac_addr_generic - Read device MAC address 2252 * e1000_read_mac_addr_generic - Read device MAC address
2143 * @hw: pointer to the HW structure 2253 * @hw: pointer to the HW structure
2144 * 2254 *
@@ -2579,25 +2689,3 @@ bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw)
2579out: 2689out:
2580 return ret_val; 2690 return ret_val;
2581} 2691}
2582
2583s32 e1000e_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
2584{
2585 s32 ret_val;
2586 u16 nvm_data;
2587
2588 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
2589 if (ret_val) {
2590 e_dbg("NVM Read Error\n");
2591 return ret_val;
2592 }
2593 *pba_num = (u32)(nvm_data << 16);
2594
2595 ret_val = e1000_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &nvm_data);
2596 if (ret_val) {
2597 e_dbg("NVM Read Error\n");
2598 return ret_val;
2599 }
2600 *pba_num |= nvm_data;
2601
2602 return 0;
2603}