1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2018
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 s32 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 s32 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)
51 status = ixgbe_clock_in_i2c_byte(hw, byte);
55 return ixgbe_clock_out_i2c_bit(hw, false);
59 * ixgbe_ones_comp_byte_add - Perform one's complement addition
63 * Returns one's complement 8-bit sum.
65 STATIC u8 ixgbe_ones_comp_byte_add(u8 add1, u8 add2)
67 u16 sum = add1 + add2;
69 sum = (sum & 0xFF) + (sum >> 8);
74 * ixgbe_read_i2c_combined_generic_int - Perform I2C read combined operation
75 * @hw: pointer to the hardware structure
76 * @addr: I2C bus address to read from
77 * @reg: I2C device register to read from
78 * @val: pointer to location to receive read value
79 * @lock: true if to take and release semaphore
81 * Returns an error code on error.
83 s32 ixgbe_read_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr, u16 reg,
86 u32 swfw_mask = hw->phy.phy_semaphore_mask;
95 reg_high = ((reg >> 7) & 0xFE) | 1; /* Indicate read combined */
96 csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
99 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
100 return IXGBE_ERR_SWFW_SYNC;
102 /* Device Address and write indication */
103 if (ixgbe_out_i2c_byte_ack(hw, addr))
105 /* Write bits 14:8 */
106 if (ixgbe_out_i2c_byte_ack(hw, reg_high))
109 if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
112 if (ixgbe_out_i2c_byte_ack(hw, csum))
114 /* Re-start condition */
116 /* Device Address and read indication */
117 if (ixgbe_out_i2c_byte_ack(hw, addr | 1))
120 if (ixgbe_in_i2c_byte_ack(hw, &high_bits))
123 if (ixgbe_in_i2c_byte_ack(hw, &low_bits))
126 if (ixgbe_clock_in_i2c_byte(hw, &csum_byte))
129 if (ixgbe_clock_out_i2c_bit(hw, false))
133 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
134 *val = (high_bits << 8) | low_bits;
138 ixgbe_i2c_bus_clear(hw);
140 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
142 if (retry < max_retry)
143 DEBUGOUT("I2C byte read combined error - Retrying.\n");
145 DEBUGOUT("I2C byte read combined error.\n");
146 } while (retry < max_retry);
148 return IXGBE_ERR_I2C;
152 * ixgbe_write_i2c_combined_generic_int - Perform I2C write combined operation
153 * @hw: pointer to the hardware structure
154 * @addr: I2C bus address to write to
155 * @reg: I2C device register to write to
156 * @val: value to write
157 * @lock: true if to take and release semaphore
159 * Returns an error code on error.
161 s32 ixgbe_write_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr, u16 reg,
164 u32 swfw_mask = hw->phy.phy_semaphore_mask;
170 reg_high = (reg >> 7) & 0xFE; /* Indicate write combined */
171 csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
172 csum = ixgbe_ones_comp_byte_add(csum, val >> 8);
173 csum = ixgbe_ones_comp_byte_add(csum, val & 0xFF);
176 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
177 return IXGBE_ERR_SWFW_SYNC;
179 /* Device Address and write indication */
180 if (ixgbe_out_i2c_byte_ack(hw, addr))
182 /* Write bits 14:8 */
183 if (ixgbe_out_i2c_byte_ack(hw, reg_high))
186 if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
188 /* Write data 15:8 */
189 if (ixgbe_out_i2c_byte_ack(hw, val >> 8))
192 if (ixgbe_out_i2c_byte_ack(hw, val & 0xFF))
195 if (ixgbe_out_i2c_byte_ack(hw, csum))
199 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
203 ixgbe_i2c_bus_clear(hw);
205 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
207 if (retry < max_retry)
208 DEBUGOUT("I2C byte write combined error - Retrying.\n");
210 DEBUGOUT("I2C byte write combined error.\n");
211 } while (retry < max_retry);
213 return IXGBE_ERR_I2C;
217 * ixgbe_init_phy_ops_generic - Inits PHY function ptrs
218 * @hw: pointer to the hardware structure
220 * Initialize the function pointers.
222 s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw)
224 struct ixgbe_phy_info *phy = &hw->phy;
226 DEBUGFUNC("ixgbe_init_phy_ops_generic");
229 phy->ops.identify = ixgbe_identify_phy_generic;
230 phy->ops.reset = ixgbe_reset_phy_generic;
231 phy->ops.read_reg = ixgbe_read_phy_reg_generic;
232 phy->ops.write_reg = ixgbe_write_phy_reg_generic;
233 phy->ops.read_reg_mdi = ixgbe_read_phy_reg_mdi;
234 phy->ops.write_reg_mdi = ixgbe_write_phy_reg_mdi;
235 phy->ops.setup_link = ixgbe_setup_phy_link_generic;
236 phy->ops.setup_link_speed = ixgbe_setup_phy_link_speed_generic;
237 phy->ops.check_link = NULL;
238 phy->ops.get_firmware_version = ixgbe_get_phy_firmware_version_generic;
239 phy->ops.read_i2c_byte = ixgbe_read_i2c_byte_generic;
240 phy->ops.write_i2c_byte = ixgbe_write_i2c_byte_generic;
241 phy->ops.read_i2c_sff8472 = ixgbe_read_i2c_sff8472_generic;
242 phy->ops.read_i2c_eeprom = ixgbe_read_i2c_eeprom_generic;
243 phy->ops.write_i2c_eeprom = ixgbe_write_i2c_eeprom_generic;
244 phy->ops.i2c_bus_clear = ixgbe_i2c_bus_clear;
245 phy->ops.identify_sfp = ixgbe_identify_module_generic;
246 phy->sfp_type = ixgbe_sfp_type_unknown;
247 phy->ops.read_i2c_byte_unlocked = ixgbe_read_i2c_byte_generic_unlocked;
248 phy->ops.write_i2c_byte_unlocked =
249 ixgbe_write_i2c_byte_generic_unlocked;
250 phy->ops.check_overtemp = ixgbe_tn_check_overtemp;
251 return IXGBE_SUCCESS;
255 * ixgbe_probe_phy - Probe a single address for a PHY
256 * @hw: pointer to hardware structure
257 * @phy_addr: PHY address to probe
259 * Returns true if PHY found
261 static bool ixgbe_probe_phy(struct ixgbe_hw *hw, u16 phy_addr)
265 if (!ixgbe_validate_phy_addr(hw, phy_addr)) {
266 DEBUGOUT1("Unable to validate PHY address 0x%04X\n",
271 if (ixgbe_get_phy_id(hw))
274 hw->phy.type = ixgbe_get_phy_type_from_id(hw->phy.id);
276 if (hw->phy.type == ixgbe_phy_unknown) {
277 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
278 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability);
280 (IXGBE_MDIO_PHY_10GBASET_ABILITY |
281 IXGBE_MDIO_PHY_1000BASET_ABILITY))
282 hw->phy.type = ixgbe_phy_cu_unknown;
284 hw->phy.type = ixgbe_phy_generic;
291 * ixgbe_identify_phy_generic - Get physical layer module
292 * @hw: pointer to hardware structure
294 * Determines the physical layer module found on the current adapter.
296 s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
298 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
301 DEBUGFUNC("ixgbe_identify_phy_generic");
303 if (!hw->phy.phy_semaphore_mask) {
305 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
307 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
310 if (hw->phy.type != ixgbe_phy_unknown)
311 return IXGBE_SUCCESS;
313 if (hw->phy.nw_mng_if_sel) {
314 phy_addr = (hw->phy.nw_mng_if_sel &
315 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
316 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
317 if (ixgbe_probe_phy(hw, phy_addr))
318 return IXGBE_SUCCESS;
320 return IXGBE_ERR_PHY_ADDR_INVALID;
323 for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
324 if (ixgbe_probe_phy(hw, phy_addr)) {
325 status = IXGBE_SUCCESS;
330 /* Certain media types do not have a phy so an address will not
331 * be found and the code will take this path. Caller has to
332 * decide if it is an error or not.
334 if (status != IXGBE_SUCCESS)
341 * ixgbe_check_reset_blocked - check status of MNG FW veto bit
342 * @hw: pointer to the hardware structure
344 * This function checks the MMNGC.MNG_VETO bit to see if there are
345 * any constraints on link from manageability. For MAC's that don't
346 * have this bit just return faluse since the link can not be blocked
349 s32 ixgbe_check_reset_blocked(struct ixgbe_hw *hw)
353 DEBUGFUNC("ixgbe_check_reset_blocked");
355 /* If we don't have this bit, it can't be blocking */
356 if (hw->mac.type == ixgbe_mac_82598EB)
359 mmngc = IXGBE_READ_REG(hw, IXGBE_MMNGC);
360 if (mmngc & IXGBE_MMNGC_MNG_VETO) {
361 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE,
362 "MNG_VETO bit detected.\n");
370 * ixgbe_validate_phy_addr - Determines phy address is valid
371 * @hw: pointer to hardware structure
372 * @phy_addr: PHY address
375 bool ixgbe_validate_phy_addr(struct ixgbe_hw *hw, u32 phy_addr)
380 DEBUGFUNC("ixgbe_validate_phy_addr");
382 hw->phy.addr = phy_addr;
383 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
384 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_id);
386 if (phy_id != 0xFFFF && phy_id != 0x0)
389 DEBUGOUT1("PHY ID HIGH is 0x%04X\n", phy_id);
395 * ixgbe_get_phy_id - Get the phy type
396 * @hw: pointer to hardware structure
399 s32 ixgbe_get_phy_id(struct ixgbe_hw *hw)
405 DEBUGFUNC("ixgbe_get_phy_id");
407 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
408 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
411 if (status == IXGBE_SUCCESS) {
412 hw->phy.id = (u32)(phy_id_high << 16);
413 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
414 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
416 hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK);
417 hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK);
419 DEBUGOUT2("PHY_ID_HIGH 0x%04X, PHY_ID_LOW 0x%04X\n",
420 phy_id_high, phy_id_low);
426 * ixgbe_get_phy_type_from_id - Get the phy type
427 * @phy_id: PHY ID information
430 enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
432 enum ixgbe_phy_type phy_type;
434 DEBUGFUNC("ixgbe_get_phy_type_from_id");
438 phy_type = ixgbe_phy_tn;
443 phy_type = ixgbe_phy_aq;
446 phy_type = ixgbe_phy_qt;
449 phy_type = ixgbe_phy_nl;
453 phy_type = ixgbe_phy_x550em_ext_t;
455 case IXGBE_M88E1500_E_PHY_ID:
456 case IXGBE_M88E1543_E_PHY_ID:
457 phy_type = ixgbe_phy_ext_1g_t;
460 phy_type = ixgbe_phy_unknown;
467 * ixgbe_reset_phy_generic - Performs a PHY reset
468 * @hw: pointer to hardware structure
470 s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
474 s32 status = IXGBE_SUCCESS;
476 DEBUGFUNC("ixgbe_reset_phy_generic");
478 if (hw->phy.type == ixgbe_phy_unknown)
479 status = ixgbe_identify_phy_generic(hw);
481 if (status != IXGBE_SUCCESS || hw->phy.type == ixgbe_phy_none)
484 /* Don't reset PHY if it's shut down due to overtemp. */
485 if (!hw->phy.reset_if_overtemp &&
486 (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
489 /* Blocked by MNG FW so bail */
490 if (ixgbe_check_reset_blocked(hw))
494 * Perform soft PHY reset to the PHY_XS.
495 * This will cause a soft reset to the PHY
497 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
498 IXGBE_MDIO_PHY_XS_DEV_TYPE,
499 IXGBE_MDIO_PHY_XS_RESET);
502 * Poll for reset bit to self-clear indicating reset is complete.
503 * Some PHYs could take up to 3 seconds to complete and need about
504 * 1.7 usec delay after the reset is complete.
506 for (i = 0; i < 30; i++) {
508 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
509 status = hw->phy.ops.read_reg(hw,
510 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
511 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
513 if (status != IXGBE_SUCCESS)
516 if (ctrl & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
521 status = hw->phy.ops.read_reg(hw,
522 IXGBE_MDIO_PHY_XS_CONTROL,
523 IXGBE_MDIO_PHY_XS_DEV_TYPE,
525 if (status != IXGBE_SUCCESS)
528 if (!(ctrl & IXGBE_MDIO_PHY_XS_RESET)) {
535 if (ctrl & IXGBE_MDIO_PHY_XS_RESET) {
536 status = IXGBE_ERR_RESET_FAILED;
537 ERROR_REPORT1(IXGBE_ERROR_POLLING,
538 "PHY reset polling failed to complete.\n");
546 * ixgbe_read_phy_mdi - Reads a value from a specified PHY register without
548 * @hw: pointer to hardware structure
549 * @reg_addr: 32 bit address of PHY register to read
550 * @device_type: 5 bit device type
551 * @phy_data: Pointer to read data from PHY register
553 s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
556 u32 i, data, command;
558 /* Setup and write the address cycle command */
559 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
560 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
561 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
562 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
564 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
567 * Check every 10 usec to see if the address cycle completed.
568 * The MDI Command bit will clear when the operation is
571 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
574 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
575 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
580 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
581 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address command did not complete.\n");
582 DEBUGOUT("PHY address command did not complete, returning IXGBE_ERR_PHY\n");
583 return IXGBE_ERR_PHY;
587 * Address cycle complete, setup and write the read
590 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
591 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
592 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
593 (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND));
595 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
598 * Check every 10 usec to see if the address cycle
599 * completed. The MDI Command bit will clear when the
600 * operation is complete
602 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
605 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
606 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
610 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
611 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY read command didn't complete\n");
612 DEBUGOUT("PHY read command didn't complete, returning IXGBE_ERR_PHY\n");
613 return IXGBE_ERR_PHY;
617 * Read operation is complete. Get the data
620 data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
621 data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
622 *phy_data = (u16)(data);
624 return IXGBE_SUCCESS;
628 * ixgbe_read_phy_reg_generic - Reads a value from a specified PHY register
629 * using the SWFW lock - this function is needed in most cases
630 * @hw: pointer to hardware structure
631 * @reg_addr: 32 bit address of PHY register to read
632 * @device_type: 5 bit device type
633 * @phy_data: Pointer to read data from PHY register
635 s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
636 u32 device_type, u16 *phy_data)
639 u32 gssr = hw->phy.phy_semaphore_mask;
641 DEBUGFUNC("ixgbe_read_phy_reg_generic");
643 if (hw->mac.ops.acquire_swfw_sync(hw, gssr))
644 return IXGBE_ERR_SWFW_SYNC;
646 status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
648 hw->mac.ops.release_swfw_sync(hw, gssr);
654 * ixgbe_write_phy_reg_mdi - Writes a value to specified PHY register
656 * @hw: pointer to hardware structure
657 * @reg_addr: 32 bit PHY register to write
658 * @device_type: 5 bit device type
659 * @phy_data: Data to write to the PHY register
661 s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,
662 u32 device_type, u16 phy_data)
666 /* Put the data in the MDI single read and write data register*/
667 IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
669 /* Setup and write the address cycle command */
670 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
671 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
672 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
673 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
675 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
678 * Check every 10 usec to see if the address cycle completed.
679 * The MDI Command bit will clear when the operation is
682 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
685 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
686 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
690 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
691 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address cmd didn't complete\n");
692 return IXGBE_ERR_PHY;
696 * Address cycle complete, setup and write the write
699 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
700 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
701 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
702 (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND));
704 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
707 * Check every 10 usec to see if the address cycle
708 * completed. The MDI Command bit will clear when the
709 * operation is complete
711 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
714 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
715 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
719 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
720 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY write cmd didn't complete\n");
721 return IXGBE_ERR_PHY;
724 return IXGBE_SUCCESS;
728 * ixgbe_write_phy_reg_generic - Writes a value to specified PHY register
729 * using SWFW lock- this function is needed in most cases
730 * @hw: pointer to hardware structure
731 * @reg_addr: 32 bit PHY register to write
732 * @device_type: 5 bit device type
733 * @phy_data: Data to write to the PHY register
735 s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
736 u32 device_type, u16 phy_data)
739 u32 gssr = hw->phy.phy_semaphore_mask;
741 DEBUGFUNC("ixgbe_write_phy_reg_generic");
743 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
744 status = hw->phy.ops.write_reg_mdi(hw, reg_addr, device_type,
746 hw->mac.ops.release_swfw_sync(hw, gssr);
748 status = IXGBE_ERR_SWFW_SYNC;
755 * ixgbe_setup_phy_link_generic - Set and restart auto-neg
756 * @hw: pointer to hardware structure
758 * Restart auto-negotiation and PHY and waits for completion.
760 s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
762 s32 status = IXGBE_SUCCESS;
763 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
764 bool autoneg = false;
765 ixgbe_link_speed speed;
767 DEBUGFUNC("ixgbe_setup_phy_link_generic");
769 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
771 /* Set or unset auto-negotiation 10G advertisement */
772 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
773 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
776 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
777 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL) &&
778 (speed & IXGBE_LINK_SPEED_10GB_FULL))
779 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
781 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
782 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
785 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
786 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
789 if (hw->mac.type == ixgbe_mac_X550) {
790 /* Set or unset auto-negotiation 5G advertisement */
791 autoneg_reg &= ~IXGBE_MII_5GBASE_T_ADVERTISE;
792 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_5GB_FULL) &&
793 (speed & IXGBE_LINK_SPEED_5GB_FULL))
794 autoneg_reg |= IXGBE_MII_5GBASE_T_ADVERTISE;
796 /* Set or unset auto-negotiation 2.5G advertisement */
797 autoneg_reg &= ~IXGBE_MII_2_5GBASE_T_ADVERTISE;
798 if ((hw->phy.autoneg_advertised &
799 IXGBE_LINK_SPEED_2_5GB_FULL) &&
800 (speed & IXGBE_LINK_SPEED_2_5GB_FULL))
801 autoneg_reg |= IXGBE_MII_2_5GBASE_T_ADVERTISE;
804 /* Set or unset auto-negotiation 1G advertisement */
805 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE;
806 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL) &&
807 (speed & IXGBE_LINK_SPEED_1GB_FULL))
808 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE;
810 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
811 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
814 /* Set or unset auto-negotiation 100M advertisement */
815 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
816 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
819 autoneg_reg &= ~(IXGBE_MII_100BASE_T_ADVERTISE |
820 IXGBE_MII_100BASE_T_ADVERTISE_HALF);
821 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL) &&
822 (speed & IXGBE_LINK_SPEED_100_FULL))
823 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
825 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
826 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
829 /* Blocked by MNG FW so don't reset PHY */
830 if (ixgbe_check_reset_blocked(hw))
833 /* Restart PHY auto-negotiation. */
834 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
835 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
837 autoneg_reg |= IXGBE_MII_RESTART;
839 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
840 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
846 * ixgbe_setup_phy_link_speed_generic - Sets the auto advertised capabilities
847 * @hw: pointer to hardware structure
848 * @speed: new link speed
849 * @autoneg_wait_to_complete: unused
851 s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
852 ixgbe_link_speed speed,
853 bool autoneg_wait_to_complete)
855 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
857 DEBUGFUNC("ixgbe_setup_phy_link_speed_generic");
860 * Clear autoneg_advertised and set new values based on input link
863 hw->phy.autoneg_advertised = 0;
865 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
866 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
868 if (speed & IXGBE_LINK_SPEED_5GB_FULL)
869 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_5GB_FULL;
871 if (speed & IXGBE_LINK_SPEED_2_5GB_FULL)
872 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_2_5GB_FULL;
874 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
875 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
877 if (speed & IXGBE_LINK_SPEED_100_FULL)
878 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
880 if (speed & IXGBE_LINK_SPEED_10_FULL)
881 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10_FULL;
883 /* Setup link based on the new speed settings */
884 ixgbe_setup_phy_link(hw);
886 return IXGBE_SUCCESS;
890 * ixgbe_get_copper_speeds_supported - Get copper link speeds from phy
891 * @hw: pointer to hardware structure
893 * Determines the supported link capabilities by reading the PHY auto
894 * negotiation register.
896 static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
901 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
902 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
907 if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
908 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
909 if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
910 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
911 if (speed_ability & IXGBE_MDIO_PHY_SPEED_100M)
912 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_100_FULL;
914 switch (hw->mac.type) {
916 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_2_5GB_FULL;
917 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_5GB_FULL;
919 case ixgbe_mac_X550EM_x:
920 case ixgbe_mac_X550EM_a:
921 hw->phy.speeds_supported &= ~IXGBE_LINK_SPEED_100_FULL;
931 * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
932 * @hw: pointer to hardware structure
933 * @speed: pointer to link speed
934 * @autoneg: boolean auto-negotiation value
936 s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
937 ixgbe_link_speed *speed,
940 s32 status = IXGBE_SUCCESS;
942 DEBUGFUNC("ixgbe_get_copper_link_capabilities_generic");
945 if (!hw->phy.speeds_supported)
946 status = ixgbe_get_copper_speeds_supported(hw);
948 *speed = hw->phy.speeds_supported;
953 * ixgbe_check_phy_link_tnx - Determine link and speed status
954 * @hw: pointer to hardware structure
955 * @speed: current link speed
956 * @link_up: true is link is up, false otherwise
958 * Reads the VS1 register to determine if link is up and the current speed for
961 s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
964 s32 status = IXGBE_SUCCESS;
966 u32 max_time_out = 10;
971 DEBUGFUNC("ixgbe_check_phy_link_tnx");
973 /* Initialize speed and link to default case */
975 *speed = IXGBE_LINK_SPEED_10GB_FULL;
978 * Check current speed and link status of the PHY register.
979 * This is a vendor specific register and may have to
980 * be changed for other copper PHYs.
982 for (time_out = 0; time_out < max_time_out; time_out++) {
984 status = hw->phy.ops.read_reg(hw,
985 IXGBE_MDIO_VENDOR_SPECIFIC_1_STATUS,
986 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
988 phy_link = phy_data & IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS;
989 phy_speed = phy_data &
990 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS;
991 if (phy_link == IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS) {
994 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS)
995 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1004 * ixgbe_setup_phy_link_tnx - Set and restart auto-neg
1005 * @hw: pointer to hardware structure
1007 * Restart auto-negotiation and PHY and waits for completion.
1009 s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
1011 s32 status = IXGBE_SUCCESS;
1012 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
1013 bool autoneg = false;
1014 ixgbe_link_speed speed;
1016 DEBUGFUNC("ixgbe_setup_phy_link_tnx");
1018 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
1020 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
1021 /* Set or unset auto-negotiation 10G advertisement */
1022 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1023 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1026 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
1027 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1028 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
1030 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1031 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1035 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
1036 /* Set or unset auto-negotiation 1G advertisement */
1037 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1038 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1041 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1042 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1043 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1045 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1046 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1050 if (speed & IXGBE_LINK_SPEED_100_FULL) {
1051 /* Set or unset auto-negotiation 100M advertisement */
1052 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1053 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1056 autoneg_reg &= ~IXGBE_MII_100BASE_T_ADVERTISE;
1057 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
1058 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
1060 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1061 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1065 /* Blocked by MNG FW so don't reset PHY */
1066 if (ixgbe_check_reset_blocked(hw))
1069 /* Restart PHY auto-negotiation. */
1070 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
1071 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
1073 autoneg_reg |= IXGBE_MII_RESTART;
1075 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
1076 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
1082 * ixgbe_get_phy_firmware_version_tnx - Gets the PHY Firmware Version
1083 * @hw: pointer to hardware structure
1084 * @firmware_version: pointer to the PHY Firmware Version
1086 s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
1087 u16 *firmware_version)
1091 DEBUGFUNC("ixgbe_get_phy_firmware_version_tnx");
1093 status = hw->phy.ops.read_reg(hw, TNX_FW_REV,
1094 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1101 * ixgbe_get_phy_firmware_version_generic - Gets the PHY Firmware Version
1102 * @hw: pointer to hardware structure
1103 * @firmware_version: pointer to the PHY Firmware Version
1105 s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
1106 u16 *firmware_version)
1110 DEBUGFUNC("ixgbe_get_phy_firmware_version_generic");
1112 status = hw->phy.ops.read_reg(hw, AQ_FW_REV,
1113 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1120 * ixgbe_reset_phy_nl - Performs a PHY reset
1121 * @hw: pointer to hardware structure
1123 s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
1125 u16 phy_offset, control, eword, edata, block_crc;
1126 bool end_data = false;
1127 u16 list_offset, data_offset;
1129 s32 ret_val = IXGBE_SUCCESS;
1132 DEBUGFUNC("ixgbe_reset_phy_nl");
1134 /* Blocked by MNG FW so bail */
1135 if (ixgbe_check_reset_blocked(hw))
1138 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1139 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1141 /* reset the PHY and poll for completion */
1142 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1143 IXGBE_MDIO_PHY_XS_DEV_TYPE,
1144 (phy_data | IXGBE_MDIO_PHY_XS_RESET));
1146 for (i = 0; i < 100; i++) {
1147 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1148 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1149 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) == 0)
1154 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) != 0) {
1155 DEBUGOUT("PHY reset did not complete.\n");
1156 ret_val = IXGBE_ERR_PHY;
1160 /* Get init offsets */
1161 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
1163 if (ret_val != IXGBE_SUCCESS)
1166 ret_val = hw->eeprom.ops.read(hw, data_offset, &block_crc);
1170 * Read control word from PHY init contents offset
1172 ret_val = hw->eeprom.ops.read(hw, data_offset, &eword);
1175 control = (eword & IXGBE_CONTROL_MASK_NL) >>
1176 IXGBE_CONTROL_SHIFT_NL;
1177 edata = eword & IXGBE_DATA_MASK_NL;
1179 case IXGBE_DELAY_NL:
1181 DEBUGOUT1("DELAY: %d MS\n", edata);
1185 DEBUGOUT("DATA:\n");
1187 ret_val = hw->eeprom.ops.read(hw, data_offset,
1192 for (i = 0; i < edata; i++) {
1193 ret_val = hw->eeprom.ops.read(hw, data_offset,
1197 hw->phy.ops.write_reg(hw, phy_offset,
1198 IXGBE_TWINAX_DEV, eword);
1199 DEBUGOUT2("Wrote %4.4x to %4.4x\n", eword,
1205 case IXGBE_CONTROL_NL:
1207 DEBUGOUT("CONTROL:\n");
1208 if (edata == IXGBE_CONTROL_EOL_NL) {
1211 } else if (edata == IXGBE_CONTROL_SOL_NL) {
1214 DEBUGOUT("Bad control value\n");
1215 ret_val = IXGBE_ERR_PHY;
1220 DEBUGOUT("Bad control type\n");
1221 ret_val = IXGBE_ERR_PHY;
1230 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1231 "eeprom read at offset %d failed", data_offset);
1232 return IXGBE_ERR_PHY;
1236 * ixgbe_identify_module_generic - Identifies module type
1237 * @hw: pointer to hardware structure
1239 * Determines HW type and calls appropriate function.
1241 s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw)
1243 s32 status = IXGBE_ERR_SFP_NOT_PRESENT;
1245 DEBUGFUNC("ixgbe_identify_module_generic");
1247 switch (hw->mac.ops.get_media_type(hw)) {
1248 case ixgbe_media_type_fiber:
1249 status = ixgbe_identify_sfp_module_generic(hw);
1252 case ixgbe_media_type_fiber_qsfp:
1253 status = ixgbe_identify_qsfp_module_generic(hw);
1257 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1258 status = IXGBE_ERR_SFP_NOT_PRESENT;
1266 * ixgbe_identify_sfp_module_generic - Identifies SFP modules
1267 * @hw: pointer to hardware structure
1269 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1271 s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
1273 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1275 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1277 u8 comp_codes_1g = 0;
1278 u8 comp_codes_10g = 0;
1279 u8 oui_bytes[3] = {0, 0, 0};
1282 u16 enforce_sfp = 0;
1284 DEBUGFUNC("ixgbe_identify_sfp_module_generic");
1286 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber) {
1287 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1288 status = IXGBE_ERR_SFP_NOT_PRESENT;
1292 /* LAN ID is needed for I2C access */
1293 hw->mac.ops.set_lan_id(hw);
1295 status = hw->phy.ops.read_i2c_eeprom(hw,
1296 IXGBE_SFF_IDENTIFIER,
1299 if (status != IXGBE_SUCCESS)
1300 goto err_read_i2c_eeprom;
1302 if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
1303 hw->phy.type = ixgbe_phy_sfp_unsupported;
1304 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1306 status = hw->phy.ops.read_i2c_eeprom(hw,
1307 IXGBE_SFF_1GBE_COMP_CODES,
1310 if (status != IXGBE_SUCCESS)
1311 goto err_read_i2c_eeprom;
1313 status = hw->phy.ops.read_i2c_eeprom(hw,
1314 IXGBE_SFF_10GBE_COMP_CODES,
1317 if (status != IXGBE_SUCCESS)
1318 goto err_read_i2c_eeprom;
1319 status = hw->phy.ops.read_i2c_eeprom(hw,
1320 IXGBE_SFF_CABLE_TECHNOLOGY,
1323 if (status != IXGBE_SUCCESS)
1324 goto err_read_i2c_eeprom;
1331 * 3 SFP_DA_CORE0 - 82599-specific
1332 * 4 SFP_DA_CORE1 - 82599-specific
1333 * 5 SFP_SR/LR_CORE0 - 82599-specific
1334 * 6 SFP_SR/LR_CORE1 - 82599-specific
1335 * 7 SFP_act_lmt_DA_CORE0 - 82599-specific
1336 * 8 SFP_act_lmt_DA_CORE1 - 82599-specific
1337 * 9 SFP_1g_cu_CORE0 - 82599-specific
1338 * 10 SFP_1g_cu_CORE1 - 82599-specific
1339 * 11 SFP_1g_sx_CORE0 - 82599-specific
1340 * 12 SFP_1g_sx_CORE1 - 82599-specific
1342 if (hw->mac.type == ixgbe_mac_82598EB) {
1343 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1344 hw->phy.sfp_type = ixgbe_sfp_type_da_cu;
1345 else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1346 hw->phy.sfp_type = ixgbe_sfp_type_sr;
1347 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1348 hw->phy.sfp_type = ixgbe_sfp_type_lr;
1350 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1352 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) {
1353 if (hw->bus.lan_id == 0)
1355 ixgbe_sfp_type_da_cu_core0;
1358 ixgbe_sfp_type_da_cu_core1;
1359 } else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) {
1360 hw->phy.ops.read_i2c_eeprom(
1361 hw, IXGBE_SFF_CABLE_SPEC_COMP,
1364 IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING) {
1365 if (hw->bus.lan_id == 0)
1367 ixgbe_sfp_type_da_act_lmt_core0;
1370 ixgbe_sfp_type_da_act_lmt_core1;
1373 ixgbe_sfp_type_unknown;
1375 } else if (comp_codes_10g &
1376 (IXGBE_SFF_10GBASESR_CAPABLE |
1377 IXGBE_SFF_10GBASELR_CAPABLE)) {
1378 if (hw->bus.lan_id == 0)
1380 ixgbe_sfp_type_srlr_core0;
1383 ixgbe_sfp_type_srlr_core1;
1384 } else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {
1385 if (hw->bus.lan_id == 0)
1387 ixgbe_sfp_type_1g_cu_core0;
1390 ixgbe_sfp_type_1g_cu_core1;
1391 } else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) {
1392 if (hw->bus.lan_id == 0)
1394 ixgbe_sfp_type_1g_sx_core0;
1397 ixgbe_sfp_type_1g_sx_core1;
1398 } else if (comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) {
1399 if (hw->bus.lan_id == 0)
1401 ixgbe_sfp_type_1g_lx_core0;
1404 ixgbe_sfp_type_1g_lx_core1;
1406 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1410 if (hw->phy.sfp_type != stored_sfp_type)
1411 hw->phy.sfp_setup_needed = true;
1413 /* Determine if the SFP+ PHY is dual speed or not. */
1414 hw->phy.multispeed_fiber = false;
1415 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1416 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1417 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1418 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1419 hw->phy.multispeed_fiber = true;
1421 /* Determine PHY vendor */
1422 if (hw->phy.type != ixgbe_phy_nl) {
1423 hw->phy.id = identifier;
1424 status = hw->phy.ops.read_i2c_eeprom(hw,
1425 IXGBE_SFF_VENDOR_OUI_BYTE0,
1428 if (status != IXGBE_SUCCESS)
1429 goto err_read_i2c_eeprom;
1431 status = hw->phy.ops.read_i2c_eeprom(hw,
1432 IXGBE_SFF_VENDOR_OUI_BYTE1,
1435 if (status != IXGBE_SUCCESS)
1436 goto err_read_i2c_eeprom;
1438 status = hw->phy.ops.read_i2c_eeprom(hw,
1439 IXGBE_SFF_VENDOR_OUI_BYTE2,
1442 if (status != IXGBE_SUCCESS)
1443 goto err_read_i2c_eeprom;
1446 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1447 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1448 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1450 switch (vendor_oui) {
1451 case IXGBE_SFF_VENDOR_OUI_TYCO:
1452 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1454 ixgbe_phy_sfp_passive_tyco;
1456 case IXGBE_SFF_VENDOR_OUI_FTL:
1457 if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1458 hw->phy.type = ixgbe_phy_sfp_ftl_active;
1460 hw->phy.type = ixgbe_phy_sfp_ftl;
1462 case IXGBE_SFF_VENDOR_OUI_AVAGO:
1463 hw->phy.type = ixgbe_phy_sfp_avago;
1465 case IXGBE_SFF_VENDOR_OUI_INTEL:
1466 hw->phy.type = ixgbe_phy_sfp_intel;
1469 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1471 ixgbe_phy_sfp_passive_unknown;
1472 else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1474 ixgbe_phy_sfp_active_unknown;
1476 hw->phy.type = ixgbe_phy_sfp_unknown;
1481 /* Allow any DA cable vendor */
1482 if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE |
1483 IXGBE_SFF_DA_ACTIVE_CABLE)) {
1484 status = IXGBE_SUCCESS;
1488 /* Verify supported 1G SFP modules */
1489 if (comp_codes_10g == 0 &&
1490 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1491 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
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_lx_core0 ||
1512 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1513 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1514 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1515 /* Make sure we're a supported PHY type */
1516 if (hw->phy.type == ixgbe_phy_sfp_intel) {
1517 status = IXGBE_SUCCESS;
1519 if (hw->allow_unsupported_sfp == true) {
1521 "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. "
1522 "Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. "
1523 "Intel Corporation is not responsible for any harm caused by using untested modules.\n");
1524 status = IXGBE_SUCCESS;
1526 DEBUGOUT("SFP+ module not supported\n");
1528 ixgbe_phy_sfp_unsupported;
1529 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1533 status = IXGBE_SUCCESS;
1540 err_read_i2c_eeprom:
1541 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1542 if (hw->phy.type != ixgbe_phy_nl) {
1544 hw->phy.type = ixgbe_phy_unknown;
1546 return IXGBE_ERR_SFP_NOT_PRESENT;
1550 * ixgbe_get_supported_phy_sfp_layer_generic - Returns physical layer type
1551 * @hw: pointer to hardware structure
1553 * Determines physical layer capabilities of the current SFP.
1555 u64 ixgbe_get_supported_phy_sfp_layer_generic(struct ixgbe_hw *hw)
1557 u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1558 u8 comp_codes_10g = 0;
1559 u8 comp_codes_1g = 0;
1561 DEBUGFUNC("ixgbe_get_supported_phy_sfp_layer_generic");
1563 hw->phy.ops.identify_sfp(hw);
1564 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1565 return physical_layer;
1567 switch (hw->phy.type) {
1568 case ixgbe_phy_sfp_passive_tyco:
1569 case ixgbe_phy_sfp_passive_unknown:
1570 case ixgbe_phy_qsfp_passive_unknown:
1571 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1573 case ixgbe_phy_sfp_ftl_active:
1574 case ixgbe_phy_sfp_active_unknown:
1575 case ixgbe_phy_qsfp_active_unknown:
1576 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA;
1578 case ixgbe_phy_sfp_avago:
1579 case ixgbe_phy_sfp_ftl:
1580 case ixgbe_phy_sfp_intel:
1581 case ixgbe_phy_sfp_unknown:
1582 hw->phy.ops.read_i2c_eeprom(hw,
1583 IXGBE_SFF_1GBE_COMP_CODES, &comp_codes_1g);
1584 hw->phy.ops.read_i2c_eeprom(hw,
1585 IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
1586 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1587 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1588 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1589 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1590 else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE)
1591 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
1592 else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE)
1593 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_SX;
1595 case ixgbe_phy_qsfp_intel:
1596 case ixgbe_phy_qsfp_unknown:
1597 hw->phy.ops.read_i2c_eeprom(hw,
1598 IXGBE_SFF_QSFP_10GBE_COMP, &comp_codes_10g);
1599 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1600 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1601 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1602 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1608 return physical_layer;
1612 * ixgbe_identify_qsfp_module_generic - Identifies QSFP modules
1613 * @hw: pointer to hardware structure
1615 * Searches for and identifies the QSFP module and assigns appropriate PHY type
1617 s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
1619 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1621 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1623 u8 comp_codes_1g = 0;
1624 u8 comp_codes_10g = 0;
1625 u8 oui_bytes[3] = {0, 0, 0};
1626 u16 enforce_sfp = 0;
1628 u8 cable_length = 0;
1630 bool active_cable = false;
1632 DEBUGFUNC("ixgbe_identify_qsfp_module_generic");
1634 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber_qsfp) {
1635 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1636 status = IXGBE_ERR_SFP_NOT_PRESENT;
1640 /* LAN ID is needed for I2C access */
1641 hw->mac.ops.set_lan_id(hw);
1643 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER,
1646 if (status != IXGBE_SUCCESS)
1647 goto err_read_i2c_eeprom;
1649 if (identifier != IXGBE_SFF_IDENTIFIER_QSFP_PLUS) {
1650 hw->phy.type = ixgbe_phy_sfp_unsupported;
1651 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1655 hw->phy.id = identifier;
1657 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_10GBE_COMP,
1660 if (status != IXGBE_SUCCESS)
1661 goto err_read_i2c_eeprom;
1663 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_1GBE_COMP,
1666 if (status != IXGBE_SUCCESS)
1667 goto err_read_i2c_eeprom;
1669 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_PASSIVE_CABLE) {
1670 hw->phy.type = ixgbe_phy_qsfp_passive_unknown;
1671 if (hw->bus.lan_id == 0)
1672 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core0;
1674 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core1;
1675 } else if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1676 IXGBE_SFF_10GBASELR_CAPABLE)) {
1677 if (hw->bus.lan_id == 0)
1678 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core0;
1680 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core1;
1682 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_ACTIVE_CABLE)
1683 active_cable = true;
1685 if (!active_cable) {
1686 /* check for active DA cables that pre-date
1688 hw->phy.ops.read_i2c_eeprom(hw,
1689 IXGBE_SFF_QSFP_CONNECTOR,
1692 hw->phy.ops.read_i2c_eeprom(hw,
1693 IXGBE_SFF_QSFP_CABLE_LENGTH,
1696 hw->phy.ops.read_i2c_eeprom(hw,
1697 IXGBE_SFF_QSFP_DEVICE_TECH,
1701 IXGBE_SFF_QSFP_CONNECTOR_NOT_SEPARABLE) &&
1702 (cable_length > 0) &&
1703 ((device_tech >> 4) ==
1704 IXGBE_SFF_QSFP_TRANSMITER_850NM_VCSEL))
1705 active_cable = true;
1709 hw->phy.type = ixgbe_phy_qsfp_active_unknown;
1710 if (hw->bus.lan_id == 0)
1712 ixgbe_sfp_type_da_act_lmt_core0;
1715 ixgbe_sfp_type_da_act_lmt_core1;
1717 /* unsupported module type */
1718 hw->phy.type = ixgbe_phy_sfp_unsupported;
1719 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1724 if (hw->phy.sfp_type != stored_sfp_type)
1725 hw->phy.sfp_setup_needed = true;
1727 /* Determine if the QSFP+ PHY is dual speed or not. */
1728 hw->phy.multispeed_fiber = false;
1729 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1730 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1731 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1732 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1733 hw->phy.multispeed_fiber = true;
1735 /* Determine PHY vendor for optical modules */
1736 if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1737 IXGBE_SFF_10GBASELR_CAPABLE)) {
1738 status = hw->phy.ops.read_i2c_eeprom(hw,
1739 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE0,
1742 if (status != IXGBE_SUCCESS)
1743 goto err_read_i2c_eeprom;
1745 status = hw->phy.ops.read_i2c_eeprom(hw,
1746 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE1,
1749 if (status != IXGBE_SUCCESS)
1750 goto err_read_i2c_eeprom;
1752 status = hw->phy.ops.read_i2c_eeprom(hw,
1753 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE2,
1756 if (status != IXGBE_SUCCESS)
1757 goto err_read_i2c_eeprom;
1760 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1761 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1762 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1764 if (vendor_oui == IXGBE_SFF_VENDOR_OUI_INTEL)
1765 hw->phy.type = ixgbe_phy_qsfp_intel;
1767 hw->phy.type = ixgbe_phy_qsfp_unknown;
1769 ixgbe_get_device_caps(hw, &enforce_sfp);
1770 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP)) {
1771 /* Make sure we're a supported PHY type */
1772 if (hw->phy.type == ixgbe_phy_qsfp_intel) {
1773 status = IXGBE_SUCCESS;
1775 if (hw->allow_unsupported_sfp == true) {
1777 "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. "
1778 "Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. "
1779 "Intel Corporation is not responsible for any harm caused by using untested modules.\n");
1780 status = IXGBE_SUCCESS;
1782 DEBUGOUT("QSFP module not supported\n");
1784 ixgbe_phy_sfp_unsupported;
1785 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1789 status = IXGBE_SUCCESS;
1796 err_read_i2c_eeprom:
1797 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1799 hw->phy.type = ixgbe_phy_unknown;
1801 return IXGBE_ERR_SFP_NOT_PRESENT;
1805 * ixgbe_get_sfp_init_sequence_offsets - Provides offset of PHY init sequence
1806 * @hw: pointer to hardware structure
1807 * @list_offset: offset to the SFP ID list
1808 * @data_offset: offset to the SFP data block
1810 * Checks the MAC's EEPROM to see if it supports a given SFP+ module type, if
1811 * so it returns the offsets to the phy init sequence block.
1813 s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
1818 u16 sfp_type = hw->phy.sfp_type;
1820 DEBUGFUNC("ixgbe_get_sfp_init_sequence_offsets");
1822 if (hw->phy.sfp_type == ixgbe_sfp_type_unknown)
1823 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1825 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1826 return IXGBE_ERR_SFP_NOT_PRESENT;
1828 if ((hw->device_id == IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) &&
1829 (hw->phy.sfp_type == ixgbe_sfp_type_da_cu))
1830 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1833 * Limiting active cables and 1G Phys must be initialized as
1836 if (sfp_type == ixgbe_sfp_type_da_act_lmt_core0 ||
1837 sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1838 sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1839 sfp_type == ixgbe_sfp_type_1g_sx_core0)
1840 sfp_type = ixgbe_sfp_type_srlr_core0;
1841 else if (sfp_type == ixgbe_sfp_type_da_act_lmt_core1 ||
1842 sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1843 sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1844 sfp_type == ixgbe_sfp_type_1g_sx_core1)
1845 sfp_type = ixgbe_sfp_type_srlr_core1;
1847 /* Read offset to PHY init contents */
1848 if (hw->eeprom.ops.read(hw, IXGBE_PHY_INIT_OFFSET_NL, list_offset)) {
1849 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1850 "eeprom read at offset %d failed",
1851 IXGBE_PHY_INIT_OFFSET_NL);
1852 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1855 if ((!*list_offset) || (*list_offset == 0xFFFF))
1856 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1858 /* Shift offset to first ID word */
1862 * Find the matching SFP ID in the EEPROM
1863 * and program the init sequence
1865 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1868 while (sfp_id != IXGBE_PHY_INIT_END_NL) {
1869 if (sfp_id == sfp_type) {
1871 if (hw->eeprom.ops.read(hw, *list_offset, data_offset))
1873 if ((!*data_offset) || (*data_offset == 0xFFFF)) {
1874 DEBUGOUT("SFP+ module not supported\n");
1875 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1880 (*list_offset) += 2;
1881 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1886 if (sfp_id == IXGBE_PHY_INIT_END_NL) {
1887 DEBUGOUT("No matching SFP+ module found\n");
1888 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1891 return IXGBE_SUCCESS;
1894 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1895 "eeprom read at offset %d failed", *list_offset);
1896 return IXGBE_ERR_PHY;
1900 * ixgbe_read_i2c_eeprom_generic - Reads 8 bit EEPROM word over I2C interface
1901 * @hw: pointer to hardware structure
1902 * @byte_offset: EEPROM byte offset to read
1903 * @eeprom_data: value read
1905 * Performs byte read operation to SFP module's EEPROM over I2C interface.
1907 s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1910 DEBUGFUNC("ixgbe_read_i2c_eeprom_generic");
1912 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1913 IXGBE_I2C_EEPROM_DEV_ADDR,
1918 * ixgbe_read_i2c_sff8472_generic - Reads 8 bit word over I2C interface
1919 * @hw: pointer to hardware structure
1920 * @byte_offset: byte offset at address 0xA2
1921 * @sff8472_data: value read
1923 * Performs byte read operation to SFP module's SFF-8472 data over I2C
1925 STATIC s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
1928 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1929 IXGBE_I2C_EEPROM_DEV_ADDR2,
1934 * ixgbe_write_i2c_eeprom_generic - Writes 8 bit EEPROM word over I2C interface
1935 * @hw: pointer to hardware structure
1936 * @byte_offset: EEPROM byte offset to write
1937 * @eeprom_data: value to write
1939 * Performs byte write operation to SFP module's EEPROM over I2C interface.
1941 s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1944 DEBUGFUNC("ixgbe_write_i2c_eeprom_generic");
1946 return hw->phy.ops.write_i2c_byte(hw, byte_offset,
1947 IXGBE_I2C_EEPROM_DEV_ADDR,
1952 * ixgbe_is_sfp_probe - Returns true if SFP is being detected
1953 * @hw: pointer to hardware structure
1954 * @offset: eeprom offset to be read
1955 * @addr: I2C address to be read
1957 STATIC bool ixgbe_is_sfp_probe(struct ixgbe_hw *hw, u8 offset, u8 addr)
1959 if (addr == IXGBE_I2C_EEPROM_DEV_ADDR &&
1960 offset == IXGBE_SFF_IDENTIFIER &&
1961 hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1967 * ixgbe_read_i2c_byte_generic_int - Reads 8 bit word over I2C
1968 * @hw: pointer to hardware structure
1969 * @byte_offset: byte offset to read
1970 * @dev_addr: address to read from
1972 * @lock: true if to take and release semaphore
1974 * Performs byte read operation to SFP module's EEPROM over I2C interface at
1975 * a specified device address.
1977 STATIC s32 ixgbe_read_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
1978 u8 dev_addr, u8 *data, bool lock)
1983 u32 swfw_mask = hw->phy.phy_semaphore_mask;
1987 DEBUGFUNC("ixgbe_read_i2c_byte_generic");
1989 if (hw->mac.type >= ixgbe_mac_X550)
1991 if (ixgbe_is_sfp_probe(hw, byte_offset, dev_addr))
1992 max_retry = IXGBE_SFP_DETECT_RETRIES;
1995 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
1996 return IXGBE_ERR_SWFW_SYNC;
1998 ixgbe_i2c_start(hw);
2000 /* Device Address and write indication */
2001 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
2002 if (status != IXGBE_SUCCESS)
2005 status = ixgbe_get_i2c_ack(hw);
2006 if (status != IXGBE_SUCCESS)
2009 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
2010 if (status != IXGBE_SUCCESS)
2013 status = ixgbe_get_i2c_ack(hw);
2014 if (status != IXGBE_SUCCESS)
2017 ixgbe_i2c_start(hw);
2019 /* Device Address and read indication */
2020 status = ixgbe_clock_out_i2c_byte(hw, (dev_addr | 0x1));
2021 if (status != IXGBE_SUCCESS)
2024 status = ixgbe_get_i2c_ack(hw);
2025 if (status != IXGBE_SUCCESS)
2028 status = ixgbe_clock_in_i2c_byte(hw, data);
2029 if (status != IXGBE_SUCCESS)
2032 status = ixgbe_clock_out_i2c_bit(hw, nack);
2033 if (status != IXGBE_SUCCESS)
2038 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2039 return IXGBE_SUCCESS;
2042 ixgbe_i2c_bus_clear(hw);
2044 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2048 if (retry < max_retry)
2049 DEBUGOUT("I2C byte read error - Retrying.\n");
2051 DEBUGOUT("I2C byte read error.\n");
2053 } while (retry < max_retry);
2059 * ixgbe_read_i2c_byte_generic - Reads 8 bit word over I2C
2060 * @hw: pointer to hardware structure
2061 * @byte_offset: byte offset to read
2062 * @dev_addr: address to read from
2065 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2066 * a specified device address.
2068 s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
2069 u8 dev_addr, u8 *data)
2071 return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2076 * ixgbe_read_i2c_byte_generic_unlocked - Reads 8 bit word over I2C
2077 * @hw: pointer to hardware structure
2078 * @byte_offset: byte offset to read
2079 * @dev_addr: address to read from
2082 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2083 * a specified device address.
2085 s32 ixgbe_read_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2086 u8 dev_addr, u8 *data)
2088 return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2093 * ixgbe_write_i2c_byte_generic_int - Writes 8 bit word over I2C
2094 * @hw: pointer to hardware structure
2095 * @byte_offset: byte offset to write
2096 * @dev_addr: address to write to
2097 * @data: value to write
2098 * @lock: true if to take and release semaphore
2100 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2101 * a specified device address.
2103 STATIC s32 ixgbe_write_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
2104 u8 dev_addr, u8 data, bool lock)
2109 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2111 DEBUGFUNC("ixgbe_write_i2c_byte_generic");
2113 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) !=
2115 return IXGBE_ERR_SWFW_SYNC;
2118 ixgbe_i2c_start(hw);
2120 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
2121 if (status != IXGBE_SUCCESS)
2124 status = ixgbe_get_i2c_ack(hw);
2125 if (status != IXGBE_SUCCESS)
2128 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
2129 if (status != IXGBE_SUCCESS)
2132 status = ixgbe_get_i2c_ack(hw);
2133 if (status != IXGBE_SUCCESS)
2136 status = ixgbe_clock_out_i2c_byte(hw, data);
2137 if (status != IXGBE_SUCCESS)
2140 status = ixgbe_get_i2c_ack(hw);
2141 if (status != IXGBE_SUCCESS)
2146 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2147 return IXGBE_SUCCESS;
2150 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");
2156 } while (retry < max_retry);
2159 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2165 * ixgbe_write_i2c_byte_generic - Writes 8 bit word over I2C
2166 * @hw: pointer to hardware structure
2167 * @byte_offset: byte offset to write
2168 * @dev_addr: address to write to
2169 * @data: value to write
2171 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2172 * a specified device address.
2174 s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
2175 u8 dev_addr, u8 data)
2177 return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2182 * ixgbe_write_i2c_byte_generic_unlocked - Writes 8 bit word over I2C
2183 * @hw: pointer to hardware structure
2184 * @byte_offset: byte offset to write
2185 * @dev_addr: address to write to
2186 * @data: value to write
2188 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2189 * a specified device address.
2191 s32 ixgbe_write_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2192 u8 dev_addr, u8 data)
2194 return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2199 * ixgbe_i2c_start - Sets I2C start condition
2200 * @hw: pointer to hardware structure
2202 * Sets I2C start condition (High -> Low on SDA while SCL is High)
2203 * Set bit-bang mode on X550 hardware.
2205 STATIC void ixgbe_i2c_start(struct ixgbe_hw *hw)
2207 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2209 DEBUGFUNC("ixgbe_i2c_start");
2211 i2cctl |= IXGBE_I2C_BB_EN_BY_MAC(hw);
2213 /* Start condition must begin with data and clock high */
2214 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2215 ixgbe_raise_i2c_clk(hw, &i2cctl);
2217 /* Setup time for start condition (4.7us) */
2218 usec_delay(IXGBE_I2C_T_SU_STA);
2220 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2222 /* Hold time for start condition (4us) */
2223 usec_delay(IXGBE_I2C_T_HD_STA);
2225 ixgbe_lower_i2c_clk(hw, &i2cctl);
2227 /* Minimum low period of clock is 4.7 us */
2228 usec_delay(IXGBE_I2C_T_LOW);
2233 * ixgbe_i2c_stop - Sets I2C stop condition
2234 * @hw: pointer to hardware structure
2236 * Sets I2C stop condition (Low -> High on SDA while SCL is High)
2237 * Disables bit-bang mode and negates data output enable on X550
2240 STATIC void ixgbe_i2c_stop(struct ixgbe_hw *hw)
2242 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2243 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2244 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2245 u32 bb_en_bit = IXGBE_I2C_BB_EN_BY_MAC(hw);
2247 DEBUGFUNC("ixgbe_i2c_stop");
2249 /* Stop condition must begin with data low and clock high */
2250 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2251 ixgbe_raise_i2c_clk(hw, &i2cctl);
2253 /* Setup time for stop condition (4us) */
2254 usec_delay(IXGBE_I2C_T_SU_STO);
2256 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2258 /* bus free time between stop and start (4.7us)*/
2259 usec_delay(IXGBE_I2C_T_BUF);
2261 if (bb_en_bit || data_oe_bit || clk_oe_bit) {
2262 i2cctl &= ~bb_en_bit;
2263 i2cctl |= data_oe_bit | clk_oe_bit;
2264 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2265 IXGBE_WRITE_FLUSH(hw);
2270 * ixgbe_clock_in_i2c_byte - Clocks in one byte via I2C
2271 * @hw: pointer to hardware structure
2272 * @data: data byte to clock in
2274 * Clocks in one byte data via I2C data/clock
2276 STATIC s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data)
2281 DEBUGFUNC("ixgbe_clock_in_i2c_byte");
2284 for (i = 7; i >= 0; i--) {
2285 ixgbe_clock_in_i2c_bit(hw, &bit);
2289 return IXGBE_SUCCESS;
2293 * ixgbe_clock_out_i2c_byte - Clocks out one byte via I2C
2294 * @hw: pointer to hardware structure
2295 * @data: data byte clocked out
2297 * Clocks out one byte data via I2C data/clock
2299 STATIC s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data)
2301 s32 status = IXGBE_SUCCESS;
2306 DEBUGFUNC("ixgbe_clock_out_i2c_byte");
2308 for (i = 7; i >= 0; i--) {
2309 bit = (data >> i) & 0x1;
2310 status = ixgbe_clock_out_i2c_bit(hw, bit);
2312 if (status != IXGBE_SUCCESS)
2316 /* Release SDA line (set high) */
2317 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2318 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2319 i2cctl |= IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2320 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2321 IXGBE_WRITE_FLUSH(hw);
2327 * ixgbe_get_i2c_ack - Polls for I2C ACK
2328 * @hw: pointer to hardware structure
2330 * Clocks in/out one bit via I2C data/clock
2332 STATIC s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw)
2334 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2335 s32 status = IXGBE_SUCCESS;
2337 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2341 DEBUGFUNC("ixgbe_get_i2c_ack");
2344 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2345 i2cctl |= data_oe_bit;
2346 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2347 IXGBE_WRITE_FLUSH(hw);
2349 ixgbe_raise_i2c_clk(hw, &i2cctl);
2351 /* Minimum high period of clock is 4us */
2352 usec_delay(IXGBE_I2C_T_HIGH);
2354 /* Poll for ACK. Note that ACK in I2C spec is
2355 * transition from 1 to 0 */
2356 for (i = 0; i < timeout; i++) {
2357 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2358 ack = ixgbe_get_i2c_data(hw, &i2cctl);
2366 DEBUGOUT("I2C ack was not received.\n");
2367 status = IXGBE_ERR_I2C;
2370 ixgbe_lower_i2c_clk(hw, &i2cctl);
2372 /* Minimum low period of clock is 4.7 us */
2373 usec_delay(IXGBE_I2C_T_LOW);
2379 * ixgbe_clock_in_i2c_bit - Clocks in one bit via I2C data/clock
2380 * @hw: pointer to hardware structure
2381 * @data: read data value
2383 * Clocks in one bit via I2C data/clock
2385 STATIC s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data)
2387 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2388 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2390 DEBUGFUNC("ixgbe_clock_in_i2c_bit");
2393 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2394 i2cctl |= data_oe_bit;
2395 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2396 IXGBE_WRITE_FLUSH(hw);
2398 ixgbe_raise_i2c_clk(hw, &i2cctl);
2400 /* Minimum high period of clock is 4us */
2401 usec_delay(IXGBE_I2C_T_HIGH);
2403 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2404 *data = ixgbe_get_i2c_data(hw, &i2cctl);
2406 ixgbe_lower_i2c_clk(hw, &i2cctl);
2408 /* Minimum low period of clock is 4.7 us */
2409 usec_delay(IXGBE_I2C_T_LOW);
2411 return IXGBE_SUCCESS;
2415 * ixgbe_clock_out_i2c_bit - Clocks in/out one bit via I2C data/clock
2416 * @hw: pointer to hardware structure
2417 * @data: data value to write
2419 * Clocks out one bit via I2C data/clock
2421 STATIC s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data)
2424 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2426 DEBUGFUNC("ixgbe_clock_out_i2c_bit");
2428 status = ixgbe_set_i2c_data(hw, &i2cctl, data);
2429 if (status == IXGBE_SUCCESS) {
2430 ixgbe_raise_i2c_clk(hw, &i2cctl);
2432 /* Minimum high period of clock is 4us */
2433 usec_delay(IXGBE_I2C_T_HIGH);
2435 ixgbe_lower_i2c_clk(hw, &i2cctl);
2437 /* Minimum low period of clock is 4.7 us.
2438 * This also takes care of the data hold time.
2440 usec_delay(IXGBE_I2C_T_LOW);
2442 status = IXGBE_ERR_I2C;
2443 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2444 "I2C data was not set to %X\n", data);
2451 * ixgbe_raise_i2c_clk - Raises the I2C SCL clock
2452 * @hw: pointer to hardware structure
2453 * @i2cctl: Current value of I2CCTL register
2455 * Raises the I2C clock line '0'->'1'
2456 * Negates the I2C clock output enable on X550 hardware.
2458 STATIC void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2460 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2462 u32 timeout = IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT;
2465 DEBUGFUNC("ixgbe_raise_i2c_clk");
2468 *i2cctl |= clk_oe_bit;
2469 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2472 for (i = 0; i < timeout; i++) {
2473 *i2cctl |= IXGBE_I2C_CLK_OUT_BY_MAC(hw);
2475 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2476 IXGBE_WRITE_FLUSH(hw);
2477 /* SCL rise time (1000ns) */
2478 usec_delay(IXGBE_I2C_T_RISE);
2480 i2cctl_r = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2481 if (i2cctl_r & IXGBE_I2C_CLK_IN_BY_MAC(hw))
2487 * ixgbe_lower_i2c_clk - Lowers the I2C SCL clock
2488 * @hw: pointer to hardware structure
2489 * @i2cctl: Current value of I2CCTL register
2491 * Lowers the I2C clock line '1'->'0'
2492 * Asserts the I2C clock output enable on X550 hardware.
2494 STATIC void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2496 DEBUGFUNC("ixgbe_lower_i2c_clk");
2498 *i2cctl &= ~(IXGBE_I2C_CLK_OUT_BY_MAC(hw));
2499 *i2cctl &= ~IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2501 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2502 IXGBE_WRITE_FLUSH(hw);
2504 /* SCL fall time (300ns) */
2505 usec_delay(IXGBE_I2C_T_FALL);
2509 * ixgbe_set_i2c_data - Sets the I2C data bit
2510 * @hw: pointer to hardware structure
2511 * @i2cctl: Current value of I2CCTL register
2512 * @data: I2C data value (0 or 1) to set
2514 * Sets the I2C data bit
2515 * Asserts the I2C data output enable on X550 hardware.
2517 STATIC s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data)
2519 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2520 s32 status = IXGBE_SUCCESS;
2522 DEBUGFUNC("ixgbe_set_i2c_data");
2525 *i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2527 *i2cctl &= ~(IXGBE_I2C_DATA_OUT_BY_MAC(hw));
2528 *i2cctl &= ~data_oe_bit;
2530 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2531 IXGBE_WRITE_FLUSH(hw);
2533 /* Data rise/fall (1000ns/300ns) and set-up time (250ns) */
2534 usec_delay(IXGBE_I2C_T_RISE + IXGBE_I2C_T_FALL + IXGBE_I2C_T_SU_DATA);
2536 if (!data) /* Can't verify data in this case */
2537 return IXGBE_SUCCESS;
2539 *i2cctl |= data_oe_bit;
2540 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2541 IXGBE_WRITE_FLUSH(hw);
2544 /* Verify data was set correctly */
2545 *i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2546 if (data != ixgbe_get_i2c_data(hw, i2cctl)) {
2547 status = IXGBE_ERR_I2C;
2548 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2549 "Error - I2C data was not set to %X.\n",
2557 * ixgbe_get_i2c_data - Reads the I2C SDA data bit
2558 * @hw: pointer to hardware structure
2559 * @i2cctl: Current value of I2CCTL register
2561 * Returns the I2C data bit value
2562 * Negates the I2C data output enable on X550 hardware.
2564 STATIC bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl)
2566 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2569 DEBUGFUNC("ixgbe_get_i2c_data");
2572 *i2cctl |= data_oe_bit;
2573 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2574 IXGBE_WRITE_FLUSH(hw);
2575 usec_delay(IXGBE_I2C_T_FALL);
2578 if (*i2cctl & IXGBE_I2C_DATA_IN_BY_MAC(hw))
2587 * ixgbe_i2c_bus_clear - Clears the I2C bus
2588 * @hw: pointer to hardware structure
2590 * Clears the I2C bus by sending nine clock pulses.
2591 * Used when data line is stuck low.
2593 void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw)
2598 DEBUGFUNC("ixgbe_i2c_bus_clear");
2600 ixgbe_i2c_start(hw);
2601 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2603 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2605 for (i = 0; i < 9; i++) {
2606 ixgbe_raise_i2c_clk(hw, &i2cctl);
2608 /* Min high period of clock is 4us */
2609 usec_delay(IXGBE_I2C_T_HIGH);
2611 ixgbe_lower_i2c_clk(hw, &i2cctl);
2613 /* Min low period of clock is 4.7us*/
2614 usec_delay(IXGBE_I2C_T_LOW);
2617 ixgbe_i2c_start(hw);
2619 /* Put the i2c bus back to default state */
2624 * ixgbe_tn_check_overtemp - Checks if an overtemp occurred.
2625 * @hw: pointer to hardware structure
2627 * Checks if the LASI temp alarm status was triggered due to overtemp
2629 s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
2631 s32 status = IXGBE_SUCCESS;
2634 DEBUGFUNC("ixgbe_tn_check_overtemp");
2636 if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
2639 /* Check that the LASI temp alarm status was triggered */
2640 hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
2641 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_data);
2643 if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))
2646 status = IXGBE_ERR_OVERTEMP;
2647 ERROR_REPORT1(IXGBE_ERROR_CAUTION, "Device over temperature");
2653 * ixgbe_set_copper_phy_power - Control power for copper phy
2654 * @hw: pointer to hardware structure
2655 * @on: true for on, false for off
2657 s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on)
2662 if (!on && ixgbe_mng_present(hw))
2665 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2666 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2672 reg &= ~IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2674 if (ixgbe_check_reset_blocked(hw))
2676 reg |= IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2679 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2680 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,