1 /******************************************************************************
3 Copyright (c) 2001-2010, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ******************************************************************************/
36 * 82575EB Gigabit Network Connection
37 * 82575EB Gigabit Backplane Connection
38 * 82575GB Gigabit Network Connection
39 * 82575GB Gigabit Network Connection
40 * 82576 Gigabit Network Connection
41 * 82576 Quad Port Gigabit Mezzanine Adapter
44 #include "e1000_api.h"
46 static s32 e1000_init_phy_params_82575(struct e1000_hw *hw);
47 static s32 e1000_init_nvm_params_82575(struct e1000_hw *hw);
48 static s32 e1000_init_mac_params_82575(struct e1000_hw *hw);
49 static s32 e1000_acquire_phy_82575(struct e1000_hw *hw);
50 static void e1000_release_phy_82575(struct e1000_hw *hw);
51 static s32 e1000_acquire_nvm_82575(struct e1000_hw *hw);
52 static void e1000_release_nvm_82575(struct e1000_hw *hw);
53 static s32 e1000_check_for_link_82575(struct e1000_hw *hw);
54 static s32 e1000_get_cfg_done_82575(struct e1000_hw *hw);
55 static s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
57 static s32 e1000_init_hw_82575(struct e1000_hw *hw);
58 static s32 e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw);
59 static s32 e1000_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
61 static s32 e1000_reset_hw_82575(struct e1000_hw *hw);
62 static s32 e1000_reset_hw_82580(struct e1000_hw *hw);
63 static s32 e1000_read_phy_reg_82580(struct e1000_hw *hw,
64 u32 offset, u16 *data);
65 static s32 e1000_write_phy_reg_82580(struct e1000_hw *hw,
66 u32 offset, u16 data);
67 static s32 e1000_set_d0_lplu_state_82575(struct e1000_hw *hw,
69 static s32 e1000_setup_copper_link_82575(struct e1000_hw *hw);
70 static s32 e1000_setup_serdes_link_82575(struct e1000_hw *hw);
71 static s32 e1000_valid_led_default_82575(struct e1000_hw *hw, u16 *data);
72 static s32 e1000_write_phy_reg_sgmii_82575(struct e1000_hw *hw,
73 u32 offset, u16 data);
74 static void e1000_clear_hw_cntrs_82575(struct e1000_hw *hw);
75 static s32 e1000_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
76 static s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
77 u16 *speed, u16 *duplex);
78 static s32 e1000_get_phy_id_82575(struct e1000_hw *hw);
79 static void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask);
80 static bool e1000_sgmii_active_82575(struct e1000_hw *hw);
81 static s32 e1000_reset_init_script_82575(struct e1000_hw *hw);
82 static s32 e1000_read_mac_addr_82575(struct e1000_hw *hw);
83 static void e1000_config_collision_dist_82575(struct e1000_hw *hw);
84 static void e1000_power_down_phy_copper_82575(struct e1000_hw *hw);
85 static void e1000_shutdown_serdes_link_82575(struct e1000_hw *hw);
86 static void e1000_power_up_serdes_link_82575(struct e1000_hw *hw);
87 static s32 e1000_set_pcie_completion_timeout(struct e1000_hw *hw);
88 static s32 e1000_reset_mdicnfg_82580(struct e1000_hw *hw);
90 static const u16 e1000_82580_rxpbs_table[] =
91 { 36, 72, 144, 1, 2, 4, 8, 16,
93 #define E1000_82580_RXPBS_TABLE_SIZE \
94 (sizeof(e1000_82580_rxpbs_table)/sizeof(u16))
98 * e1000_sgmii_uses_mdio_82575 - Determine if I2C pins are for external MDIO
99 * @hw: pointer to the HW structure
101 * Called to determine if the I2C pins are being used for I2C or as an
102 * external MDIO interface since the two options are mutually exclusive.
104 static bool e1000_sgmii_uses_mdio_82575(struct e1000_hw *hw)
107 bool ext_mdio = FALSE;
109 DEBUGFUNC("e1000_sgmii_uses_mdio_82575");
111 switch (hw->mac.type) {
114 reg = E1000_READ_REG(hw, E1000_MDIC);
115 ext_mdio = !!(reg & E1000_MDIC_DEST);
118 reg = E1000_READ_REG(hw, E1000_MDICNFG);
119 ext_mdio = !!(reg & E1000_MDICNFG_EXT_MDIO);
128 * e1000_init_phy_params_82575 - Init PHY func ptrs.
129 * @hw: pointer to the HW structure
131 static s32 e1000_init_phy_params_82575(struct e1000_hw *hw)
133 struct e1000_phy_info *phy = &hw->phy;
134 s32 ret_val = E1000_SUCCESS;
137 DEBUGFUNC("e1000_init_phy_params_82575");
139 if (hw->phy.media_type != e1000_media_type_copper) {
140 phy->type = e1000_phy_none;
144 phy->ops.power_up = e1000_power_up_phy_copper;
145 phy->ops.power_down = e1000_power_down_phy_copper_82575;
147 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
148 phy->reset_delay_us = 100;
150 phy->ops.acquire = e1000_acquire_phy_82575;
151 phy->ops.check_reset_block = e1000_check_reset_block_generic;
152 phy->ops.commit = e1000_phy_sw_reset_generic;
153 phy->ops.get_cfg_done = e1000_get_cfg_done_82575;
154 phy->ops.release = e1000_release_phy_82575;
156 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
158 if (e1000_sgmii_active_82575(hw)) {
159 phy->ops.reset = e1000_phy_hw_reset_sgmii_82575;
160 ctrl_ext |= E1000_CTRL_I2C_ENA;
162 phy->ops.reset = e1000_phy_hw_reset_generic;
163 ctrl_ext &= ~E1000_CTRL_I2C_ENA;
166 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
167 e1000_reset_mdicnfg_82580(hw);
169 if (e1000_sgmii_active_82575(hw) && !e1000_sgmii_uses_mdio_82575(hw)) {
170 phy->ops.read_reg = e1000_read_phy_reg_sgmii_82575;
171 phy->ops.write_reg = e1000_write_phy_reg_sgmii_82575;
172 } else if (hw->mac.type >= e1000_82580) {
173 phy->ops.read_reg = e1000_read_phy_reg_82580;
174 phy->ops.write_reg = e1000_write_phy_reg_82580;
176 phy->ops.read_reg = e1000_read_phy_reg_igp;
177 phy->ops.write_reg = e1000_write_phy_reg_igp;
180 /* Set phy->phy_addr and phy->id. */
181 ret_val = e1000_get_phy_id_82575(hw);
183 /* Verify phy id and set remaining function pointers */
185 case M88E1111_I_PHY_ID:
186 phy->type = e1000_phy_m88;
187 phy->ops.check_polarity = e1000_check_polarity_m88;
188 phy->ops.get_info = e1000_get_phy_info_m88;
189 phy->ops.get_cable_length = e1000_get_cable_length_m88;
190 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
192 case IGP03E1000_E_PHY_ID:
193 case IGP04E1000_E_PHY_ID:
194 phy->type = e1000_phy_igp_3;
195 phy->ops.check_polarity = e1000_check_polarity_igp;
196 phy->ops.get_info = e1000_get_phy_info_igp;
197 phy->ops.get_cable_length = e1000_get_cable_length_igp_2;
198 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp;
199 phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82575;
200 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_generic;
202 case I82580_I_PHY_ID:
203 phy->type = e1000_phy_82580;
204 phy->ops.check_polarity = e1000_check_polarity_82577;
205 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_82577;
206 phy->ops.get_cable_length = e1000_get_cable_length_82577;
207 phy->ops.get_info = e1000_get_phy_info_82577;
210 ret_val = -E1000_ERR_PHY;
219 * e1000_init_nvm_params_82575 - Init NVM func ptrs.
220 * @hw: pointer to the HW structure
222 static s32 e1000_init_nvm_params_82575(struct e1000_hw *hw)
224 struct e1000_nvm_info *nvm = &hw->nvm;
225 u32 eecd = E1000_READ_REG(hw, E1000_EECD);
228 DEBUGFUNC("e1000_init_nvm_params_82575");
230 nvm->opcode_bits = 8;
232 switch (nvm->override) {
233 case e1000_nvm_override_spi_large:
235 nvm->address_bits = 16;
237 case e1000_nvm_override_spi_small:
239 nvm->address_bits = 8;
242 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
243 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
247 nvm->type = e1000_nvm_eeprom_spi;
249 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
250 E1000_EECD_SIZE_EX_SHIFT);
253 * Added to a constant, "size" becomes the left-shift value
254 * for setting word_size.
256 size += NVM_WORD_SIZE_BASE_SHIFT;
258 /* EEPROM access above 16k is unsupported */
261 nvm->word_size = 1 << size;
263 /* Function Pointers */
264 nvm->ops.acquire = e1000_acquire_nvm_82575;
265 nvm->ops.read = e1000_read_nvm_eerd;
266 nvm->ops.release = e1000_release_nvm_82575;
267 nvm->ops.update = e1000_update_nvm_checksum_generic;
268 nvm->ops.valid_led_default = e1000_valid_led_default_82575;
269 nvm->ops.validate = e1000_validate_nvm_checksum_generic;
270 nvm->ops.write = e1000_write_nvm_spi;
272 return E1000_SUCCESS;
276 * e1000_init_mac_params_82575 - Init MAC func ptrs.
277 * @hw: pointer to the HW structure
279 static s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
281 struct e1000_mac_info *mac = &hw->mac;
282 struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
285 DEBUGFUNC("e1000_init_mac_params_82575");
289 * The 82575 uses bits 22:23 for link mode. The mode can be changed
290 * based on the EEPROM. We cannot rely upon device ID. There
291 * is no distinguishable difference between fiber and internal
292 * SerDes mode on the 82575. There can be an external PHY attached
293 * on the SGMII interface. For this, we'll set sgmii_active to TRUE.
295 hw->phy.media_type = e1000_media_type_copper;
296 dev_spec->sgmii_active = FALSE;
298 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
299 switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) {
300 case E1000_CTRL_EXT_LINK_MODE_SGMII:
301 dev_spec->sgmii_active = TRUE;
303 case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX:
304 case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
305 hw->phy.media_type = e1000_media_type_internal_serdes;
311 /* Set mta register count */
312 mac->mta_reg_count = 128;
313 /* Set uta register count */
314 mac->uta_reg_count = (hw->mac.type == e1000_82575) ? 0 : 128;
315 /* Set rar entry count */
316 mac->rar_entry_count = E1000_RAR_ENTRIES_82575;
317 if (mac->type == e1000_82576)
318 mac->rar_entry_count = E1000_RAR_ENTRIES_82576;
319 if (mac->type == e1000_82580)
320 mac->rar_entry_count = E1000_RAR_ENTRIES_82580;
321 /* Set if part includes ASF firmware */
322 mac->asf_firmware_present = TRUE;
324 mac->has_fwsm = TRUE;
325 /* ARC supported; valid only if manageability features are enabled. */
326 mac->arc_subsystem_valid =
327 (E1000_READ_REG(hw, E1000_FWSM) & E1000_FWSM_MODE_MASK)
330 /* Function pointers */
332 /* bus type/speed/width */
333 mac->ops.get_bus_info = e1000_get_bus_info_pcie_generic;
335 if (mac->type >= e1000_82580)
336 mac->ops.reset_hw = e1000_reset_hw_82580;
338 mac->ops.reset_hw = e1000_reset_hw_82575;
339 /* hw initialization */
340 mac->ops.init_hw = e1000_init_hw_82575;
342 mac->ops.setup_link = e1000_setup_link_generic;
343 /* physical interface link setup */
344 mac->ops.setup_physical_interface =
345 (hw->phy.media_type == e1000_media_type_copper)
346 ? e1000_setup_copper_link_82575
347 : e1000_setup_serdes_link_82575;
348 /* physical interface shutdown */
349 mac->ops.shutdown_serdes = e1000_shutdown_serdes_link_82575;
350 /* physical interface power up */
351 mac->ops.power_up_serdes = e1000_power_up_serdes_link_82575;
353 mac->ops.check_for_link = e1000_check_for_link_82575;
354 /* receive address register setting */
355 mac->ops.rar_set = e1000_rar_set_generic;
356 /* read mac address */
357 mac->ops.read_mac_addr = e1000_read_mac_addr_82575;
358 /* configure collision distance */
359 mac->ops.config_collision_dist = e1000_config_collision_dist_82575;
360 /* multicast address update */
361 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
363 mac->ops.write_vfta = e1000_write_vfta_generic;
365 mac->ops.clear_vfta = e1000_clear_vfta_generic;
367 mac->ops.id_led_init = e1000_id_led_init_generic;
369 mac->ops.blink_led = e1000_blink_led_generic;
371 mac->ops.setup_led = e1000_setup_led_generic;
373 mac->ops.cleanup_led = e1000_cleanup_led_generic;
374 /* turn on/off LED */
375 mac->ops.led_on = e1000_led_on_generic;
376 mac->ops.led_off = e1000_led_off_generic;
377 /* clear hardware counters */
378 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82575;
380 mac->ops.get_link_up_info = e1000_get_link_up_info_82575;
382 /* set lan id for port to determine which phy lock to use */
383 hw->mac.ops.set_lan_id(hw);
385 return E1000_SUCCESS;
389 * e1000_init_function_pointers_82575 - Init func ptrs.
390 * @hw: pointer to the HW structure
392 * Called to initialize all function pointers and parameters.
394 void e1000_init_function_pointers_82575(struct e1000_hw *hw)
396 DEBUGFUNC("e1000_init_function_pointers_82575");
398 hw->mac.ops.init_params = e1000_init_mac_params_82575;
399 hw->nvm.ops.init_params = e1000_init_nvm_params_82575;
400 hw->phy.ops.init_params = e1000_init_phy_params_82575;
401 hw->mbx.ops.init_params = e1000_init_mbx_params_pf;
405 * e1000_acquire_phy_82575 - Acquire rights to access PHY
406 * @hw: pointer to the HW structure
408 * Acquire access rights to the correct PHY.
410 static s32 e1000_acquire_phy_82575(struct e1000_hw *hw)
412 u16 mask = E1000_SWFW_PHY0_SM;
414 DEBUGFUNC("e1000_acquire_phy_82575");
416 if (hw->bus.func == E1000_FUNC_1)
417 mask = E1000_SWFW_PHY1_SM;
418 else if (hw->bus.func == E1000_FUNC_2)
419 mask = E1000_SWFW_PHY2_SM;
420 else if (hw->bus.func == E1000_FUNC_3)
421 mask = E1000_SWFW_PHY3_SM;
423 return e1000_acquire_swfw_sync_82575(hw, mask);
427 * e1000_release_phy_82575 - Release rights to access PHY
428 * @hw: pointer to the HW structure
430 * A wrapper to release access rights to the correct PHY.
432 static void e1000_release_phy_82575(struct e1000_hw *hw)
434 u16 mask = E1000_SWFW_PHY0_SM;
436 DEBUGFUNC("e1000_release_phy_82575");
438 if (hw->bus.func == E1000_FUNC_1)
439 mask = E1000_SWFW_PHY1_SM;
440 else if (hw->bus.func == E1000_FUNC_2)
441 mask = E1000_SWFW_PHY2_SM;
442 else if (hw->bus.func == E1000_FUNC_3)
443 mask = E1000_SWFW_PHY3_SM;
445 e1000_release_swfw_sync_82575(hw, mask);
449 * e1000_read_phy_reg_sgmii_82575 - Read PHY register using sgmii
450 * @hw: pointer to the HW structure
451 * @offset: register offset to be read
452 * @data: pointer to the read data
454 * Reads the PHY register at offset using the serial gigabit media independent
455 * interface and stores the retrieved information in data.
457 static s32 e1000_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
460 s32 ret_val = -E1000_ERR_PARAM;
462 DEBUGFUNC("e1000_read_phy_reg_sgmii_82575");
464 if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
465 DEBUGOUT1("PHY Address %u is out of range\n", offset);
469 ret_val = hw->phy.ops.acquire(hw);
473 ret_val = e1000_read_phy_reg_i2c(hw, offset, data);
475 hw->phy.ops.release(hw);
482 * e1000_write_phy_reg_sgmii_82575 - Write PHY register using sgmii
483 * @hw: pointer to the HW structure
484 * @offset: register offset to write to
485 * @data: data to write at register offset
487 * Writes the data to PHY register at the offset using the serial gigabit
488 * media independent interface.
490 static s32 e1000_write_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
493 s32 ret_val = -E1000_ERR_PARAM;
495 DEBUGFUNC("e1000_write_phy_reg_sgmii_82575");
497 if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
498 DEBUGOUT1("PHY Address %d is out of range\n", offset);
502 ret_val = hw->phy.ops.acquire(hw);
506 ret_val = e1000_write_phy_reg_i2c(hw, offset, data);
508 hw->phy.ops.release(hw);
515 * e1000_get_phy_id_82575 - Retrieve PHY addr and id
516 * @hw: pointer to the HW structure
518 * Retrieves the PHY address and ID for both PHY's which do and do not use
521 static s32 e1000_get_phy_id_82575(struct e1000_hw *hw)
523 struct e1000_phy_info *phy = &hw->phy;
524 s32 ret_val = E1000_SUCCESS;
529 DEBUGFUNC("e1000_get_phy_id_82575");
532 * For SGMII PHYs, we try the list of possible addresses until
533 * we find one that works. For non-SGMII PHYs
534 * (e.g. integrated copper PHYs), an address of 1 should
535 * work. The result of this function should mean phy->phy_addr
536 * and phy->id are set correctly.
538 if (!e1000_sgmii_active_82575(hw)) {
540 ret_val = e1000_get_phy_id(hw);
544 if (e1000_sgmii_uses_mdio_82575(hw)) {
545 switch (hw->mac.type) {
548 mdic = E1000_READ_REG(hw, E1000_MDIC);
549 mdic &= E1000_MDIC_PHY_MASK;
550 phy->addr = mdic >> E1000_MDIC_PHY_SHIFT;
553 mdic = E1000_READ_REG(hw, E1000_MDICNFG);
554 mdic &= E1000_MDICNFG_PHY_MASK;
555 phy->addr = mdic >> E1000_MDICNFG_PHY_SHIFT;
558 ret_val = -E1000_ERR_PHY;
562 ret_val = e1000_get_phy_id(hw);
566 /* Power on sgmii phy if it is disabled */
567 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
568 E1000_WRITE_REG(hw, E1000_CTRL_EXT,
569 ctrl_ext & ~E1000_CTRL_EXT_SDP3_DATA);
570 E1000_WRITE_FLUSH(hw);
574 * The address field in the I2CCMD register is 3 bits and 0 is invalid.
575 * Therefore, we need to test 1-7
577 for (phy->addr = 1; phy->addr < 8; phy->addr++) {
578 ret_val = e1000_read_phy_reg_sgmii_82575(hw, PHY_ID1, &phy_id);
579 if (ret_val == E1000_SUCCESS) {
580 DEBUGOUT2("Vendor ID 0x%08X read at address %u\n",
584 * At the time of this writing, The M88 part is
585 * the only supported SGMII PHY product.
587 if (phy_id == M88_VENDOR)
590 DEBUGOUT1("PHY address %u was unreadable\n",
595 /* A valid PHY type couldn't be found. */
596 if (phy->addr == 8) {
598 ret_val = -E1000_ERR_PHY;
600 ret_val = e1000_get_phy_id(hw);
603 /* restore previous sfp cage power state */
604 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
611 * e1000_phy_hw_reset_sgmii_82575 - Performs a PHY reset
612 * @hw: pointer to the HW structure
614 * Resets the PHY using the serial gigabit media independent interface.
616 static s32 e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw)
618 s32 ret_val = E1000_SUCCESS;
620 DEBUGFUNC("e1000_phy_hw_reset_sgmii_82575");
623 * This isn't a TRUE "hard" reset, but is the only reset
624 * available to us at this time.
627 DEBUGOUT("Soft resetting SGMII attached PHY...\n");
629 if (!(hw->phy.ops.write_reg))
633 * SFP documentation requires the following to configure the SPF module
634 * to work on SGMII. No further documentation is given.
636 ret_val = hw->phy.ops.write_reg(hw, 0x1B, 0x8084);
640 ret_val = hw->phy.ops.commit(hw);
647 * e1000_set_d0_lplu_state_82575 - Set Low Power Linkup D0 state
648 * @hw: pointer to the HW structure
649 * @active: TRUE to enable LPLU, FALSE to disable
651 * Sets the LPLU D0 state according to the active flag. When
652 * activating LPLU this function also disables smart speed
653 * and vice versa. LPLU will not be activated unless the
654 * device autonegotiation advertisement meets standards of
655 * either 10 or 10/100 or 10/100/1000 at all duplexes.
656 * This is a function pointer entry point only called by
657 * PHY setup routines.
659 static s32 e1000_set_d0_lplu_state_82575(struct e1000_hw *hw, bool active)
661 struct e1000_phy_info *phy = &hw->phy;
662 s32 ret_val = E1000_SUCCESS;
665 DEBUGFUNC("e1000_set_d0_lplu_state_82575");
667 if (!(hw->phy.ops.read_reg))
670 ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data);
675 data |= IGP02E1000_PM_D0_LPLU;
676 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
681 /* When LPLU is enabled, we should disable SmartSpeed */
682 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
684 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
685 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
690 data &= ~IGP02E1000_PM_D0_LPLU;
691 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
694 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
695 * during Dx states where the power conservation is most
696 * important. During driver activity we should enable
697 * SmartSpeed, so performance is maintained.
699 if (phy->smart_speed == e1000_smart_speed_on) {
700 ret_val = phy->ops.read_reg(hw,
701 IGP01E1000_PHY_PORT_CONFIG,
706 data |= IGP01E1000_PSCFR_SMART_SPEED;
707 ret_val = phy->ops.write_reg(hw,
708 IGP01E1000_PHY_PORT_CONFIG,
712 } else if (phy->smart_speed == e1000_smart_speed_off) {
713 ret_val = phy->ops.read_reg(hw,
714 IGP01E1000_PHY_PORT_CONFIG,
719 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
720 ret_val = phy->ops.write_reg(hw,
721 IGP01E1000_PHY_PORT_CONFIG,
733 * e1000_acquire_nvm_82575 - Request for access to EEPROM
734 * @hw: pointer to the HW structure
736 * Acquire the necessary semaphores for exclusive access to the EEPROM.
737 * Set the EEPROM access request bit and wait for EEPROM access grant bit.
738 * Return successful if access grant bit set, else clear the request for
739 * EEPROM access and return -E1000_ERR_NVM (-1).
741 static s32 e1000_acquire_nvm_82575(struct e1000_hw *hw)
745 DEBUGFUNC("e1000_acquire_nvm_82575");
747 ret_val = e1000_acquire_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
751 ret_val = e1000_acquire_nvm_generic(hw);
754 e1000_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
761 * e1000_release_nvm_82575 - Release exclusive access to EEPROM
762 * @hw: pointer to the HW structure
764 * Stop any current commands to the EEPROM and clear the EEPROM request bit,
765 * then release the semaphores acquired.
767 static void e1000_release_nvm_82575(struct e1000_hw *hw)
769 DEBUGFUNC("e1000_release_nvm_82575");
771 e1000_release_nvm_generic(hw);
772 e1000_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
776 * e1000_acquire_swfw_sync_82575 - Acquire SW/FW semaphore
777 * @hw: pointer to the HW structure
778 * @mask: specifies which semaphore to acquire
780 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
781 * will also specify which port we're acquiring the lock for.
783 static s32 e1000_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
787 u32 fwmask = mask << 16;
788 s32 ret_val = E1000_SUCCESS;
789 s32 i = 0, timeout = 200; /* FIXME: find real value to use here */
791 DEBUGFUNC("e1000_acquire_swfw_sync_82575");
793 while (i < timeout) {
794 if (e1000_get_hw_semaphore_generic(hw)) {
795 ret_val = -E1000_ERR_SWFW_SYNC;
799 swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
800 if (!(swfw_sync & (fwmask | swmask)))
804 * Firmware currently using resource (fwmask)
805 * or other software thread using resource (swmask)
807 e1000_put_hw_semaphore_generic(hw);
813 DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n");
814 ret_val = -E1000_ERR_SWFW_SYNC;
819 E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
821 e1000_put_hw_semaphore_generic(hw);
828 * e1000_release_swfw_sync_82575 - Release SW/FW semaphore
829 * @hw: pointer to the HW structure
830 * @mask: specifies which semaphore to acquire
832 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
833 * will also specify which port we're releasing the lock for.
835 static void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
839 DEBUGFUNC("e1000_release_swfw_sync_82575");
841 while (e1000_get_hw_semaphore_generic(hw) != E1000_SUCCESS);
844 swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
846 E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
848 e1000_put_hw_semaphore_generic(hw);
852 * e1000_get_cfg_done_82575 - Read config done bit
853 * @hw: pointer to the HW structure
855 * Read the management control register for the config done bit for
856 * completion status. NOTE: silicon which is EEPROM-less will fail trying
857 * to read the config done bit, so an error is *ONLY* logged and returns
858 * E1000_SUCCESS. If we were to return with error, EEPROM-less silicon
859 * would not be able to be reset or change link.
861 static s32 e1000_get_cfg_done_82575(struct e1000_hw *hw)
863 s32 timeout = PHY_CFG_TIMEOUT;
864 s32 ret_val = E1000_SUCCESS;
865 u32 mask = E1000_NVM_CFG_DONE_PORT_0;
867 DEBUGFUNC("e1000_get_cfg_done_82575");
869 if (hw->bus.func == E1000_FUNC_1)
870 mask = E1000_NVM_CFG_DONE_PORT_1;
871 else if (hw->bus.func == E1000_FUNC_2)
872 mask = E1000_NVM_CFG_DONE_PORT_2;
873 else if (hw->bus.func == E1000_FUNC_3)
874 mask = E1000_NVM_CFG_DONE_PORT_3;
876 if (E1000_READ_REG(hw, E1000_EEMNGCTL) & mask)
882 DEBUGOUT("MNG configuration cycle has not completed.\n");
884 /* If EEPROM is not marked present, init the PHY manually */
885 if (((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0) &&
886 (hw->phy.type == e1000_phy_igp_3))
887 e1000_phy_init_script_igp3(hw);
893 * e1000_get_link_up_info_82575 - Get link speed/duplex info
894 * @hw: pointer to the HW structure
895 * @speed: stores the current speed
896 * @duplex: stores the current duplex
898 * This is a wrapper function, if using the serial gigabit media independent
899 * interface, use PCS to retrieve the link speed and duplex information.
900 * Otherwise, use the generic function to get the link speed and duplex info.
902 static s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
907 DEBUGFUNC("e1000_get_link_up_info_82575");
909 if (hw->phy.media_type != e1000_media_type_copper)
910 ret_val = e1000_get_pcs_speed_and_duplex_82575(hw, speed,
913 ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed,
920 * e1000_check_for_link_82575 - Check for link
921 * @hw: pointer to the HW structure
923 * If sgmii is enabled, then use the pcs register to determine link, otherwise
924 * use the generic interface for determining link.
926 static s32 e1000_check_for_link_82575(struct e1000_hw *hw)
931 DEBUGFUNC("e1000_check_for_link_82575");
933 if (hw->phy.media_type != e1000_media_type_copper) {
934 ret_val = e1000_get_pcs_speed_and_duplex_82575(hw, &speed,
937 * Use this flag to determine if link needs to be checked or
938 * not. If we have link clear the flag so that we do not
939 * continue to check for link.
941 hw->mac.get_link_status = !hw->mac.serdes_has_link;
943 ret_val = e1000_check_for_copper_link_generic(hw);
950 * e1000_power_up_serdes_link_82575 - Power up the serdes link after shutdown
951 * @hw: pointer to the HW structure
953 static void e1000_power_up_serdes_link_82575(struct e1000_hw *hw)
957 DEBUGFUNC("e1000_power_up_serdes_link_82575");
959 if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
960 !e1000_sgmii_active_82575(hw))
963 /* Enable PCS to turn on link */
964 reg = E1000_READ_REG(hw, E1000_PCS_CFG0);
965 reg |= E1000_PCS_CFG_PCS_EN;
966 E1000_WRITE_REG(hw, E1000_PCS_CFG0, reg);
968 /* Power up the laser */
969 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
970 reg &= ~E1000_CTRL_EXT_SDP3_DATA;
971 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
973 /* flush the write to verify completion */
974 E1000_WRITE_FLUSH(hw);
979 * e1000_get_pcs_speed_and_duplex_82575 - Retrieve current speed/duplex
980 * @hw: pointer to the HW structure
981 * @speed: stores the current speed
982 * @duplex: stores the current duplex
984 * Using the physical coding sub-layer (PCS), retrieve the current speed and
985 * duplex, then store the values in the pointers provided.
987 static s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
988 u16 *speed, u16 *duplex)
990 struct e1000_mac_info *mac = &hw->mac;
993 DEBUGFUNC("e1000_get_pcs_speed_and_duplex_82575");
995 /* Set up defaults for the return values of this function */
996 mac->serdes_has_link = FALSE;
1001 * Read the PCS Status register for link state. For non-copper mode,
1002 * the status register is not accurate. The PCS status register is
1005 pcs = E1000_READ_REG(hw, E1000_PCS_LSTAT);
1008 * The link up bit determines when link is up on autoneg. The sync ok
1009 * gets set once both sides sync up and agree upon link. Stable link
1010 * can be determined by checking for both link up and link sync ok
1012 if ((pcs & E1000_PCS_LSTS_LINK_OK) && (pcs & E1000_PCS_LSTS_SYNK_OK)) {
1013 mac->serdes_has_link = TRUE;
1015 /* Detect and store PCS speed */
1016 if (pcs & E1000_PCS_LSTS_SPEED_1000) {
1017 *speed = SPEED_1000;
1018 } else if (pcs & E1000_PCS_LSTS_SPEED_100) {
1024 /* Detect and store PCS duplex */
1025 if (pcs & E1000_PCS_LSTS_DUPLEX_FULL) {
1026 *duplex = FULL_DUPLEX;
1028 *duplex = HALF_DUPLEX;
1032 return E1000_SUCCESS;
1036 * e1000_shutdown_serdes_link_82575 - Remove link during power down
1037 * @hw: pointer to the HW structure
1039 * In the case of serdes shut down sfp and PCS on driver unload
1040 * when management pass thru is not enabled.
1042 void e1000_shutdown_serdes_link_82575(struct e1000_hw *hw)
1046 DEBUGFUNC("e1000_shutdown_serdes_link_82575");
1048 if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
1049 !e1000_sgmii_active_82575(hw))
1052 if (!e1000_enable_mng_pass_thru(hw)) {
1053 /* Disable PCS to turn off link */
1054 reg = E1000_READ_REG(hw, E1000_PCS_CFG0);
1055 reg &= ~E1000_PCS_CFG_PCS_EN;
1056 E1000_WRITE_REG(hw, E1000_PCS_CFG0, reg);
1058 /* shutdown the laser */
1059 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1060 reg |= E1000_CTRL_EXT_SDP3_DATA;
1061 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
1063 /* flush the write to verify completion */
1064 E1000_WRITE_FLUSH(hw);
1072 * e1000_reset_hw_82575 - Reset hardware
1073 * @hw: pointer to the HW structure
1075 * This resets the hardware into a known state.
1077 static s32 e1000_reset_hw_82575(struct e1000_hw *hw)
1082 DEBUGFUNC("e1000_reset_hw_82575");
1085 * Prevent the PCI-E bus from sticking if there is no TLP connection
1086 * on the last TLP read/write transaction when MAC is reset.
1088 ret_val = e1000_disable_pcie_master_generic(hw);
1090 DEBUGOUT("PCI-E Master disable polling has failed.\n");
1093 /* set the completion timeout for interface */
1094 ret_val = e1000_set_pcie_completion_timeout(hw);
1096 DEBUGOUT("PCI-E Set completion timeout has failed.\n");
1099 DEBUGOUT("Masking off all interrupts\n");
1100 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
1102 E1000_WRITE_REG(hw, E1000_RCTL, 0);
1103 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
1104 E1000_WRITE_FLUSH(hw);
1108 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1110 DEBUGOUT("Issuing a global reset to MAC\n");
1111 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
1113 ret_val = e1000_get_auto_rd_done_generic(hw);
1116 * When auto config read does not complete, do not
1117 * return with an error. This can happen in situations
1118 * where there is no eeprom and prevents getting link.
1120 DEBUGOUT("Auto Read Done did not complete\n");
1123 /* If EEPROM is not present, run manual init scripts */
1124 if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0)
1125 e1000_reset_init_script_82575(hw);
1127 /* Clear any pending interrupt events. */
1128 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
1129 icr = E1000_READ_REG(hw, E1000_ICR);
1131 /* Install any alternate MAC address into RAR0 */
1132 ret_val = e1000_check_alt_mac_addr_generic(hw);
1138 * e1000_init_hw_82575 - Initialize hardware
1139 * @hw: pointer to the HW structure
1141 * This inits the hardware readying it for operation.
1143 static s32 e1000_init_hw_82575(struct e1000_hw *hw)
1145 struct e1000_mac_info *mac = &hw->mac;
1147 u16 i, rar_count = mac->rar_entry_count;
1149 DEBUGFUNC("e1000_init_hw_82575");
1151 /* Initialize identification LED */
1152 ret_val = mac->ops.id_led_init(hw);
1154 DEBUGOUT("Error initializing identification LED\n");
1155 /* This is not fatal and we should not stop init due to this */
1158 /* Disabling VLAN filtering */
1159 DEBUGOUT("Initializing the IEEE VLAN\n");
1160 mac->ops.clear_vfta(hw);
1162 /* Setup the receive address */
1163 e1000_init_rx_addrs_generic(hw, rar_count);
1165 /* Zero out the Multicast HASH table */
1166 DEBUGOUT("Zeroing the MTA\n");
1167 for (i = 0; i < mac->mta_reg_count; i++)
1168 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
1170 /* Zero out the Unicast HASH table */
1171 DEBUGOUT("Zeroing the UTA\n");
1172 for (i = 0; i < mac->uta_reg_count; i++)
1173 E1000_WRITE_REG_ARRAY(hw, E1000_UTA, i, 0);
1175 /* Setup link and flow control */
1176 ret_val = mac->ops.setup_link(hw);
1179 * Clear all of the statistics registers (clear on read). It is
1180 * important that we do this after we have tried to establish link
1181 * because the symbol error count will increment wildly if there
1184 e1000_clear_hw_cntrs_82575(hw);
1190 * e1000_setup_copper_link_82575 - Configure copper link settings
1191 * @hw: pointer to the HW structure
1193 * Configures the link for auto-neg or forced speed and duplex. Then we check
1194 * for link, once link is established calls to configure collision distance
1195 * and flow control are called.
1197 static s32 e1000_setup_copper_link_82575(struct e1000_hw *hw)
1202 DEBUGFUNC("e1000_setup_copper_link_82575");
1204 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1205 ctrl |= E1000_CTRL_SLU;
1206 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1207 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1209 ret_val = e1000_setup_serdes_link_82575(hw);
1213 if (e1000_sgmii_active_82575(hw) && !hw->phy.reset_disable) {
1214 /* allow time for SFP cage time to power up phy */
1217 ret_val = hw->phy.ops.reset(hw);
1219 DEBUGOUT("Error resetting the PHY.\n");
1223 switch (hw->phy.type) {
1225 ret_val = e1000_copper_link_setup_m88(hw);
1227 case e1000_phy_igp_3:
1228 ret_val = e1000_copper_link_setup_igp(hw);
1230 case e1000_phy_82580:
1231 ret_val = e1000_copper_link_setup_82577(hw);
1234 ret_val = -E1000_ERR_PHY;
1241 ret_val = e1000_setup_copper_link_generic(hw);
1247 * e1000_setup_serdes_link_82575 - Setup link for serdes
1248 * @hw: pointer to the HW structure
1250 * Configure the physical coding sub-layer (PCS) link. The PCS link is
1251 * used on copper connections where the serialized gigabit media independent
1252 * interface (sgmii), or serdes fiber is being used. Configures the link
1253 * for auto-negotiation or forces speed/duplex.
1255 static s32 e1000_setup_serdes_link_82575(struct e1000_hw *hw)
1257 u32 ctrl_ext, ctrl_reg, reg;
1260 DEBUGFUNC("e1000_setup_serdes_link_82575");
1262 if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
1263 !e1000_sgmii_active_82575(hw))
1264 return E1000_SUCCESS;
1267 * On the 82575, SerDes loopback mode persists until it is
1268 * explicitly turned off or a power cycle is performed. A read to
1269 * the register does not indicate its status. Therefore, we ensure
1270 * loopback mode is disabled during initialization.
1272 E1000_WRITE_REG(hw, E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
1274 /* power on the sfp cage if present */
1275 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
1276 ctrl_ext &= ~E1000_CTRL_EXT_SDP3_DATA;
1277 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
1279 ctrl_reg = E1000_READ_REG(hw, E1000_CTRL);
1280 ctrl_reg |= E1000_CTRL_SLU;
1282 /* set both sw defined pins on 82575/82576*/
1283 if (hw->mac.type == e1000_82575 || hw->mac.type == e1000_82576)
1284 ctrl_reg |= E1000_CTRL_SWDPIN0 | E1000_CTRL_SWDPIN1;
1286 reg = E1000_READ_REG(hw, E1000_PCS_LCTL);
1288 /* default pcs_autoneg to the same setting as mac autoneg */
1289 pcs_autoneg = hw->mac.autoneg;
1291 switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) {
1292 case E1000_CTRL_EXT_LINK_MODE_SGMII:
1293 /* sgmii mode lets the phy handle forcing speed/duplex */
1295 /* autoneg time out should be disabled for SGMII mode */
1296 reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT);
1298 case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX:
1299 /* disable PCS autoneg and support parallel detect only */
1300 pcs_autoneg = FALSE;
1301 /* fall through to default case */
1304 * non-SGMII modes only supports a speed of 1000/Full for the
1305 * link so it is best to just force the MAC and let the pcs
1306 * link either autoneg or be forced to 1000/Full
1308 ctrl_reg |= E1000_CTRL_SPD_1000 | E1000_CTRL_FRCSPD |
1309 E1000_CTRL_FD | E1000_CTRL_FRCDPX;
1311 /* set speed of 1000/Full if speed/duplex is forced */
1312 reg |= E1000_PCS_LCTL_FSV_1000 | E1000_PCS_LCTL_FDV_FULL;
1316 E1000_WRITE_REG(hw, E1000_CTRL, ctrl_reg);
1319 * New SerDes mode allows for forcing speed or autonegotiating speed
1320 * at 1gb. Autoneg should be default set by most drivers. This is the
1321 * mode that will be compatible with older link partners and switches.
1322 * However, both are supported by the hardware and some drivers/tools.
1324 reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP |
1325 E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
1328 * We force flow control to prevent the CTRL register values from being
1329 * overwritten by the autonegotiated flow control values
1331 reg |= E1000_PCS_LCTL_FORCE_FCTRL;
1334 /* Set PCS register for autoneg */
1335 reg |= E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */
1336 E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */
1337 DEBUGOUT1("Configuring Autoneg:PCS_LCTL=0x%08X\n", reg);
1339 /* Set PCS register for forced link */
1340 reg |= E1000_PCS_LCTL_FSD; /* Force Speed */
1341 DEBUGOUT1("Configuring Forced Link:PCS_LCTL=0x%08X\n", reg);
1344 E1000_WRITE_REG(hw, E1000_PCS_LCTL, reg);
1346 if (!e1000_sgmii_active_82575(hw))
1347 e1000_force_mac_fc_generic(hw);
1349 return E1000_SUCCESS;
1353 * e1000_valid_led_default_82575 - Verify a valid default LED config
1354 * @hw: pointer to the HW structure
1355 * @data: pointer to the NVM (EEPROM)
1357 * Read the EEPROM for the current default LED configuration. If the
1358 * LED configuration is not valid, set to a valid LED configuration.
1360 static s32 e1000_valid_led_default_82575(struct e1000_hw *hw, u16 *data)
1364 DEBUGFUNC("e1000_valid_led_default_82575");
1366 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
1368 DEBUGOUT("NVM Read Error\n");
1372 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF) {
1373 switch(hw->phy.media_type) {
1374 case e1000_media_type_internal_serdes:
1375 *data = ID_LED_DEFAULT_82575_SERDES;
1377 case e1000_media_type_copper:
1379 *data = ID_LED_DEFAULT;
1388 * e1000_sgmii_active_82575 - Return sgmii state
1389 * @hw: pointer to the HW structure
1391 * 82575 silicon has a serialized gigabit media independent interface (sgmii)
1392 * which can be enabled for use in the embedded applications. Simply
1393 * return the current state of the sgmii interface.
1395 static bool e1000_sgmii_active_82575(struct e1000_hw *hw)
1397 struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
1398 return dev_spec->sgmii_active;
1402 * e1000_reset_init_script_82575 - Inits HW defaults after reset
1403 * @hw: pointer to the HW structure
1405 * Inits recommended HW defaults after a reset when there is no EEPROM
1406 * detected. This is only for the 82575.
1408 static s32 e1000_reset_init_script_82575(struct e1000_hw* hw)
1410 DEBUGFUNC("e1000_reset_init_script_82575");
1412 if (hw->mac.type == e1000_82575) {
1413 DEBUGOUT("Running reset init script for 82575\n");
1414 /* SerDes configuration via SERDESCTRL */
1415 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x00, 0x0C);
1416 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x01, 0x78);
1417 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x1B, 0x23);
1418 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x23, 0x15);
1420 /* CCM configuration via CCMCTL register */
1421 e1000_write_8bit_ctrl_reg_generic(hw, E1000_CCMCTL, 0x14, 0x00);
1422 e1000_write_8bit_ctrl_reg_generic(hw, E1000_CCMCTL, 0x10, 0x00);
1424 /* PCIe lanes configuration */
1425 e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x00, 0xEC);
1426 e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x61, 0xDF);
1427 e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x34, 0x05);
1428 e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x2F, 0x81);
1430 /* PCIe PLL Configuration */
1431 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCCTL, 0x02, 0x47);
1432 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCCTL, 0x14, 0x00);
1433 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCCTL, 0x10, 0x00);
1436 return E1000_SUCCESS;
1440 * e1000_read_mac_addr_82575 - Read device MAC address
1441 * @hw: pointer to the HW structure
1443 static s32 e1000_read_mac_addr_82575(struct e1000_hw *hw)
1445 s32 ret_val = E1000_SUCCESS;
1447 DEBUGFUNC("e1000_read_mac_addr_82575");
1450 * If there's an alternate MAC address place it in RAR0
1451 * so that it will override the Si installed default perm
1454 ret_val = e1000_check_alt_mac_addr_generic(hw);
1458 ret_val = e1000_read_mac_addr_generic(hw);
1465 * e1000_config_collision_dist_82575 - Configure collision distance
1466 * @hw: pointer to the HW structure
1468 * Configures the collision distance to the default value and is used
1469 * during link setup.
1471 static void e1000_config_collision_dist_82575(struct e1000_hw *hw)
1475 DEBUGFUNC("e1000_config_collision_dist_82575");
1477 tctl_ext = E1000_READ_REG(hw, E1000_TCTL_EXT);
1479 tctl_ext &= ~E1000_TCTL_EXT_COLD;
1480 tctl_ext |= E1000_COLLISION_DISTANCE << E1000_TCTL_EXT_COLD_SHIFT;
1482 E1000_WRITE_REG(hw, E1000_TCTL_EXT, tctl_ext);
1483 E1000_WRITE_FLUSH(hw);
1487 * e1000_power_down_phy_copper_82575 - Remove link during PHY power down
1488 * @hw: pointer to the HW structure
1490 * In the case of a PHY power down to save power, or to turn off link during a
1491 * driver unload, or wake on lan is not enabled, remove the link.
1493 static void e1000_power_down_phy_copper_82575(struct e1000_hw *hw)
1495 struct e1000_phy_info *phy = &hw->phy;
1497 if (!(phy->ops.check_reset_block))
1500 /* If the management interface is not enabled, then power down */
1501 if (!(e1000_enable_mng_pass_thru(hw) || phy->ops.check_reset_block(hw)))
1502 e1000_power_down_phy_copper(hw);
1508 * e1000_clear_hw_cntrs_82575 - Clear device specific hardware counters
1509 * @hw: pointer to the HW structure
1511 * Clears the hardware counters by reading the counter registers.
1513 static void e1000_clear_hw_cntrs_82575(struct e1000_hw *hw)
1515 DEBUGFUNC("e1000_clear_hw_cntrs_82575");
1517 e1000_clear_hw_cntrs_base_generic(hw);
1519 E1000_READ_REG(hw, E1000_PRC64);
1520 E1000_READ_REG(hw, E1000_PRC127);
1521 E1000_READ_REG(hw, E1000_PRC255);
1522 E1000_READ_REG(hw, E1000_PRC511);
1523 E1000_READ_REG(hw, E1000_PRC1023);
1524 E1000_READ_REG(hw, E1000_PRC1522);
1525 E1000_READ_REG(hw, E1000_PTC64);
1526 E1000_READ_REG(hw, E1000_PTC127);
1527 E1000_READ_REG(hw, E1000_PTC255);
1528 E1000_READ_REG(hw, E1000_PTC511);
1529 E1000_READ_REG(hw, E1000_PTC1023);
1530 E1000_READ_REG(hw, E1000_PTC1522);
1532 E1000_READ_REG(hw, E1000_ALGNERRC);
1533 E1000_READ_REG(hw, E1000_RXERRC);
1534 E1000_READ_REG(hw, E1000_TNCRS);
1535 E1000_READ_REG(hw, E1000_CEXTERR);
1536 E1000_READ_REG(hw, E1000_TSCTC);
1537 E1000_READ_REG(hw, E1000_TSCTFC);
1539 E1000_READ_REG(hw, E1000_MGTPRC);
1540 E1000_READ_REG(hw, E1000_MGTPDC);
1541 E1000_READ_REG(hw, E1000_MGTPTC);
1543 E1000_READ_REG(hw, E1000_IAC);
1544 E1000_READ_REG(hw, E1000_ICRXOC);
1546 E1000_READ_REG(hw, E1000_ICRXPTC);
1547 E1000_READ_REG(hw, E1000_ICRXATC);
1548 E1000_READ_REG(hw, E1000_ICTXPTC);
1549 E1000_READ_REG(hw, E1000_ICTXATC);
1550 E1000_READ_REG(hw, E1000_ICTXQEC);
1551 E1000_READ_REG(hw, E1000_ICTXQMTC);
1552 E1000_READ_REG(hw, E1000_ICRXDMTC);
1554 E1000_READ_REG(hw, E1000_CBTMPC);
1555 E1000_READ_REG(hw, E1000_HTDPMC);
1556 E1000_READ_REG(hw, E1000_CBRMPC);
1557 E1000_READ_REG(hw, E1000_RPTHC);
1558 E1000_READ_REG(hw, E1000_HGPTC);
1559 E1000_READ_REG(hw, E1000_HTCBDPC);
1560 E1000_READ_REG(hw, E1000_HGORCL);
1561 E1000_READ_REG(hw, E1000_HGORCH);
1562 E1000_READ_REG(hw, E1000_HGOTCL);
1563 E1000_READ_REG(hw, E1000_HGOTCH);
1564 E1000_READ_REG(hw, E1000_LENERRS);
1566 /* This register should not be read in copper configurations */
1567 if ((hw->phy.media_type == e1000_media_type_internal_serdes) ||
1568 e1000_sgmii_active_82575(hw))
1569 E1000_READ_REG(hw, E1000_SCVPC);
1573 * e1000_rx_fifo_flush_82575 - Clean rx fifo after RX enable
1574 * @hw: pointer to the HW structure
1576 * After rx enable if managability is enabled then there is likely some
1577 * bad data at the start of the fifo and possibly in the DMA fifo. This
1578 * function clears the fifos and flushes any packets that came in as rx was
1581 void e1000_rx_fifo_flush_82575(struct e1000_hw *hw)
1583 u32 rctl, rlpml, rxdctl[4], rfctl, temp_rctl, rx_enabled;
1586 DEBUGFUNC("e1000_rx_fifo_workaround_82575");
1587 if (hw->mac.type != e1000_82575 ||
1588 !(E1000_READ_REG(hw, E1000_MANC) & E1000_MANC_RCV_TCO_EN))
1591 /* Disable all RX queues */
1592 for (i = 0; i < 4; i++) {
1593 rxdctl[i] = E1000_READ_REG(hw, E1000_RXDCTL(i));
1594 E1000_WRITE_REG(hw, E1000_RXDCTL(i),
1595 rxdctl[i] & ~E1000_RXDCTL_QUEUE_ENABLE);
1597 /* Poll all queues to verify they have shut down */
1598 for (ms_wait = 0; ms_wait < 10; ms_wait++) {
1601 for (i = 0; i < 4; i++)
1602 rx_enabled |= E1000_READ_REG(hw, E1000_RXDCTL(i));
1603 if (!(rx_enabled & E1000_RXDCTL_QUEUE_ENABLE))
1608 DEBUGOUT("Queue disable timed out after 10ms\n");
1610 /* Clear RLPML, RCTL.SBP, RFCTL.LEF, and set RCTL.LPE so that all
1611 * incoming packets are rejected. Set enable and wait 2ms so that
1612 * any packet that was coming in as RCTL.EN was set is flushed
1614 rfctl = E1000_READ_REG(hw, E1000_RFCTL);
1615 E1000_WRITE_REG(hw, E1000_RFCTL, rfctl & ~E1000_RFCTL_LEF);
1617 rlpml = E1000_READ_REG(hw, E1000_RLPML);
1618 E1000_WRITE_REG(hw, E1000_RLPML, 0);
1620 rctl = E1000_READ_REG(hw, E1000_RCTL);
1621 temp_rctl = rctl & ~(E1000_RCTL_EN | E1000_RCTL_SBP);
1622 temp_rctl |= E1000_RCTL_LPE;
1624 E1000_WRITE_REG(hw, E1000_RCTL, temp_rctl);
1625 E1000_WRITE_REG(hw, E1000_RCTL, temp_rctl | E1000_RCTL_EN);
1626 E1000_WRITE_FLUSH(hw);
1629 /* Enable RX queues that were previously enabled and restore our
1632 for (i = 0; i < 4; i++)
1633 E1000_WRITE_REG(hw, E1000_RXDCTL(i), rxdctl[i]);
1634 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
1635 E1000_WRITE_FLUSH(hw);
1637 E1000_WRITE_REG(hw, E1000_RLPML, rlpml);
1638 E1000_WRITE_REG(hw, E1000_RFCTL, rfctl);
1640 /* Flush receive errors generated by workaround */
1641 E1000_READ_REG(hw, E1000_ROC);
1642 E1000_READ_REG(hw, E1000_RNBC);
1643 E1000_READ_REG(hw, E1000_MPC);
1647 * e1000_set_pcie_completion_timeout - set pci-e completion timeout
1648 * @hw: pointer to the HW structure
1650 * The defaults for 82575 and 82576 should be in the range of 50us to 50ms,
1651 * however the hardware default for these parts is 500us to 1ms which is less
1652 * than the 10ms recommended by the pci-e spec. To address this we need to
1653 * increase the value to either 10ms to 200ms for capability version 1 config,
1654 * or 16ms to 55ms for version 2.
1656 static s32 e1000_set_pcie_completion_timeout(struct e1000_hw *hw)
1658 u32 gcr = E1000_READ_REG(hw, E1000_GCR);
1659 s32 ret_val = E1000_SUCCESS;
1662 /* only take action if timeout value is defaulted to 0 */
1663 if (gcr & E1000_GCR_CMPL_TMOUT_MASK)
1667 * if capababilities version is type 1 we can write the
1668 * timeout of 10ms to 200ms through the GCR register
1670 if (!(gcr & E1000_GCR_CAP_VER2)) {
1671 gcr |= E1000_GCR_CMPL_TMOUT_10ms;
1676 * for version 2 capabilities we need to write the config space
1677 * directly in order to set the completion timeout value for
1680 ret_val = e1000_read_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
1685 pcie_devctl2 |= PCIE_DEVICE_CONTROL2_16ms;
1687 ret_val = e1000_write_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
1690 /* disable completion timeout resend */
1691 gcr &= ~E1000_GCR_CMPL_TMOUT_RESEND;
1693 E1000_WRITE_REG(hw, E1000_GCR, gcr);
1699 * e1000_vmdq_set_anti_spoofing_pf - enable or disable anti-spoofing
1700 * @hw: pointer to the hardware struct
1701 * @enable: state to enter, either enabled or disabled
1702 * @pf: Physical Function pool - do not set anti-spoofing for the PF
1704 * enables/disables L2 switch anti-spoofing functionality.
1706 void e1000_vmdq_set_anti_spoofing_pf(struct e1000_hw *hw, bool enable, int pf)
1710 switch (hw->mac.type) {
1712 dtxswc = E1000_READ_REG(hw, E1000_DTXSWC);
1714 dtxswc |= (E1000_DTXSWC_MAC_SPOOF_MASK |
1715 E1000_DTXSWC_VLAN_SPOOF_MASK);
1716 /* The PF can spoof - it has to in order to
1717 * support emulation mode NICs */
1718 dtxswc ^= (1 << pf | 1 << (pf + MAX_NUM_VFS));
1720 dtxswc &= ~(E1000_DTXSWC_MAC_SPOOF_MASK |
1721 E1000_DTXSWC_VLAN_SPOOF_MASK);
1723 E1000_WRITE_REG(hw, E1000_DTXSWC, dtxswc);
1731 * e1000_vmdq_set_loopback_pf - enable or disable vmdq loopback
1732 * @hw: pointer to the hardware struct
1733 * @enable: state to enter, either enabled or disabled
1735 * enables/disables L2 switch loopback functionality.
1737 void e1000_vmdq_set_loopback_pf(struct e1000_hw *hw, bool enable)
1741 switch (hw->mac.type) {
1743 dtxswc = E1000_READ_REG(hw, E1000_DTXSWC);
1745 dtxswc |= E1000_DTXSWC_VMDQ_LOOPBACK_EN;
1747 dtxswc &= ~E1000_DTXSWC_VMDQ_LOOPBACK_EN;
1748 E1000_WRITE_REG(hw, E1000_DTXSWC, dtxswc);
1751 /* Currently no other hardware supports loopback */
1759 * e1000_vmdq_set_replication_pf - enable or disable vmdq replication
1760 * @hw: pointer to the hardware struct
1761 * @enable: state to enter, either enabled or disabled
1763 * enables/disables replication of packets across multiple pools.
1765 void e1000_vmdq_set_replication_pf(struct e1000_hw *hw, bool enable)
1767 u32 vt_ctl = E1000_READ_REG(hw, E1000_VT_CTL);
1770 vt_ctl |= E1000_VT_CTL_VM_REPL_EN;
1772 vt_ctl &= ~E1000_VT_CTL_VM_REPL_EN;
1774 E1000_WRITE_REG(hw, E1000_VT_CTL, vt_ctl);
1778 * e1000_read_phy_reg_82580 - Read 82580 MDI control register
1779 * @hw: pointer to the HW structure
1780 * @offset: register offset to be read
1781 * @data: pointer to the read data
1783 * Reads the MDI control register in the PHY at offset and stores the
1784 * information read to data.
1786 static s32 e1000_read_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 *data)
1790 DEBUGFUNC("e1000_read_phy_reg_82580");
1792 ret_val = hw->phy.ops.acquire(hw);
1796 ret_val = e1000_read_phy_reg_mdic(hw, offset, data);
1798 hw->phy.ops.release(hw);
1805 * e1000_write_phy_reg_82580 - Write 82580 MDI control register
1806 * @hw: pointer to the HW structure
1807 * @offset: register offset to write to
1808 * @data: data to write to register at offset
1810 * Writes data to MDI control register in the PHY at offset.
1812 static s32 e1000_write_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 data)
1816 DEBUGFUNC("e1000_write_phy_reg_82580");
1818 ret_val = hw->phy.ops.acquire(hw);
1822 ret_val = e1000_write_phy_reg_mdic(hw, offset, data);
1824 hw->phy.ops.release(hw);
1831 * e1000_reset_mdicnfg_82580 - Reset MDICNFG destination and com_mdio bits
1832 * @hw: pointer to the HW structure
1834 * This resets the the MDICNFG.Destination and MDICNFG.Com_MDIO bits based on
1835 * the values found in the EEPROM. This addresses an issue in which these
1836 * bits are not restored from EEPROM after reset.
1838 static s32 e1000_reset_mdicnfg_82580(struct e1000_hw *hw)
1840 s32 ret_val = E1000_SUCCESS;
1844 DEBUGFUNC("e1000_reset_mdicnfg_82580");
1846 if (hw->mac.type != e1000_82580)
1848 if (!e1000_sgmii_active_82575(hw))
1851 ret_val = hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A +
1852 NVM_82580_LAN_FUNC_OFFSET(hw->bus.func), 1,
1855 DEBUGOUT("NVM Read Error\n");
1859 mdicnfg = E1000_READ_REG(hw, E1000_MDICNFG);
1860 if (nvm_data & NVM_WORD24_EXT_MDIO)
1861 mdicnfg |= E1000_MDICNFG_EXT_MDIO;
1862 if (nvm_data & NVM_WORD24_COM_MDIO)
1863 mdicnfg |= E1000_MDICNFG_COM_MDIO;
1864 E1000_WRITE_REG(hw, E1000_MDICNFG, mdicnfg);
1870 * e1000_reset_hw_82580 - Reset hardware
1871 * @hw: pointer to the HW structure
1873 * This resets function or entire device (all ports, etc.)
1876 static s32 e1000_reset_hw_82580(struct e1000_hw *hw)
1878 s32 ret_val = E1000_SUCCESS;
1879 /* BH SW mailbox bit in SW_FW_SYNC */
1880 u16 swmbsw_mask = E1000_SW_SYNCH_MB;
1882 bool global_device_reset = hw->dev_spec._82575.global_device_reset;
1884 DEBUGFUNC("e1000_reset_hw_82580");
1886 hw->dev_spec._82575.global_device_reset = FALSE;
1888 /* Get current control state. */
1889 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1892 * Prevent the PCI-E bus from sticking if there is no TLP connection
1893 * on the last TLP read/write transaction when MAC is reset.
1895 ret_val = e1000_disable_pcie_master_generic(hw);
1897 DEBUGOUT("PCI-E Master disable polling has failed.\n");
1899 DEBUGOUT("Masking off all interrupts\n");
1900 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
1901 E1000_WRITE_REG(hw, E1000_RCTL, 0);
1902 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
1903 E1000_WRITE_FLUSH(hw);
1907 /* Determine whether or not a global dev reset is requested */
1908 if (global_device_reset &&
1909 e1000_acquire_swfw_sync_82575(hw, swmbsw_mask))
1910 global_device_reset = FALSE;
1912 if (global_device_reset &&
1913 !(E1000_READ_REG(hw, E1000_STATUS) & E1000_STAT_DEV_RST_SET))
1914 ctrl |= E1000_CTRL_DEV_RST;
1916 ctrl |= E1000_CTRL_RST;
1918 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1920 /* Add delay to insure DEV_RST has time to complete */
1921 if (global_device_reset)
1924 ret_val = e1000_get_auto_rd_done_generic(hw);
1927 * When auto config read does not complete, do not
1928 * return with an error. This can happen in situations
1929 * where there is no eeprom and prevents getting link.
1931 DEBUGOUT("Auto Read Done did not complete\n");
1934 /* If EEPROM is not present, run manual init scripts */
1935 if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0)
1936 e1000_reset_init_script_82575(hw);
1938 /* clear global device reset status bit */
1939 E1000_WRITE_REG(hw, E1000_STATUS, E1000_STAT_DEV_RST_SET);
1941 /* Clear any pending interrupt events. */
1942 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
1943 icr = E1000_READ_REG(hw, E1000_ICR);
1945 ret_val = e1000_reset_mdicnfg_82580(hw);
1947 DEBUGOUT("Could not reset MDICNFG based on EEPROM\n");
1949 /* Install any alternate MAC address into RAR0 */
1950 ret_val = e1000_check_alt_mac_addr_generic(hw);
1952 /* Release semaphore */
1953 if (global_device_reset)
1954 e1000_release_swfw_sync_82575(hw, swmbsw_mask);
1960 * e1000_rxpbs_adjust_82580 - adjust RXPBS value to reflect actual RX PBA size
1961 * @data: data received by reading RXPBS register
1963 * The 82580 uses a table based approach for packet buffer allocation sizes.
1964 * This function converts the retrieved value into the correct table value
1965 * 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7
1966 * 0x0 36 72 144 1 2 4 8 16
1967 * 0x8 35 70 140 rsv rsv rsv rsv rsv
1969 u16 e1000_rxpbs_adjust_82580(u32 data)
1973 if (data < E1000_82580_RXPBS_TABLE_SIZE)
1974 ret_val = e1000_82580_rxpbs_table[data];