1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2020 Intel Corporation
6 #include "ixgbe_common.h"
9 STATIC void ixgbe_i2c_start(struct ixgbe_hw *hw);
10 STATIC void ixgbe_i2c_stop(struct ixgbe_hw *hw);
11 STATIC void ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data);
12 STATIC s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data);
13 STATIC s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw);
14 STATIC void ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data);
15 STATIC s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data);
16 STATIC void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl);
17 STATIC void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl);
18 STATIC s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data);
19 STATIC bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl);
20 STATIC s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
24 * ixgbe_out_i2c_byte_ack - Send I2C byte with ack
25 * @hw: pointer to the hardware structure
28 * Returns an error code on error.
30 STATIC s32 ixgbe_out_i2c_byte_ack(struct ixgbe_hw *hw, u8 byte)
34 status = ixgbe_clock_out_i2c_byte(hw, byte);
37 return ixgbe_get_i2c_ack(hw);
41 * ixgbe_in_i2c_byte_ack - Receive an I2C byte and send ack
42 * @hw: pointer to the hardware structure
43 * @byte: pointer to a u8 to receive the byte
45 * Returns an error code on error.
47 STATIC s32 ixgbe_in_i2c_byte_ack(struct ixgbe_hw *hw, u8 *byte)
49 ixgbe_clock_in_i2c_byte(hw, byte);
51 return ixgbe_clock_out_i2c_bit(hw, false);
55 * ixgbe_ones_comp_byte_add - Perform one's complement addition
59 * Returns one's complement 8-bit sum.
61 STATIC u8 ixgbe_ones_comp_byte_add(u8 add1, u8 add2)
63 u16 sum = add1 + add2;
65 sum = (sum & 0xFF) + (sum >> 8);
70 * ixgbe_read_i2c_combined_generic_int - Perform I2C read combined operation
71 * @hw: pointer to the hardware structure
72 * @addr: I2C bus address to read from
73 * @reg: I2C device register to read from
74 * @val: pointer to location to receive read value
75 * @lock: true if to take and release semaphore
77 * Returns an error code on error.
79 s32 ixgbe_read_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr, u16 reg,
82 u32 swfw_mask = hw->phy.phy_semaphore_mask;
91 reg_high = ((reg >> 7) & 0xFE) | 1; /* Indicate read combined */
92 csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
95 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
96 return IXGBE_ERR_SWFW_SYNC;
98 /* Device Address and write indication */
99 if (ixgbe_out_i2c_byte_ack(hw, addr))
101 /* Write bits 14:8 */
102 if (ixgbe_out_i2c_byte_ack(hw, reg_high))
105 if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
108 if (ixgbe_out_i2c_byte_ack(hw, csum))
110 /* Re-start condition */
112 /* Device Address and read indication */
113 if (ixgbe_out_i2c_byte_ack(hw, addr | 1))
116 if (ixgbe_in_i2c_byte_ack(hw, &high_bits))
119 if (ixgbe_in_i2c_byte_ack(hw, &low_bits))
122 ixgbe_clock_in_i2c_byte(hw, &csum_byte);
124 if (ixgbe_clock_out_i2c_bit(hw, false))
128 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
129 *val = (high_bits << 8) | low_bits;
133 ixgbe_i2c_bus_clear(hw);
135 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
136 if (retry < max_retry)
137 DEBUGOUT("I2C byte read combined error - Retrying.\n");
139 DEBUGOUT("I2C byte read combined error.\n");
141 } while (retry <= max_retry);
143 return IXGBE_ERR_I2C;
147 * ixgbe_write_i2c_combined_generic_int - Perform I2C write combined operation
148 * @hw: pointer to the hardware structure
149 * @addr: I2C bus address to write to
150 * @reg: I2C device register to write to
151 * @val: value to write
152 * @lock: true if to take and release semaphore
154 * Returns an error code on error.
156 s32 ixgbe_write_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr, u16 reg,
159 u32 swfw_mask = hw->phy.phy_semaphore_mask;
165 reg_high = (reg >> 7) & 0xFE; /* Indicate write combined */
166 csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
167 csum = ixgbe_ones_comp_byte_add(csum, val >> 8);
168 csum = ixgbe_ones_comp_byte_add(csum, val & 0xFF);
171 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
172 return IXGBE_ERR_SWFW_SYNC;
174 /* Device Address and write indication */
175 if (ixgbe_out_i2c_byte_ack(hw, addr))
177 /* Write bits 14:8 */
178 if (ixgbe_out_i2c_byte_ack(hw, reg_high))
181 if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
183 /* Write data 15:8 */
184 if (ixgbe_out_i2c_byte_ack(hw, val >> 8))
187 if (ixgbe_out_i2c_byte_ack(hw, val & 0xFF))
190 if (ixgbe_out_i2c_byte_ack(hw, csum))
194 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
198 ixgbe_i2c_bus_clear(hw);
200 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
201 if (retry < max_retry)
202 DEBUGOUT("I2C byte write combined error - Retrying.\n");
204 DEBUGOUT("I2C byte write combined error.\n");
206 } while (retry <= max_retry);
208 return IXGBE_ERR_I2C;
212 * ixgbe_init_phy_ops_generic - Inits PHY function ptrs
213 * @hw: pointer to the hardware structure
215 * Initialize the function pointers.
217 s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw)
219 struct ixgbe_phy_info *phy = &hw->phy;
221 DEBUGFUNC("ixgbe_init_phy_ops_generic");
224 phy->ops.identify = ixgbe_identify_phy_generic;
225 phy->ops.reset = ixgbe_reset_phy_generic;
226 phy->ops.read_reg = ixgbe_read_phy_reg_generic;
227 phy->ops.write_reg = ixgbe_write_phy_reg_generic;
228 phy->ops.read_reg_mdi = ixgbe_read_phy_reg_mdi;
229 phy->ops.write_reg_mdi = ixgbe_write_phy_reg_mdi;
230 phy->ops.setup_link = ixgbe_setup_phy_link_generic;
231 phy->ops.setup_link_speed = ixgbe_setup_phy_link_speed_generic;
232 phy->ops.check_link = NULL;
233 phy->ops.get_firmware_version = ixgbe_get_phy_firmware_version_generic;
234 phy->ops.read_i2c_byte = ixgbe_read_i2c_byte_generic;
235 phy->ops.write_i2c_byte = ixgbe_write_i2c_byte_generic;
236 phy->ops.read_i2c_sff8472 = ixgbe_read_i2c_sff8472_generic;
237 phy->ops.read_i2c_eeprom = ixgbe_read_i2c_eeprom_generic;
238 phy->ops.write_i2c_eeprom = ixgbe_write_i2c_eeprom_generic;
239 phy->ops.i2c_bus_clear = ixgbe_i2c_bus_clear;
240 phy->ops.identify_sfp = ixgbe_identify_module_generic;
241 phy->sfp_type = ixgbe_sfp_type_unknown;
242 phy->ops.read_i2c_byte_unlocked = ixgbe_read_i2c_byte_generic_unlocked;
243 phy->ops.write_i2c_byte_unlocked =
244 ixgbe_write_i2c_byte_generic_unlocked;
245 phy->ops.check_overtemp = ixgbe_tn_check_overtemp;
246 return IXGBE_SUCCESS;
250 * ixgbe_probe_phy - Probe a single address for a PHY
251 * @hw: pointer to hardware structure
252 * @phy_addr: PHY address to probe
254 * Returns true if PHY found
256 static bool ixgbe_probe_phy(struct ixgbe_hw *hw, u16 phy_addr)
260 if (!ixgbe_validate_phy_addr(hw, phy_addr)) {
261 DEBUGOUT1("Unable to validate PHY address 0x%04X\n",
266 if (ixgbe_get_phy_id(hw))
269 hw->phy.type = ixgbe_get_phy_type_from_id(hw->phy.id);
271 if (hw->phy.type == ixgbe_phy_unknown) {
272 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
273 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability);
275 (IXGBE_MDIO_PHY_10GBASET_ABILITY |
276 IXGBE_MDIO_PHY_1000BASET_ABILITY))
277 hw->phy.type = ixgbe_phy_cu_unknown;
279 hw->phy.type = ixgbe_phy_generic;
286 * ixgbe_identify_phy_generic - Get physical layer module
287 * @hw: pointer to hardware structure
289 * Determines the physical layer module found on the current adapter.
291 s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
293 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
296 DEBUGFUNC("ixgbe_identify_phy_generic");
298 if (!hw->phy.phy_semaphore_mask) {
300 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
302 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
305 if (hw->phy.type != ixgbe_phy_unknown)
306 return IXGBE_SUCCESS;
308 if (hw->phy.nw_mng_if_sel) {
309 phy_addr = (hw->phy.nw_mng_if_sel &
310 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
311 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
312 if (ixgbe_probe_phy(hw, phy_addr))
313 return IXGBE_SUCCESS;
315 return IXGBE_ERR_PHY_ADDR_INVALID;
318 for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
319 if (ixgbe_probe_phy(hw, phy_addr)) {
320 status = IXGBE_SUCCESS;
325 /* Certain media types do not have a phy so an address will not
326 * be found and the code will take this path. Caller has to
327 * decide if it is an error or not.
329 if (status != IXGBE_SUCCESS)
336 * ixgbe_check_reset_blocked - check status of MNG FW veto bit
337 * @hw: pointer to the hardware structure
339 * This function checks the MMNGC.MNG_VETO bit to see if there are
340 * any constraints on link from manageability. For MAC's that don't
341 * have this bit just return faluse since the link can not be blocked
344 s32 ixgbe_check_reset_blocked(struct ixgbe_hw *hw)
348 DEBUGFUNC("ixgbe_check_reset_blocked");
350 /* If we don't have this bit, it can't be blocking */
351 if (hw->mac.type == ixgbe_mac_82598EB)
354 mmngc = IXGBE_READ_REG(hw, IXGBE_MMNGC);
355 if (mmngc & IXGBE_MMNGC_MNG_VETO) {
356 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE,
357 "MNG_VETO bit detected.\n");
365 * ixgbe_validate_phy_addr - Determines phy address is valid
366 * @hw: pointer to hardware structure
367 * @phy_addr: PHY address
370 bool ixgbe_validate_phy_addr(struct ixgbe_hw *hw, u32 phy_addr)
375 DEBUGFUNC("ixgbe_validate_phy_addr");
377 hw->phy.addr = phy_addr;
378 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
379 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_id);
381 if (phy_id != 0xFFFF && phy_id != 0x0)
384 DEBUGOUT1("PHY ID HIGH is 0x%04X\n", phy_id);
390 * ixgbe_get_phy_id - Get the phy type
391 * @hw: pointer to hardware structure
394 s32 ixgbe_get_phy_id(struct ixgbe_hw *hw)
400 DEBUGFUNC("ixgbe_get_phy_id");
402 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
403 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
406 if (status == IXGBE_SUCCESS) {
407 hw->phy.id = (u32)(phy_id_high << 16);
408 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
409 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
411 hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK);
412 hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK);
414 DEBUGOUT2("PHY_ID_HIGH 0x%04X, PHY_ID_LOW 0x%04X\n",
415 phy_id_high, phy_id_low);
421 * ixgbe_get_phy_type_from_id - Get the phy type
422 * @phy_id: PHY ID information
425 enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
427 enum ixgbe_phy_type phy_type;
429 DEBUGFUNC("ixgbe_get_phy_type_from_id");
433 phy_type = ixgbe_phy_tn;
438 phy_type = ixgbe_phy_aq;
441 phy_type = ixgbe_phy_qt;
444 phy_type = ixgbe_phy_nl;
448 phy_type = ixgbe_phy_x550em_ext_t;
450 case IXGBE_M88E1500_E_PHY_ID:
451 case IXGBE_M88E1543_E_PHY_ID:
452 phy_type = ixgbe_phy_ext_1g_t;
455 phy_type = ixgbe_phy_unknown;
462 * ixgbe_reset_phy_generic - Performs a PHY reset
463 * @hw: pointer to hardware structure
465 s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
469 s32 status = IXGBE_SUCCESS;
471 DEBUGFUNC("ixgbe_reset_phy_generic");
473 if (hw->phy.type == ixgbe_phy_unknown)
474 status = ixgbe_identify_phy_generic(hw);
476 if (status != IXGBE_SUCCESS || hw->phy.type == ixgbe_phy_none)
479 /* Don't reset PHY if it's shut down due to overtemp. */
480 if (!hw->phy.reset_if_overtemp &&
481 (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
484 /* Blocked by MNG FW so bail */
485 if (ixgbe_check_reset_blocked(hw))
489 * Perform soft PHY reset to the PHY_XS.
490 * This will cause a soft reset to the PHY
492 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
493 IXGBE_MDIO_PHY_XS_DEV_TYPE,
494 IXGBE_MDIO_PHY_XS_RESET);
497 * Poll for reset bit to self-clear indicating reset is complete.
498 * Some PHYs could take up to 3 seconds to complete and need about
499 * 1.7 usec delay after the reset is complete.
501 for (i = 0; i < 30; i++) {
503 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
504 status = hw->phy.ops.read_reg(hw,
505 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
506 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
508 if (status != IXGBE_SUCCESS)
511 if (ctrl & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
516 status = hw->phy.ops.read_reg(hw,
517 IXGBE_MDIO_PHY_XS_CONTROL,
518 IXGBE_MDIO_PHY_XS_DEV_TYPE,
520 if (status != IXGBE_SUCCESS)
523 if (!(ctrl & IXGBE_MDIO_PHY_XS_RESET)) {
530 if (ctrl & IXGBE_MDIO_PHY_XS_RESET) {
531 status = IXGBE_ERR_RESET_FAILED;
532 ERROR_REPORT1(IXGBE_ERROR_POLLING,
533 "PHY reset polling failed to complete.\n");
541 * ixgbe_restart_auto_neg - Restart auto negotiation on the PHY
542 * @hw: pointer to hardware structure
544 void ixgbe_restart_auto_neg(struct ixgbe_hw *hw)
548 /* Check if PHY reset is blocked by MNG FW */
549 if (ixgbe_check_reset_blocked(hw))
552 /* Restart PHY auto-negotiation. */
553 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
554 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
555 autoneg_reg |= IXGBE_MII_RESTART;
556 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
557 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
561 * ixgbe_read_phy_mdi - Reads a value from a specified PHY register without
563 * @hw: pointer to hardware structure
564 * @reg_addr: 32 bit address of PHY register to read
565 * @device_type: 5 bit device type
566 * @phy_data: Pointer to read data from PHY register
568 s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
571 u32 i, data, command;
573 /* Setup and write the address cycle command */
574 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
575 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
576 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
577 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
579 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
582 * Check every 10 usec to see if the address cycle completed.
583 * The MDI Command bit will clear when the operation is
586 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
589 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
590 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
595 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
596 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address command did not complete.\n");
597 DEBUGOUT("PHY address command did not complete, returning IXGBE_ERR_PHY\n");
598 return IXGBE_ERR_PHY;
602 * Address cycle complete, setup and write the read
605 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
606 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
607 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
608 (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND));
610 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
613 * Check every 10 usec to see if the address cycle
614 * completed. The MDI Command bit will clear when the
615 * operation is complete
617 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
620 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
621 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
625 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
626 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY read command didn't complete\n");
627 DEBUGOUT("PHY read command didn't complete, returning IXGBE_ERR_PHY\n");
628 return IXGBE_ERR_PHY;
632 * Read operation is complete. Get the data
635 data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
636 data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
637 *phy_data = (u16)(data);
639 return IXGBE_SUCCESS;
643 * ixgbe_read_phy_reg_generic - Reads a value from a specified PHY register
644 * using the SWFW lock - this function is needed in most cases
645 * @hw: pointer to hardware structure
646 * @reg_addr: 32 bit address of PHY register to read
647 * @device_type: 5 bit device type
648 * @phy_data: Pointer to read data from PHY register
650 s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
651 u32 device_type, u16 *phy_data)
654 u32 gssr = hw->phy.phy_semaphore_mask;
656 DEBUGFUNC("ixgbe_read_phy_reg_generic");
658 if (hw->mac.ops.acquire_swfw_sync(hw, gssr))
659 return IXGBE_ERR_SWFW_SYNC;
661 status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
663 hw->mac.ops.release_swfw_sync(hw, gssr);
669 * ixgbe_write_phy_reg_mdi - Writes a value to specified PHY register
671 * @hw: pointer to hardware structure
672 * @reg_addr: 32 bit PHY register to write
673 * @device_type: 5 bit device type
674 * @phy_data: Data to write to the PHY register
676 s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,
677 u32 device_type, u16 phy_data)
681 /* Put the data in the MDI single read and write data register*/
682 IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
684 /* Setup and write the address cycle command */
685 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
686 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
687 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
688 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
690 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
693 * Check every 10 usec to see if the address cycle completed.
694 * The MDI Command bit will clear when the operation is
697 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
700 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
701 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
705 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
706 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address cmd didn't complete\n");
707 return IXGBE_ERR_PHY;
711 * Address cycle complete, setup and write the write
714 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
715 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
716 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
717 (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND));
719 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
722 * Check every 10 usec to see if the address cycle
723 * completed. The MDI Command bit will clear when the
724 * operation is complete
726 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
729 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
730 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
734 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
735 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY write cmd didn't complete\n");
736 return IXGBE_ERR_PHY;
739 return IXGBE_SUCCESS;
743 * ixgbe_write_phy_reg_generic - Writes a value to specified PHY register
744 * using SWFW lock- this function is needed in most cases
745 * @hw: pointer to hardware structure
746 * @reg_addr: 32 bit PHY register to write
747 * @device_type: 5 bit device type
748 * @phy_data: Data to write to the PHY register
750 s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
751 u32 device_type, u16 phy_data)
754 u32 gssr = hw->phy.phy_semaphore_mask;
756 DEBUGFUNC("ixgbe_write_phy_reg_generic");
758 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
759 status = hw->phy.ops.write_reg_mdi(hw, reg_addr, device_type,
761 hw->mac.ops.release_swfw_sync(hw, gssr);
763 status = IXGBE_ERR_SWFW_SYNC;
770 * ixgbe_setup_phy_link_generic - Set and restart auto-neg
771 * @hw: pointer to hardware structure
773 * Restart auto-negotiation and PHY and waits for completion.
775 s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
777 s32 status = IXGBE_SUCCESS;
778 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
779 bool autoneg = false;
780 ixgbe_link_speed speed;
782 DEBUGFUNC("ixgbe_setup_phy_link_generic");
784 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
786 /* Set or unset auto-negotiation 10G advertisement */
787 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
788 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
791 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
792 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL) &&
793 (speed & IXGBE_LINK_SPEED_10GB_FULL))
794 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
796 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
797 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
800 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
801 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
804 if (hw->mac.type == ixgbe_mac_X550) {
805 /* Set or unset auto-negotiation 5G advertisement */
806 autoneg_reg &= ~IXGBE_MII_5GBASE_T_ADVERTISE;
807 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_5GB_FULL) &&
808 (speed & IXGBE_LINK_SPEED_5GB_FULL))
809 autoneg_reg |= IXGBE_MII_5GBASE_T_ADVERTISE;
811 /* Set or unset auto-negotiation 2.5G advertisement */
812 autoneg_reg &= ~IXGBE_MII_2_5GBASE_T_ADVERTISE;
813 if ((hw->phy.autoneg_advertised &
814 IXGBE_LINK_SPEED_2_5GB_FULL) &&
815 (speed & IXGBE_LINK_SPEED_2_5GB_FULL))
816 autoneg_reg |= IXGBE_MII_2_5GBASE_T_ADVERTISE;
819 /* Set or unset auto-negotiation 1G advertisement */
820 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE;
821 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL) &&
822 (speed & IXGBE_LINK_SPEED_1GB_FULL))
823 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE;
825 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
826 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
829 /* Set or unset auto-negotiation 100M advertisement */
830 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
831 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
834 autoneg_reg &= ~(IXGBE_MII_100BASE_T_ADVERTISE |
835 IXGBE_MII_100BASE_T_ADVERTISE_HALF);
836 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL) &&
837 (speed & IXGBE_LINK_SPEED_100_FULL))
838 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
840 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
841 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
844 ixgbe_restart_auto_neg(hw);
849 * ixgbe_setup_phy_link_speed_generic - Sets the auto advertised capabilities
850 * @hw: pointer to hardware structure
851 * @speed: new link speed
852 * @autoneg_wait_to_complete: unused
854 s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
855 ixgbe_link_speed speed,
856 bool autoneg_wait_to_complete)
858 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
860 DEBUGFUNC("ixgbe_setup_phy_link_speed_generic");
863 * Clear autoneg_advertised and set new values based on input link
866 hw->phy.autoneg_advertised = 0;
868 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
869 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
871 if (speed & IXGBE_LINK_SPEED_5GB_FULL)
872 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_5GB_FULL;
874 if (speed & IXGBE_LINK_SPEED_2_5GB_FULL)
875 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_2_5GB_FULL;
877 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
878 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
880 if (speed & IXGBE_LINK_SPEED_100_FULL)
881 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
883 if (speed & IXGBE_LINK_SPEED_10_FULL)
884 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10_FULL;
886 /* Setup link based on the new speed settings */
887 ixgbe_setup_phy_link(hw);
889 return IXGBE_SUCCESS;
893 * ixgbe_get_copper_speeds_supported - Get copper link speeds from phy
894 * @hw: pointer to hardware structure
896 * Determines the supported link capabilities by reading the PHY auto
897 * negotiation register.
899 static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
904 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
905 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
910 if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
911 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
912 if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
913 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
914 if (speed_ability & IXGBE_MDIO_PHY_SPEED_100M)
915 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_100_FULL;
917 switch (hw->mac.type) {
919 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_2_5GB_FULL;
920 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_5GB_FULL;
922 case ixgbe_mac_X550EM_x:
923 case ixgbe_mac_X550EM_a:
924 hw->phy.speeds_supported &= ~IXGBE_LINK_SPEED_100_FULL;
934 * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
935 * @hw: pointer to hardware structure
936 * @speed: pointer to link speed
937 * @autoneg: boolean auto-negotiation value
939 s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
940 ixgbe_link_speed *speed,
943 s32 status = IXGBE_SUCCESS;
945 DEBUGFUNC("ixgbe_get_copper_link_capabilities_generic");
948 if (!hw->phy.speeds_supported)
949 status = ixgbe_get_copper_speeds_supported(hw);
951 *speed = hw->phy.speeds_supported;
956 * ixgbe_check_phy_link_tnx - Determine link and speed status
957 * @hw: pointer to hardware structure
958 * @speed: current link speed
959 * @link_up: true is link is up, false otherwise
961 * Reads the VS1 register to determine if link is up and the current speed for
964 s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
967 s32 status = IXGBE_SUCCESS;
969 u32 max_time_out = 10;
974 DEBUGFUNC("ixgbe_check_phy_link_tnx");
976 /* Initialize speed and link to default case */
978 *speed = IXGBE_LINK_SPEED_10GB_FULL;
981 * Check current speed and link status of the PHY register.
982 * This is a vendor specific register and may have to
983 * be changed for other copper PHYs.
985 for (time_out = 0; time_out < max_time_out; time_out++) {
987 status = hw->phy.ops.read_reg(hw,
988 IXGBE_MDIO_VENDOR_SPECIFIC_1_STATUS,
989 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
991 phy_link = phy_data & IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS;
992 phy_speed = phy_data &
993 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS;
994 if (phy_link == IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS) {
997 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS)
998 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1007 * ixgbe_setup_phy_link_tnx - Set and restart auto-neg
1008 * @hw: pointer to hardware structure
1010 * Restart auto-negotiation and PHY and waits for completion.
1012 s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
1014 s32 status = IXGBE_SUCCESS;
1015 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
1016 bool autoneg = false;
1017 ixgbe_link_speed speed;
1019 DEBUGFUNC("ixgbe_setup_phy_link_tnx");
1021 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
1023 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
1024 /* Set or unset auto-negotiation 10G advertisement */
1025 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1026 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1029 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
1030 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1031 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
1033 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1034 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1038 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
1039 /* Set or unset auto-negotiation 1G advertisement */
1040 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1041 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1044 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1045 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1046 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1048 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1049 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1053 if (speed & IXGBE_LINK_SPEED_100_FULL) {
1054 /* Set or unset auto-negotiation 100M advertisement */
1055 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1056 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1059 autoneg_reg &= ~IXGBE_MII_100BASE_T_ADVERTISE;
1060 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
1061 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
1063 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1064 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1068 ixgbe_restart_auto_neg(hw);
1073 * ixgbe_get_phy_firmware_version_tnx - Gets the PHY Firmware Version
1074 * @hw: pointer to hardware structure
1075 * @firmware_version: pointer to the PHY Firmware Version
1077 s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
1078 u16 *firmware_version)
1082 DEBUGFUNC("ixgbe_get_phy_firmware_version_tnx");
1084 status = hw->phy.ops.read_reg(hw, TNX_FW_REV,
1085 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1092 * ixgbe_get_phy_firmware_version_generic - Gets the PHY Firmware Version
1093 * @hw: pointer to hardware structure
1094 * @firmware_version: pointer to the PHY Firmware Version
1096 s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
1097 u16 *firmware_version)
1101 DEBUGFUNC("ixgbe_get_phy_firmware_version_generic");
1103 status = hw->phy.ops.read_reg(hw, AQ_FW_REV,
1104 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1111 * ixgbe_reset_phy_nl - Performs a PHY reset
1112 * @hw: pointer to hardware structure
1114 s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
1116 u16 phy_offset, control, eword, edata, block_crc;
1117 bool end_data = false;
1118 u16 list_offset, data_offset;
1120 s32 ret_val = IXGBE_SUCCESS;
1123 DEBUGFUNC("ixgbe_reset_phy_nl");
1125 /* Blocked by MNG FW so bail */
1126 if (ixgbe_check_reset_blocked(hw))
1129 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1130 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1132 /* reset the PHY and poll for completion */
1133 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1134 IXGBE_MDIO_PHY_XS_DEV_TYPE,
1135 (phy_data | IXGBE_MDIO_PHY_XS_RESET));
1137 for (i = 0; i < 100; i++) {
1138 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1139 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1140 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) == 0)
1145 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) != 0) {
1146 DEBUGOUT("PHY reset did not complete.\n");
1147 ret_val = IXGBE_ERR_PHY;
1151 /* Get init offsets */
1152 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
1154 if (ret_val != IXGBE_SUCCESS)
1157 ret_val = hw->eeprom.ops.read(hw, data_offset, &block_crc);
1161 * Read control word from PHY init contents offset
1163 ret_val = hw->eeprom.ops.read(hw, data_offset, &eword);
1166 control = (eword & IXGBE_CONTROL_MASK_NL) >>
1167 IXGBE_CONTROL_SHIFT_NL;
1168 edata = eword & IXGBE_DATA_MASK_NL;
1170 case IXGBE_DELAY_NL:
1172 DEBUGOUT1("DELAY: %d MS\n", edata);
1176 DEBUGOUT("DATA:\n");
1178 ret_val = hw->eeprom.ops.read(hw, data_offset,
1183 for (i = 0; i < edata; i++) {
1184 ret_val = hw->eeprom.ops.read(hw, data_offset,
1188 hw->phy.ops.write_reg(hw, phy_offset,
1189 IXGBE_TWINAX_DEV, eword);
1190 DEBUGOUT2("Wrote %4.4x to %4.4x\n", eword,
1196 case IXGBE_CONTROL_NL:
1198 DEBUGOUT("CONTROL:\n");
1199 if (edata == IXGBE_CONTROL_EOL_NL) {
1202 } else if (edata == IXGBE_CONTROL_SOL_NL) {
1205 DEBUGOUT("Bad control value\n");
1206 ret_val = IXGBE_ERR_PHY;
1211 DEBUGOUT("Bad control type\n");
1212 ret_val = IXGBE_ERR_PHY;
1221 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1222 "eeprom read at offset %d failed", data_offset);
1223 return IXGBE_ERR_PHY;
1227 * ixgbe_identify_module_generic - Identifies module type
1228 * @hw: pointer to hardware structure
1230 * Determines HW type and calls appropriate function.
1232 s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw)
1234 s32 status = IXGBE_ERR_SFP_NOT_PRESENT;
1236 DEBUGFUNC("ixgbe_identify_module_generic");
1238 switch (hw->mac.ops.get_media_type(hw)) {
1239 case ixgbe_media_type_fiber:
1240 status = ixgbe_identify_sfp_module_generic(hw);
1243 case ixgbe_media_type_fiber_qsfp:
1244 status = ixgbe_identify_qsfp_module_generic(hw);
1248 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1249 status = IXGBE_ERR_SFP_NOT_PRESENT;
1257 * ixgbe_identify_sfp_module_generic - Identifies SFP modules
1258 * @hw: pointer to hardware structure
1260 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1262 s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
1264 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1266 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1268 u8 comp_codes_1g = 0;
1269 u8 comp_codes_10g = 0;
1270 u8 oui_bytes[3] = {0, 0, 0};
1273 u16 enforce_sfp = 0;
1275 DEBUGFUNC("ixgbe_identify_sfp_module_generic");
1277 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber) {
1278 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1279 status = IXGBE_ERR_SFP_NOT_PRESENT;
1283 /* LAN ID is needed for I2C access */
1284 hw->mac.ops.set_lan_id(hw);
1286 status = hw->phy.ops.read_i2c_eeprom(hw,
1287 IXGBE_SFF_IDENTIFIER,
1290 if (status != IXGBE_SUCCESS)
1291 goto err_read_i2c_eeprom;
1293 if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
1294 hw->phy.type = ixgbe_phy_sfp_unsupported;
1295 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1297 status = hw->phy.ops.read_i2c_eeprom(hw,
1298 IXGBE_SFF_1GBE_COMP_CODES,
1301 if (status != IXGBE_SUCCESS)
1302 goto err_read_i2c_eeprom;
1304 status = hw->phy.ops.read_i2c_eeprom(hw,
1305 IXGBE_SFF_10GBE_COMP_CODES,
1308 if (status != IXGBE_SUCCESS)
1309 goto err_read_i2c_eeprom;
1310 status = hw->phy.ops.read_i2c_eeprom(hw,
1311 IXGBE_SFF_CABLE_TECHNOLOGY,
1314 if (status != IXGBE_SUCCESS)
1315 goto err_read_i2c_eeprom;
1322 * 3 SFP_DA_CORE0 - 82599-specific
1323 * 4 SFP_DA_CORE1 - 82599-specific
1324 * 5 SFP_SR/LR_CORE0 - 82599-specific
1325 * 6 SFP_SR/LR_CORE1 - 82599-specific
1326 * 7 SFP_act_lmt_DA_CORE0 - 82599-specific
1327 * 8 SFP_act_lmt_DA_CORE1 - 82599-specific
1328 * 9 SFP_1g_cu_CORE0 - 82599-specific
1329 * 10 SFP_1g_cu_CORE1 - 82599-specific
1330 * 11 SFP_1g_sx_CORE0 - 82599-specific
1331 * 12 SFP_1g_sx_CORE1 - 82599-specific
1333 if (hw->mac.type == ixgbe_mac_82598EB) {
1334 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1335 hw->phy.sfp_type = ixgbe_sfp_type_da_cu;
1336 else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1337 hw->phy.sfp_type = ixgbe_sfp_type_sr;
1338 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1339 hw->phy.sfp_type = ixgbe_sfp_type_lr;
1341 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1343 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) {
1344 if (hw->bus.lan_id == 0)
1346 ixgbe_sfp_type_da_cu_core0;
1349 ixgbe_sfp_type_da_cu_core1;
1350 } else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) {
1351 hw->phy.ops.read_i2c_eeprom(
1352 hw, IXGBE_SFF_CABLE_SPEC_COMP,
1355 IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING) {
1356 if (hw->bus.lan_id == 0)
1358 ixgbe_sfp_type_da_act_lmt_core0;
1361 ixgbe_sfp_type_da_act_lmt_core1;
1364 ixgbe_sfp_type_unknown;
1366 } else if (comp_codes_10g &
1367 (IXGBE_SFF_10GBASESR_CAPABLE |
1368 IXGBE_SFF_10GBASELR_CAPABLE)) {
1369 if (hw->bus.lan_id == 0)
1371 ixgbe_sfp_type_srlr_core0;
1374 ixgbe_sfp_type_srlr_core1;
1375 } else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {
1376 if (hw->bus.lan_id == 0)
1378 ixgbe_sfp_type_1g_cu_core0;
1381 ixgbe_sfp_type_1g_cu_core1;
1382 } else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) {
1383 if (hw->bus.lan_id == 0)
1385 ixgbe_sfp_type_1g_sx_core0;
1388 ixgbe_sfp_type_1g_sx_core1;
1389 } else if (comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) {
1390 if (hw->bus.lan_id == 0)
1392 ixgbe_sfp_type_1g_lx_core0;
1395 ixgbe_sfp_type_1g_lx_core1;
1396 } else if (comp_codes_1g & IXGBE_SFF_1GBASELHA_CAPABLE) {
1397 if (hw->bus.lan_id == 0)
1399 ixgbe_sfp_type_1g_lha_core0;
1402 ixgbe_sfp_type_1g_lha_core1;
1404 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1408 if (hw->phy.sfp_type != stored_sfp_type)
1409 hw->phy.sfp_setup_needed = true;
1411 /* Determine if the SFP+ PHY is dual speed or not. */
1412 hw->phy.multispeed_fiber = false;
1413 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1414 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1415 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1416 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1417 hw->phy.multispeed_fiber = true;
1419 /* Determine PHY vendor */
1420 if (hw->phy.type != ixgbe_phy_nl) {
1421 hw->phy.id = identifier;
1422 status = hw->phy.ops.read_i2c_eeprom(hw,
1423 IXGBE_SFF_VENDOR_OUI_BYTE0,
1426 if (status != IXGBE_SUCCESS)
1427 goto err_read_i2c_eeprom;
1429 status = hw->phy.ops.read_i2c_eeprom(hw,
1430 IXGBE_SFF_VENDOR_OUI_BYTE1,
1433 if (status != IXGBE_SUCCESS)
1434 goto err_read_i2c_eeprom;
1436 status = hw->phy.ops.read_i2c_eeprom(hw,
1437 IXGBE_SFF_VENDOR_OUI_BYTE2,
1440 if (status != IXGBE_SUCCESS)
1441 goto err_read_i2c_eeprom;
1444 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1445 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1446 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1448 switch (vendor_oui) {
1449 case IXGBE_SFF_VENDOR_OUI_TYCO:
1450 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1452 ixgbe_phy_sfp_passive_tyco;
1454 case IXGBE_SFF_VENDOR_OUI_FTL:
1455 if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1456 hw->phy.type = ixgbe_phy_sfp_ftl_active;
1458 hw->phy.type = ixgbe_phy_sfp_ftl;
1460 case IXGBE_SFF_VENDOR_OUI_AVAGO:
1461 hw->phy.type = ixgbe_phy_sfp_avago;
1463 case IXGBE_SFF_VENDOR_OUI_INTEL:
1464 hw->phy.type = ixgbe_phy_sfp_intel;
1467 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1469 ixgbe_phy_sfp_passive_unknown;
1470 else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1472 ixgbe_phy_sfp_active_unknown;
1474 hw->phy.type = ixgbe_phy_sfp_unknown;
1479 /* Allow any DA cable vendor */
1480 if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE |
1481 IXGBE_SFF_DA_ACTIVE_CABLE)) {
1482 status = IXGBE_SUCCESS;
1486 /* Verify supported 1G SFP modules */
1487 if (comp_codes_10g == 0 &&
1488 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1489 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1490 hw->phy.sfp_type == ixgbe_sfp_type_1g_lha_core0 ||
1491 hw->phy.sfp_type == ixgbe_sfp_type_1g_lha_core1 ||
1492 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1493 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1494 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1495 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1496 hw->phy.type = ixgbe_phy_sfp_unsupported;
1497 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1501 /* Anything else 82598-based is supported */
1502 if (hw->mac.type == ixgbe_mac_82598EB) {
1503 status = IXGBE_SUCCESS;
1507 ixgbe_get_device_caps(hw, &enforce_sfp);
1508 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP) &&
1509 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1510 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1511 hw->phy.sfp_type == ixgbe_sfp_type_1g_lha_core0 ||
1512 hw->phy.sfp_type == ixgbe_sfp_type_1g_lha_core1 ||
1513 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1514 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1515 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1516 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1517 /* Make sure we're a supported PHY type */
1518 if (hw->phy.type == ixgbe_phy_sfp_intel) {
1519 status = IXGBE_SUCCESS;
1521 if (hw->allow_unsupported_sfp == true) {
1523 "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. "
1524 "Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. "
1525 "Intel Corporation is not responsible for any harm caused by using untested modules.\n");
1526 status = IXGBE_SUCCESS;
1528 DEBUGOUT("SFP+ module not supported\n");
1530 ixgbe_phy_sfp_unsupported;
1531 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1535 status = IXGBE_SUCCESS;
1542 err_read_i2c_eeprom:
1543 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1544 if (hw->phy.type != ixgbe_phy_nl) {
1546 hw->phy.type = ixgbe_phy_unknown;
1548 return IXGBE_ERR_SFP_NOT_PRESENT;
1552 * ixgbe_get_supported_phy_sfp_layer_generic - Returns physical layer type
1553 * @hw: pointer to hardware structure
1555 * Determines physical layer capabilities of the current SFP.
1557 u64 ixgbe_get_supported_phy_sfp_layer_generic(struct ixgbe_hw *hw)
1559 u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1560 u8 comp_codes_10g = 0;
1561 u8 comp_codes_1g = 0;
1563 DEBUGFUNC("ixgbe_get_supported_phy_sfp_layer_generic");
1565 hw->phy.ops.identify_sfp(hw);
1566 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1567 return physical_layer;
1569 switch (hw->phy.type) {
1570 case ixgbe_phy_sfp_passive_tyco:
1571 case ixgbe_phy_sfp_passive_unknown:
1572 case ixgbe_phy_qsfp_passive_unknown:
1573 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1575 case ixgbe_phy_sfp_ftl_active:
1576 case ixgbe_phy_sfp_active_unknown:
1577 case ixgbe_phy_qsfp_active_unknown:
1578 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA;
1580 case ixgbe_phy_sfp_avago:
1581 case ixgbe_phy_sfp_ftl:
1582 case ixgbe_phy_sfp_intel:
1583 case ixgbe_phy_sfp_unknown:
1584 hw->phy.ops.read_i2c_eeprom(hw,
1585 IXGBE_SFF_1GBE_COMP_CODES, &comp_codes_1g);
1586 hw->phy.ops.read_i2c_eeprom(hw,
1587 IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
1588 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1589 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1590 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1591 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1592 else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE)
1593 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
1594 else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE)
1595 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_SX;
1597 case ixgbe_phy_qsfp_intel:
1598 case ixgbe_phy_qsfp_unknown:
1599 hw->phy.ops.read_i2c_eeprom(hw,
1600 IXGBE_SFF_QSFP_10GBE_COMP, &comp_codes_10g);
1601 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1602 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1603 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1604 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1610 return physical_layer;
1614 * ixgbe_identify_qsfp_module_generic - Identifies QSFP modules
1615 * @hw: pointer to hardware structure
1617 * Searches for and identifies the QSFP module and assigns appropriate PHY type
1619 s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
1621 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1623 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1625 u8 comp_codes_1g = 0;
1626 u8 comp_codes_10g = 0;
1627 u8 oui_bytes[3] = {0, 0, 0};
1628 u16 enforce_sfp = 0;
1630 u8 cable_length = 0;
1632 bool active_cable = false;
1634 DEBUGFUNC("ixgbe_identify_qsfp_module_generic");
1636 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber_qsfp) {
1637 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1638 status = IXGBE_ERR_SFP_NOT_PRESENT;
1642 /* LAN ID is needed for I2C access */
1643 hw->mac.ops.set_lan_id(hw);
1645 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER,
1648 if (status != IXGBE_SUCCESS)
1649 goto err_read_i2c_eeprom;
1651 if (identifier != IXGBE_SFF_IDENTIFIER_QSFP_PLUS) {
1652 hw->phy.type = ixgbe_phy_sfp_unsupported;
1653 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1657 hw->phy.id = identifier;
1659 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_10GBE_COMP,
1662 if (status != IXGBE_SUCCESS)
1663 goto err_read_i2c_eeprom;
1665 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_1GBE_COMP,
1668 if (status != IXGBE_SUCCESS)
1669 goto err_read_i2c_eeprom;
1671 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_PASSIVE_CABLE) {
1672 hw->phy.type = ixgbe_phy_qsfp_passive_unknown;
1673 if (hw->bus.lan_id == 0)
1674 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core0;
1676 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core1;
1677 } else if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1678 IXGBE_SFF_10GBASELR_CAPABLE)) {
1679 if (hw->bus.lan_id == 0)
1680 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core0;
1682 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core1;
1684 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_ACTIVE_CABLE)
1685 active_cable = true;
1687 if (!active_cable) {
1688 /* check for active DA cables that pre-date
1690 hw->phy.ops.read_i2c_eeprom(hw,
1691 IXGBE_SFF_QSFP_CONNECTOR,
1694 hw->phy.ops.read_i2c_eeprom(hw,
1695 IXGBE_SFF_QSFP_CABLE_LENGTH,
1698 hw->phy.ops.read_i2c_eeprom(hw,
1699 IXGBE_SFF_QSFP_DEVICE_TECH,
1703 IXGBE_SFF_QSFP_CONNECTOR_NOT_SEPARABLE) &&
1704 (cable_length > 0) &&
1705 ((device_tech >> 4) ==
1706 IXGBE_SFF_QSFP_TRANSMITER_850NM_VCSEL))
1707 active_cable = true;
1711 hw->phy.type = ixgbe_phy_qsfp_active_unknown;
1712 if (hw->bus.lan_id == 0)
1714 ixgbe_sfp_type_da_act_lmt_core0;
1717 ixgbe_sfp_type_da_act_lmt_core1;
1719 /* unsupported module type */
1720 hw->phy.type = ixgbe_phy_sfp_unsupported;
1721 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1726 if (hw->phy.sfp_type != stored_sfp_type)
1727 hw->phy.sfp_setup_needed = true;
1729 /* Determine if the QSFP+ PHY is dual speed or not. */
1730 hw->phy.multispeed_fiber = false;
1731 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1732 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1733 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1734 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1735 hw->phy.multispeed_fiber = true;
1737 /* Determine PHY vendor for optical modules */
1738 if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1739 IXGBE_SFF_10GBASELR_CAPABLE)) {
1740 status = hw->phy.ops.read_i2c_eeprom(hw,
1741 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE0,
1744 if (status != IXGBE_SUCCESS)
1745 goto err_read_i2c_eeprom;
1747 status = hw->phy.ops.read_i2c_eeprom(hw,
1748 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE1,
1751 if (status != IXGBE_SUCCESS)
1752 goto err_read_i2c_eeprom;
1754 status = hw->phy.ops.read_i2c_eeprom(hw,
1755 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE2,
1758 if (status != IXGBE_SUCCESS)
1759 goto err_read_i2c_eeprom;
1762 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1763 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1764 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1766 if (vendor_oui == IXGBE_SFF_VENDOR_OUI_INTEL)
1767 hw->phy.type = ixgbe_phy_qsfp_intel;
1769 hw->phy.type = ixgbe_phy_qsfp_unknown;
1771 ixgbe_get_device_caps(hw, &enforce_sfp);
1772 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP)) {
1773 /* Make sure we're a supported PHY type */
1774 if (hw->phy.type == ixgbe_phy_qsfp_intel) {
1775 status = IXGBE_SUCCESS;
1777 if (hw->allow_unsupported_sfp == true) {
1779 "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. "
1780 "Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. "
1781 "Intel Corporation is not responsible for any harm caused by using untested modules.\n");
1782 status = IXGBE_SUCCESS;
1784 DEBUGOUT("QSFP module not supported\n");
1786 ixgbe_phy_sfp_unsupported;
1787 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1791 status = IXGBE_SUCCESS;
1798 err_read_i2c_eeprom:
1799 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1801 hw->phy.type = ixgbe_phy_unknown;
1803 return IXGBE_ERR_SFP_NOT_PRESENT;
1807 * ixgbe_get_sfp_init_sequence_offsets - Provides offset of PHY init sequence
1808 * @hw: pointer to hardware structure
1809 * @list_offset: offset to the SFP ID list
1810 * @data_offset: offset to the SFP data block
1812 * Checks the MAC's EEPROM to see if it supports a given SFP+ module type, if
1813 * so it returns the offsets to the phy init sequence block.
1815 s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
1820 u16 sfp_type = hw->phy.sfp_type;
1822 DEBUGFUNC("ixgbe_get_sfp_init_sequence_offsets");
1824 if (hw->phy.sfp_type == ixgbe_sfp_type_unknown)
1825 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1827 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1828 return IXGBE_ERR_SFP_NOT_PRESENT;
1830 if ((hw->device_id == IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) &&
1831 (hw->phy.sfp_type == ixgbe_sfp_type_da_cu))
1832 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1835 * Limiting active cables and 1G Phys must be initialized as
1838 if (sfp_type == ixgbe_sfp_type_da_act_lmt_core0 ||
1839 sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1840 sfp_type == ixgbe_sfp_type_1g_lha_core0 ||
1841 sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1842 sfp_type == ixgbe_sfp_type_1g_sx_core0)
1843 sfp_type = ixgbe_sfp_type_srlr_core0;
1844 else if (sfp_type == ixgbe_sfp_type_da_act_lmt_core1 ||
1845 sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1846 sfp_type == ixgbe_sfp_type_1g_lha_core1 ||
1847 sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1848 sfp_type == ixgbe_sfp_type_1g_sx_core1)
1849 sfp_type = ixgbe_sfp_type_srlr_core1;
1851 /* Read offset to PHY init contents */
1852 if (hw->eeprom.ops.read(hw, IXGBE_PHY_INIT_OFFSET_NL, list_offset)) {
1853 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1854 "eeprom read at offset %d failed",
1855 IXGBE_PHY_INIT_OFFSET_NL);
1856 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1859 if ((!*list_offset) || (*list_offset == 0xFFFF))
1860 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1862 /* Shift offset to first ID word */
1866 * Find the matching SFP ID in the EEPROM
1867 * and program the init sequence
1869 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1872 while (sfp_id != IXGBE_PHY_INIT_END_NL) {
1873 if (sfp_id == sfp_type) {
1875 if (hw->eeprom.ops.read(hw, *list_offset, data_offset))
1877 if ((!*data_offset) || (*data_offset == 0xFFFF)) {
1878 DEBUGOUT("SFP+ module not supported\n");
1879 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1884 (*list_offset) += 2;
1885 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1890 if (sfp_id == IXGBE_PHY_INIT_END_NL) {
1891 DEBUGOUT("No matching SFP+ module found\n");
1892 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1895 return IXGBE_SUCCESS;
1898 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1899 "eeprom read at offset %d failed", *list_offset);
1900 return IXGBE_ERR_PHY;
1904 * ixgbe_read_i2c_eeprom_generic - Reads 8 bit EEPROM word over I2C interface
1905 * @hw: pointer to hardware structure
1906 * @byte_offset: EEPROM byte offset to read
1907 * @eeprom_data: value read
1909 * Performs byte read operation to SFP module's EEPROM over I2C interface.
1911 s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1914 DEBUGFUNC("ixgbe_read_i2c_eeprom_generic");
1916 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1917 IXGBE_I2C_EEPROM_DEV_ADDR,
1922 * ixgbe_read_i2c_sff8472_generic - Reads 8 bit word over I2C interface
1923 * @hw: pointer to hardware structure
1924 * @byte_offset: byte offset at address 0xA2
1925 * @sff8472_data: value read
1927 * Performs byte read operation to SFP module's SFF-8472 data over I2C
1929 STATIC s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
1932 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1933 IXGBE_I2C_EEPROM_DEV_ADDR2,
1938 * ixgbe_write_i2c_eeprom_generic - Writes 8 bit EEPROM word over I2C interface
1939 * @hw: pointer to hardware structure
1940 * @byte_offset: EEPROM byte offset to write
1941 * @eeprom_data: value to write
1943 * Performs byte write operation to SFP module's EEPROM over I2C interface.
1945 s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1948 DEBUGFUNC("ixgbe_write_i2c_eeprom_generic");
1950 return hw->phy.ops.write_i2c_byte(hw, byte_offset,
1951 IXGBE_I2C_EEPROM_DEV_ADDR,
1956 * ixgbe_is_sfp_probe - Returns true if SFP is being detected
1957 * @hw: pointer to hardware structure
1958 * @offset: eeprom offset to be read
1959 * @addr: I2C address to be read
1961 STATIC bool ixgbe_is_sfp_probe(struct ixgbe_hw *hw, u8 offset, u8 addr)
1963 if (addr == IXGBE_I2C_EEPROM_DEV_ADDR &&
1964 offset == IXGBE_SFF_IDENTIFIER &&
1965 hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1971 * ixgbe_read_i2c_byte_generic_int - Reads 8 bit word over I2C
1972 * @hw: pointer to hardware structure
1973 * @byte_offset: byte offset to read
1974 * @dev_addr: address to read from
1976 * @lock: true if to take and release semaphore
1978 * Performs byte read operation to SFP module's EEPROM over I2C interface at
1979 * a specified device address.
1981 STATIC s32 ixgbe_read_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
1982 u8 dev_addr, u8 *data, bool lock)
1987 u32 swfw_mask = hw->phy.phy_semaphore_mask;
1991 DEBUGFUNC("ixgbe_read_i2c_byte_generic");
1993 if (hw->mac.type >= ixgbe_mac_X550)
1995 if (ixgbe_is_sfp_probe(hw, byte_offset, dev_addr))
1996 max_retry = IXGBE_SFP_DETECT_RETRIES;
1999 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
2000 return IXGBE_ERR_SWFW_SYNC;
2002 ixgbe_i2c_start(hw);
2004 /* Device Address and write indication */
2005 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
2006 if (status != IXGBE_SUCCESS)
2009 status = ixgbe_get_i2c_ack(hw);
2010 if (status != IXGBE_SUCCESS)
2013 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
2014 if (status != IXGBE_SUCCESS)
2017 status = ixgbe_get_i2c_ack(hw);
2018 if (status != IXGBE_SUCCESS)
2021 ixgbe_i2c_start(hw);
2023 /* Device Address and read indication */
2024 status = ixgbe_clock_out_i2c_byte(hw, (dev_addr | 0x1));
2025 if (status != IXGBE_SUCCESS)
2028 status = ixgbe_get_i2c_ack(hw);
2029 if (status != IXGBE_SUCCESS)
2032 ixgbe_clock_in_i2c_byte(hw, data);
2034 status = ixgbe_clock_out_i2c_bit(hw, nack);
2035 if (status != IXGBE_SUCCESS)
2040 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2041 return IXGBE_SUCCESS;
2044 ixgbe_i2c_bus_clear(hw);
2046 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2049 if (retry < max_retry)
2050 DEBUGOUT("I2C byte read error - Retrying.\n");
2052 DEBUGOUT("I2C byte read error.\n");
2054 } while (retry <= max_retry);
2060 * ixgbe_read_i2c_byte_generic - Reads 8 bit word over I2C
2061 * @hw: pointer to hardware structure
2062 * @byte_offset: byte offset to read
2063 * @dev_addr: address to read from
2066 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2067 * a specified device address.
2069 s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
2070 u8 dev_addr, u8 *data)
2072 return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2077 * ixgbe_read_i2c_byte_generic_unlocked - Reads 8 bit word over I2C
2078 * @hw: pointer to hardware structure
2079 * @byte_offset: byte offset to read
2080 * @dev_addr: address to read from
2083 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2084 * a specified device address.
2086 s32 ixgbe_read_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2087 u8 dev_addr, u8 *data)
2089 return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2094 * ixgbe_write_i2c_byte_generic_int - Writes 8 bit word over I2C
2095 * @hw: pointer to hardware structure
2096 * @byte_offset: byte offset to write
2097 * @dev_addr: address to write to
2098 * @data: value to write
2099 * @lock: true if to take and release semaphore
2101 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2102 * a specified device address.
2104 STATIC s32 ixgbe_write_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
2105 u8 dev_addr, u8 data, bool lock)
2110 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2112 DEBUGFUNC("ixgbe_write_i2c_byte_generic");
2114 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) !=
2116 return IXGBE_ERR_SWFW_SYNC;
2119 ixgbe_i2c_start(hw);
2121 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
2122 if (status != IXGBE_SUCCESS)
2125 status = ixgbe_get_i2c_ack(hw);
2126 if (status != IXGBE_SUCCESS)
2129 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
2130 if (status != IXGBE_SUCCESS)
2133 status = ixgbe_get_i2c_ack(hw);
2134 if (status != IXGBE_SUCCESS)
2137 status = ixgbe_clock_out_i2c_byte(hw, data);
2138 if (status != IXGBE_SUCCESS)
2141 status = ixgbe_get_i2c_ack(hw);
2142 if (status != IXGBE_SUCCESS)
2147 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2148 return IXGBE_SUCCESS;
2151 ixgbe_i2c_bus_clear(hw);
2152 if (retry < max_retry)
2153 DEBUGOUT("I2C byte write error - Retrying.\n");
2155 DEBUGOUT("I2C byte write error.\n");
2157 } while (retry <= max_retry);
2160 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2166 * ixgbe_write_i2c_byte_generic - Writes 8 bit word over I2C
2167 * @hw: pointer to hardware structure
2168 * @byte_offset: byte offset to write
2169 * @dev_addr: address to write to
2170 * @data: value to write
2172 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2173 * a specified device address.
2175 s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
2176 u8 dev_addr, u8 data)
2178 return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2183 * ixgbe_write_i2c_byte_generic_unlocked - Writes 8 bit word over I2C
2184 * @hw: pointer to hardware structure
2185 * @byte_offset: byte offset to write
2186 * @dev_addr: address to write to
2187 * @data: value to write
2189 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2190 * a specified device address.
2192 s32 ixgbe_write_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2193 u8 dev_addr, u8 data)
2195 return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2200 * ixgbe_i2c_start - Sets I2C start condition
2201 * @hw: pointer to hardware structure
2203 * Sets I2C start condition (High -> Low on SDA while SCL is High)
2204 * Set bit-bang mode on X550 hardware.
2206 STATIC void ixgbe_i2c_start(struct ixgbe_hw *hw)
2208 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2210 DEBUGFUNC("ixgbe_i2c_start");
2212 i2cctl |= IXGBE_I2C_BB_EN_BY_MAC(hw);
2214 /* Start condition must begin with data and clock high */
2215 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2216 ixgbe_raise_i2c_clk(hw, &i2cctl);
2218 /* Setup time for start condition (4.7us) */
2219 usec_delay(IXGBE_I2C_T_SU_STA);
2221 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2223 /* Hold time for start condition (4us) */
2224 usec_delay(IXGBE_I2C_T_HD_STA);
2226 ixgbe_lower_i2c_clk(hw, &i2cctl);
2228 /* Minimum low period of clock is 4.7 us */
2229 usec_delay(IXGBE_I2C_T_LOW);
2234 * ixgbe_i2c_stop - Sets I2C stop condition
2235 * @hw: pointer to hardware structure
2237 * Sets I2C stop condition (Low -> High on SDA while SCL is High)
2238 * Disables bit-bang mode and negates data output enable on X550
2241 STATIC void ixgbe_i2c_stop(struct ixgbe_hw *hw)
2243 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2244 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2245 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2246 u32 bb_en_bit = IXGBE_I2C_BB_EN_BY_MAC(hw);
2248 DEBUGFUNC("ixgbe_i2c_stop");
2250 /* Stop condition must begin with data low and clock high */
2251 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2252 ixgbe_raise_i2c_clk(hw, &i2cctl);
2254 /* Setup time for stop condition (4us) */
2255 usec_delay(IXGBE_I2C_T_SU_STO);
2257 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2259 /* bus free time between stop and start (4.7us)*/
2260 usec_delay(IXGBE_I2C_T_BUF);
2262 if (bb_en_bit || data_oe_bit || clk_oe_bit) {
2263 i2cctl &= ~bb_en_bit;
2264 i2cctl |= data_oe_bit | clk_oe_bit;
2265 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2266 IXGBE_WRITE_FLUSH(hw);
2271 * ixgbe_clock_in_i2c_byte - Clocks in one byte via I2C
2272 * @hw: pointer to hardware structure
2273 * @data: data byte to clock in
2275 * Clocks in one byte data via I2C data/clock
2277 STATIC void ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data)
2282 DEBUGFUNC("ixgbe_clock_in_i2c_byte");
2285 for (i = 7; i >= 0; i--) {
2286 ixgbe_clock_in_i2c_bit(hw, &bit);
2292 * ixgbe_clock_out_i2c_byte - Clocks out one byte via I2C
2293 * @hw: pointer to hardware structure
2294 * @data: data byte clocked out
2296 * Clocks out one byte data via I2C data/clock
2298 STATIC s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data)
2300 s32 status = IXGBE_SUCCESS;
2305 DEBUGFUNC("ixgbe_clock_out_i2c_byte");
2307 for (i = 7; i >= 0; i--) {
2308 bit = (data >> i) & 0x1;
2309 status = ixgbe_clock_out_i2c_bit(hw, bit);
2311 if (status != IXGBE_SUCCESS)
2315 /* Release SDA line (set high) */
2316 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2317 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2318 i2cctl |= IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2319 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2320 IXGBE_WRITE_FLUSH(hw);
2326 * ixgbe_get_i2c_ack - Polls for I2C ACK
2327 * @hw: pointer to hardware structure
2329 * Clocks in/out one bit via I2C data/clock
2331 STATIC s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw)
2333 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2334 s32 status = IXGBE_SUCCESS;
2336 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2340 DEBUGFUNC("ixgbe_get_i2c_ack");
2343 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2344 i2cctl |= data_oe_bit;
2345 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2346 IXGBE_WRITE_FLUSH(hw);
2348 ixgbe_raise_i2c_clk(hw, &i2cctl);
2350 /* Minimum high period of clock is 4us */
2351 usec_delay(IXGBE_I2C_T_HIGH);
2353 /* Poll for ACK. Note that ACK in I2C spec is
2354 * transition from 1 to 0 */
2355 for (i = 0; i < timeout; i++) {
2356 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2357 ack = ixgbe_get_i2c_data(hw, &i2cctl);
2365 DEBUGOUT("I2C ack was not received.\n");
2366 status = IXGBE_ERR_I2C;
2369 ixgbe_lower_i2c_clk(hw, &i2cctl);
2371 /* Minimum low period of clock is 4.7 us */
2372 usec_delay(IXGBE_I2C_T_LOW);
2378 * ixgbe_clock_in_i2c_bit - Clocks in one bit via I2C data/clock
2379 * @hw: pointer to hardware structure
2380 * @data: read data value
2382 * Clocks in one bit via I2C data/clock
2384 STATIC void ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data)
2386 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2387 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2389 DEBUGFUNC("ixgbe_clock_in_i2c_bit");
2392 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2393 i2cctl |= data_oe_bit;
2394 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2395 IXGBE_WRITE_FLUSH(hw);
2397 ixgbe_raise_i2c_clk(hw, &i2cctl);
2399 /* Minimum high period of clock is 4us */
2400 usec_delay(IXGBE_I2C_T_HIGH);
2402 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2403 *data = ixgbe_get_i2c_data(hw, &i2cctl);
2405 ixgbe_lower_i2c_clk(hw, &i2cctl);
2407 /* Minimum low period of clock is 4.7 us */
2408 usec_delay(IXGBE_I2C_T_LOW);
2412 * ixgbe_clock_out_i2c_bit - Clocks in/out one bit via I2C data/clock
2413 * @hw: pointer to hardware structure
2414 * @data: data value to write
2416 * Clocks out one bit via I2C data/clock
2418 STATIC s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data)
2421 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2423 DEBUGFUNC("ixgbe_clock_out_i2c_bit");
2425 status = ixgbe_set_i2c_data(hw, &i2cctl, data);
2426 if (status == IXGBE_SUCCESS) {
2427 ixgbe_raise_i2c_clk(hw, &i2cctl);
2429 /* Minimum high period of clock is 4us */
2430 usec_delay(IXGBE_I2C_T_HIGH);
2432 ixgbe_lower_i2c_clk(hw, &i2cctl);
2434 /* Minimum low period of clock is 4.7 us.
2435 * This also takes care of the data hold time.
2437 usec_delay(IXGBE_I2C_T_LOW);
2439 status = IXGBE_ERR_I2C;
2440 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2441 "I2C data was not set to %X\n", data);
2448 * ixgbe_raise_i2c_clk - Raises the I2C SCL clock
2449 * @hw: pointer to hardware structure
2450 * @i2cctl: Current value of I2CCTL register
2452 * Raises the I2C clock line '0'->'1'
2453 * Negates the I2C clock output enable on X550 hardware.
2455 STATIC void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2457 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2459 u32 timeout = IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT;
2462 DEBUGFUNC("ixgbe_raise_i2c_clk");
2465 *i2cctl |= clk_oe_bit;
2466 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2469 for (i = 0; i < timeout; i++) {
2470 *i2cctl |= IXGBE_I2C_CLK_OUT_BY_MAC(hw);
2472 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2473 IXGBE_WRITE_FLUSH(hw);
2474 /* SCL rise time (1000ns) */
2475 usec_delay(IXGBE_I2C_T_RISE);
2477 i2cctl_r = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2478 if (i2cctl_r & IXGBE_I2C_CLK_IN_BY_MAC(hw))
2484 * ixgbe_lower_i2c_clk - Lowers the I2C SCL clock
2485 * @hw: pointer to hardware structure
2486 * @i2cctl: Current value of I2CCTL register
2488 * Lowers the I2C clock line '1'->'0'
2489 * Asserts the I2C clock output enable on X550 hardware.
2491 STATIC void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2493 DEBUGFUNC("ixgbe_lower_i2c_clk");
2495 *i2cctl &= ~(IXGBE_I2C_CLK_OUT_BY_MAC(hw));
2496 *i2cctl &= ~IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2498 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2499 IXGBE_WRITE_FLUSH(hw);
2501 /* SCL fall time (300ns) */
2502 usec_delay(IXGBE_I2C_T_FALL);
2506 * ixgbe_set_i2c_data - Sets the I2C data bit
2507 * @hw: pointer to hardware structure
2508 * @i2cctl: Current value of I2CCTL register
2509 * @data: I2C data value (0 or 1) to set
2511 * Sets the I2C data bit
2512 * Asserts the I2C data output enable on X550 hardware.
2514 STATIC s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data)
2516 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2517 s32 status = IXGBE_SUCCESS;
2519 DEBUGFUNC("ixgbe_set_i2c_data");
2522 *i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2524 *i2cctl &= ~(IXGBE_I2C_DATA_OUT_BY_MAC(hw));
2525 *i2cctl &= ~data_oe_bit;
2527 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2528 IXGBE_WRITE_FLUSH(hw);
2530 /* Data rise/fall (1000ns/300ns) and set-up time (250ns) */
2531 usec_delay(IXGBE_I2C_T_RISE + IXGBE_I2C_T_FALL + IXGBE_I2C_T_SU_DATA);
2533 if (!data) /* Can't verify data in this case */
2534 return IXGBE_SUCCESS;
2536 *i2cctl |= data_oe_bit;
2537 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2538 IXGBE_WRITE_FLUSH(hw);
2541 /* Verify data was set correctly */
2542 *i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2543 if (data != ixgbe_get_i2c_data(hw, i2cctl)) {
2544 status = IXGBE_ERR_I2C;
2545 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2546 "Error - I2C data was not set to %X.\n",
2554 * ixgbe_get_i2c_data - Reads the I2C SDA data bit
2555 * @hw: pointer to hardware structure
2556 * @i2cctl: Current value of I2CCTL register
2558 * Returns the I2C data bit value
2559 * Negates the I2C data output enable on X550 hardware.
2561 STATIC bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl)
2563 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2566 DEBUGFUNC("ixgbe_get_i2c_data");
2569 *i2cctl |= data_oe_bit;
2570 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2571 IXGBE_WRITE_FLUSH(hw);
2572 usec_delay(IXGBE_I2C_T_FALL);
2575 if (*i2cctl & IXGBE_I2C_DATA_IN_BY_MAC(hw))
2584 * ixgbe_i2c_bus_clear - Clears the I2C bus
2585 * @hw: pointer to hardware structure
2587 * Clears the I2C bus by sending nine clock pulses.
2588 * Used when data line is stuck low.
2590 void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw)
2595 DEBUGFUNC("ixgbe_i2c_bus_clear");
2597 ixgbe_i2c_start(hw);
2598 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2600 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2602 for (i = 0; i < 9; i++) {
2603 ixgbe_raise_i2c_clk(hw, &i2cctl);
2605 /* Min high period of clock is 4us */
2606 usec_delay(IXGBE_I2C_T_HIGH);
2608 ixgbe_lower_i2c_clk(hw, &i2cctl);
2610 /* Min low period of clock is 4.7us*/
2611 usec_delay(IXGBE_I2C_T_LOW);
2614 ixgbe_i2c_start(hw);
2616 /* Put the i2c bus back to default state */
2621 * ixgbe_tn_check_overtemp - Checks if an overtemp occurred.
2622 * @hw: pointer to hardware structure
2624 * Checks if the LASI temp alarm status was triggered due to overtemp
2626 s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
2628 s32 status = IXGBE_SUCCESS;
2631 DEBUGFUNC("ixgbe_tn_check_overtemp");
2633 if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
2636 /* Check that the LASI temp alarm status was triggered */
2637 hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
2638 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_data);
2640 if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))
2643 status = IXGBE_ERR_OVERTEMP;
2644 ERROR_REPORT1(IXGBE_ERROR_CAUTION, "Device over temperature");
2650 * ixgbe_set_copper_phy_power - Control power for copper phy
2651 * @hw: pointer to hardware structure
2652 * @on: true for on, false for off
2654 s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on)
2659 if (!on && ixgbe_mng_present(hw))
2662 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2663 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2669 reg &= ~IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2671 if (ixgbe_check_reset_blocked(hw))
2673 reg |= IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2676 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2677 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,