aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e/ich8lan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000e/ich8lan.c')
-rw-r--r--drivers/net/e1000e/ich8lan.c173
1 files changed, 162 insertions, 11 deletions
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 9e38452a738c..019b9c0bcdcb 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -43,7 +43,9 @@
43 * 82567LM-2 Gigabit Network Connection 43 * 82567LM-2 Gigabit Network Connection
44 * 82567LF-2 Gigabit Network Connection 44 * 82567LF-2 Gigabit Network Connection
45 * 82567V-2 Gigabit Network Connection 45 * 82567V-2 Gigabit Network Connection
46 * 82562GT-3 10/100 Network Connection 46 * 82567LF-3 Gigabit Network Connection
47 * 82567LM-3 Gigabit Network Connection
48 * 82567LM-4 Gigabit Network Connection
47 */ 49 */
48 50
49#include <linux/netdevice.h> 51#include <linux/netdevice.h>
@@ -157,12 +159,15 @@ static s32 e1000_check_polarity_ife_ich8lan(struct e1000_hw *hw);
157static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank); 159static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank);
158static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw, 160static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw,
159 u32 offset, u8 byte); 161 u32 offset, u8 byte);
162static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
163 u8 *data);
160static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset, 164static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
161 u16 *data); 165 u16 *data);
162static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, 166static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
163 u8 size, u16 *data); 167 u8 size, u16 *data);
164static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw); 168static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
165static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw); 169static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
170static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
166 171
167static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg) 172static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
168{ 173{
@@ -417,6 +422,22 @@ static void e1000_release_swflag_ich8lan(struct e1000_hw *hw)
417} 422}
418 423
419/** 424/**
425 * e1000_check_mng_mode_ich8lan - Checks management mode
426 * @hw: pointer to the HW structure
427 *
428 * This checks if the adapter has manageability enabled.
429 * This is a function pointer entry point only called by read/write
430 * routines for the PHY and NVM parts.
431 **/
432static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw)
433{
434 u32 fwsm = er32(FWSM);
435
436 return (fwsm & E1000_FWSM_MODE_MASK) ==
437 (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT);
438}
439
440/**
420 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked 441 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
421 * @hw: pointer to the HW structure 442 * @hw: pointer to the HW structure
422 * 443 *
@@ -897,6 +918,56 @@ static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
897} 918}
898 919
899/** 920/**
921 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
922 * @hw: pointer to the HW structure
923 * @bank: pointer to the variable that returns the active bank
924 *
925 * Reads signature byte from the NVM using the flash access registers.
926 **/
927static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank)
928{
929 struct e1000_nvm_info *nvm = &hw->nvm;
930 /* flash bank size is in words */
931 u32 bank1_offset = nvm->flash_bank_size * sizeof(u16);
932 u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1;
933 u8 bank_high_byte = 0;
934
935 if (hw->mac.type != e1000_ich10lan) {
936 if (er32(EECD) & E1000_EECD_SEC1VAL)
937 *bank = 1;
938 else
939 *bank = 0;
940 } else {
941 /*
942 * Make sure the signature for bank 0 is valid,
943 * if not check for bank1
944 */
945 e1000_read_flash_byte_ich8lan(hw, act_offset, &bank_high_byte);
946 if ((bank_high_byte & 0xC0) == 0x80) {
947 *bank = 0;
948 } else {
949 /*
950 * find if segment 1 is valid by verifying
951 * bit 15:14 = 10b in word 0x13
952 */
953 e1000_read_flash_byte_ich8lan(hw,
954 act_offset + bank1_offset,
955 &bank_high_byte);
956
957 /* bank1 has a valid signature equivalent to SEC1V */
958 if ((bank_high_byte & 0xC0) == 0x80) {
959 *bank = 1;
960 } else {
961 hw_dbg(hw, "ERROR: EEPROM not present\n");
962 return -E1000_ERR_NVM;
963 }
964 }
965 }
966
967 return 0;
968}
969
970/**
900 * e1000_read_nvm_ich8lan - Read word(s) from the NVM 971 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
901 * @hw: pointer to the HW structure 972 * @hw: pointer to the HW structure
902 * @offset: The offset (in bytes) of the word(s) to read. 973 * @offset: The offset (in bytes) of the word(s) to read.
@@ -912,6 +983,7 @@ static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
912 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 983 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
913 u32 act_offset; 984 u32 act_offset;
914 s32 ret_val; 985 s32 ret_val;
986 u32 bank = 0;
915 u16 i, word; 987 u16 i, word;
916 988
917 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || 989 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
@@ -924,10 +996,11 @@ static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
924 if (ret_val) 996 if (ret_val)
925 return ret_val; 997 return ret_val;
926 998
927 /* Start with the bank offset, then add the relative offset. */ 999 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
928 act_offset = (er32(EECD) & E1000_EECD_SEC1VAL) 1000 if (ret_val)
929 ? nvm->flash_bank_size 1001 return ret_val;
930 : 0; 1002
1003 act_offset = (bank) ? nvm->flash_bank_size : 0;
931 act_offset += offset; 1004 act_offset += offset;
932 1005
933 for (i = 0; i < words; i++) { 1006 for (i = 0; i < words; i++) {
@@ -1075,6 +1148,29 @@ static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,
1075} 1148}
1076 1149
1077/** 1150/**
1151 * e1000_read_flash_byte_ich8lan - Read byte from flash
1152 * @hw: pointer to the HW structure
1153 * @offset: The offset of the byte to read.
1154 * @data: Pointer to a byte to store the value read.
1155 *
1156 * Reads a single byte from the NVM using the flash access registers.
1157 **/
1158static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset,
1159 u8 *data)
1160{
1161 s32 ret_val;
1162 u16 word = 0;
1163
1164 ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word);
1165 if (ret_val)
1166 return ret_val;
1167
1168 *data = (u8)word;
1169
1170 return 0;
1171}
1172
1173/**
1078 * e1000_read_flash_data_ich8lan - Read byte or word from NVM 1174 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
1079 * @hw: pointer to the HW structure 1175 * @hw: pointer to the HW structure
1080 * @offset: The offset (in bytes) of the byte or word to read. 1176 * @offset: The offset (in bytes) of the byte or word to read.
@@ -1205,7 +1301,7 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
1205{ 1301{
1206 struct e1000_nvm_info *nvm = &hw->nvm; 1302 struct e1000_nvm_info *nvm = &hw->nvm;
1207 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 1303 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
1208 u32 i, act_offset, new_bank_offset, old_bank_offset; 1304 u32 i, act_offset, new_bank_offset, old_bank_offset, bank;
1209 s32 ret_val; 1305 s32 ret_val;
1210 u16 data; 1306 u16 data;
1211 1307
@@ -1225,7 +1321,11 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
1225 * write to bank 0 etc. We also need to erase the segment that 1321 * write to bank 0 etc. We also need to erase the segment that
1226 * is going to be written 1322 * is going to be written
1227 */ 1323 */
1228 if (!(er32(EECD) & E1000_EECD_SEC1VAL)) { 1324 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
1325 if (ret_val)
1326 return ret_val;
1327
1328 if (bank == 0) {
1229 new_bank_offset = nvm->flash_bank_size; 1329 new_bank_offset = nvm->flash_bank_size;
1230 old_bank_offset = 0; 1330 old_bank_offset = 0;
1231 e1000_erase_flash_bank_ich8lan(hw, 1); 1331 e1000_erase_flash_bank_ich8lan(hw, 1);
@@ -2189,13 +2289,14 @@ void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
2189 * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation 2289 * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation
2190 * to a lower speed. 2290 * to a lower speed.
2191 * 2291 *
2192 * Should only be called for ICH9 devices. 2292 * Should only be called for ICH9 and ICH10 devices.
2193 **/ 2293 **/
2194void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw) 2294void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw)
2195{ 2295{
2196 u32 phy_ctrl; 2296 u32 phy_ctrl;
2197 2297
2198 if (hw->mac.type == e1000_ich9lan) { 2298 if ((hw->mac.type == e1000_ich10lan) ||
2299 (hw->mac.type == e1000_ich9lan)) {
2199 phy_ctrl = er32(PHY_CTRL); 2300 phy_ctrl = er32(PHY_CTRL);
2200 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU | 2301 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU |
2201 E1000_PHY_CTRL_GBE_DISABLE; 2302 E1000_PHY_CTRL_GBE_DISABLE;
@@ -2253,6 +2354,39 @@ static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
2253} 2354}
2254 2355
2255/** 2356/**
2357 * e1000_get_cfg_done_ich8lan - Read config done bit
2358 * @hw: pointer to the HW structure
2359 *
2360 * Read the management control register for the config done bit for
2361 * completion status. NOTE: silicon which is EEPROM-less will fail trying
2362 * to read the config done bit, so an error is *ONLY* logged and returns
2363 * E1000_SUCCESS. If we were to return with error, EEPROM-less silicon
2364 * would not be able to be reset or change link.
2365 **/
2366static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
2367{
2368 u32 bank = 0;
2369
2370 e1000e_get_cfg_done(hw);
2371
2372 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
2373 if (hw->mac.type != e1000_ich10lan) {
2374 if (((er32(EECD) & E1000_EECD_PRES) == 0) &&
2375 (hw->phy.type == e1000_phy_igp_3)) {
2376 e1000e_phy_init_script_igp3(hw);
2377 }
2378 } else {
2379 if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) {
2380 /* Maybe we should do a basic PHY config */
2381 hw_dbg(hw, "EEPROM not present\n");
2382 return -E1000_ERR_CONFIG;
2383 }
2384 }
2385
2386 return 0;
2387}
2388
2389/**
2256 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters 2390 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
2257 * @hw: pointer to the HW structure 2391 * @hw: pointer to the HW structure
2258 * 2392 *
@@ -2282,7 +2416,7 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
2282} 2416}
2283 2417
2284static struct e1000_mac_operations ich8_mac_ops = { 2418static struct e1000_mac_operations ich8_mac_ops = {
2285 .mng_mode_enab = E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT, 2419 .check_mng_mode = e1000_check_mng_mode_ich8lan,
2286 .check_for_link = e1000e_check_for_copper_link, 2420 .check_for_link = e1000e_check_for_copper_link,
2287 .cleanup_led = e1000_cleanup_led_ich8lan, 2421 .cleanup_led = e1000_cleanup_led_ich8lan,
2288 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan, 2422 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
@@ -2302,7 +2436,7 @@ static struct e1000_phy_operations ich8_phy_ops = {
2302 .check_reset_block = e1000_check_reset_block_ich8lan, 2436 .check_reset_block = e1000_check_reset_block_ich8lan,
2303 .commit_phy = NULL, 2437 .commit_phy = NULL,
2304 .force_speed_duplex = e1000_phy_force_speed_duplex_ich8lan, 2438 .force_speed_duplex = e1000_phy_force_speed_duplex_ich8lan,
2305 .get_cfg_done = e1000e_get_cfg_done, 2439 .get_cfg_done = e1000_get_cfg_done_ich8lan,
2306 .get_cable_length = e1000e_get_cable_length_igp_2, 2440 .get_cable_length = e1000e_get_cable_length_igp_2,
2307 .get_phy_info = e1000_get_phy_info_ich8lan, 2441 .get_phy_info = e1000_get_phy_info_ich8lan,
2308 .read_phy_reg = e1000e_read_phy_reg_igp, 2442 .read_phy_reg = e1000e_read_phy_reg_igp,
@@ -2357,3 +2491,20 @@ struct e1000_info e1000_ich9_info = {
2357 .nvm_ops = &ich8_nvm_ops, 2491 .nvm_ops = &ich8_nvm_ops,
2358}; 2492};
2359 2493
2494struct e1000_info e1000_ich10_info = {
2495 .mac = e1000_ich10lan,
2496 .flags = FLAG_HAS_JUMBO_FRAMES
2497 | FLAG_IS_ICH
2498 | FLAG_HAS_WOL
2499 | FLAG_RX_CSUM_ENABLED
2500 | FLAG_HAS_CTRLEXT_ON_LOAD
2501 | FLAG_HAS_AMT
2502 | FLAG_HAS_ERT
2503 | FLAG_HAS_FLASH
2504 | FLAG_APME_IN_WUC,
2505 .pba = 10,
2506 .get_variants = e1000_get_variants_ich8lan,
2507 .mac_ops = &ich8_mac_ops,
2508 .phy_ops = &ich8_phy_ops,
2509 .nvm_ops = &ich8_nvm_ops,
2510};