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);
89 static const u16 e1000_82580_rxpbs_table[] =
90 { 36, 72, 144, 1, 2, 4, 8, 16,
92 #define E1000_82580_RXPBS_TABLE_SIZE \
93 (sizeof(e1000_82580_rxpbs_table)/sizeof(u16))
96 * e1000_init_phy_params_82575 - Init PHY func ptrs.
97 * @hw: pointer to the HW structure
99 static s32 e1000_init_phy_params_82575(struct e1000_hw *hw)
101 struct e1000_phy_info *phy = &hw->phy;
102 s32 ret_val = E1000_SUCCESS;
104 DEBUGFUNC("e1000_init_phy_params_82575");
106 if (hw->phy.media_type != e1000_media_type_copper) {
107 phy->type = e1000_phy_none;
111 phy->ops.power_up = e1000_power_up_phy_copper;
112 phy->ops.power_down = e1000_power_down_phy_copper_82575;
114 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
115 phy->reset_delay_us = 100;
117 phy->ops.acquire = e1000_acquire_phy_82575;
118 phy->ops.check_reset_block = e1000_check_reset_block_generic;
119 phy->ops.commit = e1000_phy_sw_reset_generic;
120 phy->ops.get_cfg_done = e1000_get_cfg_done_82575;
121 phy->ops.release = e1000_release_phy_82575;
123 if (e1000_sgmii_active_82575(hw)) {
124 phy->ops.reset = e1000_phy_hw_reset_sgmii_82575;
125 phy->ops.read_reg = e1000_read_phy_reg_sgmii_82575;
126 phy->ops.write_reg = e1000_write_phy_reg_sgmii_82575;
127 } else if (hw->mac.type >= e1000_82580) {
128 phy->ops.reset = e1000_phy_hw_reset_generic;
129 phy->ops.read_reg = e1000_read_phy_reg_82580;
130 phy->ops.write_reg = e1000_write_phy_reg_82580;
132 phy->ops.reset = e1000_phy_hw_reset_generic;
133 phy->ops.read_reg = e1000_read_phy_reg_igp;
134 phy->ops.write_reg = e1000_write_phy_reg_igp;
137 /* Set phy->phy_addr and phy->id. */
138 ret_val = e1000_get_phy_id_82575(hw);
140 /* Verify phy id and set remaining function pointers */
142 case M88E1111_I_PHY_ID:
143 phy->type = e1000_phy_m88;
144 phy->ops.check_polarity = e1000_check_polarity_m88;
145 phy->ops.get_info = e1000_get_phy_info_m88;
146 phy->ops.get_cable_length = e1000_get_cable_length_m88;
147 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_m88;
149 case IGP03E1000_E_PHY_ID:
150 case IGP04E1000_E_PHY_ID:
151 phy->type = e1000_phy_igp_3;
152 phy->ops.check_polarity = e1000_check_polarity_igp;
153 phy->ops.get_info = e1000_get_phy_info_igp;
154 phy->ops.get_cable_length = e1000_get_cable_length_igp_2;
155 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp;
156 phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_82575;
157 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_generic;
159 case I82580_I_PHY_ID:
160 phy->type = e1000_phy_82580;
161 phy->ops.check_polarity = e1000_check_polarity_82577;
162 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_82577;
163 phy->ops.get_cable_length = e1000_get_cable_length_82577;
164 phy->ops.get_info = e1000_get_phy_info_82577;
167 ret_val = -E1000_ERR_PHY;
176 * e1000_init_nvm_params_82575 - Init NVM func ptrs.
177 * @hw: pointer to the HW structure
179 static s32 e1000_init_nvm_params_82575(struct e1000_hw *hw)
181 struct e1000_nvm_info *nvm = &hw->nvm;
182 u32 eecd = E1000_READ_REG(hw, E1000_EECD);
185 DEBUGFUNC("e1000_init_nvm_params_82575");
187 nvm->opcode_bits = 8;
189 switch (nvm->override) {
190 case e1000_nvm_override_spi_large:
192 nvm->address_bits = 16;
194 case e1000_nvm_override_spi_small:
196 nvm->address_bits = 8;
199 nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8;
200 nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? 16 : 8;
204 nvm->type = e1000_nvm_eeprom_spi;
206 size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>
207 E1000_EECD_SIZE_EX_SHIFT);
210 * Added to a constant, "size" becomes the left-shift value
211 * for setting word_size.
213 size += NVM_WORD_SIZE_BASE_SHIFT;
215 /* EEPROM access above 16k is unsupported */
218 nvm->word_size = 1 << size;
220 /* Function Pointers */
221 nvm->ops.acquire = e1000_acquire_nvm_82575;
222 nvm->ops.read = e1000_read_nvm_eerd;
223 nvm->ops.release = e1000_release_nvm_82575;
224 nvm->ops.update = e1000_update_nvm_checksum_generic;
225 nvm->ops.valid_led_default = e1000_valid_led_default_82575;
226 nvm->ops.validate = e1000_validate_nvm_checksum_generic;
227 nvm->ops.write = e1000_write_nvm_spi;
229 return E1000_SUCCESS;
233 * e1000_init_mac_params_82575 - Init MAC func ptrs.
234 * @hw: pointer to the HW structure
236 static s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
238 struct e1000_mac_info *mac = &hw->mac;
239 struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
242 DEBUGFUNC("e1000_init_mac_params_82575");
246 * The 82575 uses bits 22:23 for link mode. The mode can be changed
247 * based on the EEPROM. We cannot rely upon device ID. There
248 * is no distinguishable difference between fiber and internal
249 * SerDes mode on the 82575. There can be an external PHY attached
250 * on the SGMII interface. For this, we'll set sgmii_active to TRUE.
252 hw->phy.media_type = e1000_media_type_copper;
253 dev_spec->sgmii_active = FALSE;
255 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
256 switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) {
257 case E1000_CTRL_EXT_LINK_MODE_SGMII:
258 dev_spec->sgmii_active = TRUE;
259 ctrl_ext |= E1000_CTRL_I2C_ENA;
261 case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX:
262 case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
263 hw->phy.media_type = e1000_media_type_internal_serdes;
264 ctrl_ext |= E1000_CTRL_I2C_ENA;
267 ctrl_ext &= ~E1000_CTRL_I2C_ENA;
271 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
274 * if using i2c make certain the MDICNFG register is cleared to prevent
275 * communications from being misrouted to the mdic registers
277 if ((ctrl_ext & E1000_CTRL_I2C_ENA) && (hw->mac.type == e1000_82580))
278 E1000_WRITE_REG(hw, E1000_MDICNFG, 0);
280 /* Set mta register count */
281 mac->mta_reg_count = 128;
282 /* Set uta register count */
283 mac->uta_reg_count = (hw->mac.type == e1000_82575) ? 0 : 128;
284 /* Set rar entry count */
285 mac->rar_entry_count = E1000_RAR_ENTRIES_82575;
286 if (mac->type == e1000_82576)
287 mac->rar_entry_count = E1000_RAR_ENTRIES_82576;
288 if (mac->type == e1000_82580)
289 mac->rar_entry_count = E1000_RAR_ENTRIES_82580;
290 /* Set if part includes ASF firmware */
291 mac->asf_firmware_present = TRUE;
293 mac->has_fwsm = TRUE;
294 /* ARC supported; valid only if manageability features are enabled. */
295 mac->arc_subsystem_valid =
296 (E1000_READ_REG(hw, E1000_FWSM) & E1000_FWSM_MODE_MASK)
299 /* Function pointers */
301 /* bus type/speed/width */
302 mac->ops.get_bus_info = e1000_get_bus_info_pcie_generic;
304 if (mac->type >= e1000_82580)
305 mac->ops.reset_hw = e1000_reset_hw_82580;
307 mac->ops.reset_hw = e1000_reset_hw_82575;
308 /* hw initialization */
309 mac->ops.init_hw = e1000_init_hw_82575;
311 mac->ops.setup_link = e1000_setup_link_generic;
312 /* physical interface link setup */
313 mac->ops.setup_physical_interface =
314 (hw->phy.media_type == e1000_media_type_copper)
315 ? e1000_setup_copper_link_82575
316 : e1000_setup_serdes_link_82575;
317 /* physical interface shutdown */
318 mac->ops.shutdown_serdes = e1000_shutdown_serdes_link_82575;
319 /* physical interface power up */
320 mac->ops.power_up_serdes = e1000_power_up_serdes_link_82575;
322 mac->ops.check_for_link = e1000_check_for_link_82575;
323 /* receive address register setting */
324 mac->ops.rar_set = e1000_rar_set_generic;
325 /* read mac address */
326 mac->ops.read_mac_addr = e1000_read_mac_addr_82575;
327 /* configure collision distance */
328 mac->ops.config_collision_dist = e1000_config_collision_dist_82575;
329 /* multicast address update */
330 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
332 mac->ops.write_vfta = e1000_write_vfta_generic;
334 mac->ops.clear_vfta = e1000_clear_vfta_generic;
336 mac->ops.id_led_init = e1000_id_led_init_generic;
338 mac->ops.blink_led = e1000_blink_led_generic;
340 mac->ops.setup_led = e1000_setup_led_generic;
342 mac->ops.cleanup_led = e1000_cleanup_led_generic;
343 /* turn on/off LED */
344 mac->ops.led_on = e1000_led_on_generic;
345 mac->ops.led_off = e1000_led_off_generic;
346 /* clear hardware counters */
347 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82575;
349 mac->ops.get_link_up_info = e1000_get_link_up_info_82575;
351 /* set lan id for port to determine which phy lock to use */
352 hw->mac.ops.set_lan_id(hw);
354 return E1000_SUCCESS;
358 * e1000_init_function_pointers_82575 - Init func ptrs.
359 * @hw: pointer to the HW structure
361 * Called to initialize all function pointers and parameters.
363 void e1000_init_function_pointers_82575(struct e1000_hw *hw)
365 DEBUGFUNC("e1000_init_function_pointers_82575");
367 hw->mac.ops.init_params = e1000_init_mac_params_82575;
368 hw->nvm.ops.init_params = e1000_init_nvm_params_82575;
369 hw->phy.ops.init_params = e1000_init_phy_params_82575;
373 * e1000_acquire_phy_82575 - Acquire rights to access PHY
374 * @hw: pointer to the HW structure
376 * Acquire access rights to the correct PHY.
378 static s32 e1000_acquire_phy_82575(struct e1000_hw *hw)
380 u16 mask = E1000_SWFW_PHY0_SM;
382 DEBUGFUNC("e1000_acquire_phy_82575");
384 if (hw->bus.func == E1000_FUNC_1)
385 mask = E1000_SWFW_PHY1_SM;
386 else if (hw->bus.func == E1000_FUNC_2)
387 mask = E1000_SWFW_PHY2_SM;
388 else if (hw->bus.func == E1000_FUNC_3)
389 mask = E1000_SWFW_PHY3_SM;
391 return e1000_acquire_swfw_sync_82575(hw, mask);
395 * e1000_release_phy_82575 - Release rights to access PHY
396 * @hw: pointer to the HW structure
398 * A wrapper to release access rights to the correct PHY.
400 static void e1000_release_phy_82575(struct e1000_hw *hw)
402 u16 mask = E1000_SWFW_PHY0_SM;
404 DEBUGFUNC("e1000_release_phy_82575");
406 if (hw->bus.func == E1000_FUNC_1)
407 mask = E1000_SWFW_PHY1_SM;
408 else if (hw->bus.func == E1000_FUNC_2)
409 mask = E1000_SWFW_PHY2_SM;
410 else if (hw->bus.func == E1000_FUNC_3)
411 mask = E1000_SWFW_PHY3_SM;
413 e1000_release_swfw_sync_82575(hw, mask);
417 * e1000_read_phy_reg_sgmii_82575 - Read PHY register using sgmii
418 * @hw: pointer to the HW structure
419 * @offset: register offset to be read
420 * @data: pointer to the read data
422 * Reads the PHY register at offset using the serial gigabit media independent
423 * interface and stores the retrieved information in data.
425 static s32 e1000_read_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
428 s32 ret_val = -E1000_ERR_PARAM;
430 DEBUGFUNC("e1000_read_phy_reg_sgmii_82575");
432 if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
433 DEBUGOUT1("PHY Address %u is out of range\n", offset);
437 ret_val = hw->phy.ops.acquire(hw);
441 ret_val = e1000_read_phy_reg_i2c(hw, offset, data);
443 hw->phy.ops.release(hw);
450 * e1000_write_phy_reg_sgmii_82575 - Write PHY register using sgmii
451 * @hw: pointer to the HW structure
452 * @offset: register offset to write to
453 * @data: data to write at register offset
455 * Writes the data to PHY register at the offset using the serial gigabit
456 * media independent interface.
458 static s32 e1000_write_phy_reg_sgmii_82575(struct e1000_hw *hw, u32 offset,
461 s32 ret_val = -E1000_ERR_PARAM;
463 DEBUGFUNC("e1000_write_phy_reg_sgmii_82575");
465 if (offset > E1000_MAX_SGMII_PHY_REG_ADDR) {
466 DEBUGOUT1("PHY Address %d is out of range\n", offset);
470 ret_val = hw->phy.ops.acquire(hw);
474 ret_val = e1000_write_phy_reg_i2c(hw, offset, data);
476 hw->phy.ops.release(hw);
483 * e1000_get_phy_id_82575 - Retrieve PHY addr and id
484 * @hw: pointer to the HW structure
486 * Retrieves the PHY address and ID for both PHY's which do and do not use
489 static s32 e1000_get_phy_id_82575(struct e1000_hw *hw)
491 struct e1000_phy_info *phy = &hw->phy;
492 s32 ret_val = E1000_SUCCESS;
496 DEBUGFUNC("e1000_get_phy_id_82575");
499 * For SGMII PHYs, we try the list of possible addresses until
500 * we find one that works. For non-SGMII PHYs
501 * (e.g. integrated copper PHYs), an address of 1 should
502 * work. The result of this function should mean phy->phy_addr
503 * and phy->id are set correctly.
505 if (!e1000_sgmii_active_82575(hw)) {
507 ret_val = e1000_get_phy_id(hw);
511 /* Power on sgmii phy if it is disabled */
512 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
513 E1000_WRITE_REG(hw, E1000_CTRL_EXT,
514 ctrl_ext & ~E1000_CTRL_EXT_SDP3_DATA);
515 E1000_WRITE_FLUSH(hw);
519 * The address field in the I2CCMD register is 3 bits and 0 is invalid.
520 * Therefore, we need to test 1-7
522 for (phy->addr = 1; phy->addr < 8; phy->addr++) {
523 ret_val = e1000_read_phy_reg_sgmii_82575(hw, PHY_ID1, &phy_id);
524 if (ret_val == E1000_SUCCESS) {
525 DEBUGOUT2("Vendor ID 0x%08X read at address %u\n",
529 * At the time of this writing, The M88 part is
530 * the only supported SGMII PHY product.
532 if (phy_id == M88_VENDOR)
535 DEBUGOUT1("PHY address %u was unreadable\n",
540 /* A valid PHY type couldn't be found. */
541 if (phy->addr == 8) {
543 ret_val = -E1000_ERR_PHY;
545 ret_val = e1000_get_phy_id(hw);
548 /* restore previous sfp cage power state */
549 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
556 * e1000_phy_hw_reset_sgmii_82575 - Performs a PHY reset
557 * @hw: pointer to the HW structure
559 * Resets the PHY using the serial gigabit media independent interface.
561 static s32 e1000_phy_hw_reset_sgmii_82575(struct e1000_hw *hw)
563 s32 ret_val = E1000_SUCCESS;
565 DEBUGFUNC("e1000_phy_hw_reset_sgmii_82575");
568 * This isn't a TRUE "hard" reset, but is the only reset
569 * available to us at this time.
572 DEBUGOUT("Soft resetting SGMII attached PHY...\n");
574 if (!(hw->phy.ops.write_reg))
578 * SFP documentation requires the following to configure the SPF module
579 * to work on SGMII. No further documentation is given.
581 ret_val = hw->phy.ops.write_reg(hw, 0x1B, 0x8084);
585 ret_val = hw->phy.ops.commit(hw);
592 * e1000_set_d0_lplu_state_82575 - Set Low Power Linkup D0 state
593 * @hw: pointer to the HW structure
594 * @active: TRUE to enable LPLU, FALSE to disable
596 * Sets the LPLU D0 state according to the active flag. When
597 * activating LPLU this function also disables smart speed
598 * and vice versa. LPLU will not be activated unless the
599 * device autonegotiation advertisement meets standards of
600 * either 10 or 10/100 or 10/100/1000 at all duplexes.
601 * This is a function pointer entry point only called by
602 * PHY setup routines.
604 static s32 e1000_set_d0_lplu_state_82575(struct e1000_hw *hw, bool active)
606 struct e1000_phy_info *phy = &hw->phy;
607 s32 ret_val = E1000_SUCCESS;
610 DEBUGFUNC("e1000_set_d0_lplu_state_82575");
612 if (!(hw->phy.ops.read_reg))
615 ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data);
620 data |= IGP02E1000_PM_D0_LPLU;
621 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
626 /* When LPLU is enabled, we should disable SmartSpeed */
627 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
629 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
630 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
635 data &= ~IGP02E1000_PM_D0_LPLU;
636 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT,
639 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
640 * during Dx states where the power conservation is most
641 * important. During driver activity we should enable
642 * SmartSpeed, so performance is maintained.
644 if (phy->smart_speed == e1000_smart_speed_on) {
645 ret_val = phy->ops.read_reg(hw,
646 IGP01E1000_PHY_PORT_CONFIG,
651 data |= IGP01E1000_PSCFR_SMART_SPEED;
652 ret_val = phy->ops.write_reg(hw,
653 IGP01E1000_PHY_PORT_CONFIG,
657 } else if (phy->smart_speed == e1000_smart_speed_off) {
658 ret_val = phy->ops.read_reg(hw,
659 IGP01E1000_PHY_PORT_CONFIG,
664 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
665 ret_val = phy->ops.write_reg(hw,
666 IGP01E1000_PHY_PORT_CONFIG,
678 * e1000_acquire_nvm_82575 - Request for access to EEPROM
679 * @hw: pointer to the HW structure
681 * Acquire the necessary semaphores for exclusive access to the EEPROM.
682 * Set the EEPROM access request bit and wait for EEPROM access grant bit.
683 * Return successful if access grant bit set, else clear the request for
684 * EEPROM access and return -E1000_ERR_NVM (-1).
686 static s32 e1000_acquire_nvm_82575(struct e1000_hw *hw)
690 DEBUGFUNC("e1000_acquire_nvm_82575");
692 ret_val = e1000_acquire_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
696 ret_val = e1000_acquire_nvm_generic(hw);
699 e1000_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
706 * e1000_release_nvm_82575 - Release exclusive access to EEPROM
707 * @hw: pointer to the HW structure
709 * Stop any current commands to the EEPROM and clear the EEPROM request bit,
710 * then release the semaphores acquired.
712 static void e1000_release_nvm_82575(struct e1000_hw *hw)
714 DEBUGFUNC("e1000_release_nvm_82575");
716 e1000_release_nvm_generic(hw);
717 e1000_release_swfw_sync_82575(hw, E1000_SWFW_EEP_SM);
721 * e1000_acquire_swfw_sync_82575 - Acquire SW/FW semaphore
722 * @hw: pointer to the HW structure
723 * @mask: specifies which semaphore to acquire
725 * Acquire the SW/FW semaphore to access the PHY or NVM. The mask
726 * will also specify which port we're acquiring the lock for.
728 static s32 e1000_acquire_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
732 u32 fwmask = mask << 16;
733 s32 ret_val = E1000_SUCCESS;
734 s32 i = 0, timeout = 200; /* FIXME: find real value to use here */
736 DEBUGFUNC("e1000_acquire_swfw_sync_82575");
738 while (i < timeout) {
739 if (e1000_get_hw_semaphore_generic(hw)) {
740 ret_val = -E1000_ERR_SWFW_SYNC;
744 swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
745 if (!(swfw_sync & (fwmask | swmask)))
749 * Firmware currently using resource (fwmask)
750 * or other software thread using resource (swmask)
752 e1000_put_hw_semaphore_generic(hw);
758 DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n");
759 ret_val = -E1000_ERR_SWFW_SYNC;
764 E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
766 e1000_put_hw_semaphore_generic(hw);
773 * e1000_release_swfw_sync_82575 - Release SW/FW semaphore
774 * @hw: pointer to the HW structure
775 * @mask: specifies which semaphore to acquire
777 * Release the SW/FW semaphore used to access the PHY or NVM. The mask
778 * will also specify which port we're releasing the lock for.
780 static void e1000_release_swfw_sync_82575(struct e1000_hw *hw, u16 mask)
784 DEBUGFUNC("e1000_release_swfw_sync_82575");
786 while (e1000_get_hw_semaphore_generic(hw) != E1000_SUCCESS);
789 swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
791 E1000_WRITE_REG(hw, E1000_SW_FW_SYNC, swfw_sync);
793 e1000_put_hw_semaphore_generic(hw);
797 * e1000_get_cfg_done_82575 - Read config done bit
798 * @hw: pointer to the HW structure
800 * Read the management control register for the config done bit for
801 * completion status. NOTE: silicon which is EEPROM-less will fail trying
802 * to read the config done bit, so an error is *ONLY* logged and returns
803 * E1000_SUCCESS. If we were to return with error, EEPROM-less silicon
804 * would not be able to be reset or change link.
806 static s32 e1000_get_cfg_done_82575(struct e1000_hw *hw)
808 s32 timeout = PHY_CFG_TIMEOUT;
809 s32 ret_val = E1000_SUCCESS;
810 u32 mask = E1000_NVM_CFG_DONE_PORT_0;
812 DEBUGFUNC("e1000_get_cfg_done_82575");
814 if (hw->bus.func == E1000_FUNC_1)
815 mask = E1000_NVM_CFG_DONE_PORT_1;
816 else if (hw->bus.func == E1000_FUNC_2)
817 mask = E1000_NVM_CFG_DONE_PORT_2;
818 else if (hw->bus.func == E1000_FUNC_3)
819 mask = E1000_NVM_CFG_DONE_PORT_3;
821 if (E1000_READ_REG(hw, E1000_EEMNGCTL) & mask)
827 DEBUGOUT("MNG configuration cycle has not completed.\n");
829 /* If EEPROM is not marked present, init the PHY manually */
830 if (((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0) &&
831 (hw->phy.type == e1000_phy_igp_3))
832 e1000_phy_init_script_igp3(hw);
838 * e1000_get_link_up_info_82575 - Get link speed/duplex info
839 * @hw: pointer to the HW structure
840 * @speed: stores the current speed
841 * @duplex: stores the current duplex
843 * This is a wrapper function, if using the serial gigabit media independent
844 * interface, use PCS to retrieve the link speed and duplex information.
845 * Otherwise, use the generic function to get the link speed and duplex info.
847 static s32 e1000_get_link_up_info_82575(struct e1000_hw *hw, u16 *speed,
852 DEBUGFUNC("e1000_get_link_up_info_82575");
854 if (hw->phy.media_type != e1000_media_type_copper)
855 ret_val = e1000_get_pcs_speed_and_duplex_82575(hw, speed,
858 ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed,
865 * e1000_check_for_link_82575 - Check for link
866 * @hw: pointer to the HW structure
868 * If sgmii is enabled, then use the pcs register to determine link, otherwise
869 * use the generic interface for determining link.
871 static s32 e1000_check_for_link_82575(struct e1000_hw *hw)
876 DEBUGFUNC("e1000_check_for_link_82575");
878 if (hw->phy.media_type != e1000_media_type_copper) {
879 ret_val = e1000_get_pcs_speed_and_duplex_82575(hw, &speed,
882 * Use this flag to determine if link needs to be checked or
883 * not. If we have link clear the flag so that we do not
884 * continue to check for link.
886 hw->mac.get_link_status = !hw->mac.serdes_has_link;
888 ret_val = e1000_check_for_copper_link_generic(hw);
895 * e1000_power_up_serdes_link_82575 - Power up the serdes link after shutdown
896 * @hw: pointer to the HW structure
898 static void e1000_power_up_serdes_link_82575(struct e1000_hw *hw)
902 DEBUGFUNC("e1000_power_up_serdes_link_82575");
904 if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
905 !e1000_sgmii_active_82575(hw))
908 /* Enable PCS to turn on link */
909 reg = E1000_READ_REG(hw, E1000_PCS_CFG0);
910 reg |= E1000_PCS_CFG_PCS_EN;
911 E1000_WRITE_REG(hw, E1000_PCS_CFG0, reg);
913 /* Power up the laser */
914 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
915 reg &= ~E1000_CTRL_EXT_SDP3_DATA;
916 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
918 /* flush the write to verify completion */
919 E1000_WRITE_FLUSH(hw);
924 * e1000_get_pcs_speed_and_duplex_82575 - Retrieve current speed/duplex
925 * @hw: pointer to the HW structure
926 * @speed: stores the current speed
927 * @duplex: stores the current duplex
929 * Using the physical coding sub-layer (PCS), retrieve the current speed and
930 * duplex, then store the values in the pointers provided.
932 static s32 e1000_get_pcs_speed_and_duplex_82575(struct e1000_hw *hw,
933 u16 *speed, u16 *duplex)
935 struct e1000_mac_info *mac = &hw->mac;
938 DEBUGFUNC("e1000_get_pcs_speed_and_duplex_82575");
940 /* Set up defaults for the return values of this function */
941 mac->serdes_has_link = FALSE;
946 * Read the PCS Status register for link state. For non-copper mode,
947 * the status register is not accurate. The PCS status register is
950 pcs = E1000_READ_REG(hw, E1000_PCS_LSTAT);
953 * The link up bit determines when link is up on autoneg. The sync ok
954 * gets set once both sides sync up and agree upon link. Stable link
955 * can be determined by checking for both link up and link sync ok
957 if ((pcs & E1000_PCS_LSTS_LINK_OK) && (pcs & E1000_PCS_LSTS_SYNK_OK)) {
958 mac->serdes_has_link = TRUE;
960 /* Detect and store PCS speed */
961 if (pcs & E1000_PCS_LSTS_SPEED_1000) {
963 } else if (pcs & E1000_PCS_LSTS_SPEED_100) {
969 /* Detect and store PCS duplex */
970 if (pcs & E1000_PCS_LSTS_DUPLEX_FULL) {
971 *duplex = FULL_DUPLEX;
973 *duplex = HALF_DUPLEX;
977 return E1000_SUCCESS;
981 * e1000_shutdown_serdes_link_82575 - Remove link during power down
982 * @hw: pointer to the HW structure
984 * In the case of serdes shut down sfp and PCS on driver unload
985 * when management pass thru is not enabled.
987 void e1000_shutdown_serdes_link_82575(struct e1000_hw *hw)
991 DEBUGFUNC("e1000_shutdown_serdes_link_82575");
993 if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
994 !e1000_sgmii_active_82575(hw))
997 if (!e1000_enable_mng_pass_thru(hw)) {
998 /* Disable PCS to turn off link */
999 reg = E1000_READ_REG(hw, E1000_PCS_CFG0);
1000 reg &= ~E1000_PCS_CFG_PCS_EN;
1001 E1000_WRITE_REG(hw, E1000_PCS_CFG0, reg);
1003 /* shutdown the laser */
1004 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1005 reg |= E1000_CTRL_EXT_SDP3_DATA;
1006 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
1008 /* flush the write to verify completion */
1009 E1000_WRITE_FLUSH(hw);
1017 * e1000_reset_hw_82575 - Reset hardware
1018 * @hw: pointer to the HW structure
1020 * This resets the hardware into a known state.
1022 static s32 e1000_reset_hw_82575(struct e1000_hw *hw)
1027 DEBUGFUNC("e1000_reset_hw_82575");
1030 * Prevent the PCI-E bus from sticking if there is no TLP connection
1031 * on the last TLP read/write transaction when MAC is reset.
1033 ret_val = e1000_disable_pcie_master_generic(hw);
1035 DEBUGOUT("PCI-E Master disable polling has failed.\n");
1038 /* set the completion timeout for interface */
1039 ret_val = e1000_set_pcie_completion_timeout(hw);
1041 DEBUGOUT("PCI-E Set completion timeout has failed.\n");
1044 DEBUGOUT("Masking off all interrupts\n");
1045 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
1047 E1000_WRITE_REG(hw, E1000_RCTL, 0);
1048 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
1049 E1000_WRITE_FLUSH(hw);
1053 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1055 DEBUGOUT("Issuing a global reset to MAC\n");
1056 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
1058 ret_val = e1000_get_auto_rd_done_generic(hw);
1061 * When auto config read does not complete, do not
1062 * return with an error. This can happen in situations
1063 * where there is no eeprom and prevents getting link.
1065 DEBUGOUT("Auto Read Done did not complete\n");
1068 /* If EEPROM is not present, run manual init scripts */
1069 if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0)
1070 e1000_reset_init_script_82575(hw);
1072 /* Clear any pending interrupt events. */
1073 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
1074 icr = E1000_READ_REG(hw, E1000_ICR);
1076 /* Install any alternate MAC address into RAR0 */
1077 ret_val = e1000_check_alt_mac_addr_generic(hw);
1083 * e1000_init_hw_82575 - Initialize hardware
1084 * @hw: pointer to the HW structure
1086 * This inits the hardware readying it for operation.
1088 static s32 e1000_init_hw_82575(struct e1000_hw *hw)
1090 struct e1000_mac_info *mac = &hw->mac;
1092 u16 i, rar_count = mac->rar_entry_count;
1094 DEBUGFUNC("e1000_init_hw_82575");
1096 /* Initialize identification LED */
1097 ret_val = mac->ops.id_led_init(hw);
1099 DEBUGOUT("Error initializing identification LED\n");
1100 /* This is not fatal and we should not stop init due to this */
1103 /* Disabling VLAN filtering */
1104 DEBUGOUT("Initializing the IEEE VLAN\n");
1105 mac->ops.clear_vfta(hw);
1107 /* Setup the receive address */
1108 e1000_init_rx_addrs_generic(hw, rar_count);
1110 /* Zero out the Multicast HASH table */
1111 DEBUGOUT("Zeroing the MTA\n");
1112 for (i = 0; i < mac->mta_reg_count; i++)
1113 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
1115 /* Zero out the Unicast HASH table */
1116 DEBUGOUT("Zeroing the UTA\n");
1117 for (i = 0; i < mac->uta_reg_count; i++)
1118 E1000_WRITE_REG_ARRAY(hw, E1000_UTA, i, 0);
1120 /* Setup link and flow control */
1121 ret_val = mac->ops.setup_link(hw);
1124 * Clear all of the statistics registers (clear on read). It is
1125 * important that we do this after we have tried to establish link
1126 * because the symbol error count will increment wildly if there
1129 e1000_clear_hw_cntrs_82575(hw);
1135 * e1000_setup_copper_link_82575 - Configure copper link settings
1136 * @hw: pointer to the HW structure
1138 * Configures the link for auto-neg or forced speed and duplex. Then we check
1139 * for link, once link is established calls to configure collision distance
1140 * and flow control are called.
1142 static s32 e1000_setup_copper_link_82575(struct e1000_hw *hw)
1147 DEBUGFUNC("e1000_setup_copper_link_82575");
1149 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1150 ctrl |= E1000_CTRL_SLU;
1151 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
1152 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1154 ret_val = e1000_setup_serdes_link_82575(hw);
1158 if (e1000_sgmii_active_82575(hw) && !hw->phy.reset_disable) {
1159 /* allow time for SFP cage time to power up phy */
1162 ret_val = hw->phy.ops.reset(hw);
1164 DEBUGOUT("Error resetting the PHY.\n");
1168 switch (hw->phy.type) {
1170 ret_val = e1000_copper_link_setup_m88(hw);
1172 case e1000_phy_igp_3:
1173 ret_val = e1000_copper_link_setup_igp(hw);
1175 case e1000_phy_82580:
1176 ret_val = e1000_copper_link_setup_82577(hw);
1179 ret_val = -E1000_ERR_PHY;
1186 ret_val = e1000_setup_copper_link_generic(hw);
1192 * e1000_setup_serdes_link_82575 - Setup link for serdes
1193 * @hw: pointer to the HW structure
1195 * Configure the physical coding sub-layer (PCS) link. The PCS link is
1196 * used on copper connections where the serialized gigabit media independent
1197 * interface (sgmii), or serdes fiber is being used. Configures the link
1198 * for auto-negotiation or forces speed/duplex.
1200 static s32 e1000_setup_serdes_link_82575(struct e1000_hw *hw)
1202 u32 ctrl_ext, ctrl_reg, reg;
1205 DEBUGFUNC("e1000_setup_serdes_link_82575");
1207 if ((hw->phy.media_type != e1000_media_type_internal_serdes) &&
1208 !e1000_sgmii_active_82575(hw))
1209 return E1000_SUCCESS;
1212 * On the 82575, SerDes loopback mode persists until it is
1213 * explicitly turned off or a power cycle is performed. A read to
1214 * the register does not indicate its status. Therefore, we ensure
1215 * loopback mode is disabled during initialization.
1217 E1000_WRITE_REG(hw, E1000_SCTL, E1000_SCTL_DISABLE_SERDES_LOOPBACK);
1219 /* power on the sfp cage if present */
1220 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
1221 ctrl_ext &= ~E1000_CTRL_EXT_SDP3_DATA;
1222 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
1224 ctrl_reg = E1000_READ_REG(hw, E1000_CTRL);
1225 ctrl_reg |= E1000_CTRL_SLU;
1227 /* set both sw defined pins on 82575/82576*/
1228 if (hw->mac.type == e1000_82575 || hw->mac.type == e1000_82576)
1229 ctrl_reg |= E1000_CTRL_SWDPIN0 | E1000_CTRL_SWDPIN1;
1231 reg = E1000_READ_REG(hw, E1000_PCS_LCTL);
1233 /* default pcs_autoneg to the same setting as mac autoneg */
1234 pcs_autoneg = hw->mac.autoneg;
1236 switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) {
1237 case E1000_CTRL_EXT_LINK_MODE_SGMII:
1238 /* sgmii mode lets the phy handle forcing speed/duplex */
1240 /* autoneg time out should be disabled for SGMII mode */
1241 reg &= ~(E1000_PCS_LCTL_AN_TIMEOUT);
1243 case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX:
1244 /* disable PCS autoneg and support parallel detect only */
1245 pcs_autoneg = FALSE;
1248 * non-SGMII modes only supports a speed of 1000/Full for the
1249 * link so it is best to just force the MAC and let the pcs
1250 * link either autoneg or be forced to 1000/Full
1252 ctrl_reg |= E1000_CTRL_SPD_1000 | E1000_CTRL_FRCSPD |
1253 E1000_CTRL_FD | E1000_CTRL_FRCDPX;
1255 /* set speed of 1000/Full if speed/duplex is forced */
1256 reg |= E1000_PCS_LCTL_FSV_1000 | E1000_PCS_LCTL_FDV_FULL;
1260 E1000_WRITE_REG(hw, E1000_CTRL, ctrl_reg);
1263 * New SerDes mode allows for forcing speed or autonegotiating speed
1264 * at 1gb. Autoneg should be default set by most drivers. This is the
1265 * mode that will be compatible with older link partners and switches.
1266 * However, both are supported by the hardware and some drivers/tools.
1268 reg &= ~(E1000_PCS_LCTL_AN_ENABLE | E1000_PCS_LCTL_FLV_LINK_UP |
1269 E1000_PCS_LCTL_FSD | E1000_PCS_LCTL_FORCE_LINK);
1272 * We force flow control to prevent the CTRL register values from being
1273 * overwritten by the autonegotiated flow control values
1275 reg |= E1000_PCS_LCTL_FORCE_FCTRL;
1278 /* Set PCS register for autoneg */
1279 reg |= E1000_PCS_LCTL_AN_ENABLE | /* Enable Autoneg */
1280 E1000_PCS_LCTL_AN_RESTART; /* Restart autoneg */
1281 DEBUGOUT1("Configuring Autoneg:PCS_LCTL=0x%08X\n", reg);
1283 /* Set PCS register for forced link */
1284 reg |= E1000_PCS_LCTL_FSD; /* Force Speed */
1285 DEBUGOUT1("Configuring Forced Link:PCS_LCTL=0x%08X\n", reg);
1288 E1000_WRITE_REG(hw, E1000_PCS_LCTL, reg);
1290 if (!e1000_sgmii_active_82575(hw))
1291 e1000_force_mac_fc_generic(hw);
1293 return E1000_SUCCESS;
1297 * e1000_valid_led_default_82575 - Verify a valid default LED config
1298 * @hw: pointer to the HW structure
1299 * @data: pointer to the NVM (EEPROM)
1301 * Read the EEPROM for the current default LED configuration. If the
1302 * LED configuration is not valid, set to a valid LED configuration.
1304 static s32 e1000_valid_led_default_82575(struct e1000_hw *hw, u16 *data)
1308 DEBUGFUNC("e1000_valid_led_default_82575");
1310 ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
1312 DEBUGOUT("NVM Read Error\n");
1316 if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF) {
1317 switch(hw->phy.media_type) {
1318 case e1000_media_type_internal_serdes:
1319 *data = ID_LED_DEFAULT_82575_SERDES;
1321 case e1000_media_type_copper:
1323 *data = ID_LED_DEFAULT;
1332 * e1000_sgmii_active_82575 - Return sgmii state
1333 * @hw: pointer to the HW structure
1335 * 82575 silicon has a serialized gigabit media independent interface (sgmii)
1336 * which can be enabled for use in the embedded applications. Simply
1337 * return the current state of the sgmii interface.
1339 static bool e1000_sgmii_active_82575(struct e1000_hw *hw)
1341 struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
1342 return dev_spec->sgmii_active;
1346 * e1000_reset_init_script_82575 - Inits HW defaults after reset
1347 * @hw: pointer to the HW structure
1349 * Inits recommended HW defaults after a reset when there is no EEPROM
1350 * detected. This is only for the 82575.
1352 static s32 e1000_reset_init_script_82575(struct e1000_hw* hw)
1354 DEBUGFUNC("e1000_reset_init_script_82575");
1356 if (hw->mac.type == e1000_82575) {
1357 DEBUGOUT("Running reset init script for 82575\n");
1358 /* SerDes configuration via SERDESCTRL */
1359 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x00, 0x0C);
1360 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x01, 0x78);
1361 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x1B, 0x23);
1362 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCTL, 0x23, 0x15);
1364 /* CCM configuration via CCMCTL register */
1365 e1000_write_8bit_ctrl_reg_generic(hw, E1000_CCMCTL, 0x14, 0x00);
1366 e1000_write_8bit_ctrl_reg_generic(hw, E1000_CCMCTL, 0x10, 0x00);
1368 /* PCIe lanes configuration */
1369 e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x00, 0xEC);
1370 e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x61, 0xDF);
1371 e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x34, 0x05);
1372 e1000_write_8bit_ctrl_reg_generic(hw, E1000_GIOCTL, 0x2F, 0x81);
1374 /* PCIe PLL Configuration */
1375 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCCTL, 0x02, 0x47);
1376 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCCTL, 0x14, 0x00);
1377 e1000_write_8bit_ctrl_reg_generic(hw, E1000_SCCTL, 0x10, 0x00);
1380 return E1000_SUCCESS;
1384 * e1000_read_mac_addr_82575 - Read device MAC address
1385 * @hw: pointer to the HW structure
1387 static s32 e1000_read_mac_addr_82575(struct e1000_hw *hw)
1389 s32 ret_val = E1000_SUCCESS;
1391 DEBUGFUNC("e1000_read_mac_addr_82575");
1394 * If there's an alternate MAC address place it in RAR0
1395 * so that it will override the Si installed default perm
1398 ret_val = e1000_check_alt_mac_addr_generic(hw);
1402 ret_val = e1000_read_mac_addr_generic(hw);
1409 * e1000_config_collision_dist_82575 - Configure collision distance
1410 * @hw: pointer to the HW structure
1412 * Configures the collision distance to the default value and is used
1413 * during link setup.
1415 static void e1000_config_collision_dist_82575(struct e1000_hw *hw)
1419 DEBUGFUNC("e1000_config_collision_dist_82575");
1421 tctl_ext = E1000_READ_REG(hw, E1000_TCTL_EXT);
1423 tctl_ext &= ~E1000_TCTL_EXT_COLD;
1424 tctl_ext |= E1000_COLLISION_DISTANCE << E1000_TCTL_EXT_COLD_SHIFT;
1426 E1000_WRITE_REG(hw, E1000_TCTL_EXT, tctl_ext);
1427 E1000_WRITE_FLUSH(hw);
1431 * e1000_power_down_phy_copper_82575 - Remove link during PHY power down
1432 * @hw: pointer to the HW structure
1434 * In the case of a PHY power down to save power, or to turn off link during a
1435 * driver unload, or wake on lan is not enabled, remove the link.
1437 static void e1000_power_down_phy_copper_82575(struct e1000_hw *hw)
1439 struct e1000_phy_info *phy = &hw->phy;
1441 if (!(phy->ops.check_reset_block))
1444 /* If the management interface is not enabled, then power down */
1445 if (!(e1000_enable_mng_pass_thru(hw) || phy->ops.check_reset_block(hw)))
1446 e1000_power_down_phy_copper(hw);
1452 * e1000_clear_hw_cntrs_82575 - Clear device specific hardware counters
1453 * @hw: pointer to the HW structure
1455 * Clears the hardware counters by reading the counter registers.
1457 static void e1000_clear_hw_cntrs_82575(struct e1000_hw *hw)
1459 DEBUGFUNC("e1000_clear_hw_cntrs_82575");
1461 e1000_clear_hw_cntrs_base_generic(hw);
1463 E1000_READ_REG(hw, E1000_PRC64);
1464 E1000_READ_REG(hw, E1000_PRC127);
1465 E1000_READ_REG(hw, E1000_PRC255);
1466 E1000_READ_REG(hw, E1000_PRC511);
1467 E1000_READ_REG(hw, E1000_PRC1023);
1468 E1000_READ_REG(hw, E1000_PRC1522);
1469 E1000_READ_REG(hw, E1000_PTC64);
1470 E1000_READ_REG(hw, E1000_PTC127);
1471 E1000_READ_REG(hw, E1000_PTC255);
1472 E1000_READ_REG(hw, E1000_PTC511);
1473 E1000_READ_REG(hw, E1000_PTC1023);
1474 E1000_READ_REG(hw, E1000_PTC1522);
1476 E1000_READ_REG(hw, E1000_ALGNERRC);
1477 E1000_READ_REG(hw, E1000_RXERRC);
1478 E1000_READ_REG(hw, E1000_TNCRS);
1479 E1000_READ_REG(hw, E1000_CEXTERR);
1480 E1000_READ_REG(hw, E1000_TSCTC);
1481 E1000_READ_REG(hw, E1000_TSCTFC);
1483 E1000_READ_REG(hw, E1000_MGTPRC);
1484 E1000_READ_REG(hw, E1000_MGTPDC);
1485 E1000_READ_REG(hw, E1000_MGTPTC);
1487 E1000_READ_REG(hw, E1000_IAC);
1488 E1000_READ_REG(hw, E1000_ICRXOC);
1490 E1000_READ_REG(hw, E1000_ICRXPTC);
1491 E1000_READ_REG(hw, E1000_ICRXATC);
1492 E1000_READ_REG(hw, E1000_ICTXPTC);
1493 E1000_READ_REG(hw, E1000_ICTXATC);
1494 E1000_READ_REG(hw, E1000_ICTXQEC);
1495 E1000_READ_REG(hw, E1000_ICTXQMTC);
1496 E1000_READ_REG(hw, E1000_ICRXDMTC);
1498 E1000_READ_REG(hw, E1000_CBTMPC);
1499 E1000_READ_REG(hw, E1000_HTDPMC);
1500 E1000_READ_REG(hw, E1000_CBRMPC);
1501 E1000_READ_REG(hw, E1000_RPTHC);
1502 E1000_READ_REG(hw, E1000_HGPTC);
1503 E1000_READ_REG(hw, E1000_HTCBDPC);
1504 E1000_READ_REG(hw, E1000_HGORCL);
1505 E1000_READ_REG(hw, E1000_HGORCH);
1506 E1000_READ_REG(hw, E1000_HGOTCL);
1507 E1000_READ_REG(hw, E1000_HGOTCH);
1508 E1000_READ_REG(hw, E1000_LENERRS);
1510 /* This register should not be read in copper configurations */
1511 if ((hw->phy.media_type == e1000_media_type_internal_serdes) ||
1512 e1000_sgmii_active_82575(hw))
1513 E1000_READ_REG(hw, E1000_SCVPC);
1517 * e1000_rx_fifo_flush_82575 - Clean rx fifo after RX enable
1518 * @hw: pointer to the HW structure
1520 * After rx enable if managability is enabled then there is likely some
1521 * bad data at the start of the fifo and possibly in the DMA fifo. This
1522 * function clears the fifos and flushes any packets that came in as rx was
1525 void e1000_rx_fifo_flush_82575(struct e1000_hw *hw)
1527 u32 rctl, rlpml, rxdctl[4], rfctl, temp_rctl, rx_enabled;
1530 DEBUGFUNC("e1000_rx_fifo_workaround_82575");
1531 if (hw->mac.type != e1000_82575 ||
1532 !(E1000_READ_REG(hw, E1000_MANC) & E1000_MANC_RCV_TCO_EN))
1535 /* Disable all RX queues */
1536 for (i = 0; i < 4; i++) {
1537 rxdctl[i] = E1000_READ_REG(hw, E1000_RXDCTL(i));
1538 E1000_WRITE_REG(hw, E1000_RXDCTL(i),
1539 rxdctl[i] & ~E1000_RXDCTL_QUEUE_ENABLE);
1541 /* Poll all queues to verify they have shut down */
1542 for (ms_wait = 0; ms_wait < 10; ms_wait++) {
1545 for (i = 0; i < 4; i++)
1546 rx_enabled |= E1000_READ_REG(hw, E1000_RXDCTL(i));
1547 if (!(rx_enabled & E1000_RXDCTL_QUEUE_ENABLE))
1552 DEBUGOUT("Queue disable timed out after 10ms\n");
1554 /* Clear RLPML, RCTL.SBP, RFCTL.LEF, and set RCTL.LPE so that all
1555 * incoming packets are rejected. Set enable and wait 2ms so that
1556 * any packet that was coming in as RCTL.EN was set is flushed
1558 rfctl = E1000_READ_REG(hw, E1000_RFCTL);
1559 E1000_WRITE_REG(hw, E1000_RFCTL, rfctl & ~E1000_RFCTL_LEF);
1561 rlpml = E1000_READ_REG(hw, E1000_RLPML);
1562 E1000_WRITE_REG(hw, E1000_RLPML, 0);
1564 rctl = E1000_READ_REG(hw, E1000_RCTL);
1565 temp_rctl = rctl & ~(E1000_RCTL_EN | E1000_RCTL_SBP);
1566 temp_rctl |= E1000_RCTL_LPE;
1568 E1000_WRITE_REG(hw, E1000_RCTL, temp_rctl);
1569 E1000_WRITE_REG(hw, E1000_RCTL, temp_rctl | E1000_RCTL_EN);
1570 E1000_WRITE_FLUSH(hw);
1573 /* Enable RX queues that were previously enabled and restore our
1576 for (i = 0; i < 4; i++)
1577 E1000_WRITE_REG(hw, E1000_RXDCTL(i), rxdctl[i]);
1578 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
1579 E1000_WRITE_FLUSH(hw);
1581 E1000_WRITE_REG(hw, E1000_RLPML, rlpml);
1582 E1000_WRITE_REG(hw, E1000_RFCTL, rfctl);
1584 /* Flush receive errors generated by workaround */
1585 E1000_READ_REG(hw, E1000_ROC);
1586 E1000_READ_REG(hw, E1000_RNBC);
1587 E1000_READ_REG(hw, E1000_MPC);
1591 * e1000_set_pcie_completion_timeout - set pci-e completion timeout
1592 * @hw: pointer to the HW structure
1594 * The defaults for 82575 and 82576 should be in the range of 50us to 50ms,
1595 * however the hardware default for these parts is 500us to 1ms which is less
1596 * than the 10ms recommended by the pci-e spec. To address this we need to
1597 * increase the value to either 10ms to 200ms for capability version 1 config,
1598 * or 16ms to 55ms for version 2.
1600 static s32 e1000_set_pcie_completion_timeout(struct e1000_hw *hw)
1602 u32 gcr = E1000_READ_REG(hw, E1000_GCR);
1603 s32 ret_val = E1000_SUCCESS;
1606 /* only take action if timeout value is defaulted to 0 */
1607 if (gcr & E1000_GCR_CMPL_TMOUT_MASK)
1611 * if capababilities version is type 1 we can write the
1612 * timeout of 10ms to 200ms through the GCR register
1614 if (!(gcr & E1000_GCR_CAP_VER2)) {
1615 gcr |= E1000_GCR_CMPL_TMOUT_10ms;
1620 * for version 2 capabilities we need to write the config space
1621 * directly in order to set the completion timeout value for
1624 ret_val = e1000_read_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
1629 pcie_devctl2 |= PCIE_DEVICE_CONTROL2_16ms;
1631 ret_val = e1000_write_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
1634 /* disable completion timeout resend */
1635 gcr &= ~E1000_GCR_CMPL_TMOUT_RESEND;
1637 E1000_WRITE_REG(hw, E1000_GCR, gcr);
1642 * e1000_vmdq_set_loopback_pf - enable or disable vmdq loopback
1643 * @hw: pointer to the hardware struct
1644 * @enable: state to enter, either enabled or disabled
1646 * enables/disables L2 switch loopback functionality.
1648 void e1000_vmdq_set_loopback_pf(struct e1000_hw *hw, bool enable)
1652 switch (hw->mac.type) {
1654 dtxswc = E1000_READ_REG(hw, E1000_DTXSWC);
1656 dtxswc |= E1000_DTXSWC_VMDQ_LOOPBACK_EN;
1658 dtxswc &= ~E1000_DTXSWC_VMDQ_LOOPBACK_EN;
1659 E1000_WRITE_REG(hw, E1000_DTXSWC, dtxswc);
1662 /* Currently no other hardware supports loopback */
1670 * e1000_vmdq_set_replication_pf - enable or disable vmdq replication
1671 * @hw: pointer to the hardware struct
1672 * @enable: state to enter, either enabled or disabled
1674 * enables/disables replication of packets across multiple pools.
1676 void e1000_vmdq_set_replication_pf(struct e1000_hw *hw, bool enable)
1678 u32 vt_ctl = E1000_READ_REG(hw, E1000_VT_CTL);
1681 vt_ctl |= E1000_VT_CTL_VM_REPL_EN;
1683 vt_ctl &= ~E1000_VT_CTL_VM_REPL_EN;
1685 E1000_WRITE_REG(hw, E1000_VT_CTL, vt_ctl);
1689 * e1000_read_phy_reg_82580 - Read 82580 MDI control register
1690 * @hw: pointer to the HW structure
1691 * @offset: register offset to be read
1692 * @data: pointer to the read data
1694 * Reads the MDI control register in the PHY at offset and stores the
1695 * information read to data.
1697 static s32 e1000_read_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 *data)
1701 DEBUGFUNC("e1000_read_phy_reg_82580");
1703 ret_val = hw->phy.ops.acquire(hw);
1707 ret_val = e1000_read_phy_reg_mdic(hw, offset, data);
1709 hw->phy.ops.release(hw);
1716 * e1000_write_phy_reg_82580 - Write 82580 MDI control register
1717 * @hw: pointer to the HW structure
1718 * @offset: register offset to write to
1719 * @data: data to write to register at offset
1721 * Writes data to MDI control register in the PHY at offset.
1723 static s32 e1000_write_phy_reg_82580(struct e1000_hw *hw, u32 offset, u16 data)
1727 DEBUGFUNC("e1000_write_phy_reg_82580");
1729 ret_val = hw->phy.ops.acquire(hw);
1733 ret_val = e1000_write_phy_reg_mdic(hw, offset, data);
1735 hw->phy.ops.release(hw);
1742 * e1000_reset_hw_82580 - Reset hardware
1743 * @hw: pointer to the HW structure
1745 * This resets function or entire device (all ports, etc.)
1748 static s32 e1000_reset_hw_82580(struct e1000_hw *hw)
1750 s32 ret_val = E1000_SUCCESS;
1751 /* BH SW mailbox bit in SW_FW_SYNC */
1752 u16 swmbsw_mask = E1000_SW_SYNCH_MB;
1754 bool global_device_reset = hw->dev_spec._82575.global_device_reset;
1756 DEBUGFUNC("e1000_reset_hw_82580");
1758 hw->dev_spec._82575.global_device_reset = FALSE;
1760 /* Get current control state. */
1761 ctrl = E1000_READ_REG(hw, E1000_CTRL);
1764 * Prevent the PCI-E bus from sticking if there is no TLP connection
1765 * on the last TLP read/write transaction when MAC is reset.
1767 ret_val = e1000_disable_pcie_master_generic(hw);
1769 DEBUGOUT("PCI-E Master disable polling has failed.\n");
1771 DEBUGOUT("Masking off all interrupts\n");
1772 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
1773 E1000_WRITE_REG(hw, E1000_RCTL, 0);
1774 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
1775 E1000_WRITE_FLUSH(hw);
1779 /* Determine whether or not a global dev reset is requested */
1780 if (global_device_reset &&
1781 e1000_acquire_swfw_sync_82575(hw, swmbsw_mask))
1782 global_device_reset = FALSE;
1784 if (global_device_reset &&
1785 !(E1000_READ_REG(hw, E1000_STATUS) & E1000_STAT_DEV_RST_SET))
1786 ctrl |= E1000_CTRL_DEV_RST;
1788 ctrl |= E1000_CTRL_RST;
1790 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
1792 /* Add delay to insure DEV_RST has time to complete */
1793 if (global_device_reset)
1796 ret_val = e1000_get_auto_rd_done_generic(hw);
1799 * When auto config read does not complete, do not
1800 * return with an error. This can happen in situations
1801 * where there is no eeprom and prevents getting link.
1803 DEBUGOUT("Auto Read Done did not complete\n");
1806 /* If EEPROM is not present, run manual init scripts */
1807 if ((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0)
1808 e1000_reset_init_script_82575(hw);
1810 /* clear global device reset status bit */
1811 E1000_WRITE_REG(hw, E1000_STATUS, E1000_STAT_DEV_RST_SET);
1813 /* Clear any pending interrupt events. */
1814 E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff);
1815 icr = E1000_READ_REG(hw, E1000_ICR);
1817 /* Install any alternate MAC address into RAR0 */
1818 ret_val = e1000_check_alt_mac_addr_generic(hw);
1820 /* Release semaphore */
1821 if (global_device_reset)
1822 e1000_release_swfw_sync_82575(hw, swmbsw_mask);
1828 * e1000_rxpbs_adjust_82580 - adjust RXPBS value to reflect actual RX PBA size
1829 * @data: data received by reading RXPBS register
1831 * The 82580 uses a table based approach for packet buffer allocation sizes.
1832 * This function converts the retrieved value into the correct table value
1833 * 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7
1834 * 0x0 36 72 144 1 2 4 8 16
1835 * 0x8 35 70 140 rsv rsv rsv rsv rsv
1837 u16 e1000_rxpbs_adjust_82580(u32 data)
1841 if (data < E1000_82580_RXPBS_TABLE_SIZE)
1842 ret_val = e1000_82580_rxpbs_table[data];