1 /******************************************************************************
2 SPDX-License-Identifier: BSD-3-Clause
4 Copyright (c) 2001-2020, Intel Corporation
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 3. Neither the name of the Intel Corporation nor the names of its
18 contributors may be used to endorse or promote products derived from
19 this software without specific prior written permission.
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 POSSIBILITY OF SUCH DAMAGE.
33 ******************************************************************************/
36 #include "ixgbe_api.h"
37 #include "ixgbe_common.h"
38 #include "ixgbe_phy.h"
40 static void ixgbe_i2c_start(struct ixgbe_hw *hw);
41 static void ixgbe_i2c_stop(struct ixgbe_hw *hw);
42 static s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data);
43 static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data);
44 static s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw);
45 static s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data);
46 static s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data);
47 static void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl);
48 static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl);
49 static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data);
50 static bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl);
51 static s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
55 * ixgbe_out_i2c_byte_ack - Send I2C byte with ack
56 * @hw: pointer to the hardware structure
59 * Returns an error code on error.
61 static s32 ixgbe_out_i2c_byte_ack(struct ixgbe_hw *hw, u8 byte)
65 status = ixgbe_clock_out_i2c_byte(hw, byte);
68 return ixgbe_get_i2c_ack(hw);
72 * ixgbe_in_i2c_byte_ack - Receive an I2C byte and send ack
73 * @hw: pointer to the hardware structure
74 * @byte: pointer to a u8 to receive the byte
76 * Returns an error code on error.
78 static s32 ixgbe_in_i2c_byte_ack(struct ixgbe_hw *hw, u8 *byte)
82 status = ixgbe_clock_in_i2c_byte(hw, byte);
86 return ixgbe_clock_out_i2c_bit(hw, false);
90 * ixgbe_ones_comp_byte_add - Perform one's complement addition
94 * Returns one's complement 8-bit sum.
96 static u8 ixgbe_ones_comp_byte_add(u8 add1, u8 add2)
98 u16 sum = add1 + add2;
100 sum = (sum & 0xFF) + (sum >> 8);
105 * ixgbe_read_i2c_combined_generic_int - Perform I2C read combined operation
106 * @hw: pointer to the hardware structure
107 * @addr: I2C bus address to read from
108 * @reg: I2C device register to read from
109 * @val: pointer to location to receive read value
110 * @lock: true if to take and release semaphore
112 * Returns an error code on error.
114 s32 ixgbe_read_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr, u16 reg,
117 u32 swfw_mask = hw->phy.phy_semaphore_mask;
126 reg_high = ((reg >> 7) & 0xFE) | 1; /* Indicate read combined */
127 csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
130 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
131 return IXGBE_ERR_SWFW_SYNC;
133 /* Device Address and write indication */
134 if (ixgbe_out_i2c_byte_ack(hw, addr))
136 /* Write bits 14:8 */
137 if (ixgbe_out_i2c_byte_ack(hw, reg_high))
140 if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
143 if (ixgbe_out_i2c_byte_ack(hw, csum))
145 /* Re-start condition */
147 /* Device Address and read indication */
148 if (ixgbe_out_i2c_byte_ack(hw, addr | 1))
151 if (ixgbe_in_i2c_byte_ack(hw, &high_bits))
154 if (ixgbe_in_i2c_byte_ack(hw, &low_bits))
157 if (ixgbe_clock_in_i2c_byte(hw, &csum_byte))
160 if (ixgbe_clock_out_i2c_bit(hw, false))
164 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
165 *val = (high_bits << 8) | low_bits;
169 ixgbe_i2c_bus_clear(hw);
171 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
172 if (retry < max_retry)
173 DEBUGOUT("I2C byte read combined error - Retrying.\n");
175 DEBUGOUT("I2C byte read combined error.\n");
177 } while (retry <= max_retry);
179 return IXGBE_ERR_I2C;
183 * ixgbe_write_i2c_combined_generic_int - Perform I2C write combined operation
184 * @hw: pointer to the hardware structure
185 * @addr: I2C bus address to write to
186 * @reg: I2C device register to write to
187 * @val: value to write
188 * @lock: true if to take and release semaphore
190 * Returns an error code on error.
192 s32 ixgbe_write_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr, u16 reg,
195 u32 swfw_mask = hw->phy.phy_semaphore_mask;
201 reg_high = (reg >> 7) & 0xFE; /* Indicate write combined */
202 csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
203 csum = ixgbe_ones_comp_byte_add(csum, val >> 8);
204 csum = ixgbe_ones_comp_byte_add(csum, val & 0xFF);
207 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
208 return IXGBE_ERR_SWFW_SYNC;
210 /* Device Address and write indication */
211 if (ixgbe_out_i2c_byte_ack(hw, addr))
213 /* Write bits 14:8 */
214 if (ixgbe_out_i2c_byte_ack(hw, reg_high))
217 if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
219 /* Write data 15:8 */
220 if (ixgbe_out_i2c_byte_ack(hw, val >> 8))
223 if (ixgbe_out_i2c_byte_ack(hw, val & 0xFF))
226 if (ixgbe_out_i2c_byte_ack(hw, csum))
230 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
234 ixgbe_i2c_bus_clear(hw);
236 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
237 if (retry < max_retry)
238 DEBUGOUT("I2C byte write combined error - Retrying.\n");
240 DEBUGOUT("I2C byte write combined error.\n");
242 } while (retry <= max_retry);
244 return IXGBE_ERR_I2C;
248 * ixgbe_init_phy_ops_generic - Inits PHY function ptrs
249 * @hw: pointer to the hardware structure
251 * Initialize the function pointers.
253 s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw)
255 struct ixgbe_phy_info *phy = &hw->phy;
257 DEBUGFUNC("ixgbe_init_phy_ops_generic");
260 phy->ops.identify = ixgbe_identify_phy_generic;
261 phy->ops.reset = ixgbe_reset_phy_generic;
262 phy->ops.read_reg = ixgbe_read_phy_reg_generic;
263 phy->ops.write_reg = ixgbe_write_phy_reg_generic;
264 phy->ops.read_reg_mdi = ixgbe_read_phy_reg_mdi;
265 phy->ops.write_reg_mdi = ixgbe_write_phy_reg_mdi;
266 phy->ops.setup_link = ixgbe_setup_phy_link_generic;
267 phy->ops.setup_link_speed = ixgbe_setup_phy_link_speed_generic;
268 phy->ops.check_link = NULL;
269 phy->ops.get_firmware_version = ixgbe_get_phy_firmware_version_generic;
270 phy->ops.read_i2c_byte = ixgbe_read_i2c_byte_generic;
271 phy->ops.write_i2c_byte = ixgbe_write_i2c_byte_generic;
272 phy->ops.read_i2c_sff8472 = ixgbe_read_i2c_sff8472_generic;
273 phy->ops.read_i2c_eeprom = ixgbe_read_i2c_eeprom_generic;
274 phy->ops.write_i2c_eeprom = ixgbe_write_i2c_eeprom_generic;
275 phy->ops.i2c_bus_clear = ixgbe_i2c_bus_clear;
276 phy->ops.identify_sfp = ixgbe_identify_module_generic;
277 phy->sfp_type = ixgbe_sfp_type_unknown;
278 phy->ops.read_i2c_byte_unlocked = ixgbe_read_i2c_byte_generic_unlocked;
279 phy->ops.write_i2c_byte_unlocked =
280 ixgbe_write_i2c_byte_generic_unlocked;
281 phy->ops.check_overtemp = ixgbe_tn_check_overtemp;
282 return IXGBE_SUCCESS;
286 * ixgbe_probe_phy - Probe a single address for a PHY
287 * @hw: pointer to hardware structure
288 * @phy_addr: PHY address to probe
290 * Returns true if PHY found
292 static bool ixgbe_probe_phy(struct ixgbe_hw *hw, u16 phy_addr)
296 if (!ixgbe_validate_phy_addr(hw, phy_addr)) {
297 DEBUGOUT1("Unable to validate PHY address 0x%04X\n",
302 if (ixgbe_get_phy_id(hw))
305 hw->phy.type = ixgbe_get_phy_type_from_id(hw->phy.id);
307 if (hw->phy.type == ixgbe_phy_unknown) {
308 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
309 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability);
311 (IXGBE_MDIO_PHY_10GBASET_ABILITY |
312 IXGBE_MDIO_PHY_1000BASET_ABILITY))
313 hw->phy.type = ixgbe_phy_cu_unknown;
315 hw->phy.type = ixgbe_phy_generic;
322 * ixgbe_identify_phy_generic - Get physical layer module
323 * @hw: pointer to hardware structure
325 * Determines the physical layer module found on the current adapter.
327 s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
329 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
332 DEBUGFUNC("ixgbe_identify_phy_generic");
334 if (!hw->phy.phy_semaphore_mask) {
336 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
338 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
341 if (hw->phy.type != ixgbe_phy_unknown)
342 return IXGBE_SUCCESS;
344 if (hw->phy.nw_mng_if_sel) {
345 phy_addr = (hw->phy.nw_mng_if_sel &
346 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
347 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
348 if (ixgbe_probe_phy(hw, phy_addr))
349 return IXGBE_SUCCESS;
351 return IXGBE_ERR_PHY_ADDR_INVALID;
354 for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
355 if (ixgbe_probe_phy(hw, phy_addr)) {
356 status = IXGBE_SUCCESS;
361 /* Certain media types do not have a phy so an address will not
362 * be found and the code will take this path. Caller has to
363 * decide if it is an error or not.
365 if (status != IXGBE_SUCCESS)
372 * ixgbe_check_reset_blocked - check status of MNG FW veto bit
373 * @hw: pointer to the hardware structure
375 * This function checks the MMNGC.MNG_VETO bit to see if there are
376 * any constraints on link from manageability. For MAC's that don't
377 * have this bit just return faluse since the link can not be blocked
380 s32 ixgbe_check_reset_blocked(struct ixgbe_hw *hw)
384 DEBUGFUNC("ixgbe_check_reset_blocked");
386 /* If we don't have this bit, it can't be blocking */
387 if (hw->mac.type == ixgbe_mac_82598EB)
390 mmngc = IXGBE_READ_REG(hw, IXGBE_MMNGC);
391 if (mmngc & IXGBE_MMNGC_MNG_VETO) {
392 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE,
393 "MNG_VETO bit detected.\n");
401 * ixgbe_validate_phy_addr - Determines phy address is valid
402 * @hw: pointer to hardware structure
403 * @phy_addr: PHY address
406 bool ixgbe_validate_phy_addr(struct ixgbe_hw *hw, u32 phy_addr)
411 DEBUGFUNC("ixgbe_validate_phy_addr");
413 hw->phy.addr = phy_addr;
414 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
415 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_id);
417 if (phy_id != 0xFFFF && phy_id != 0x0)
420 DEBUGOUT1("PHY ID HIGH is 0x%04X\n", phy_id);
426 * ixgbe_get_phy_id - Get the phy type
427 * @hw: pointer to hardware structure
430 s32 ixgbe_get_phy_id(struct ixgbe_hw *hw)
436 DEBUGFUNC("ixgbe_get_phy_id");
438 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
439 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
442 if (status == IXGBE_SUCCESS) {
443 hw->phy.id = (u32)(phy_id_high << 16);
444 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
445 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
447 hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK);
448 hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK);
450 DEBUGOUT2("PHY_ID_HIGH 0x%04X, PHY_ID_LOW 0x%04X\n",
451 phy_id_high, phy_id_low);
457 * ixgbe_get_phy_type_from_id - Get the phy type
458 * @phy_id: PHY ID information
461 enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
463 enum ixgbe_phy_type phy_type;
465 DEBUGFUNC("ixgbe_get_phy_type_from_id");
469 phy_type = ixgbe_phy_tn;
474 phy_type = ixgbe_phy_aq;
477 phy_type = ixgbe_phy_qt;
480 phy_type = ixgbe_phy_nl;
484 phy_type = ixgbe_phy_x550em_ext_t;
486 case IXGBE_M88E1500_E_PHY_ID:
487 case IXGBE_M88E1543_E_PHY_ID:
488 phy_type = ixgbe_phy_ext_1g_t;
491 phy_type = ixgbe_phy_unknown;
498 * ixgbe_reset_phy_generic - Performs a PHY reset
499 * @hw: pointer to hardware structure
501 s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
505 s32 status = IXGBE_SUCCESS;
507 DEBUGFUNC("ixgbe_reset_phy_generic");
509 if (hw->phy.type == ixgbe_phy_unknown)
510 status = ixgbe_identify_phy_generic(hw);
512 if (status != IXGBE_SUCCESS || hw->phy.type == ixgbe_phy_none)
515 /* Don't reset PHY if it's shut down due to overtemp. */
516 if (!hw->phy.reset_if_overtemp &&
517 (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
520 /* Blocked by MNG FW so bail */
521 if (ixgbe_check_reset_blocked(hw))
525 * Perform soft PHY reset to the PHY_XS.
526 * This will cause a soft reset to the PHY
528 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
529 IXGBE_MDIO_PHY_XS_DEV_TYPE,
530 IXGBE_MDIO_PHY_XS_RESET);
533 * Poll for reset bit to self-clear indicating reset is complete.
534 * Some PHYs could take up to 3 seconds to complete and need about
535 * 1.7 usec delay after the reset is complete.
537 for (i = 0; i < 30; i++) {
539 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
540 status = hw->phy.ops.read_reg(hw,
541 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
542 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
544 if (status != IXGBE_SUCCESS)
547 if (ctrl & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
552 status = hw->phy.ops.read_reg(hw,
553 IXGBE_MDIO_PHY_XS_CONTROL,
554 IXGBE_MDIO_PHY_XS_DEV_TYPE,
556 if (status != IXGBE_SUCCESS)
559 if (!(ctrl & IXGBE_MDIO_PHY_XS_RESET)) {
566 if (ctrl & IXGBE_MDIO_PHY_XS_RESET) {
567 status = IXGBE_ERR_RESET_FAILED;
568 ERROR_REPORT1(IXGBE_ERROR_POLLING,
569 "PHY reset polling failed to complete.\n");
577 * ixgbe_restart_auto_neg - Restart auto negotiation on the PHY
578 * @hw: pointer to hardware structure
580 void ixgbe_restart_auto_neg(struct ixgbe_hw *hw)
584 /* Check if PHY reset is blocked by MNG FW */
585 if (ixgbe_check_reset_blocked(hw))
588 /* Restart PHY auto-negotiation. */
589 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
590 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
591 autoneg_reg |= IXGBE_MII_RESTART;
592 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
593 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
597 * ixgbe_read_phy_mdi - Reads a value from a specified PHY register without
599 * @hw: pointer to hardware structure
600 * @reg_addr: 32 bit address of PHY register to read
601 * @device_type: 5 bit device type
602 * @phy_data: Pointer to read data from PHY register
604 s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
607 u32 i, data, command;
609 /* Setup and write the address cycle command */
610 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
611 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
612 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
613 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
615 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
618 * Check every 10 usec to see if the address cycle completed.
619 * The MDI Command bit will clear when the operation is
622 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
625 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
626 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
631 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
632 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address command did not complete.\n");
633 DEBUGOUT("PHY address command did not complete, returning IXGBE_ERR_PHY\n");
634 return IXGBE_ERR_PHY;
638 * Address cycle complete, setup and write the read
641 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
642 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
643 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
644 (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND));
646 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
649 * Check every 10 usec to see if the address cycle
650 * completed. The MDI Command bit will clear when the
651 * operation is complete
653 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
656 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
657 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
661 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
662 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY read command didn't complete\n");
663 DEBUGOUT("PHY read command didn't complete, returning IXGBE_ERR_PHY\n");
664 return IXGBE_ERR_PHY;
668 * Read operation is complete. Get the data
671 data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
672 data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
673 *phy_data = (u16)(data);
675 return IXGBE_SUCCESS;
679 * ixgbe_read_phy_reg_generic - Reads a value from a specified PHY register
680 * using the SWFW lock - this function is needed in most cases
681 * @hw: pointer to hardware structure
682 * @reg_addr: 32 bit address of PHY register to read
683 * @device_type: 5 bit device type
684 * @phy_data: Pointer to read data from PHY register
686 s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
687 u32 device_type, u16 *phy_data)
690 u32 gssr = hw->phy.phy_semaphore_mask;
692 DEBUGFUNC("ixgbe_read_phy_reg_generic");
694 if (hw->mac.ops.acquire_swfw_sync(hw, gssr))
695 return IXGBE_ERR_SWFW_SYNC;
697 status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
699 hw->mac.ops.release_swfw_sync(hw, gssr);
705 * ixgbe_write_phy_reg_mdi - Writes a value to specified PHY register
707 * @hw: pointer to hardware structure
708 * @reg_addr: 32 bit PHY register to write
709 * @device_type: 5 bit device type
710 * @phy_data: Data to write to the PHY register
712 s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,
713 u32 device_type, u16 phy_data)
717 /* Put the data in the MDI single read and write data register*/
718 IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
720 /* Setup and write the address cycle command */
721 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
722 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
723 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
724 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
726 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
729 * Check every 10 usec to see if the address cycle completed.
730 * The MDI Command bit will clear when the operation is
733 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
736 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
737 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
741 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
742 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address cmd didn't complete\n");
743 return IXGBE_ERR_PHY;
747 * Address cycle complete, setup and write the write
750 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
751 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
752 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
753 (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND));
755 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
758 * Check every 10 usec to see if the address cycle
759 * completed. The MDI Command bit will clear when the
760 * operation is complete
762 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
765 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
766 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
770 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
771 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY write cmd didn't complete\n");
772 return IXGBE_ERR_PHY;
775 return IXGBE_SUCCESS;
779 * ixgbe_write_phy_reg_generic - Writes a value to specified PHY register
780 * using SWFW lock- this function is needed in most cases
781 * @hw: pointer to hardware structure
782 * @reg_addr: 32 bit PHY register to write
783 * @device_type: 5 bit device type
784 * @phy_data: Data to write to the PHY register
786 s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
787 u32 device_type, u16 phy_data)
790 u32 gssr = hw->phy.phy_semaphore_mask;
792 DEBUGFUNC("ixgbe_write_phy_reg_generic");
794 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
795 status = hw->phy.ops.write_reg_mdi(hw, reg_addr, device_type,
797 hw->mac.ops.release_swfw_sync(hw, gssr);
799 status = IXGBE_ERR_SWFW_SYNC;
806 * ixgbe_setup_phy_link_generic - Set and restart auto-neg
807 * @hw: pointer to hardware structure
809 * Restart auto-negotiation and PHY and waits for completion.
811 s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
813 s32 status = IXGBE_SUCCESS;
814 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
815 bool autoneg = false;
816 ixgbe_link_speed speed;
818 DEBUGFUNC("ixgbe_setup_phy_link_generic");
820 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
822 /* Set or unset auto-negotiation 10G advertisement */
823 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
824 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
827 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
828 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL) &&
829 (speed & IXGBE_LINK_SPEED_10GB_FULL))
830 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
832 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
833 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
836 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
837 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
840 if (hw->mac.type == ixgbe_mac_X550) {
841 /* Set or unset auto-negotiation 5G advertisement */
842 autoneg_reg &= ~IXGBE_MII_5GBASE_T_ADVERTISE;
843 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_5GB_FULL) &&
844 (speed & IXGBE_LINK_SPEED_5GB_FULL))
845 autoneg_reg |= IXGBE_MII_5GBASE_T_ADVERTISE;
847 /* Set or unset auto-negotiation 2.5G advertisement */
848 autoneg_reg &= ~IXGBE_MII_2_5GBASE_T_ADVERTISE;
849 if ((hw->phy.autoneg_advertised &
850 IXGBE_LINK_SPEED_2_5GB_FULL) &&
851 (speed & IXGBE_LINK_SPEED_2_5GB_FULL))
852 autoneg_reg |= IXGBE_MII_2_5GBASE_T_ADVERTISE;
855 /* Set or unset auto-negotiation 1G advertisement */
856 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE;
857 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL) &&
858 (speed & IXGBE_LINK_SPEED_1GB_FULL))
859 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE;
861 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
862 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
865 /* Set or unset auto-negotiation 100M advertisement */
866 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
867 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
870 autoneg_reg &= ~(IXGBE_MII_100BASE_T_ADVERTISE |
871 IXGBE_MII_100BASE_T_ADVERTISE_HALF);
872 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL) &&
873 (speed & IXGBE_LINK_SPEED_100_FULL))
874 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
876 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
877 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
880 ixgbe_restart_auto_neg(hw);
885 * ixgbe_setup_phy_link_speed_generic - Sets the auto advertised capabilities
886 * @hw: pointer to hardware structure
887 * @speed: new link speed
888 * @autoneg_wait_to_complete: unused
890 s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
891 ixgbe_link_speed speed,
892 bool autoneg_wait_to_complete)
894 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
896 DEBUGFUNC("ixgbe_setup_phy_link_speed_generic");
899 * Clear autoneg_advertised and set new values based on input link
902 hw->phy.autoneg_advertised = 0;
904 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
905 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
907 if (speed & IXGBE_LINK_SPEED_5GB_FULL)
908 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_5GB_FULL;
910 if (speed & IXGBE_LINK_SPEED_2_5GB_FULL)
911 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_2_5GB_FULL;
913 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
914 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
916 if (speed & IXGBE_LINK_SPEED_100_FULL)
917 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
919 if (speed & IXGBE_LINK_SPEED_10_FULL)
920 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10_FULL;
922 /* Setup link based on the new speed settings */
923 ixgbe_setup_phy_link(hw);
925 return IXGBE_SUCCESS;
929 * ixgbe_get_copper_speeds_supported - Get copper link speeds from phy
930 * @hw: pointer to hardware structure
932 * Determines the supported link capabilities by reading the PHY auto
933 * negotiation register.
935 static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
940 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
941 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
946 if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
947 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
948 if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
949 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
950 if (speed_ability & IXGBE_MDIO_PHY_SPEED_100M)
951 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_100_FULL;
953 switch (hw->mac.type) {
955 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_2_5GB_FULL;
956 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_5GB_FULL;
958 case ixgbe_mac_X550EM_x:
959 case ixgbe_mac_X550EM_a:
960 hw->phy.speeds_supported &= ~IXGBE_LINK_SPEED_100_FULL;
970 * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
971 * @hw: pointer to hardware structure
972 * @speed: pointer to link speed
973 * @autoneg: boolean auto-negotiation value
975 s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
976 ixgbe_link_speed *speed,
979 s32 status = IXGBE_SUCCESS;
981 DEBUGFUNC("ixgbe_get_copper_link_capabilities_generic");
984 if (!hw->phy.speeds_supported)
985 status = ixgbe_get_copper_speeds_supported(hw);
987 *speed = hw->phy.speeds_supported;
992 * ixgbe_check_phy_link_tnx - Determine link and speed status
993 * @hw: pointer to hardware structure
994 * @speed: current link speed
995 * @link_up: true is link is up, false otherwise
997 * Reads the VS1 register to determine if link is up and the current speed for
1000 s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
1003 s32 status = IXGBE_SUCCESS;
1005 u32 max_time_out = 10;
1010 DEBUGFUNC("ixgbe_check_phy_link_tnx");
1012 /* Initialize speed and link to default case */
1014 *speed = IXGBE_LINK_SPEED_10GB_FULL;
1017 * Check current speed and link status of the PHY register.
1018 * This is a vendor specific register and may have to
1019 * be changed for other copper PHYs.
1021 for (time_out = 0; time_out < max_time_out; time_out++) {
1023 status = hw->phy.ops.read_reg(hw,
1024 IXGBE_MDIO_VENDOR_SPECIFIC_1_STATUS,
1025 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1027 phy_link = phy_data & IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS;
1028 phy_speed = phy_data &
1029 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS;
1030 if (phy_link == IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS) {
1033 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS)
1034 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1043 * ixgbe_setup_phy_link_tnx - Set and restart auto-neg
1044 * @hw: pointer to hardware structure
1046 * Restart auto-negotiation and PHY and waits for completion.
1048 s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
1050 s32 status = IXGBE_SUCCESS;
1051 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
1052 bool autoneg = false;
1053 ixgbe_link_speed speed;
1055 DEBUGFUNC("ixgbe_setup_phy_link_tnx");
1057 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
1059 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
1060 /* Set or unset auto-negotiation 10G advertisement */
1061 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1062 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1065 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
1066 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1067 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
1069 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1070 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1074 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
1075 /* Set or unset auto-negotiation 1G advertisement */
1076 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1077 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1080 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1081 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1082 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1084 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1085 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1089 if (speed & IXGBE_LINK_SPEED_100_FULL) {
1090 /* Set or unset auto-negotiation 100M advertisement */
1091 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1092 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1095 autoneg_reg &= ~IXGBE_MII_100BASE_T_ADVERTISE;
1096 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
1097 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
1099 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1100 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1104 ixgbe_restart_auto_neg(hw);
1109 * ixgbe_get_phy_firmware_version_tnx - Gets the PHY Firmware Version
1110 * @hw: pointer to hardware structure
1111 * @firmware_version: pointer to the PHY Firmware Version
1113 s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
1114 u16 *firmware_version)
1118 DEBUGFUNC("ixgbe_get_phy_firmware_version_tnx");
1120 status = hw->phy.ops.read_reg(hw, TNX_FW_REV,
1121 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1128 * ixgbe_get_phy_firmware_version_generic - Gets the PHY Firmware Version
1129 * @hw: pointer to hardware structure
1130 * @firmware_version: pointer to the PHY Firmware Version
1132 s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
1133 u16 *firmware_version)
1137 DEBUGFUNC("ixgbe_get_phy_firmware_version_generic");
1139 status = hw->phy.ops.read_reg(hw, AQ_FW_REV,
1140 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1147 * ixgbe_reset_phy_nl - Performs a PHY reset
1148 * @hw: pointer to hardware structure
1150 s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
1152 u16 phy_offset, control, eword, edata, block_crc;
1153 bool end_data = false;
1154 u16 list_offset, data_offset;
1156 s32 ret_val = IXGBE_SUCCESS;
1159 DEBUGFUNC("ixgbe_reset_phy_nl");
1161 /* Blocked by MNG FW so bail */
1162 if (ixgbe_check_reset_blocked(hw))
1165 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1166 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1168 /* reset the PHY and poll for completion */
1169 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1170 IXGBE_MDIO_PHY_XS_DEV_TYPE,
1171 (phy_data | IXGBE_MDIO_PHY_XS_RESET));
1173 for (i = 0; i < 100; i++) {
1174 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1175 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1176 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) == 0)
1181 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) != 0) {
1182 DEBUGOUT("PHY reset did not complete.\n");
1183 ret_val = IXGBE_ERR_PHY;
1187 /* Get init offsets */
1188 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
1190 if (ret_val != IXGBE_SUCCESS)
1193 ret_val = hw->eeprom.ops.read(hw, data_offset, &block_crc);
1197 * Read control word from PHY init contents offset
1199 ret_val = hw->eeprom.ops.read(hw, data_offset, &eword);
1202 control = (eword & IXGBE_CONTROL_MASK_NL) >>
1203 IXGBE_CONTROL_SHIFT_NL;
1204 edata = eword & IXGBE_DATA_MASK_NL;
1206 case IXGBE_DELAY_NL:
1208 DEBUGOUT1("DELAY: %d MS\n", edata);
1212 DEBUGOUT("DATA:\n");
1214 ret_val = hw->eeprom.ops.read(hw, data_offset,
1219 for (i = 0; i < edata; i++) {
1220 ret_val = hw->eeprom.ops.read(hw, data_offset,
1224 hw->phy.ops.write_reg(hw, phy_offset,
1225 IXGBE_TWINAX_DEV, eword);
1226 DEBUGOUT2("Wrote %4.4x to %4.4x\n", eword,
1232 case IXGBE_CONTROL_NL:
1234 DEBUGOUT("CONTROL:\n");
1235 if (edata == IXGBE_CONTROL_EOL_NL) {
1238 } else if (edata == IXGBE_CONTROL_SOL_NL) {
1241 DEBUGOUT("Bad control value\n");
1242 ret_val = IXGBE_ERR_PHY;
1247 DEBUGOUT("Bad control type\n");
1248 ret_val = IXGBE_ERR_PHY;
1257 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1258 "eeprom read at offset %d failed", data_offset);
1259 return IXGBE_ERR_PHY;
1263 * ixgbe_identify_module_generic - Identifies module type
1264 * @hw: pointer to hardware structure
1266 * Determines HW type and calls appropriate function.
1268 s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw)
1270 s32 status = IXGBE_ERR_SFP_NOT_PRESENT;
1272 DEBUGFUNC("ixgbe_identify_module_generic");
1274 switch (hw->mac.ops.get_media_type(hw)) {
1275 case ixgbe_media_type_fiber:
1276 status = ixgbe_identify_sfp_module_generic(hw);
1279 case ixgbe_media_type_fiber_qsfp:
1280 status = ixgbe_identify_qsfp_module_generic(hw);
1284 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1285 status = IXGBE_ERR_SFP_NOT_PRESENT;
1293 * ixgbe_identify_sfp_module_generic - Identifies SFP modules
1294 * @hw: pointer to hardware structure
1296 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1298 s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
1300 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1302 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1304 u8 comp_codes_1g = 0;
1305 u8 comp_codes_10g = 0;
1306 u8 oui_bytes[3] = {0, 0, 0};
1309 u16 enforce_sfp = 0;
1311 DEBUGFUNC("ixgbe_identify_sfp_module_generic");
1313 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber) {
1314 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1315 status = IXGBE_ERR_SFP_NOT_PRESENT;
1319 /* LAN ID is needed for I2C access */
1320 hw->mac.ops.set_lan_id(hw);
1322 status = hw->phy.ops.read_i2c_eeprom(hw,
1323 IXGBE_SFF_IDENTIFIER,
1326 if (status != IXGBE_SUCCESS)
1327 goto err_read_i2c_eeprom;
1329 if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
1330 hw->phy.type = ixgbe_phy_sfp_unsupported;
1331 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1333 status = hw->phy.ops.read_i2c_eeprom(hw,
1334 IXGBE_SFF_1GBE_COMP_CODES,
1337 if (status != IXGBE_SUCCESS)
1338 goto err_read_i2c_eeprom;
1340 status = hw->phy.ops.read_i2c_eeprom(hw,
1341 IXGBE_SFF_10GBE_COMP_CODES,
1344 if (status != IXGBE_SUCCESS)
1345 goto err_read_i2c_eeprom;
1346 status = hw->phy.ops.read_i2c_eeprom(hw,
1347 IXGBE_SFF_CABLE_TECHNOLOGY,
1350 if (status != IXGBE_SUCCESS)
1351 goto err_read_i2c_eeprom;
1358 * 3 SFP_DA_CORE0 - 82599-specific
1359 * 4 SFP_DA_CORE1 - 82599-specific
1360 * 5 SFP_SR/LR_CORE0 - 82599-specific
1361 * 6 SFP_SR/LR_CORE1 - 82599-specific
1362 * 7 SFP_act_lmt_DA_CORE0 - 82599-specific
1363 * 8 SFP_act_lmt_DA_CORE1 - 82599-specific
1364 * 9 SFP_1g_cu_CORE0 - 82599-specific
1365 * 10 SFP_1g_cu_CORE1 - 82599-specific
1366 * 11 SFP_1g_sx_CORE0 - 82599-specific
1367 * 12 SFP_1g_sx_CORE1 - 82599-specific
1369 if (hw->mac.type == ixgbe_mac_82598EB) {
1370 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1371 hw->phy.sfp_type = ixgbe_sfp_type_da_cu;
1372 else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1373 hw->phy.sfp_type = ixgbe_sfp_type_sr;
1374 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1375 hw->phy.sfp_type = ixgbe_sfp_type_lr;
1377 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1379 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) {
1380 if (hw->bus.lan_id == 0)
1382 ixgbe_sfp_type_da_cu_core0;
1385 ixgbe_sfp_type_da_cu_core1;
1386 } else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) {
1387 hw->phy.ops.read_i2c_eeprom(
1388 hw, IXGBE_SFF_CABLE_SPEC_COMP,
1391 IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING) {
1392 if (hw->bus.lan_id == 0)
1394 ixgbe_sfp_type_da_act_lmt_core0;
1397 ixgbe_sfp_type_da_act_lmt_core1;
1400 ixgbe_sfp_type_unknown;
1402 } else if (comp_codes_10g &
1403 (IXGBE_SFF_10GBASESR_CAPABLE |
1404 IXGBE_SFF_10GBASELR_CAPABLE)) {
1405 if (hw->bus.lan_id == 0)
1407 ixgbe_sfp_type_srlr_core0;
1410 ixgbe_sfp_type_srlr_core1;
1411 } else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {
1412 if (hw->bus.lan_id == 0)
1414 ixgbe_sfp_type_1g_cu_core0;
1417 ixgbe_sfp_type_1g_cu_core1;
1418 } else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) {
1419 if (hw->bus.lan_id == 0)
1421 ixgbe_sfp_type_1g_sx_core0;
1424 ixgbe_sfp_type_1g_sx_core1;
1425 } else if (comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) {
1426 if (hw->bus.lan_id == 0)
1428 ixgbe_sfp_type_1g_lx_core0;
1431 ixgbe_sfp_type_1g_lx_core1;
1433 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1437 if (hw->phy.sfp_type != stored_sfp_type)
1438 hw->phy.sfp_setup_needed = true;
1440 /* Determine if the SFP+ PHY is dual speed or not. */
1441 hw->phy.multispeed_fiber = false;
1442 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1443 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1444 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1445 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1446 hw->phy.multispeed_fiber = true;
1448 /* Determine PHY vendor */
1449 if (hw->phy.type != ixgbe_phy_nl) {
1450 hw->phy.id = identifier;
1451 status = hw->phy.ops.read_i2c_eeprom(hw,
1452 IXGBE_SFF_VENDOR_OUI_BYTE0,
1455 if (status != IXGBE_SUCCESS)
1456 goto err_read_i2c_eeprom;
1458 status = hw->phy.ops.read_i2c_eeprom(hw,
1459 IXGBE_SFF_VENDOR_OUI_BYTE1,
1462 if (status != IXGBE_SUCCESS)
1463 goto err_read_i2c_eeprom;
1465 status = hw->phy.ops.read_i2c_eeprom(hw,
1466 IXGBE_SFF_VENDOR_OUI_BYTE2,
1469 if (status != IXGBE_SUCCESS)
1470 goto err_read_i2c_eeprom;
1473 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1474 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1475 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1477 switch (vendor_oui) {
1478 case IXGBE_SFF_VENDOR_OUI_TYCO:
1479 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1481 ixgbe_phy_sfp_passive_tyco;
1483 case IXGBE_SFF_VENDOR_OUI_FTL:
1484 if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1485 hw->phy.type = ixgbe_phy_sfp_ftl_active;
1487 hw->phy.type = ixgbe_phy_sfp_ftl;
1489 case IXGBE_SFF_VENDOR_OUI_AVAGO:
1490 hw->phy.type = ixgbe_phy_sfp_avago;
1492 case IXGBE_SFF_VENDOR_OUI_INTEL:
1493 hw->phy.type = ixgbe_phy_sfp_intel;
1496 hw->phy.type = ixgbe_phy_sfp_unknown;
1501 /* Allow any DA cable vendor */
1502 if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE |
1503 IXGBE_SFF_DA_ACTIVE_CABLE)) {
1504 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1505 hw->phy.type = ixgbe_phy_sfp_passive_unknown;
1506 else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1507 hw->phy.type = ixgbe_phy_sfp_active_unknown;
1508 status = IXGBE_SUCCESS;
1512 /* Verify supported 1G SFP modules */
1513 if (comp_codes_10g == 0 &&
1514 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1515 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1516 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1517 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1518 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1519 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1520 hw->phy.type = ixgbe_phy_sfp_unsupported;
1521 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1525 /* Anything else 82598-based is supported */
1526 if (hw->mac.type == ixgbe_mac_82598EB) {
1527 status = IXGBE_SUCCESS;
1531 ixgbe_get_device_caps(hw, &enforce_sfp);
1532 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP) &&
1533 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1534 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1535 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1536 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1537 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1538 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1539 /* Make sure we're a supported PHY type */
1540 if (hw->phy.type == ixgbe_phy_sfp_intel) {
1541 status = IXGBE_SUCCESS;
1543 if (hw->allow_unsupported_sfp == true) {
1544 EWARN(hw, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n");
1545 status = IXGBE_SUCCESS;
1547 DEBUGOUT("SFP+ module not supported\n");
1549 ixgbe_phy_sfp_unsupported;
1550 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1554 status = IXGBE_SUCCESS;
1561 err_read_i2c_eeprom:
1562 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1563 if (hw->phy.type != ixgbe_phy_nl) {
1565 hw->phy.type = ixgbe_phy_unknown;
1567 return IXGBE_ERR_SFP_NOT_PRESENT;
1571 * ixgbe_get_supported_phy_sfp_layer_generic - Returns physical layer type
1572 * @hw: pointer to hardware structure
1574 * Determines physical layer capabilities of the current SFP.
1576 u64 ixgbe_get_supported_phy_sfp_layer_generic(struct ixgbe_hw *hw)
1578 u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1579 u8 comp_codes_10g = 0;
1580 u8 comp_codes_1g = 0;
1582 DEBUGFUNC("ixgbe_get_supported_phy_sfp_layer_generic");
1584 hw->phy.ops.identify_sfp(hw);
1585 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1586 return physical_layer;
1588 switch (hw->phy.type) {
1589 case ixgbe_phy_sfp_passive_tyco:
1590 case ixgbe_phy_sfp_passive_unknown:
1591 case ixgbe_phy_qsfp_passive_unknown:
1592 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1594 case ixgbe_phy_sfp_ftl_active:
1595 case ixgbe_phy_sfp_active_unknown:
1596 case ixgbe_phy_qsfp_active_unknown:
1597 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA;
1599 case ixgbe_phy_sfp_avago:
1600 case ixgbe_phy_sfp_ftl:
1601 case ixgbe_phy_sfp_intel:
1602 case ixgbe_phy_sfp_unknown:
1603 hw->phy.ops.read_i2c_eeprom(hw,
1604 IXGBE_SFF_1GBE_COMP_CODES, &comp_codes_1g);
1605 hw->phy.ops.read_i2c_eeprom(hw,
1606 IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
1607 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1608 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1609 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1610 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1611 else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE)
1612 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
1613 else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE)
1614 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_SX;
1616 case ixgbe_phy_qsfp_intel:
1617 case ixgbe_phy_qsfp_unknown:
1618 hw->phy.ops.read_i2c_eeprom(hw,
1619 IXGBE_SFF_QSFP_10GBE_COMP, &comp_codes_10g);
1620 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1621 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1622 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1623 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1629 return physical_layer;
1633 * ixgbe_identify_qsfp_module_generic - Identifies QSFP modules
1634 * @hw: pointer to hardware structure
1636 * Searches for and identifies the QSFP module and assigns appropriate PHY type
1638 s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
1640 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1642 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1644 u8 comp_codes_1g = 0;
1645 u8 comp_codes_10g = 0;
1646 u8 oui_bytes[3] = {0, 0, 0};
1647 u16 enforce_sfp = 0;
1649 u8 cable_length = 0;
1651 bool active_cable = false;
1653 DEBUGFUNC("ixgbe_identify_qsfp_module_generic");
1655 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber_qsfp) {
1656 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1657 status = IXGBE_ERR_SFP_NOT_PRESENT;
1661 /* LAN ID is needed for I2C access */
1662 hw->mac.ops.set_lan_id(hw);
1664 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER,
1667 if (status != IXGBE_SUCCESS)
1668 goto err_read_i2c_eeprom;
1670 if (identifier != IXGBE_SFF_IDENTIFIER_QSFP_PLUS) {
1671 hw->phy.type = ixgbe_phy_sfp_unsupported;
1672 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1676 hw->phy.id = identifier;
1678 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_10GBE_COMP,
1681 if (status != IXGBE_SUCCESS)
1682 goto err_read_i2c_eeprom;
1684 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_1GBE_COMP,
1687 if (status != IXGBE_SUCCESS)
1688 goto err_read_i2c_eeprom;
1690 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_PASSIVE_CABLE) {
1691 hw->phy.type = ixgbe_phy_qsfp_passive_unknown;
1692 if (hw->bus.lan_id == 0)
1693 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core0;
1695 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core1;
1696 } else if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1697 IXGBE_SFF_10GBASELR_CAPABLE)) {
1698 if (hw->bus.lan_id == 0)
1699 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core0;
1701 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core1;
1703 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_ACTIVE_CABLE)
1704 active_cable = true;
1706 if (!active_cable) {
1707 /* check for active DA cables that pre-date
1709 hw->phy.ops.read_i2c_eeprom(hw,
1710 IXGBE_SFF_QSFP_CONNECTOR,
1713 hw->phy.ops.read_i2c_eeprom(hw,
1714 IXGBE_SFF_QSFP_CABLE_LENGTH,
1717 hw->phy.ops.read_i2c_eeprom(hw,
1718 IXGBE_SFF_QSFP_DEVICE_TECH,
1722 IXGBE_SFF_QSFP_CONNECTOR_NOT_SEPARABLE) &&
1723 (cable_length > 0) &&
1724 ((device_tech >> 4) ==
1725 IXGBE_SFF_QSFP_TRANSMITER_850NM_VCSEL))
1726 active_cable = true;
1730 hw->phy.type = ixgbe_phy_qsfp_active_unknown;
1731 if (hw->bus.lan_id == 0)
1733 ixgbe_sfp_type_da_act_lmt_core0;
1736 ixgbe_sfp_type_da_act_lmt_core1;
1738 /* unsupported module type */
1739 hw->phy.type = ixgbe_phy_sfp_unsupported;
1740 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1745 if (hw->phy.sfp_type != stored_sfp_type)
1746 hw->phy.sfp_setup_needed = true;
1748 /* Determine if the QSFP+ PHY is dual speed or not. */
1749 hw->phy.multispeed_fiber = false;
1750 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1751 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1752 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1753 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1754 hw->phy.multispeed_fiber = true;
1756 /* Determine PHY vendor for optical modules */
1757 if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1758 IXGBE_SFF_10GBASELR_CAPABLE)) {
1759 status = hw->phy.ops.read_i2c_eeprom(hw,
1760 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE0,
1763 if (status != IXGBE_SUCCESS)
1764 goto err_read_i2c_eeprom;
1766 status = hw->phy.ops.read_i2c_eeprom(hw,
1767 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE1,
1770 if (status != IXGBE_SUCCESS)
1771 goto err_read_i2c_eeprom;
1773 status = hw->phy.ops.read_i2c_eeprom(hw,
1774 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE2,
1777 if (status != IXGBE_SUCCESS)
1778 goto err_read_i2c_eeprom;
1781 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1782 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1783 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1785 if (vendor_oui == IXGBE_SFF_VENDOR_OUI_INTEL)
1786 hw->phy.type = ixgbe_phy_qsfp_intel;
1788 hw->phy.type = ixgbe_phy_qsfp_unknown;
1790 ixgbe_get_device_caps(hw, &enforce_sfp);
1791 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP)) {
1792 /* Make sure we're a supported PHY type */
1793 if (hw->phy.type == ixgbe_phy_qsfp_intel) {
1794 status = IXGBE_SUCCESS;
1796 if (hw->allow_unsupported_sfp == true) {
1797 EWARN(hw, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n");
1798 status = IXGBE_SUCCESS;
1800 DEBUGOUT("QSFP module not supported\n");
1802 ixgbe_phy_sfp_unsupported;
1803 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1807 status = IXGBE_SUCCESS;
1814 err_read_i2c_eeprom:
1815 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1817 hw->phy.type = ixgbe_phy_unknown;
1819 return IXGBE_ERR_SFP_NOT_PRESENT;
1823 * ixgbe_get_sfp_init_sequence_offsets - Provides offset of PHY init sequence
1824 * @hw: pointer to hardware structure
1825 * @list_offset: offset to the SFP ID list
1826 * @data_offset: offset to the SFP data block
1828 * Checks the MAC's EEPROM to see if it supports a given SFP+ module type, if
1829 * so it returns the offsets to the phy init sequence block.
1831 s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
1836 u16 sfp_type = hw->phy.sfp_type;
1838 DEBUGFUNC("ixgbe_get_sfp_init_sequence_offsets");
1840 if (hw->phy.sfp_type == ixgbe_sfp_type_unknown)
1841 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1843 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1844 return IXGBE_ERR_SFP_NOT_PRESENT;
1846 if ((hw->device_id == IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) &&
1847 (hw->phy.sfp_type == ixgbe_sfp_type_da_cu))
1848 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1851 * Limiting active cables and 1G Phys must be initialized as
1854 if (sfp_type == ixgbe_sfp_type_da_act_lmt_core0 ||
1855 sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1856 sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1857 sfp_type == ixgbe_sfp_type_1g_sx_core0)
1858 sfp_type = ixgbe_sfp_type_srlr_core0;
1859 else if (sfp_type == ixgbe_sfp_type_da_act_lmt_core1 ||
1860 sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1861 sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1862 sfp_type == ixgbe_sfp_type_1g_sx_core1)
1863 sfp_type = ixgbe_sfp_type_srlr_core1;
1865 /* Read offset to PHY init contents */
1866 if (hw->eeprom.ops.read(hw, IXGBE_PHY_INIT_OFFSET_NL, list_offset)) {
1867 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1868 "eeprom read at offset %d failed",
1869 IXGBE_PHY_INIT_OFFSET_NL);
1870 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1873 if ((!*list_offset) || (*list_offset == 0xFFFF))
1874 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1876 /* Shift offset to first ID word */
1880 * Find the matching SFP ID in the EEPROM
1881 * and program the init sequence
1883 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1886 while (sfp_id != IXGBE_PHY_INIT_END_NL) {
1887 if (sfp_id == sfp_type) {
1889 if (hw->eeprom.ops.read(hw, *list_offset, data_offset))
1891 if ((!*data_offset) || (*data_offset == 0xFFFF)) {
1892 DEBUGOUT("SFP+ module not supported\n");
1893 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1898 (*list_offset) += 2;
1899 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1904 if (sfp_id == IXGBE_PHY_INIT_END_NL) {
1905 DEBUGOUT("No matching SFP+ module found\n");
1906 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1909 return IXGBE_SUCCESS;
1912 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1913 "eeprom read at offset %d failed", *list_offset);
1914 return IXGBE_ERR_PHY;
1918 * ixgbe_read_i2c_eeprom_generic - Reads 8 bit EEPROM word over I2C interface
1919 * @hw: pointer to hardware structure
1920 * @byte_offset: EEPROM byte offset to read
1921 * @eeprom_data: value read
1923 * Performs byte read operation to SFP module's EEPROM over I2C interface.
1925 s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1928 DEBUGFUNC("ixgbe_read_i2c_eeprom_generic");
1930 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1931 IXGBE_I2C_EEPROM_DEV_ADDR,
1936 * ixgbe_read_i2c_sff8472_generic - Reads 8 bit word over I2C interface
1937 * @hw: pointer to hardware structure
1938 * @byte_offset: byte offset at address 0xA2
1939 * @sff8472_data: value read
1941 * Performs byte read operation to SFP module's SFF-8472 data over I2C
1943 static s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
1946 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1947 IXGBE_I2C_EEPROM_DEV_ADDR2,
1952 * ixgbe_write_i2c_eeprom_generic - Writes 8 bit EEPROM word over I2C interface
1953 * @hw: pointer to hardware structure
1954 * @byte_offset: EEPROM byte offset to write
1955 * @eeprom_data: value to write
1957 * Performs byte write operation to SFP module's EEPROM over I2C interface.
1959 s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1962 DEBUGFUNC("ixgbe_write_i2c_eeprom_generic");
1964 return hw->phy.ops.write_i2c_byte(hw, byte_offset,
1965 IXGBE_I2C_EEPROM_DEV_ADDR,
1970 * ixgbe_is_sfp_probe - Returns true if SFP is being detected
1971 * @hw: pointer to hardware structure
1972 * @offset: eeprom offset to be read
1973 * @addr: I2C address to be read
1975 static bool ixgbe_is_sfp_probe(struct ixgbe_hw *hw, u8 offset, u8 addr)
1977 if (addr == IXGBE_I2C_EEPROM_DEV_ADDR &&
1978 offset == IXGBE_SFF_IDENTIFIER &&
1979 hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1985 * ixgbe_read_i2c_byte_generic_int - Reads 8 bit word over I2C
1986 * @hw: pointer to hardware structure
1987 * @byte_offset: byte offset to read
1988 * @dev_addr: address to read from
1990 * @lock: true if to take and release semaphore
1992 * Performs byte read operation to SFP module's EEPROM over I2C interface at
1993 * a specified device address.
1995 static s32 ixgbe_read_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
1996 u8 dev_addr, u8 *data, bool lock)
2001 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2005 DEBUGFUNC("ixgbe_read_i2c_byte_generic");
2007 if (hw->mac.type >= ixgbe_mac_X550)
2009 if (ixgbe_is_sfp_probe(hw, byte_offset, dev_addr))
2010 max_retry = IXGBE_SFP_DETECT_RETRIES;
2013 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
2014 return IXGBE_ERR_SWFW_SYNC;
2016 ixgbe_i2c_start(hw);
2018 /* Device Address and write indication */
2019 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
2020 if (status != IXGBE_SUCCESS)
2023 status = ixgbe_get_i2c_ack(hw);
2024 if (status != IXGBE_SUCCESS)
2027 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
2028 if (status != IXGBE_SUCCESS)
2031 status = ixgbe_get_i2c_ack(hw);
2032 if (status != IXGBE_SUCCESS)
2035 ixgbe_i2c_start(hw);
2037 /* Device Address and read indication */
2038 status = ixgbe_clock_out_i2c_byte(hw, (dev_addr | 0x1));
2039 if (status != IXGBE_SUCCESS)
2042 status = ixgbe_get_i2c_ack(hw);
2043 if (status != IXGBE_SUCCESS)
2046 status = ixgbe_clock_in_i2c_byte(hw, data);
2047 if (status != IXGBE_SUCCESS)
2050 status = ixgbe_clock_out_i2c_bit(hw, nack);
2051 if (status != IXGBE_SUCCESS)
2056 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2057 return IXGBE_SUCCESS;
2060 ixgbe_i2c_bus_clear(hw);
2062 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2065 if (retry < max_retry)
2066 DEBUGOUT("I2C byte read error - Retrying.\n");
2068 DEBUGOUT("I2C byte read error.\n");
2070 } while (retry <= max_retry);
2076 * ixgbe_read_i2c_byte_generic - 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(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_read_i2c_byte_generic_unlocked - Reads 8 bit word over I2C
2094 * @hw: pointer to hardware structure
2095 * @byte_offset: byte offset to read
2096 * @dev_addr: address to read from
2099 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2100 * a specified device address.
2102 s32 ixgbe_read_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2103 u8 dev_addr, u8 *data)
2105 return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2110 * ixgbe_write_i2c_byte_generic_int - Writes 8 bit word over I2C
2111 * @hw: pointer to hardware structure
2112 * @byte_offset: byte offset to write
2113 * @dev_addr: address to write to
2114 * @data: value to write
2115 * @lock: true if to take and release semaphore
2117 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2118 * a specified device address.
2120 static s32 ixgbe_write_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
2121 u8 dev_addr, u8 data, bool lock)
2126 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2128 DEBUGFUNC("ixgbe_write_i2c_byte_generic");
2130 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) !=
2132 return IXGBE_ERR_SWFW_SYNC;
2135 ixgbe_i2c_start(hw);
2137 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
2138 if (status != IXGBE_SUCCESS)
2141 status = ixgbe_get_i2c_ack(hw);
2142 if (status != IXGBE_SUCCESS)
2145 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
2146 if (status != IXGBE_SUCCESS)
2149 status = ixgbe_get_i2c_ack(hw);
2150 if (status != IXGBE_SUCCESS)
2153 status = ixgbe_clock_out_i2c_byte(hw, data);
2154 if (status != IXGBE_SUCCESS)
2157 status = ixgbe_get_i2c_ack(hw);
2158 if (status != IXGBE_SUCCESS)
2163 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2164 return IXGBE_SUCCESS;
2167 ixgbe_i2c_bus_clear(hw);
2168 if (retry < max_retry)
2169 DEBUGOUT("I2C byte write error - Retrying.\n");
2171 DEBUGOUT("I2C byte write error.\n");
2173 } while (retry <= max_retry);
2176 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2182 * ixgbe_write_i2c_byte_generic - 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(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_write_i2c_byte_generic_unlocked - Writes 8 bit word over I2C
2200 * @hw: pointer to hardware structure
2201 * @byte_offset: byte offset to write
2202 * @dev_addr: address to write to
2203 * @data: value to write
2205 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2206 * a specified device address.
2208 s32 ixgbe_write_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2209 u8 dev_addr, u8 data)
2211 return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2216 * ixgbe_i2c_start - Sets I2C start condition
2217 * @hw: pointer to hardware structure
2219 * Sets I2C start condition (High -> Low on SDA while SCL is High)
2220 * Set bit-bang mode on X550 hardware.
2222 static void ixgbe_i2c_start(struct ixgbe_hw *hw)
2224 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2226 DEBUGFUNC("ixgbe_i2c_start");
2228 i2cctl |= IXGBE_I2C_BB_EN_BY_MAC(hw);
2230 /* Start condition must begin with data and clock high */
2231 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2232 ixgbe_raise_i2c_clk(hw, &i2cctl);
2234 /* Setup time for start condition (4.7us) */
2235 usec_delay(IXGBE_I2C_T_SU_STA);
2237 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2239 /* Hold time for start condition (4us) */
2240 usec_delay(IXGBE_I2C_T_HD_STA);
2242 ixgbe_lower_i2c_clk(hw, &i2cctl);
2244 /* Minimum low period of clock is 4.7 us */
2245 usec_delay(IXGBE_I2C_T_LOW);
2250 * ixgbe_i2c_stop - Sets I2C stop condition
2251 * @hw: pointer to hardware structure
2253 * Sets I2C stop condition (Low -> High on SDA while SCL is High)
2254 * Disables bit-bang mode and negates data output enable on X550
2257 static void ixgbe_i2c_stop(struct ixgbe_hw *hw)
2259 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2260 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2261 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2262 u32 bb_en_bit = IXGBE_I2C_BB_EN_BY_MAC(hw);
2264 DEBUGFUNC("ixgbe_i2c_stop");
2266 /* Stop condition must begin with data low and clock high */
2267 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2268 ixgbe_raise_i2c_clk(hw, &i2cctl);
2270 /* Setup time for stop condition (4us) */
2271 usec_delay(IXGBE_I2C_T_SU_STO);
2273 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2275 /* bus free time between stop and start (4.7us)*/
2276 usec_delay(IXGBE_I2C_T_BUF);
2278 if (bb_en_bit || data_oe_bit || clk_oe_bit) {
2279 i2cctl &= ~bb_en_bit;
2280 i2cctl |= data_oe_bit | clk_oe_bit;
2281 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2282 IXGBE_WRITE_FLUSH(hw);
2287 * ixgbe_clock_in_i2c_byte - Clocks in one byte via I2C
2288 * @hw: pointer to hardware structure
2289 * @data: data byte to clock in
2291 * Clocks in one byte data via I2C data/clock
2293 static s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data)
2298 DEBUGFUNC("ixgbe_clock_in_i2c_byte");
2301 for (i = 7; i >= 0; i--) {
2302 ixgbe_clock_in_i2c_bit(hw, &bit);
2306 return IXGBE_SUCCESS;
2310 * ixgbe_clock_out_i2c_byte - Clocks out one byte via I2C
2311 * @hw: pointer to hardware structure
2312 * @data: data byte clocked out
2314 * Clocks out one byte data via I2C data/clock
2316 static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data)
2318 s32 status = IXGBE_SUCCESS;
2323 DEBUGFUNC("ixgbe_clock_out_i2c_byte");
2325 for (i = 7; i >= 0; i--) {
2326 bit = (data >> i) & 0x1;
2327 status = ixgbe_clock_out_i2c_bit(hw, bit);
2329 if (status != IXGBE_SUCCESS)
2333 /* Release SDA line (set high) */
2334 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2335 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2336 i2cctl |= IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2337 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2338 IXGBE_WRITE_FLUSH(hw);
2344 * ixgbe_get_i2c_ack - Polls for I2C ACK
2345 * @hw: pointer to hardware structure
2347 * Clocks in/out one bit via I2C data/clock
2349 static s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw)
2351 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2352 s32 status = IXGBE_SUCCESS;
2354 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2358 DEBUGFUNC("ixgbe_get_i2c_ack");
2361 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2362 i2cctl |= data_oe_bit;
2363 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2364 IXGBE_WRITE_FLUSH(hw);
2366 ixgbe_raise_i2c_clk(hw, &i2cctl);
2368 /* Minimum high period of clock is 4us */
2369 usec_delay(IXGBE_I2C_T_HIGH);
2371 /* Poll for ACK. Note that ACK in I2C spec is
2372 * transition from 1 to 0 */
2373 for (i = 0; i < timeout; i++) {
2374 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2375 ack = ixgbe_get_i2c_data(hw, &i2cctl);
2383 DEBUGOUT("I2C ack was not received.\n");
2384 status = IXGBE_ERR_I2C;
2387 ixgbe_lower_i2c_clk(hw, &i2cctl);
2389 /* Minimum low period of clock is 4.7 us */
2390 usec_delay(IXGBE_I2C_T_LOW);
2396 * ixgbe_clock_in_i2c_bit - Clocks in one bit via I2C data/clock
2397 * @hw: pointer to hardware structure
2398 * @data: read data value
2400 * Clocks in one bit via I2C data/clock
2402 static s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data)
2404 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2405 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2407 DEBUGFUNC("ixgbe_clock_in_i2c_bit");
2410 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2411 i2cctl |= data_oe_bit;
2412 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2413 IXGBE_WRITE_FLUSH(hw);
2415 ixgbe_raise_i2c_clk(hw, &i2cctl);
2417 /* Minimum high period of clock is 4us */
2418 usec_delay(IXGBE_I2C_T_HIGH);
2420 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2421 *data = ixgbe_get_i2c_data(hw, &i2cctl);
2423 ixgbe_lower_i2c_clk(hw, &i2cctl);
2425 /* Minimum low period of clock is 4.7 us */
2426 usec_delay(IXGBE_I2C_T_LOW);
2428 return IXGBE_SUCCESS;
2432 * ixgbe_clock_out_i2c_bit - Clocks in/out one bit via I2C data/clock
2433 * @hw: pointer to hardware structure
2434 * @data: data value to write
2436 * Clocks out one bit via I2C data/clock
2438 static s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data)
2441 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2443 DEBUGFUNC("ixgbe_clock_out_i2c_bit");
2445 status = ixgbe_set_i2c_data(hw, &i2cctl, data);
2446 if (status == IXGBE_SUCCESS) {
2447 ixgbe_raise_i2c_clk(hw, &i2cctl);
2449 /* Minimum high period of clock is 4us */
2450 usec_delay(IXGBE_I2C_T_HIGH);
2452 ixgbe_lower_i2c_clk(hw, &i2cctl);
2454 /* Minimum low period of clock is 4.7 us.
2455 * This also takes care of the data hold time.
2457 usec_delay(IXGBE_I2C_T_LOW);
2459 status = IXGBE_ERR_I2C;
2460 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2461 "I2C data was not set to %X\n", data);
2468 * ixgbe_raise_i2c_clk - Raises the I2C SCL clock
2469 * @hw: pointer to hardware structure
2470 * @i2cctl: Current value of I2CCTL register
2472 * Raises the I2C clock line '0'->'1'
2473 * Negates the I2C clock output enable on X550 hardware.
2475 static void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2477 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2479 u32 timeout = IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT;
2482 DEBUGFUNC("ixgbe_raise_i2c_clk");
2485 *i2cctl |= clk_oe_bit;
2486 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2489 for (i = 0; i < timeout; i++) {
2490 *i2cctl |= IXGBE_I2C_CLK_OUT_BY_MAC(hw);
2492 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2493 IXGBE_WRITE_FLUSH(hw);
2494 /* SCL rise time (1000ns) */
2495 usec_delay(IXGBE_I2C_T_RISE);
2497 i2cctl_r = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2498 if (i2cctl_r & IXGBE_I2C_CLK_IN_BY_MAC(hw))
2504 * ixgbe_lower_i2c_clk - Lowers the I2C SCL clock
2505 * @hw: pointer to hardware structure
2506 * @i2cctl: Current value of I2CCTL register
2508 * Lowers the I2C clock line '1'->'0'
2509 * Asserts the I2C clock output enable on X550 hardware.
2511 static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2513 DEBUGFUNC("ixgbe_lower_i2c_clk");
2515 *i2cctl &= ~(IXGBE_I2C_CLK_OUT_BY_MAC(hw));
2516 *i2cctl &= ~IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2518 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2519 IXGBE_WRITE_FLUSH(hw);
2521 /* SCL fall time (300ns) */
2522 usec_delay(IXGBE_I2C_T_FALL);
2526 * ixgbe_set_i2c_data - Sets the I2C data bit
2527 * @hw: pointer to hardware structure
2528 * @i2cctl: Current value of I2CCTL register
2529 * @data: I2C data value (0 or 1) to set
2531 * Sets the I2C data bit
2532 * Asserts the I2C data output enable on X550 hardware.
2534 static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data)
2536 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2537 s32 status = IXGBE_SUCCESS;
2539 DEBUGFUNC("ixgbe_set_i2c_data");
2542 *i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2544 *i2cctl &= ~(IXGBE_I2C_DATA_OUT_BY_MAC(hw));
2545 *i2cctl &= ~data_oe_bit;
2547 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2548 IXGBE_WRITE_FLUSH(hw);
2550 /* Data rise/fall (1000ns/300ns) and set-up time (250ns) */
2551 usec_delay(IXGBE_I2C_T_RISE + IXGBE_I2C_T_FALL + IXGBE_I2C_T_SU_DATA);
2553 if (!data) /* Can't verify data in this case */
2554 return IXGBE_SUCCESS;
2556 *i2cctl |= data_oe_bit;
2557 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2558 IXGBE_WRITE_FLUSH(hw);
2561 /* Verify data was set correctly */
2562 *i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2563 if (data != ixgbe_get_i2c_data(hw, i2cctl)) {
2564 status = IXGBE_ERR_I2C;
2565 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2566 "Error - I2C data was not set to %X.\n",
2574 * ixgbe_get_i2c_data - Reads the I2C SDA data bit
2575 * @hw: pointer to hardware structure
2576 * @i2cctl: Current value of I2CCTL register
2578 * Returns the I2C data bit value
2579 * Negates the I2C data output enable on X550 hardware.
2581 static bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl)
2583 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2585 UNREFERENCED_1PARAMETER(hw);
2587 DEBUGFUNC("ixgbe_get_i2c_data");
2590 *i2cctl |= data_oe_bit;
2591 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2592 IXGBE_WRITE_FLUSH(hw);
2593 usec_delay(IXGBE_I2C_T_FALL);
2596 if (*i2cctl & IXGBE_I2C_DATA_IN_BY_MAC(hw))
2605 * ixgbe_i2c_bus_clear - Clears the I2C bus
2606 * @hw: pointer to hardware structure
2608 * Clears the I2C bus by sending nine clock pulses.
2609 * Used when data line is stuck low.
2611 void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw)
2616 DEBUGFUNC("ixgbe_i2c_bus_clear");
2618 ixgbe_i2c_start(hw);
2619 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2621 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2623 for (i = 0; i < 9; i++) {
2624 ixgbe_raise_i2c_clk(hw, &i2cctl);
2626 /* Min high period of clock is 4us */
2627 usec_delay(IXGBE_I2C_T_HIGH);
2629 ixgbe_lower_i2c_clk(hw, &i2cctl);
2631 /* Min low period of clock is 4.7us*/
2632 usec_delay(IXGBE_I2C_T_LOW);
2635 ixgbe_i2c_start(hw);
2637 /* Put the i2c bus back to default state */
2642 * ixgbe_tn_check_overtemp - Checks if an overtemp occurred.
2643 * @hw: pointer to hardware structure
2645 * Checks if the LASI temp alarm status was triggered due to overtemp
2647 s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
2649 s32 status = IXGBE_SUCCESS;
2652 DEBUGFUNC("ixgbe_tn_check_overtemp");
2654 if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
2657 /* Check that the LASI temp alarm status was triggered */
2658 hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
2659 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_data);
2661 if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))
2664 status = IXGBE_ERR_OVERTEMP;
2665 ERROR_REPORT1(IXGBE_ERROR_CAUTION, "Device over temperature");
2671 * ixgbe_set_copper_phy_power - Control power for copper phy
2672 * @hw: pointer to hardware structure
2673 * @on: true for on, false for off
2675 s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on)
2680 if (!on && ixgbe_mng_present(hw))
2683 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2684 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2690 reg &= ~IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2692 if (ixgbe_check_reset_blocked(hw))
2694 reg |= IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2697 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2698 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,