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 #include "e1000_api.h"
00032
00033
00034
00035
00036
00037
00038
00039
00040 s32 e1000_init_mac_params(struct e1000_hw *hw)
00041 {
00042 s32 ret_val = E1000_SUCCESS;
00043
00044 if (hw->mac.ops.init_params) {
00045 ret_val = hw->mac.ops.init_params(hw);
00046 if (ret_val) {
00047 DEBUGOUT("MAC Initialization Error\n");
00048 goto out;
00049 }
00050 } else {
00051 DEBUGOUT("mac.init_mac_params was NULL\n");
00052 ret_val = -E1000_ERR_CONFIG;
00053 }
00054
00055 out:
00056 return ret_val;
00057 }
00058
00059
00060
00061
00062
00063
00064
00065
00066 s32 e1000_init_nvm_params(struct e1000_hw *hw)
00067 {
00068 s32 ret_val = E1000_SUCCESS;
00069
00070 if (hw->nvm.ops.init_params) {
00071 ret_val = hw->nvm.ops.init_params(hw);
00072 if (ret_val) {
00073 DEBUGOUT("NVM Initialization Error\n");
00074 goto out;
00075 }
00076 } else {
00077 DEBUGOUT("nvm.init_nvm_params was NULL\n");
00078 ret_val = -E1000_ERR_CONFIG;
00079 }
00080
00081 out:
00082 return ret_val;
00083 }
00084
00085
00086
00087
00088
00089
00090
00091
00092 s32 e1000_init_phy_params(struct e1000_hw *hw)
00093 {
00094 s32 ret_val = E1000_SUCCESS;
00095
00096 if (hw->phy.ops.init_params) {
00097 ret_val = hw->phy.ops.init_params(hw);
00098 if (ret_val) {
00099 DEBUGOUT("PHY Initialization Error\n");
00100 goto out;
00101 }
00102 } else {
00103 DEBUGOUT("phy.init_phy_params was NULL\n");
00104 ret_val = -E1000_ERR_CONFIG;
00105 }
00106
00107 out:
00108 return ret_val;
00109 }
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 s32 e1000_set_mac_type(struct e1000_hw *hw)
00121 {
00122 struct e1000_mac_info *mac = &hw->mac;
00123 s32 ret_val = E1000_SUCCESS;
00124
00125 DEBUGFUNC("e1000_set_mac_type");
00126
00127 switch (hw->device_id) {
00128 case E1000_DEV_ID_82542:
00129 mac->type = e1000_82542;
00130 break;
00131 case E1000_DEV_ID_82543GC_FIBER:
00132 case E1000_DEV_ID_82543GC_COPPER:
00133 mac->type = e1000_82543;
00134 break;
00135 case E1000_DEV_ID_82544EI_COPPER:
00136 case E1000_DEV_ID_82544EI_FIBER:
00137 case E1000_DEV_ID_82544GC_COPPER:
00138 case E1000_DEV_ID_82544GC_LOM:
00139 mac->type = e1000_82544;
00140 break;
00141 case E1000_DEV_ID_82540EM:
00142 case E1000_DEV_ID_82540EM_LOM:
00143 case E1000_DEV_ID_82540EP:
00144 case E1000_DEV_ID_82540EP_LOM:
00145 case E1000_DEV_ID_82540EP_LP:
00146 mac->type = e1000_82540;
00147 break;
00148 case E1000_DEV_ID_82545EM_COPPER:
00149 case E1000_DEV_ID_82545EM_FIBER:
00150 mac->type = e1000_82545;
00151 break;
00152 case E1000_DEV_ID_82545GM_COPPER:
00153 case E1000_DEV_ID_82545GM_FIBER:
00154 case E1000_DEV_ID_82545GM_SERDES:
00155 mac->type = e1000_82545_rev_3;
00156 break;
00157 case E1000_DEV_ID_82546EB_COPPER:
00158 case E1000_DEV_ID_82546EB_FIBER:
00159 case E1000_DEV_ID_82546EB_QUAD_COPPER:
00160 mac->type = e1000_82546;
00161 break;
00162 case E1000_DEV_ID_82546GB_COPPER:
00163 case E1000_DEV_ID_82546GB_FIBER:
00164 case E1000_DEV_ID_82546GB_SERDES:
00165 case E1000_DEV_ID_82546GB_PCIE:
00166 case E1000_DEV_ID_82546GB_QUAD_COPPER:
00167 case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
00168 mac->type = e1000_82546_rev_3;
00169 break;
00170 case E1000_DEV_ID_82541EI:
00171 case E1000_DEV_ID_82541EI_MOBILE:
00172 case E1000_DEV_ID_82541ER_LOM:
00173 mac->type = e1000_82541;
00174 break;
00175 case E1000_DEV_ID_82541ER:
00176 case E1000_DEV_ID_82541GI:
00177 case E1000_DEV_ID_82541GI_LF:
00178 case E1000_DEV_ID_82541GI_MOBILE:
00179 mac->type = e1000_82541_rev_2;
00180 break;
00181 case E1000_DEV_ID_82547EI:
00182 case E1000_DEV_ID_82547EI_MOBILE:
00183 mac->type = e1000_82547;
00184 break;
00185 case E1000_DEV_ID_82547GI:
00186 mac->type = e1000_82547_rev_2;
00187 break;
00188 default:
00189
00190 ret_val = -E1000_ERR_MAC_INIT;
00191 break;
00192 }
00193
00194 return ret_val;
00195 }
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
00210 {
00211 s32 ret_val;
00212
00213
00214 ret_val = e1000_set_mac_type(hw);
00215 if (ret_val) {
00216 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
00217 goto out;
00218 }
00219
00220 if (!hw->hw_addr) {
00221 DEBUGOUT("ERROR: Registers not mapped\n");
00222 ret_val = -E1000_ERR_CONFIG;
00223 goto out;
00224 }
00225
00226
00227
00228
00229
00230 e1000_init_mac_ops_generic(hw);
00231 e1000_init_phy_ops_generic(hw);
00232 e1000_init_nvm_ops_generic(hw);
00233
00234
00235
00236
00237
00238
00239 switch (hw->mac.type) {
00240 case e1000_82542:
00241 e1000_init_function_pointers_82542(hw);
00242 break;
00243 case e1000_82543:
00244 case e1000_82544:
00245 e1000_init_function_pointers_82543(hw);
00246 break;
00247 case e1000_82540:
00248 case e1000_82545:
00249 case e1000_82545_rev_3:
00250 case e1000_82546:
00251 case e1000_82546_rev_3:
00252 e1000_init_function_pointers_82540(hw);
00253 break;
00254 case e1000_82541:
00255 case e1000_82541_rev_2:
00256 case e1000_82547:
00257 case e1000_82547_rev_2:
00258 e1000_init_function_pointers_82541(hw);
00259 break;
00260 default:
00261 DEBUGOUT("Hardware not supported\n");
00262 ret_val = -E1000_ERR_CONFIG;
00263 break;
00264 }
00265
00266
00267
00268
00269
00270 if (!(ret_val) && init_device) {
00271 ret_val = e1000_init_mac_params(hw);
00272 if (ret_val)
00273 goto out;
00274
00275 ret_val = e1000_init_nvm_params(hw);
00276 if (ret_val)
00277 goto out;
00278
00279 ret_val = e1000_init_phy_params(hw);
00280 if (ret_val)
00281 goto out;
00282 }
00283
00284 out:
00285 return ret_val;
00286 }
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 s32 e1000_get_bus_info(struct e1000_hw *hw)
00297 {
00298 if (hw->mac.ops.get_bus_info)
00299 return hw->mac.ops.get_bus_info(hw);
00300
00301 return E1000_SUCCESS;
00302 }
00303
00304
00305
00306
00307
00308
00309
00310
00311 void e1000_clear_vfta(struct e1000_hw *hw)
00312 {
00313 if (hw->mac.ops.clear_vfta)
00314 hw->mac.ops.clear_vfta(hw);
00315 }
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326 void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
00327 {
00328 if (hw->mac.ops.write_vfta)
00329 hw->mac.ops.write_vfta(hw, offset, value);
00330 }
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341 void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
00342 u32 mc_addr_count)
00343 {
00344 if (hw->mac.ops.update_mc_addr_list)
00345 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list,
00346 mc_addr_count);
00347 }
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357 s32 e1000_force_mac_fc(struct e1000_hw *hw)
00358 {
00359 return e1000_force_mac_fc_generic(hw);
00360 }
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370 s32 e1000_check_for_link(struct e1000_hw *hw)
00371 {
00372 if (hw->mac.ops.check_for_link)
00373 return hw->mac.ops.check_for_link(hw);
00374
00375 return -E1000_ERR_CONFIG;
00376 }
00377
00378 #if 0
00379
00380
00381
00382
00383
00384
00385
00386 bool e1000_check_mng_mode(struct e1000_hw *hw)
00387 {
00388 if (hw->mac.ops.check_mng_mode)
00389 return hw->mac.ops.check_mng_mode(hw);
00390
00391 return false;
00392 }
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402 s32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
00403 {
00404 return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
00405 }
00406 #endif
00407
00408
00409
00410
00411
00412
00413
00414
00415 s32 e1000_reset_hw(struct e1000_hw *hw)
00416 {
00417 if (hw->mac.ops.reset_hw)
00418 return hw->mac.ops.reset_hw(hw);
00419
00420 return -E1000_ERR_CONFIG;
00421 }
00422
00423
00424
00425
00426
00427
00428
00429
00430 s32 e1000_init_hw(struct e1000_hw *hw)
00431 {
00432 if (hw->mac.ops.init_hw)
00433 return hw->mac.ops.init_hw(hw);
00434
00435 return -E1000_ERR_CONFIG;
00436 }
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446 s32 e1000_setup_link(struct e1000_hw *hw)
00447 {
00448 if (hw->mac.ops.setup_link)
00449 return hw->mac.ops.setup_link(hw);
00450
00451 return -E1000_ERR_CONFIG;
00452 }
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464 s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
00465 {
00466 if (hw->mac.ops.get_link_up_info)
00467 return hw->mac.ops.get_link_up_info(hw, speed, duplex);
00468
00469 return -E1000_ERR_CONFIG;
00470 }
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480 s32 e1000_setup_led(struct e1000_hw *hw)
00481 {
00482 if (hw->mac.ops.setup_led)
00483 return hw->mac.ops.setup_led(hw);
00484
00485 return E1000_SUCCESS;
00486 }
00487
00488
00489
00490
00491
00492
00493
00494
00495 s32 e1000_cleanup_led(struct e1000_hw *hw)
00496 {
00497 if (hw->mac.ops.cleanup_led)
00498 return hw->mac.ops.cleanup_led(hw);
00499
00500 return E1000_SUCCESS;
00501 }
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511 s32 e1000_blink_led(struct e1000_hw *hw)
00512 {
00513 if (hw->mac.ops.blink_led)
00514 return hw->mac.ops.blink_led(hw);
00515
00516 return E1000_SUCCESS;
00517 }
00518
00519
00520
00521
00522
00523
00524
00525
00526 s32 e1000_id_led_init(struct e1000_hw *hw)
00527 {
00528 if (hw->mac.ops.id_led_init)
00529 return hw->mac.ops.id_led_init(hw);
00530
00531 return E1000_SUCCESS;
00532 }
00533
00534
00535
00536
00537
00538
00539
00540
00541 s32 e1000_led_on(struct e1000_hw *hw)
00542 {
00543 if (hw->mac.ops.led_on)
00544 return hw->mac.ops.led_on(hw);
00545
00546 return E1000_SUCCESS;
00547 }
00548
00549
00550
00551
00552
00553
00554
00555
00556 s32 e1000_led_off(struct e1000_hw *hw)
00557 {
00558 if (hw->mac.ops.led_off)
00559 return hw->mac.ops.led_off(hw);
00560
00561 return E1000_SUCCESS;
00562 }
00563
00564
00565
00566
00567
00568
00569
00570
00571 void e1000_reset_adaptive(struct e1000_hw *hw)
00572 {
00573 e1000_reset_adaptive_generic(hw);
00574 }
00575
00576
00577
00578
00579
00580
00581
00582
00583 void e1000_update_adaptive(struct e1000_hw *hw)
00584 {
00585 e1000_update_adaptive_generic(hw);
00586 }
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596 s32 e1000_disable_pcie_master(struct e1000_hw *hw)
00597 {
00598 return e1000_disable_pcie_master_generic(hw);
00599 }
00600
00601
00602
00603
00604
00605
00606
00607
00608 void e1000_config_collision_dist(struct e1000_hw *hw)
00609 {
00610 if (hw->mac.ops.config_collision_dist)
00611 hw->mac.ops.config_collision_dist(hw);
00612 }
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622 void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
00623 {
00624 if (hw->mac.ops.rar_set)
00625 hw->mac.ops.rar_set(hw, addr, index);
00626 }
00627
00628
00629
00630
00631
00632
00633
00634 s32 e1000_validate_mdi_setting(struct e1000_hw *hw)
00635 {
00636 if (hw->mac.ops.validate_mdi_setting)
00637 return hw->mac.ops.validate_mdi_setting(hw);
00638
00639 return E1000_SUCCESS;
00640 }
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650 void e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
00651 {
00652 if (hw->mac.ops.mta_set)
00653 hw->mac.ops.mta_set(hw, hash_value);
00654 }
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665 u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
00666 {
00667 return e1000_hash_mc_addr_generic(hw, mc_addr);
00668 }
00669
00670 #if 0
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680 bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
00681 {
00682 return e1000_enable_tx_pkt_filtering_generic(hw);
00683 }
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697 s32 e1000_mng_host_if_write(struct e1000_hw * hw, u8 *buffer, u16 length,
00698 u16 offset, u8 *sum)
00699 {
00700 if (hw->mac.ops.mng_host_if_write)
00701 return hw->mac.ops.mng_host_if_write(hw, buffer, length,
00702 offset, sum);
00703
00704 return E1000_NOT_IMPLEMENTED;
00705 }
00706
00707
00708
00709
00710
00711
00712
00713
00714 s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
00715 struct e1000_host_mng_command_header *hdr)
00716 {
00717 if (hw->mac.ops.mng_write_cmd_header)
00718 return hw->mac.ops.mng_write_cmd_header(hw, hdr);
00719
00720 return E1000_NOT_IMPLEMENTED;
00721 }
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733 s32 e1000_mng_enable_host_if(struct e1000_hw * hw)
00734 {
00735 if (hw->mac.ops.mng_enable_host_if)
00736 return hw->mac.ops.mng_enable_host_if(hw);
00737
00738 return E1000_NOT_IMPLEMENTED;
00739 }
00740 #endif
00741
00742
00743
00744
00745
00746
00747
00748
00749 s32 e1000_wait_autoneg(struct e1000_hw *hw)
00750 {
00751 if (hw->mac.ops.wait_autoneg)
00752 return hw->mac.ops.wait_autoneg(hw);
00753
00754 return E1000_SUCCESS;
00755 }
00756
00757
00758
00759
00760
00761
00762
00763
00764 s32 e1000_check_reset_block(struct e1000_hw *hw)
00765 {
00766 if (hw->phy.ops.check_reset_block)
00767 return hw->phy.ops.check_reset_block(hw);
00768
00769 return E1000_SUCCESS;
00770 }
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781 s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
00782 {
00783 if (hw->phy.ops.read_reg)
00784 return hw->phy.ops.read_reg(hw, offset, data);
00785
00786 return E1000_SUCCESS;
00787 }
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798 s32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
00799 {
00800 if (hw->phy.ops.write_reg)
00801 return hw->phy.ops.write_reg(hw, offset, data);
00802
00803 return E1000_SUCCESS;
00804 }
00805
00806
00807
00808
00809
00810
00811
00812
00813 void e1000_release_phy(struct e1000_hw *hw)
00814 {
00815 if (hw->phy.ops.release)
00816 hw->phy.ops.release(hw);
00817 }
00818
00819
00820
00821
00822
00823
00824
00825
00826 s32 e1000_acquire_phy(struct e1000_hw *hw)
00827 {
00828 if (hw->phy.ops.acquire)
00829 return hw->phy.ops.acquire(hw);
00830
00831 return E1000_SUCCESS;
00832 }
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844 s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
00845 {
00846 return e1000_read_kmrn_reg_generic(hw, offset, data);
00847 }
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859 s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
00860 {
00861 return e1000_write_kmrn_reg_generic(hw, offset, data);
00862 }
00863
00864 #if 0
00865
00866
00867
00868
00869
00870
00871
00872
00873 s32 e1000_get_cable_length(struct e1000_hw *hw)
00874 {
00875 if (hw->phy.ops.get_cable_length)
00876 return hw->phy.ops.get_cable_length(hw);
00877
00878 return E1000_SUCCESS;
00879 }
00880 #endif
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890 s32 e1000_get_phy_info(struct e1000_hw *hw)
00891 {
00892 if (hw->phy.ops.get_info)
00893 return hw->phy.ops.get_info(hw);
00894
00895 return E1000_SUCCESS;
00896 }
00897
00898
00899
00900
00901
00902
00903
00904
00905 s32 e1000_phy_hw_reset(struct e1000_hw *hw)
00906 {
00907 if (hw->phy.ops.reset)
00908 return hw->phy.ops.reset(hw);
00909
00910 return E1000_SUCCESS;
00911 }
00912
00913
00914
00915
00916
00917
00918
00919
00920 s32 e1000_phy_commit(struct e1000_hw *hw)
00921 {
00922 if (hw->phy.ops.commit)
00923 return hw->phy.ops.commit(hw);
00924
00925 return E1000_SUCCESS;
00926 }
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942 s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
00943 {
00944 if (hw->phy.ops.set_d0_lplu_state)
00945 return hw->phy.ops.set_d0_lplu_state(hw, active);
00946
00947 return E1000_SUCCESS;
00948 }
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964 s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
00965 {
00966 if (hw->phy.ops.set_d3_lplu_state)
00967 return hw->phy.ops.set_d3_lplu_state(hw, active);
00968
00969 return E1000_SUCCESS;
00970 }
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980 s32 e1000_read_mac_addr(struct e1000_hw *hw)
00981 {
00982 if (hw->mac.ops.read_mac_addr)
00983 return hw->mac.ops.read_mac_addr(hw);
00984
00985 return e1000_read_mac_addr_generic(hw);
00986 }
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998 s32 e1000_read_pba_num(struct e1000_hw *hw, u32 *pba_num)
00999 {
01000 return e1000_read_pba_num_generic(hw, pba_num);
01001 }
01002
01003
01004
01005
01006
01007
01008
01009
01010 s32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
01011 {
01012 if (hw->nvm.ops.validate)
01013 return hw->nvm.ops.validate(hw);
01014
01015 return -E1000_ERR_CONFIG;
01016 }
01017
01018
01019
01020
01021
01022
01023
01024
01025 s32 e1000_update_nvm_checksum(struct e1000_hw *hw)
01026 {
01027 if (hw->nvm.ops.update)
01028 return hw->nvm.ops.update(hw);
01029
01030 return -E1000_ERR_CONFIG;
01031 }
01032
01033
01034
01035
01036
01037
01038
01039
01040 void e1000_reload_nvm(struct e1000_hw *hw)
01041 {
01042 if (hw->nvm.ops.reload)
01043 hw->nvm.ops.reload(hw);
01044 }
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056 s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
01057 {
01058 if (hw->nvm.ops.read)
01059 return hw->nvm.ops.read(hw, offset, words, data);
01060
01061 return -E1000_ERR_CONFIG;
01062 }
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074 s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
01075 {
01076 if (hw->nvm.ops.write)
01077 return hw->nvm.ops.write(hw, offset, words, data);
01078
01079 return E1000_SUCCESS;
01080 }
01081
01082
01083
01084
01085
01086
01087
01088
01089 void e1000_power_up_phy(struct e1000_hw *hw)
01090 {
01091 if (hw->phy.ops.power_up)
01092 hw->phy.ops.power_up(hw);
01093
01094 e1000_setup_link(hw);
01095 }
01096
01097
01098
01099
01100
01101
01102
01103
01104 void e1000_power_down_phy(struct e1000_hw *hw)
01105 {
01106 if (hw->phy.ops.power_down)
01107 hw->phy.ops.power_down(hw);
01108 }