00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 FILE_LICENCE ( GPL2_OR_LATER );
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include "e1000_api.h"
00041
00042 static s32 e1000_init_phy_params_82543(struct e1000_hw *hw);
00043 static s32 e1000_init_nvm_params_82543(struct e1000_hw *hw);
00044 static s32 e1000_init_mac_params_82543(struct e1000_hw *hw);
00045 static s32 e1000_read_phy_reg_82543(struct e1000_hw *hw, u32 offset,
00046 u16 *data);
00047 static s32 e1000_write_phy_reg_82543(struct e1000_hw *hw, u32 offset,
00048 u16 data);
00049 #if 0
00050 static s32 e1000_phy_force_speed_duplex_82543(struct e1000_hw *hw);
00051 #endif
00052 static s32 e1000_phy_hw_reset_82543(struct e1000_hw *hw);
00053 static s32 e1000_reset_hw_82543(struct e1000_hw *hw);
00054 static s32 e1000_init_hw_82543(struct e1000_hw *hw);
00055 static s32 e1000_setup_link_82543(struct e1000_hw *hw);
00056 static s32 e1000_setup_copper_link_82543(struct e1000_hw *hw);
00057 static s32 e1000_setup_fiber_link_82543(struct e1000_hw *hw);
00058 static s32 e1000_check_for_copper_link_82543(struct e1000_hw *hw);
00059 static s32 e1000_check_for_fiber_link_82543(struct e1000_hw *hw);
00060 static s32 e1000_led_on_82543(struct e1000_hw *hw);
00061 static s32 e1000_led_off_82543(struct e1000_hw *hw);
00062 static void e1000_write_vfta_82543(struct e1000_hw *hw, u32 offset,
00063 u32 value);
00064 static void e1000_mta_set_82543(struct e1000_hw *hw, u32 hash_value);
00065 static void e1000_clear_hw_cntrs_82543(struct e1000_hw *hw);
00066 static s32 e1000_config_mac_to_phy_82543(struct e1000_hw *hw);
00067 static bool e1000_init_phy_disabled_82543(struct e1000_hw *hw);
00068 static void e1000_lower_mdi_clk_82543(struct e1000_hw *hw, u32 *ctrl);
00069 static s32 e1000_polarity_reversal_workaround_82543(struct e1000_hw *hw);
00070 static void e1000_raise_mdi_clk_82543(struct e1000_hw *hw, u32 *ctrl);
00071 static u16 e1000_shift_in_mdi_bits_82543(struct e1000_hw *hw);
00072 static void e1000_shift_out_mdi_bits_82543(struct e1000_hw *hw, u32 data,
00073 u16 count);
00074 static bool e1000_tbi_compatibility_enabled_82543(struct e1000_hw *hw);
00075 static void e1000_set_tbi_compatibility_82543(struct e1000_hw *hw, bool state);
00076 static void e1000_set_tbi_sbp_82543(struct e1000_hw *hw, bool state);
00077
00078
00079
00080
00081
00082 static s32 e1000_init_phy_params_82543(struct e1000_hw *hw)
00083 {
00084 struct e1000_phy_info *phy = &hw->phy;
00085 s32 ret_val = E1000_SUCCESS;
00086
00087 DEBUGFUNC("e1000_init_phy_params_82543");
00088
00089 if (hw->phy.media_type != e1000_media_type_copper) {
00090 phy->type = e1000_phy_none;
00091 goto out;
00092 } else {
00093 phy->ops.power_up = e1000_power_up_phy_copper;
00094 phy->ops.power_down = e1000_power_down_phy_copper;
00095 }
00096
00097 phy->addr = 1;
00098 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
00099 phy->reset_delay_us = 10000;
00100 phy->type = e1000_phy_m88;
00101
00102
00103 phy->ops.check_polarity = e1000_check_polarity_m88;
00104 phy->ops.commit = e1000_phy_sw_reset_generic;
00105 #if 0
00106 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_82543;
00107 #endif
00108 #if 0
00109 phy->ops.get_cable_length = e1000_get_cable_length_m88;
00110 #endif
00111 phy->ops.get_cfg_done = e1000_get_cfg_done_generic;
00112 phy->ops.read_reg = (hw->mac.type == e1000_82543)
00113 ? e1000_read_phy_reg_82543
00114 : e1000_read_phy_reg_m88;
00115 phy->ops.reset = (hw->mac.type == e1000_82543)
00116 ? e1000_phy_hw_reset_82543
00117 : e1000_phy_hw_reset_generic;
00118 phy->ops.write_reg = (hw->mac.type == e1000_82543)
00119 ? e1000_write_phy_reg_82543
00120 : e1000_write_phy_reg_m88;
00121 phy->ops.get_info = e1000_get_phy_info_m88;
00122
00123
00124
00125
00126
00127
00128 if (!e1000_init_phy_disabled_82543(hw)) {
00129 ret_val = phy->ops.reset(hw);
00130 if (ret_val) {
00131 DEBUGOUT("Resetting PHY during init failed.\n");
00132 goto out;
00133 }
00134 msec_delay(20);
00135 }
00136
00137 ret_val = e1000_get_phy_id(hw);
00138 if (ret_val)
00139 goto out;
00140
00141
00142 switch (hw->mac.type) {
00143 case e1000_82543:
00144 if (phy->id != M88E1000_E_PHY_ID) {
00145 ret_val = -E1000_ERR_PHY;
00146 goto out;
00147 }
00148 break;
00149 case e1000_82544:
00150 if (phy->id != M88E1000_I_PHY_ID) {
00151 ret_val = -E1000_ERR_PHY;
00152 goto out;
00153 }
00154 break;
00155 default:
00156 ret_val = -E1000_ERR_PHY;
00157 goto out;
00158 break;
00159 }
00160
00161 out:
00162 return ret_val;
00163 }
00164
00165
00166
00167
00168
00169 static s32 e1000_init_nvm_params_82543(struct e1000_hw *hw)
00170 {
00171 struct e1000_nvm_info *nvm = &hw->nvm;
00172
00173 DEBUGFUNC("e1000_init_nvm_params_82543");
00174
00175 nvm->type = e1000_nvm_eeprom_microwire;
00176 nvm->word_size = 64;
00177 nvm->delay_usec = 50;
00178 nvm->address_bits = 6;
00179 nvm->opcode_bits = 3;
00180
00181
00182 nvm->ops.read = e1000_read_nvm_microwire;
00183 nvm->ops.update = e1000_update_nvm_checksum_generic;
00184 nvm->ops.valid_led_default = e1000_valid_led_default_generic;
00185 nvm->ops.validate = e1000_validate_nvm_checksum_generic;
00186 nvm->ops.write = e1000_write_nvm_microwire;
00187
00188 return E1000_SUCCESS;
00189 }
00190
00191
00192
00193
00194
00195 static s32 e1000_init_mac_params_82543(struct e1000_hw *hw)
00196 {
00197 struct e1000_mac_info *mac = &hw->mac;
00198
00199 DEBUGFUNC("e1000_init_mac_params_82543");
00200
00201
00202 switch (hw->device_id) {
00203 case E1000_DEV_ID_82543GC_FIBER:
00204 case E1000_DEV_ID_82544EI_FIBER:
00205 hw->phy.media_type = e1000_media_type_fiber;
00206 break;
00207 default:
00208 hw->phy.media_type = e1000_media_type_copper;
00209 break;
00210 }
00211
00212
00213 mac->mta_reg_count = 128;
00214
00215 mac->rar_entry_count = E1000_RAR_ENTRIES;
00216
00217
00218
00219
00220 mac->ops.get_bus_info = e1000_get_bus_info_pci_generic;
00221
00222 mac->ops.set_lan_id = e1000_set_lan_id_multi_port_pci;
00223
00224 mac->ops.reset_hw = e1000_reset_hw_82543;
00225
00226 mac->ops.init_hw = e1000_init_hw_82543;
00227
00228 mac->ops.setup_link = e1000_setup_link_82543;
00229
00230 mac->ops.setup_physical_interface =
00231 (hw->phy.media_type == e1000_media_type_copper)
00232 ? e1000_setup_copper_link_82543
00233 : e1000_setup_fiber_link_82543;
00234
00235 mac->ops.check_for_link =
00236 (hw->phy.media_type == e1000_media_type_copper)
00237 ? e1000_check_for_copper_link_82543
00238 : e1000_check_for_fiber_link_82543;
00239
00240 mac->ops.get_link_up_info =
00241 (hw->phy.media_type == e1000_media_type_copper)
00242 ? e1000_get_speed_and_duplex_copper_generic
00243 : e1000_get_speed_and_duplex_fiber_serdes_generic;
00244
00245 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
00246
00247 mac->ops.write_vfta = e1000_write_vfta_82543;
00248
00249 mac->ops.clear_vfta = e1000_clear_vfta_generic;
00250
00251 mac->ops.mta_set = e1000_mta_set_82543;
00252
00253 mac->ops.led_on = e1000_led_on_82543;
00254 mac->ops.led_off = e1000_led_off_82543;
00255
00256 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82543;
00257
00258
00259 if ((hw->mac.type != e1000_82543) ||
00260 (hw->phy.media_type == e1000_media_type_fiber))
00261 e1000_set_tbi_compatibility_82543(hw, false);
00262
00263 return E1000_SUCCESS;
00264 }
00265
00266
00267
00268
00269
00270
00271
00272 void e1000_init_function_pointers_82543(struct e1000_hw *hw)
00273 {
00274 DEBUGFUNC("e1000_init_function_pointers_82543");
00275
00276 hw->mac.ops.init_params = e1000_init_mac_params_82543;
00277 hw->nvm.ops.init_params = e1000_init_nvm_params_82543;
00278 hw->phy.ops.init_params = e1000_init_phy_params_82543;
00279 }
00280
00281
00282
00283
00284
00285
00286
00287
00288 static bool e1000_tbi_compatibility_enabled_82543(struct e1000_hw *hw)
00289 {
00290 struct e1000_dev_spec_82543 *dev_spec = &hw->dev_spec._82543;
00291 bool state = false;
00292
00293 DEBUGFUNC("e1000_tbi_compatibility_enabled_82543");
00294
00295 if (hw->mac.type != e1000_82543) {
00296 DEBUGOUT("TBI compatibility workaround for 82543 only.\n");
00297 goto out;
00298 }
00299
00300 state = (dev_spec->tbi_compatibility & TBI_COMPAT_ENABLED)
00301 ? true : false;
00302
00303 out:
00304 return state;
00305 }
00306
00307
00308
00309
00310
00311
00312
00313
00314 static void e1000_set_tbi_compatibility_82543(struct e1000_hw *hw, bool state)
00315 {
00316 struct e1000_dev_spec_82543 *dev_spec = &hw->dev_spec._82543;
00317
00318 DEBUGFUNC("e1000_set_tbi_compatibility_82543");
00319
00320 if (hw->mac.type != e1000_82543) {
00321 DEBUGOUT("TBI compatibility workaround for 82543 only.\n");
00322 goto out;
00323 }
00324
00325 if (state)
00326 dev_spec->tbi_compatibility |= TBI_COMPAT_ENABLED;
00327 else
00328 dev_spec->tbi_compatibility &= ~TBI_COMPAT_ENABLED;
00329
00330 out:
00331 return;
00332 }
00333
00334
00335
00336
00337
00338
00339
00340
00341 bool e1000_tbi_sbp_enabled_82543(struct e1000_hw *hw)
00342 {
00343 struct e1000_dev_spec_82543 *dev_spec = &hw->dev_spec._82543;
00344 bool state = false;
00345
00346 DEBUGFUNC("e1000_tbi_sbp_enabled_82543");
00347
00348 if (hw->mac.type != e1000_82543) {
00349 DEBUGOUT("TBI compatibility workaround for 82543 only.\n");
00350 goto out;
00351 }
00352
00353 state = (dev_spec->tbi_compatibility & TBI_SBP_ENABLED)
00354 ? true : false;
00355
00356 out:
00357 return state;
00358 }
00359
00360
00361
00362
00363
00364
00365
00366
00367 static void e1000_set_tbi_sbp_82543(struct e1000_hw *hw, bool state)
00368 {
00369 struct e1000_dev_spec_82543 *dev_spec = &hw->dev_spec._82543;
00370
00371 DEBUGFUNC("e1000_set_tbi_sbp_82543");
00372
00373 if (state && e1000_tbi_compatibility_enabled_82543(hw))
00374 dev_spec->tbi_compatibility |= TBI_SBP_ENABLED;
00375 else
00376 dev_spec->tbi_compatibility &= ~TBI_SBP_ENABLED;
00377
00378 return;
00379 }
00380
00381
00382
00383
00384
00385
00386
00387
00388 static bool e1000_init_phy_disabled_82543(struct e1000_hw *hw)
00389 {
00390 struct e1000_dev_spec_82543 *dev_spec = &hw->dev_spec._82543;
00391 bool ret_val;
00392
00393 DEBUGFUNC("e1000_init_phy_disabled_82543");
00394
00395 if (hw->mac.type != e1000_82543) {
00396 ret_val = false;
00397 goto out;
00398 }
00399
00400 ret_val = dev_spec->init_phy_disabled;
00401
00402 out:
00403 return ret_val;
00404 }
00405
00406 #if 0
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417 void e1000_tbi_adjust_stats_82543(struct e1000_hw *hw,
00418 struct e1000_hw_stats *stats, u32 frame_len,
00419 u8 *mac_addr, u32 max_frame_size)
00420 {
00421 if (!(e1000_tbi_sbp_enabled_82543(hw)))
00422 goto out;
00423
00424
00425 frame_len--;
00426
00427
00428
00429
00430
00431
00432 stats->crcerrs--;
00433
00434 stats->gprc++;
00435
00436
00437 stats->gorc += frame_len;
00438
00439
00440
00441
00442
00443
00444 if ((mac_addr[0] == 0xff) && (mac_addr[1] == 0xff))
00445
00446 stats->bprc++;
00447 else if (*mac_addr & 0x01)
00448
00449 stats->mprc++;
00450
00451
00452
00453
00454
00455 if ((frame_len == max_frame_size) && (stats->roc > 0))
00456 stats->roc--;
00457
00458
00459
00460
00461
00462 if (frame_len == 64) {
00463 stats->prc64++;
00464 stats->prc127--;
00465 } else if (frame_len == 127) {
00466 stats->prc127++;
00467 stats->prc255--;
00468 } else if (frame_len == 255) {
00469 stats->prc255++;
00470 stats->prc511--;
00471 } else if (frame_len == 511) {
00472 stats->prc511++;
00473 stats->prc1023--;
00474 } else if (frame_len == 1023) {
00475 stats->prc1023++;
00476 stats->prc1522--;
00477 } else if (frame_len == 1522) {
00478 stats->prc1522++;
00479 }
00480
00481 out:
00482 return;
00483 }
00484 #endif
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494 static s32 e1000_read_phy_reg_82543(struct e1000_hw *hw, u32 offset, u16 *data)
00495 {
00496 u32 mdic;
00497 s32 ret_val = E1000_SUCCESS;
00498
00499 DEBUGFUNC("e1000_read_phy_reg_82543");
00500
00501 if (offset > MAX_PHY_REG_ADDRESS) {
00502 DEBUGOUT1("PHY Address %d is out of range\n", offset);
00503 ret_val = -E1000_ERR_PARAM;
00504 goto out;
00505 }
00506
00507
00508
00509
00510
00511
00512 e1000_shift_out_mdi_bits_82543(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526 mdic = (offset | (hw->phy.addr << 5) |
00527 (PHY_OP_READ << 10) | (PHY_SOF << 12));
00528
00529 e1000_shift_out_mdi_bits_82543(hw, mdic, 14);
00530
00531
00532
00533
00534
00535
00536 *data = e1000_shift_in_mdi_bits_82543(hw);
00537
00538 out:
00539 return ret_val;
00540 }
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550 static s32 e1000_write_phy_reg_82543(struct e1000_hw *hw, u32 offset, u16 data)
00551 {
00552 u32 mdic;
00553 s32 ret_val = E1000_SUCCESS;
00554
00555 DEBUGFUNC("e1000_write_phy_reg_82543");
00556
00557 if (offset > MAX_PHY_REG_ADDRESS) {
00558 DEBUGOUT1("PHY Address %d is out of range\n", offset);
00559 ret_val = -E1000_ERR_PARAM;
00560 goto out;
00561 }
00562
00563
00564
00565
00566
00567
00568
00569 e1000_shift_out_mdi_bits_82543(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);
00570
00571
00572
00573
00574
00575
00576
00577
00578 mdic = ((PHY_TURNAROUND) | (offset << 2) | (hw->phy.addr << 7) |
00579 (PHY_OP_WRITE << 12) | (PHY_SOF << 14));
00580 mdic <<= 16;
00581 mdic |= (u32) data;
00582
00583 e1000_shift_out_mdi_bits_82543(hw, mdic, 32);
00584
00585 out:
00586 return ret_val;
00587 }
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597 static void e1000_raise_mdi_clk_82543(struct e1000_hw *hw, u32 *ctrl)
00598 {
00599
00600
00601
00602
00603 E1000_WRITE_REG(hw, E1000_CTRL, (*ctrl | E1000_CTRL_MDC));
00604 E1000_WRITE_FLUSH(hw);
00605 usec_delay(10);
00606 }
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616 static void e1000_lower_mdi_clk_82543(struct e1000_hw *hw, u32 *ctrl)
00617 {
00618
00619
00620
00621
00622 E1000_WRITE_REG(hw, E1000_CTRL, (*ctrl & ~E1000_CTRL_MDC));
00623 E1000_WRITE_FLUSH(hw);
00624 usec_delay(10);
00625 }
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637 static void e1000_shift_out_mdi_bits_82543(struct e1000_hw *hw, u32 data,
00638 u16 count)
00639 {
00640 u32 ctrl, mask;
00641
00642
00643
00644
00645
00646
00647
00648 mask = 0x01;
00649 mask <<= (count -1);
00650
00651 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00652
00653
00654 ctrl |= (E1000_CTRL_MDIO_DIR | E1000_CTRL_MDC_DIR);
00655
00656 while (mask) {
00657
00658
00659
00660
00661
00662
00663 if (data & mask) ctrl |= E1000_CTRL_MDIO;
00664 else ctrl &= ~E1000_CTRL_MDIO;
00665
00666 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
00667 E1000_WRITE_FLUSH(hw);
00668
00669 usec_delay(10);
00670
00671 e1000_raise_mdi_clk_82543(hw, &ctrl);
00672 e1000_lower_mdi_clk_82543(hw, &ctrl);
00673
00674 mask >>= 1;
00675 }
00676 }
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687 static u16 e1000_shift_in_mdi_bits_82543(struct e1000_hw *hw)
00688 {
00689 u32 ctrl;
00690 u16 data = 0;
00691 u8 i;
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00703
00704
00705
00706
00707
00708 ctrl &= ~E1000_CTRL_MDIO_DIR;
00709 ctrl &= ~E1000_CTRL_MDIO;
00710
00711 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
00712 E1000_WRITE_FLUSH(hw);
00713
00714
00715
00716
00717
00718
00719 e1000_raise_mdi_clk_82543(hw, &ctrl);
00720 e1000_lower_mdi_clk_82543(hw, &ctrl);
00721
00722 for (data = 0, i = 0; i < 16; i++) {
00723 data <<= 1;
00724 e1000_raise_mdi_clk_82543(hw, &ctrl);
00725 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00726
00727 if (ctrl & E1000_CTRL_MDIO)
00728 data |= 1;
00729 e1000_lower_mdi_clk_82543(hw, &ctrl);
00730 }
00731
00732 e1000_raise_mdi_clk_82543(hw, &ctrl);
00733 e1000_lower_mdi_clk_82543(hw, &ctrl);
00734
00735 return data;
00736 }
00737
00738 #if 0
00739
00740
00741
00742
00743
00744
00745
00746
00747 static s32 e1000_phy_force_speed_duplex_82543(struct e1000_hw *hw)
00748 {
00749 s32 ret_val;
00750
00751 DEBUGFUNC("e1000_phy_force_speed_duplex_82543");
00752
00753 ret_val = e1000_phy_force_speed_duplex_m88(hw);
00754 if (ret_val)
00755 goto out;
00756
00757 if (!hw->mac.autoneg &&
00758 (hw->mac.forced_speed_duplex & E1000_ALL_10_SPEED))
00759 ret_val = e1000_polarity_reversal_workaround_82543(hw);
00760
00761 out:
00762 return ret_val;
00763 }
00764 #endif
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774 static s32 e1000_polarity_reversal_workaround_82543(struct e1000_hw *hw)
00775 {
00776 s32 ret_val = E1000_SUCCESS;
00777 u16 mii_status_reg;
00778 u16 i;
00779 bool link;
00780
00781 if (!(hw->phy.ops.write_reg))
00782 goto out;
00783
00784
00785
00786
00787
00788 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0019);
00789 if (ret_val)
00790 goto out;
00791 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFFFF);
00792 if (ret_val)
00793 goto out;
00794
00795 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0000);
00796 if (ret_val)
00797 goto out;
00798
00799
00800
00801
00802
00803 for (i = PHY_FORCE_TIME; i > 0; i--) {
00804
00805
00806
00807
00808
00809 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &mii_status_reg);
00810 if (ret_val)
00811 goto out;
00812
00813 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &mii_status_reg);
00814 if (ret_val)
00815 goto out;
00816
00817 if ((mii_status_reg & ~MII_SR_LINK_STATUS) == 0)
00818 break;
00819 msec_delay_irq(100);
00820 }
00821
00822
00823 msec_delay_irq(1000);
00824
00825
00826
00827 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0019);
00828 if (ret_val)
00829 goto out;
00830 msec_delay_irq(50);
00831 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFFF0);
00832 if (ret_val)
00833 goto out;
00834 msec_delay_irq(50);
00835 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xFF00);
00836 if (ret_val)
00837 goto out;
00838 msec_delay_irq(50);
00839 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0x0000);
00840 if (ret_val)
00841 goto out;
00842
00843 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_PAGE_SELECT, 0x0000);
00844 if (ret_val)
00845 goto out;
00846
00847
00848
00849
00850
00851 ret_val = e1000_phy_has_link_generic(hw, PHY_FORCE_TIME, 100000, &link);
00852 if (ret_val)
00853 goto out;
00854
00855 out:
00856 return ret_val;
00857 }
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868 static s32 e1000_phy_hw_reset_82543(struct e1000_hw *hw)
00869 {
00870 u32 ctrl_ext;
00871 s32 ret_val;
00872
00873 DEBUGFUNC("e1000_phy_hw_reset_82543");
00874
00875
00876
00877
00878
00879 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
00880 ctrl_ext |= E1000_CTRL_EXT_SDP4_DIR;
00881 ctrl_ext &= ~E1000_CTRL_EXT_SDP4_DATA;
00882 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
00883 E1000_WRITE_FLUSH(hw);
00884
00885 msec_delay(10);
00886
00887
00888 ctrl_ext |= E1000_CTRL_EXT_SDP4_DATA;
00889 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
00890 E1000_WRITE_FLUSH(hw);
00891
00892 usec_delay(150);
00893
00894 if (!(hw->phy.ops.get_cfg_done))
00895 return E1000_SUCCESS;
00896
00897 ret_val = hw->phy.ops.get_cfg_done(hw);
00898
00899 return ret_val;
00900 }
00901
00902
00903
00904
00905
00906
00907
00908 static s32 e1000_reset_hw_82543(struct e1000_hw *hw)
00909 {
00910 u32 ctrl, icr;
00911 s32 ret_val = E1000_SUCCESS;
00912
00913 DEBUGFUNC("e1000_reset_hw_82543");
00914
00915 DEBUGOUT("Masking off all interrupts\n");
00916 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
00917
00918 E1000_WRITE_REG(hw, E1000_RCTL, 0);
00919 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
00920 E1000_WRITE_FLUSH(hw);
00921
00922 e1000_set_tbi_sbp_82543(hw, false);
00923
00924
00925
00926
00927
00928 msec_delay(10);
00929
00930 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00931
00932 DEBUGOUT("Issuing a global reset to 82543/82544 MAC\n");
00933 if (hw->mac.type == e1000_82543) {
00934 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
00935 } else {
00936
00937
00938
00939
00940 E1000_WRITE_REG_IO(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
00941 }
00942
00943
00944
00945
00946
00947 hw->nvm.ops.reload(hw);
00948 msec_delay(2);
00949
00950
00951 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
00952 icr = E1000_READ_REG(hw, E1000_ICR);
00953
00954 return ret_val;
00955 }
00956
00957
00958
00959
00960
00961
00962
00963 static s32 e1000_init_hw_82543(struct e1000_hw *hw)
00964 {
00965 struct e1000_mac_info *mac = &hw->mac;
00966 struct e1000_dev_spec_82543 *dev_spec = &hw->dev_spec._82543;
00967 u32 ctrl;
00968 s32 ret_val;
00969 u16 i;
00970
00971 DEBUGFUNC("e1000_init_hw_82543");
00972
00973
00974 E1000_WRITE_REG(hw, E1000_VET, 0);
00975 mac->ops.clear_vfta(hw);
00976
00977
00978 e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
00979
00980
00981 DEBUGOUT("Zeroing the MTA\n");
00982 for (i = 0; i < mac->mta_reg_count; i++) {
00983 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
00984 E1000_WRITE_FLUSH(hw);
00985 }
00986
00987
00988
00989
00990
00991
00992 if (hw->mac.type == e1000_82543 && dev_spec->dma_fairness) {
00993 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00994 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_PRIOR);
00995 }
00996
00997 e1000_pcix_mmrbc_workaround_generic(hw);
00998
00999
01000 ret_val = mac->ops.setup_link(hw);
01001
01002
01003
01004
01005
01006
01007
01008 e1000_clear_hw_cntrs_82543(hw);
01009
01010 return ret_val;
01011 }
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026 static s32 e1000_setup_link_82543(struct e1000_hw *hw)
01027 {
01028 u32 ctrl_ext;
01029 s32 ret_val;
01030 u16 data;
01031
01032 DEBUGFUNC("e1000_setup_link_82543");
01033
01034
01035
01036
01037
01038
01039
01040
01041 if (hw->mac.type == e1000_82543) {
01042 ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL2_REG, 1, &data);
01043 if (ret_val) {
01044 DEBUGOUT("NVM Read Error\n");
01045 ret_val = -E1000_ERR_NVM;
01046 goto out;
01047 }
01048 ctrl_ext = ((data & NVM_WORD0F_SWPDIO_EXT_MASK) <<
01049 NVM_SWDPIO_EXT_SHIFT);
01050 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
01051 }
01052
01053 ret_val = e1000_setup_link_generic(hw);
01054
01055 out:
01056 return ret_val;
01057 }
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067 static s32 e1000_setup_copper_link_82543(struct e1000_hw *hw)
01068 {
01069 u32 ctrl;
01070 s32 ret_val;
01071 bool link;
01072
01073 DEBUGFUNC("e1000_setup_copper_link_82543");
01074
01075 ctrl = E1000_READ_REG(hw, E1000_CTRL) | E1000_CTRL_SLU;
01076
01077
01078
01079
01080
01081
01082 if (hw->mac.type == e1000_82543) {
01083 ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
01084 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
01085 ret_val = hw->phy.ops.reset(hw);
01086 if (ret_val)
01087 goto out;
01088 hw->phy.reset_disable = false;
01089 } else {
01090 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
01091 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
01092 }
01093
01094
01095 ret_val = e1000_copper_link_setup_m88(hw);
01096 if (ret_val)
01097 goto out;
01098
01099 if (hw->mac.autoneg) {
01100
01101
01102
01103
01104 ret_val = e1000_copper_link_autoneg(hw);
01105 if (ret_val)
01106 goto out;
01107 } else {
01108
01109
01110
01111
01112 #if 0
01113 DEBUGOUT("Forcing Speed and Duplex\n");
01114 ret_val = e1000_phy_force_speed_duplex_82543(hw);
01115 if (ret_val) {
01116 DEBUGOUT("Error Forcing Speed and Duplex\n");
01117 goto out;
01118 }
01119 #endif
01120 }
01121
01122
01123
01124
01125
01126 ret_val = e1000_phy_has_link_generic(hw,
01127 COPPER_LINK_UP_LIMIT,
01128 10,
01129 &link);
01130 if (ret_val)
01131 goto out;
01132
01133
01134 if (link) {
01135 DEBUGOUT("Valid link established!!!\n");
01136
01137 if (hw->mac.type == e1000_82544) {
01138 e1000_config_collision_dist_generic(hw);
01139 } else {
01140 ret_val = e1000_config_mac_to_phy_82543(hw);
01141 if (ret_val)
01142 goto out;
01143 }
01144 ret_val = e1000_config_fc_after_link_up_generic(hw);
01145 } else {
01146 DEBUGOUT("Unable to establish link!!!\n");
01147 }
01148
01149 out:
01150 return ret_val;
01151 }
01152
01153
01154
01155
01156
01157
01158
01159
01160 static s32 e1000_setup_fiber_link_82543(struct e1000_hw *hw)
01161 {
01162 u32 ctrl;
01163 s32 ret_val;
01164
01165 DEBUGFUNC("e1000_setup_fiber_link_82543");
01166
01167 ctrl = E1000_READ_REG(hw, E1000_CTRL);
01168
01169
01170 ctrl &= ~E1000_CTRL_LRST;
01171
01172 e1000_config_collision_dist_generic(hw);
01173
01174 ret_val = e1000_commit_fc_settings_generic(hw);
01175 if (ret_val)
01176 goto out;
01177
01178 DEBUGOUT("Auto-negotiation enabled\n");
01179
01180 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
01181 E1000_WRITE_FLUSH(hw);
01182 msec_delay(1);
01183
01184
01185
01186
01187
01188
01189 if (!(E1000_READ_REG(hw, E1000_CTRL) & E1000_CTRL_SWDPIN1)) {
01190 ret_val = e1000_poll_fiber_serdes_link_generic(hw);
01191 } else {
01192 DEBUGOUT("No signal detected\n");
01193 }
01194
01195 out:
01196 return ret_val;
01197 }
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210 static s32 e1000_check_for_copper_link_82543(struct e1000_hw *hw)
01211 {
01212 struct e1000_mac_info *mac = &hw->mac;
01213 u32 icr, rctl;
01214 s32 ret_val;
01215 u16 speed, duplex;
01216 bool link;
01217
01218 DEBUGFUNC("e1000_check_for_copper_link_82543");
01219
01220 if (!mac->get_link_status) {
01221 ret_val = E1000_SUCCESS;
01222 goto out;
01223 }
01224
01225 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
01226 if (ret_val)
01227 goto out;
01228
01229 if (!link)
01230 goto out;
01231
01232 mac->get_link_status = false;
01233
01234 e1000_check_downshift_generic(hw);
01235
01236
01237
01238
01239
01240 if (!mac->autoneg) {
01241
01242
01243
01244
01245
01246
01247
01248
01249 if (mac->forced_speed_duplex & E1000_ALL_10_SPEED) {
01250 E1000_WRITE_REG(hw, E1000_IMC, 0xFFFFFFFF);
01251 ret_val = e1000_polarity_reversal_workaround_82543(hw);
01252 icr = E1000_READ_REG(hw, E1000_ICR);
01253 E1000_WRITE_REG(hw, E1000_ICS, (icr & ~E1000_ICS_LSC));
01254 E1000_WRITE_REG(hw, E1000_IMS, IMS_ENABLE_MASK);
01255 }
01256
01257 ret_val = -E1000_ERR_CONFIG;
01258 goto out;
01259 }
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270 if (mac->type == e1000_82544)
01271 e1000_config_collision_dist_generic(hw);
01272 else {
01273 ret_val = e1000_config_mac_to_phy_82543(hw);
01274 if (ret_val) {
01275 DEBUGOUT("Error configuring MAC to PHY settings\n");
01276 goto out;
01277 }
01278 }
01279
01280
01281
01282
01283
01284
01285
01286 ret_val = e1000_config_fc_after_link_up_generic(hw);
01287 if (ret_val) {
01288 DEBUGOUT("Error configuring flow control\n");
01289 }
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299 if (e1000_tbi_compatibility_enabled_82543(hw)) {
01300 ret_val = mac->ops.get_link_up_info(hw, &speed, &duplex);
01301 if (ret_val) {
01302 DEBUGOUT("Error getting link speed and duplex\n");
01303 return ret_val;
01304 }
01305 if (speed != SPEED_1000) {
01306
01307
01308
01309
01310 if (e1000_tbi_sbp_enabled_82543(hw)) {
01311
01312
01313
01314
01315 e1000_set_tbi_sbp_82543(hw, false);
01316 rctl = E1000_READ_REG(hw, E1000_RCTL);
01317 rctl &= ~E1000_RCTL_SBP;
01318 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
01319 }
01320 } else {
01321
01322
01323
01324
01325
01326
01327
01328 if (!e1000_tbi_sbp_enabled_82543(hw)) {
01329 e1000_set_tbi_sbp_82543(hw, true);
01330 rctl = E1000_READ_REG(hw, E1000_RCTL);
01331 rctl |= E1000_RCTL_SBP;
01332 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
01333 }
01334 }
01335 }
01336 out:
01337 return ret_val;
01338 }
01339
01340
01341
01342
01343
01344
01345
01346
01347 static s32 e1000_check_for_fiber_link_82543(struct e1000_hw *hw)
01348 {
01349 struct e1000_mac_info *mac = &hw->mac;
01350 u32 rxcw, ctrl, status;
01351 s32 ret_val = E1000_SUCCESS;
01352
01353 DEBUGFUNC("e1000_check_for_fiber_link_82543");
01354
01355 ctrl = E1000_READ_REG(hw, E1000_CTRL);
01356 status = E1000_READ_REG(hw, E1000_STATUS);
01357 rxcw = E1000_READ_REG(hw, E1000_RXCW);
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368 if ((!(ctrl & E1000_CTRL_SWDPIN1)) &&
01369 (!(status & E1000_STATUS_LU)) &&
01370 (!(rxcw & E1000_RXCW_C))) {
01371 if (mac->autoneg_failed == 0) {
01372 mac->autoneg_failed = 1;
01373 ret_val = 0;
01374 goto out;
01375 }
01376 DEBUGOUT("NOT RXing /C/, disable AutoNeg and force link.\n");
01377
01378
01379 E1000_WRITE_REG(hw, E1000_TXCW, (mac->txcw & ~E1000_TXCW_ANE));
01380
01381
01382 ctrl = E1000_READ_REG(hw, E1000_CTRL);
01383 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD);
01384 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
01385
01386
01387 ret_val = e1000_config_fc_after_link_up_generic(hw);
01388 if (ret_val) {
01389 DEBUGOUT("Error configuring flow control\n");
01390 goto out;
01391 }
01392 } else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) {
01393
01394
01395
01396
01397
01398
01399 DEBUGOUT("RXing /C/, enable AutoNeg and stop forcing link.\n");
01400 E1000_WRITE_REG(hw, E1000_TXCW, mac->txcw);
01401 E1000_WRITE_REG(hw, E1000_CTRL, (ctrl & ~E1000_CTRL_SLU));
01402
01403 mac->serdes_has_link = true;
01404 }
01405
01406 out:
01407 return ret_val;
01408 }
01409
01410
01411
01412
01413
01414
01415
01416
01417 static s32 e1000_config_mac_to_phy_82543(struct e1000_hw *hw)
01418 {
01419 u32 ctrl;
01420 s32 ret_val = E1000_SUCCESS;
01421 u16 phy_data;
01422
01423 DEBUGFUNC("e1000_config_mac_to_phy_82543");
01424
01425 if (!(hw->phy.ops.read_reg))
01426 goto out;
01427
01428
01429 ctrl = E1000_READ_REG(hw, E1000_CTRL);
01430 ctrl |= (E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
01431 ctrl &= ~(E1000_CTRL_SPD_SEL | E1000_CTRL_ILOS);
01432
01433
01434
01435
01436
01437 ret_val = hw->phy.ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
01438 if (ret_val)
01439 goto out;
01440
01441 ctrl &= ~E1000_CTRL_FD;
01442 if (phy_data & M88E1000_PSSR_DPLX)
01443 ctrl |= E1000_CTRL_FD;
01444
01445 e1000_config_collision_dist_generic(hw);
01446
01447
01448
01449
01450
01451 if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)
01452 ctrl |= E1000_CTRL_SPD_1000;
01453 else if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_100MBS)
01454 ctrl |= E1000_CTRL_SPD_100;
01455
01456 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
01457
01458 out:
01459 return ret_val;
01460 }
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471 static void e1000_write_vfta_82543(struct e1000_hw *hw, u32 offset, u32 value)
01472 {
01473 u32 temp;
01474
01475 DEBUGFUNC("e1000_write_vfta_82543");
01476
01477 if ((hw->mac.type == e1000_82544) && (offset & 1)) {
01478 temp = E1000_READ_REG_ARRAY(hw, E1000_VFTA, offset - 1);
01479 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, value);
01480 E1000_WRITE_FLUSH(hw);
01481 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset - 1, temp);
01482 E1000_WRITE_FLUSH(hw);
01483 } else {
01484 e1000_write_vfta_generic(hw, offset, value);
01485 }
01486 }
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498 static void e1000_mta_set_82543(struct e1000_hw *hw, u32 hash_value)
01499 {
01500 u32 hash_bit, hash_reg, mta, temp;
01501
01502 DEBUGFUNC("e1000_mta_set_82543");
01503
01504 hash_reg = (hash_value >> 5);
01505
01506
01507
01508
01509
01510
01511 if ((hw->mac.type == e1000_82544) && (hash_reg & 1)) {
01512 hash_reg &= (hw->mac.mta_reg_count - 1);
01513 hash_bit = hash_value & 0x1F;
01514 mta = E1000_READ_REG_ARRAY(hw, E1000_MTA, hash_reg);
01515 mta |= (1 << hash_bit);
01516 temp = E1000_READ_REG_ARRAY(hw, E1000_MTA, hash_reg - 1);
01517
01518 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, hash_reg, mta);
01519 E1000_WRITE_FLUSH(hw);
01520 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, hash_reg - 1, temp);
01521 E1000_WRITE_FLUSH(hw);
01522 } else {
01523 e1000_mta_set_generic(hw, hash_value);
01524 }
01525 }
01526
01527
01528
01529
01530
01531
01532
01533 static s32 e1000_led_on_82543(struct e1000_hw *hw __unused)
01534 {
01535 #if 0
01536 u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
01537
01538 DEBUGFUNC("e1000_led_on_82543");
01539
01540 if (hw->mac.type == e1000_82544 &&
01541 hw->phy.media_type == e1000_media_type_copper) {
01542
01543 ctrl &= ~E1000_CTRL_SWDPIN0;
01544 ctrl |= E1000_CTRL_SWDPIO0;
01545 } else {
01546
01547 ctrl |= E1000_CTRL_SWDPIN0;
01548 ctrl |= E1000_CTRL_SWDPIO0;
01549 }
01550 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
01551
01552 return E1000_SUCCESS;
01553 #endif
01554 return 0;
01555 }
01556
01557
01558
01559
01560
01561
01562
01563 static s32 e1000_led_off_82543(struct e1000_hw *hw __unused)
01564 {
01565 #if 0
01566 u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
01567
01568 DEBUGFUNC("e1000_led_off_82543");
01569
01570 if (hw->mac.type == e1000_82544 &&
01571 hw->phy.media_type == e1000_media_type_copper) {
01572
01573 ctrl |= E1000_CTRL_SWDPIN0;
01574 ctrl |= E1000_CTRL_SWDPIO0;
01575 } else {
01576 ctrl &= ~E1000_CTRL_SWDPIN0;
01577 ctrl |= E1000_CTRL_SWDPIO0;
01578 }
01579 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
01580
01581 return E1000_SUCCESS;
01582 #endif
01583 return 0;
01584 }
01585
01586
01587
01588
01589
01590
01591
01592 static void e1000_clear_hw_cntrs_82543(struct e1000_hw *hw)
01593 {
01594 DEBUGFUNC("e1000_clear_hw_cntrs_82543");
01595
01596 e1000_clear_hw_cntrs_base_generic(hw);
01597
01598 #if 0
01599 E1000_READ_REG(hw, E1000_PRC64);
01600 E1000_READ_REG(hw, E1000_PRC127);
01601 E1000_READ_REG(hw, E1000_PRC255);
01602 E1000_READ_REG(hw, E1000_PRC511);
01603 E1000_READ_REG(hw, E1000_PRC1023);
01604 E1000_READ_REG(hw, E1000_PRC1522);
01605 E1000_READ_REG(hw, E1000_PTC64);
01606 E1000_READ_REG(hw, E1000_PTC127);
01607 E1000_READ_REG(hw, E1000_PTC255);
01608 E1000_READ_REG(hw, E1000_PTC511);
01609 E1000_READ_REG(hw, E1000_PTC1023);
01610 E1000_READ_REG(hw, E1000_PTC1522);
01611
01612 E1000_READ_REG(hw, E1000_ALGNERRC);
01613 E1000_READ_REG(hw, E1000_RXERRC);
01614 E1000_READ_REG(hw, E1000_TNCRS);
01615 E1000_READ_REG(hw, E1000_CEXTERR);
01616 E1000_READ_REG(hw, E1000_TSCTC);
01617 E1000_READ_REG(hw, E1000_TSCTFC);
01618 #endif
01619 }
01620
01621 static struct pci_device_id e1000_82543_nics[] = {
01622 PCI_ROM(0x8086, 0x1001, "E1000_DEV_ID_82543GC_FIBER", "E1000_DEV_ID_82543GC_FIBER", e1000_82543),
01623 PCI_ROM(0x8086, 0x1004, "E1000_DEV_ID_82543GC_COPPER", "E1000_DEV_ID_82543GC_COPPER", e1000_82543),
01624 PCI_ROM(0x8086, 0x1008, "E1000_DEV_ID_82544EI_COPPER", "E1000_DEV_ID_82544EI_COPPER", e1000_82544),
01625 PCI_ROM(0x8086, 0x1009, "E1000_DEV_ID_82544EI_FIBER", "E1000_DEV_ID_82544EI_FIBER", e1000_82544),
01626 PCI_ROM(0x8086, 0x100C, "E1000_DEV_ID_82544GC_COPPER", "E1000_DEV_ID_82544GC_COPPER", e1000_82544),
01627 PCI_ROM(0x8086, 0x100D, "E1000_DEV_ID_82544GC_LOM", "E1000_DEV_ID_82544GC_LOM", e1000_82544),
01628 };
01629
01630 struct pci_driver e1000_82543_driver __pci_driver = {
01631 .ids = e1000_82543_nics,
01632 .id_count = (sizeof (e1000_82543_nics) / sizeof (e1000_82543_nics[0])),
01633 .probe = e1000_probe,
01634 .remove = e1000_remove,
01635 };