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 #include "e1000_api.h"
00036
00037 static s32 e1000_init_phy_params_82542(struct e1000_hw *hw);
00038 static s32 e1000_init_nvm_params_82542(struct e1000_hw *hw);
00039 static s32 e1000_init_mac_params_82542(struct e1000_hw *hw);
00040 static s32 e1000_get_bus_info_82542(struct e1000_hw *hw);
00041 static s32 e1000_reset_hw_82542(struct e1000_hw *hw);
00042 static s32 e1000_init_hw_82542(struct e1000_hw *hw);
00043 static s32 e1000_setup_link_82542(struct e1000_hw *hw);
00044 static s32 e1000_led_on_82542(struct e1000_hw *hw);
00045 static s32 e1000_led_off_82542(struct e1000_hw *hw);
00046 static void e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index);
00047 static void e1000_clear_hw_cntrs_82542(struct e1000_hw *hw);
00048
00049
00050
00051
00052
00053 static s32 e1000_init_phy_params_82542(struct e1000_hw *hw)
00054 {
00055 struct e1000_phy_info *phy = &hw->phy;
00056 s32 ret_val = E1000_SUCCESS;
00057
00058 DEBUGFUNC("e1000_init_phy_params_82542");
00059
00060 phy->type = e1000_phy_none;
00061
00062 return ret_val;
00063 }
00064
00065
00066
00067
00068
00069 static s32 e1000_init_nvm_params_82542(struct e1000_hw *hw)
00070 {
00071 struct e1000_nvm_info *nvm = &hw->nvm;
00072
00073 DEBUGFUNC("e1000_init_nvm_params_82542");
00074
00075 nvm->address_bits = 6;
00076 nvm->delay_usec = 50;
00077 nvm->opcode_bits = 3;
00078 nvm->type = e1000_nvm_eeprom_microwire;
00079 nvm->word_size = 64;
00080
00081
00082 nvm->ops.read = e1000_read_nvm_microwire;
00083 nvm->ops.release = e1000_stop_nvm;
00084 nvm->ops.write = e1000_write_nvm_microwire;
00085 nvm->ops.update = e1000_update_nvm_checksum_generic;
00086 nvm->ops.validate = e1000_validate_nvm_checksum_generic;
00087
00088 return E1000_SUCCESS;
00089 }
00090
00091
00092
00093
00094
00095 static s32 e1000_init_mac_params_82542(struct e1000_hw *hw)
00096 {
00097 struct e1000_mac_info *mac = &hw->mac;
00098
00099 DEBUGFUNC("e1000_init_mac_params_82542");
00100
00101
00102 hw->phy.media_type = e1000_media_type_fiber;
00103
00104
00105 mac->mta_reg_count = 128;
00106
00107 mac->rar_entry_count = E1000_RAR_ENTRIES;
00108
00109
00110
00111
00112 mac->ops.get_bus_info = e1000_get_bus_info_82542;
00113
00114 mac->ops.set_lan_id = e1000_set_lan_id_multi_port_pci;
00115
00116 mac->ops.reset_hw = e1000_reset_hw_82542;
00117
00118 mac->ops.init_hw = e1000_init_hw_82542;
00119
00120 mac->ops.setup_link = e1000_setup_link_82542;
00121
00122 mac->ops.setup_physical_interface = e1000_setup_fiber_serdes_link_generic;
00123
00124 mac->ops.check_for_link = e1000_check_for_fiber_link_generic;
00125
00126 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
00127
00128 mac->ops.write_vfta = e1000_write_vfta_generic;
00129
00130 mac->ops.clear_vfta = e1000_clear_vfta_generic;
00131
00132 mac->ops.mta_set = e1000_mta_set_generic;
00133
00134 mac->ops.rar_set = e1000_rar_set_82542;
00135
00136 mac->ops.led_on = e1000_led_on_82542;
00137 mac->ops.led_off = e1000_led_off_82542;
00138
00139 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82542;
00140
00141 mac->ops.get_link_up_info = e1000_get_speed_and_duplex_fiber_serdes_generic;
00142
00143 return E1000_SUCCESS;
00144 }
00145
00146
00147
00148
00149
00150
00151
00152 void e1000_init_function_pointers_82542(struct e1000_hw *hw)
00153 {
00154 DEBUGFUNC("e1000_init_function_pointers_82542");
00155
00156 hw->mac.ops.init_params = e1000_init_mac_params_82542;
00157 hw->nvm.ops.init_params = e1000_init_nvm_params_82542;
00158 hw->phy.ops.init_params = e1000_init_phy_params_82542;
00159 }
00160
00161
00162
00163
00164
00165
00166
00167
00168 static s32 e1000_get_bus_info_82542(struct e1000_hw *hw)
00169 {
00170 DEBUGFUNC("e1000_get_bus_info_82542");
00171
00172 hw->bus.type = e1000_bus_type_pci;
00173 hw->bus.speed = e1000_bus_speed_unknown;
00174 hw->bus.width = e1000_bus_width_unknown;
00175
00176 return E1000_SUCCESS;
00177 }
00178
00179
00180
00181
00182
00183
00184
00185 static s32 e1000_reset_hw_82542(struct e1000_hw *hw)
00186 {
00187 struct e1000_bus_info *bus = &hw->bus;
00188 s32 ret_val = E1000_SUCCESS;
00189 u32 ctrl, icr;
00190
00191 DEBUGFUNC("e1000_reset_hw_82542");
00192
00193 if (hw->revision_id == E1000_REVISION_2) {
00194 DEBUGOUT("Disabling MWI on 82542 rev 2\n");
00195 e1000_pci_clear_mwi(hw);
00196 }
00197
00198 DEBUGOUT("Masking off all interrupts\n");
00199 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
00200
00201 E1000_WRITE_REG(hw, E1000_RCTL, 0);
00202 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
00203 E1000_WRITE_FLUSH(hw);
00204
00205
00206
00207
00208
00209 msec_delay(10);
00210
00211 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00212
00213 DEBUGOUT("Issuing a global reset to 82542/82543 MAC\n");
00214 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
00215
00216 hw->nvm.ops.reload(hw);
00217 msec_delay(2);
00218
00219 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
00220 icr = E1000_READ_REG(hw, E1000_ICR);
00221
00222 if (hw->revision_id == E1000_REVISION_2) {
00223 if (bus->pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
00224 e1000_pci_set_mwi(hw);
00225 }
00226
00227 return ret_val;
00228 }
00229
00230
00231
00232
00233
00234
00235
00236 static s32 e1000_init_hw_82542(struct e1000_hw *hw)
00237 {
00238 struct e1000_mac_info *mac = &hw->mac;
00239 struct e1000_dev_spec_82542 *dev_spec = &hw->dev_spec._82542;
00240 s32 ret_val = E1000_SUCCESS;
00241 u32 ctrl;
00242 u16 i;
00243
00244 DEBUGFUNC("e1000_init_hw_82542");
00245
00246
00247 E1000_WRITE_REG(hw, E1000_VET, 0);
00248 mac->ops.clear_vfta(hw);
00249
00250
00251 if (hw->revision_id == E1000_REVISION_2) {
00252 DEBUGOUT("Disabling MWI on 82542 rev 2.0\n");
00253 e1000_pci_clear_mwi(hw);
00254 E1000_WRITE_REG(hw, E1000_RCTL, E1000_RCTL_RST);
00255 E1000_WRITE_FLUSH(hw);
00256 msec_delay(5);
00257 }
00258
00259
00260 e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
00261
00262
00263 if (hw->revision_id == E1000_REVISION_2) {
00264 E1000_WRITE_REG(hw, E1000_RCTL, 0);
00265 E1000_WRITE_FLUSH(hw);
00266 msec_delay(1);
00267 if (hw->bus.pci_cmd_word & CMD_MEM_WRT_INVALIDATE)
00268 e1000_pci_set_mwi(hw);
00269 }
00270
00271
00272 DEBUGOUT("Zeroing the MTA\n");
00273 for (i = 0; i < mac->mta_reg_count; i++)
00274 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
00275
00276
00277
00278
00279
00280
00281 if (dev_spec->dma_fairness) {
00282 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00283 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_PRIOR);
00284 }
00285
00286
00287 ret_val = e1000_setup_link_82542(hw);
00288
00289
00290
00291
00292
00293
00294
00295 e1000_clear_hw_cntrs_82542(hw);
00296
00297 return ret_val;
00298 }
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310 static s32 e1000_setup_link_82542(struct e1000_hw *hw)
00311 {
00312 struct e1000_mac_info *mac = &hw->mac;
00313 s32 ret_val = E1000_SUCCESS;
00314
00315 DEBUGFUNC("e1000_setup_link_82542");
00316
00317 ret_val = e1000_set_default_fc_generic(hw);
00318 if (ret_val)
00319 goto out;
00320
00321 hw->fc.requested_mode &= ~e1000_fc_tx_pause;
00322
00323 if (mac->report_tx_early == 1)
00324 hw->fc.requested_mode &= ~e1000_fc_rx_pause;
00325
00326
00327
00328
00329
00330 hw->fc.current_mode = hw->fc.requested_mode;
00331
00332 DEBUGOUT1("After fix-ups FlowControl is now = %x\n",
00333 hw->fc.current_mode);
00334
00335
00336 ret_val = mac->ops.setup_physical_interface(hw);
00337 if (ret_val)
00338 goto out;
00339
00340
00341
00342
00343
00344
00345
00346 DEBUGOUT("Initializing Flow Control address, type and timer regs\n");
00347
00348 E1000_WRITE_REG(hw, E1000_FCAL, FLOW_CONTROL_ADDRESS_LOW);
00349 E1000_WRITE_REG(hw, E1000_FCAH, FLOW_CONTROL_ADDRESS_HIGH);
00350 E1000_WRITE_REG(hw, E1000_FCT, FLOW_CONTROL_TYPE);
00351
00352 E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time);
00353
00354 ret_val = e1000_set_fc_watermarks_generic(hw);
00355
00356 out:
00357 return ret_val;
00358 }
00359
00360
00361
00362
00363
00364
00365
00366 static s32 e1000_led_on_82542(struct e1000_hw *hw __unused)
00367 {
00368 #if 0
00369 u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00370
00371 DEBUGFUNC("e1000_led_on_82542");
00372
00373 ctrl |= E1000_CTRL_SWDPIN0;
00374 ctrl |= E1000_CTRL_SWDPIO0;
00375 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
00376
00377 return E1000_SUCCESS;
00378 #endif
00379 return 0;
00380 }
00381
00382
00383
00384
00385
00386
00387
00388 static s32 e1000_led_off_82542(struct e1000_hw *hw __unused)
00389 {
00390 #if 0
00391 u32 ctrl = E1000_READ_REG(hw, E1000_CTRL);
00392
00393 DEBUGFUNC("e1000_led_off_82542");
00394
00395 ctrl &= ~E1000_CTRL_SWDPIN0;
00396 ctrl |= E1000_CTRL_SWDPIO0;
00397 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
00398
00399 return E1000_SUCCESS;
00400 #endif
00401 return 0;
00402 }
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413 static void e1000_rar_set_82542(struct e1000_hw *hw, u8 *addr, u32 index)
00414 {
00415 u32 rar_low, rar_high;
00416
00417 DEBUGFUNC("e1000_rar_set_82542");
00418
00419
00420
00421
00422
00423 rar_low = ((u32) addr[0] |
00424 ((u32) addr[1] << 8) |
00425 ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
00426
00427 rar_high = ((u32) addr[4] | ((u32) addr[5] << 8));
00428
00429
00430 if (rar_low || rar_high)
00431 rar_high |= E1000_RAH_AV;
00432
00433 E1000_WRITE_REG_ARRAY(hw, E1000_RA, (index << 1), rar_low);
00434 E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((index << 1) + 1), rar_high);
00435 }
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446 u32 e1000_translate_register_82542(u32 reg)
00447 {
00448
00449
00450
00451
00452
00453
00454 switch (reg) {
00455 case E1000_RA:
00456 reg = 0x00040;
00457 break;
00458 case E1000_RDTR:
00459 reg = 0x00108;
00460 break;
00461 case E1000_RDBAL(0):
00462 reg = 0x00110;
00463 break;
00464 case E1000_RDBAH(0):
00465 reg = 0x00114;
00466 break;
00467 case E1000_RDLEN(0):
00468 reg = 0x00118;
00469 break;
00470 case E1000_RDH(0):
00471 reg = 0x00120;
00472 break;
00473 case E1000_RDT(0):
00474 reg = 0x00128;
00475 break;
00476 case E1000_RDBAL(1):
00477 reg = 0x00138;
00478 break;
00479 case E1000_RDBAH(1):
00480 reg = 0x0013C;
00481 break;
00482 case E1000_RDLEN(1):
00483 reg = 0x00140;
00484 break;
00485 case E1000_RDH(1):
00486 reg = 0x00148;
00487 break;
00488 case E1000_RDT(1):
00489 reg = 0x00150;
00490 break;
00491 case E1000_FCRTH:
00492 reg = 0x00160;
00493 break;
00494 case E1000_FCRTL:
00495 reg = 0x00168;
00496 break;
00497 case E1000_MTA:
00498 reg = 0x00200;
00499 break;
00500 case E1000_TDBAL(0):
00501 reg = 0x00420;
00502 break;
00503 case E1000_TDBAH(0):
00504 reg = 0x00424;
00505 break;
00506 case E1000_TDLEN(0):
00507 reg = 0x00428;
00508 break;
00509 case E1000_TDH(0):
00510 reg = 0x00430;
00511 break;
00512 case E1000_TDT(0):
00513 reg = 0x00438;
00514 break;
00515 case E1000_TIDV:
00516 reg = 0x00440;
00517 break;
00518 case E1000_VFTA:
00519 reg = 0x00600;
00520 break;
00521 case E1000_TDFH:
00522 reg = 0x08010;
00523 break;
00524 case E1000_TDFT:
00525 reg = 0x08018;
00526 break;
00527 default:
00528 break;
00529 }
00530
00531 return reg;
00532 }
00533
00534
00535
00536
00537
00538
00539
00540 static void e1000_clear_hw_cntrs_82542(struct e1000_hw *hw)
00541 {
00542 DEBUGFUNC("e1000_clear_hw_cntrs_82542");
00543
00544 e1000_clear_hw_cntrs_base_generic(hw);
00545
00546 #if 0
00547 E1000_READ_REG(hw, E1000_PRC64);
00548 E1000_READ_REG(hw, E1000_PRC127);
00549 E1000_READ_REG(hw, E1000_PRC255);
00550 E1000_READ_REG(hw, E1000_PRC511);
00551 E1000_READ_REG(hw, E1000_PRC1023);
00552 E1000_READ_REG(hw, E1000_PRC1522);
00553 E1000_READ_REG(hw, E1000_PTC64);
00554 E1000_READ_REG(hw, E1000_PTC127);
00555 E1000_READ_REG(hw, E1000_PTC255);
00556 E1000_READ_REG(hw, E1000_PTC511);
00557 E1000_READ_REG(hw, E1000_PTC1023);
00558 E1000_READ_REG(hw, E1000_PTC1522);
00559 #endif
00560 }
00561
00562 static struct pci_device_id e1000_82542_nics[] = {
00563 PCI_ROM(0x8086, 0x1000, "E1000_DEV_ID_82542", "E1000_DEV_ID_82542", e1000_82542),
00564 };
00565
00566 struct pci_driver e1000_82542_driver __pci_driver = {
00567 .ids = e1000_82542_nics,
00568 .id_count = (sizeof (e1000_82542_nics) / sizeof (e1000_82542_nics[0])),
00569 .probe = e1000_probe,
00570 .remove = e1000_remove,
00571 };