1 /******************************************************************************
2 SPDX-License-Identifier: BSD-3-Clause
4 Copyright (c) 2001-2017, 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);
173 if (retry < max_retry)
174 DEBUGOUT("I2C byte read combined error - Retrying.\n");
176 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);
238 if (retry < max_retry)
239 DEBUGOUT("I2C byte write combined error - Retrying.\n");
241 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
405 bool ixgbe_validate_phy_addr(struct ixgbe_hw *hw, u32 phy_addr)
410 DEBUGFUNC("ixgbe_validate_phy_addr");
412 hw->phy.addr = phy_addr;
413 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
414 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_id);
416 if (phy_id != 0xFFFF && phy_id != 0x0)
419 DEBUGOUT1("PHY ID HIGH is 0x%04X\n", phy_id);
425 * ixgbe_get_phy_id - Get the phy type
426 * @hw: pointer to hardware structure
429 s32 ixgbe_get_phy_id(struct ixgbe_hw *hw)
435 DEBUGFUNC("ixgbe_get_phy_id");
437 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
438 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
441 if (status == IXGBE_SUCCESS) {
442 hw->phy.id = (u32)(phy_id_high << 16);
443 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
444 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
446 hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK);
447 hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK);
449 DEBUGOUT2("PHY_ID_HIGH 0x%04X, PHY_ID_LOW 0x%04X\n",
450 phy_id_high, phy_id_low);
456 * ixgbe_get_phy_type_from_id - Get the phy type
457 * @phy_id: PHY ID information
460 enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
462 enum ixgbe_phy_type phy_type;
464 DEBUGFUNC("ixgbe_get_phy_type_from_id");
468 phy_type = ixgbe_phy_tn;
473 phy_type = ixgbe_phy_aq;
476 phy_type = ixgbe_phy_qt;
479 phy_type = ixgbe_phy_nl;
483 phy_type = ixgbe_phy_x550em_ext_t;
485 case IXGBE_M88E1500_E_PHY_ID:
486 case IXGBE_M88E1543_E_PHY_ID:
487 phy_type = ixgbe_phy_ext_1g_t;
490 phy_type = ixgbe_phy_unknown;
497 * ixgbe_reset_phy_generic - Performs a PHY reset
498 * @hw: pointer to hardware structure
500 s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
504 s32 status = IXGBE_SUCCESS;
506 DEBUGFUNC("ixgbe_reset_phy_generic");
508 if (hw->phy.type == ixgbe_phy_unknown)
509 status = ixgbe_identify_phy_generic(hw);
511 if (status != IXGBE_SUCCESS || hw->phy.type == ixgbe_phy_none)
514 /* Don't reset PHY if it's shut down due to overtemp. */
515 if (!hw->phy.reset_if_overtemp &&
516 (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
519 /* Blocked by MNG FW so bail */
520 if (ixgbe_check_reset_blocked(hw))
524 * Perform soft PHY reset to the PHY_XS.
525 * This will cause a soft reset to the PHY
527 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
528 IXGBE_MDIO_PHY_XS_DEV_TYPE,
529 IXGBE_MDIO_PHY_XS_RESET);
532 * Poll for reset bit to self-clear indicating reset is complete.
533 * Some PHYs could take up to 3 seconds to complete and need about
534 * 1.7 usec delay after the reset is complete.
536 for (i = 0; i < 30; i++) {
538 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
539 status = hw->phy.ops.read_reg(hw,
540 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
541 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
543 if (status != IXGBE_SUCCESS)
546 if (ctrl & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
551 status = hw->phy.ops.read_reg(hw,
552 IXGBE_MDIO_PHY_XS_CONTROL,
553 IXGBE_MDIO_PHY_XS_DEV_TYPE,
555 if (status != IXGBE_SUCCESS)
558 if (!(ctrl & IXGBE_MDIO_PHY_XS_RESET)) {
565 if (ctrl & IXGBE_MDIO_PHY_XS_RESET) {
566 status = IXGBE_ERR_RESET_FAILED;
567 ERROR_REPORT1(IXGBE_ERROR_POLLING,
568 "PHY reset polling failed to complete.\n");
576 * ixgbe_read_phy_mdi - Reads a value from a specified PHY register without
578 * @hw: pointer to hardware structure
579 * @reg_addr: 32 bit address of PHY register to read
580 * @phy_data: Pointer to read data from PHY register
582 s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
585 u32 i, data, command;
587 /* Setup and write the address cycle command */
588 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
589 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
590 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
591 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
593 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
596 * Check every 10 usec to see if the address cycle completed.
597 * The MDI Command bit will clear when the operation is
600 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
603 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
604 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
609 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
610 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address command did not complete.\n");
611 DEBUGOUT("PHY address command did not complete, returning IXGBE_ERR_PHY\n");
612 return IXGBE_ERR_PHY;
616 * Address cycle complete, setup and write the read
619 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
620 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
621 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
622 (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND));
624 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
627 * Check every 10 usec to see if the address cycle
628 * completed. The MDI Command bit will clear when the
629 * operation is complete
631 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
634 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
635 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
639 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
640 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY read command didn't complete\n");
641 DEBUGOUT("PHY read command didn't complete, returning IXGBE_ERR_PHY\n");
642 return IXGBE_ERR_PHY;
646 * Read operation is complete. Get the data
649 data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
650 data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
651 *phy_data = (u16)(data);
653 return IXGBE_SUCCESS;
657 * ixgbe_read_phy_reg_generic - Reads a value from a specified PHY register
658 * using the SWFW lock - this function is needed in most cases
659 * @hw: pointer to hardware structure
660 * @reg_addr: 32 bit address of PHY register to read
661 * @phy_data: Pointer to read data from PHY register
663 s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
664 u32 device_type, u16 *phy_data)
667 u32 gssr = hw->phy.phy_semaphore_mask;
669 DEBUGFUNC("ixgbe_read_phy_reg_generic");
671 if (hw->mac.ops.acquire_swfw_sync(hw, gssr))
672 return IXGBE_ERR_SWFW_SYNC;
674 status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
676 hw->mac.ops.release_swfw_sync(hw, gssr);
682 * ixgbe_write_phy_reg_mdi - Writes a value to specified PHY register
684 * @hw: pointer to hardware structure
685 * @reg_addr: 32 bit PHY register to write
686 * @device_type: 5 bit device type
687 * @phy_data: Data to write to the PHY register
689 s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,
690 u32 device_type, u16 phy_data)
694 /* Put the data in the MDI single read and write data register*/
695 IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
697 /* Setup and write the address cycle command */
698 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
699 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
700 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
701 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
703 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
706 * Check every 10 usec to see if the address cycle completed.
707 * The MDI Command bit will clear when the operation is
710 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
713 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
714 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
718 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
719 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address cmd didn't complete\n");
720 return IXGBE_ERR_PHY;
724 * Address cycle complete, setup and write the write
727 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
728 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
729 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
730 (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND));
732 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
735 * Check every 10 usec to see if the address cycle
736 * completed. The MDI Command bit will clear when the
737 * operation is complete
739 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
742 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
743 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
747 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
748 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY write cmd didn't complete\n");
749 return IXGBE_ERR_PHY;
752 return IXGBE_SUCCESS;
756 * ixgbe_write_phy_reg_generic - Writes a value to specified PHY register
757 * using SWFW lock- this function is needed in most cases
758 * @hw: pointer to hardware structure
759 * @reg_addr: 32 bit PHY register to write
760 * @device_type: 5 bit device type
761 * @phy_data: Data to write to the PHY register
763 s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
764 u32 device_type, u16 phy_data)
767 u32 gssr = hw->phy.phy_semaphore_mask;
769 DEBUGFUNC("ixgbe_write_phy_reg_generic");
771 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
772 status = hw->phy.ops.write_reg_mdi(hw, reg_addr, device_type,
774 hw->mac.ops.release_swfw_sync(hw, gssr);
776 status = IXGBE_ERR_SWFW_SYNC;
783 * ixgbe_setup_phy_link_generic - Set and restart auto-neg
784 * @hw: pointer to hardware structure
786 * Restart auto-negotiation and PHY and waits for completion.
788 s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
790 s32 status = IXGBE_SUCCESS;
791 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
792 bool autoneg = FALSE;
793 ixgbe_link_speed speed;
795 DEBUGFUNC("ixgbe_setup_phy_link_generic");
797 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
799 /* Set or unset auto-negotiation 10G advertisement */
800 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
801 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
804 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
805 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL) &&
806 (speed & IXGBE_LINK_SPEED_10GB_FULL))
807 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
809 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
810 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
813 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
814 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
817 if (hw->mac.type == ixgbe_mac_X550) {
818 /* Set or unset auto-negotiation 5G advertisement */
819 autoneg_reg &= ~IXGBE_MII_5GBASE_T_ADVERTISE;
820 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_5GB_FULL) &&
821 (speed & IXGBE_LINK_SPEED_5GB_FULL))
822 autoneg_reg |= IXGBE_MII_5GBASE_T_ADVERTISE;
824 /* Set or unset auto-negotiation 2.5G advertisement */
825 autoneg_reg &= ~IXGBE_MII_2_5GBASE_T_ADVERTISE;
826 if ((hw->phy.autoneg_advertised &
827 IXGBE_LINK_SPEED_2_5GB_FULL) &&
828 (speed & IXGBE_LINK_SPEED_2_5GB_FULL))
829 autoneg_reg |= IXGBE_MII_2_5GBASE_T_ADVERTISE;
832 /* Set or unset auto-negotiation 1G advertisement */
833 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE;
834 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL) &&
835 (speed & IXGBE_LINK_SPEED_1GB_FULL))
836 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE;
838 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
839 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
842 /* Set or unset auto-negotiation 100M advertisement */
843 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
844 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
847 autoneg_reg &= ~(IXGBE_MII_100BASE_T_ADVERTISE |
848 IXGBE_MII_100BASE_T_ADVERTISE_HALF);
849 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL) &&
850 (speed & IXGBE_LINK_SPEED_100_FULL))
851 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
853 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
854 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
857 /* Blocked by MNG FW so don't reset PHY */
858 if (ixgbe_check_reset_blocked(hw))
861 /* Restart PHY auto-negotiation. */
862 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
863 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
865 autoneg_reg |= IXGBE_MII_RESTART;
867 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
868 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
874 * ixgbe_setup_phy_link_speed_generic - Sets the auto advertised capabilities
875 * @hw: pointer to hardware structure
876 * @speed: new link speed
878 s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
879 ixgbe_link_speed speed,
880 bool autoneg_wait_to_complete)
882 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
884 DEBUGFUNC("ixgbe_setup_phy_link_speed_generic");
887 * Clear autoneg_advertised and set new values based on input link
890 hw->phy.autoneg_advertised = 0;
892 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
893 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
895 if (speed & IXGBE_LINK_SPEED_5GB_FULL)
896 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_5GB_FULL;
898 if (speed & IXGBE_LINK_SPEED_2_5GB_FULL)
899 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_2_5GB_FULL;
901 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
902 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
904 if (speed & IXGBE_LINK_SPEED_100_FULL)
905 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
907 if (speed & IXGBE_LINK_SPEED_10_FULL)
908 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10_FULL;
910 /* Setup link based on the new speed settings */
911 ixgbe_setup_phy_link(hw);
913 return IXGBE_SUCCESS;
917 * ixgbe_get_copper_speeds_supported - Get copper link speeds from phy
918 * @hw: pointer to hardware structure
920 * Determines the supported link capabilities by reading the PHY auto
921 * negotiation register.
923 static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
928 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
929 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
934 if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
935 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
936 if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
937 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
938 if (speed_ability & IXGBE_MDIO_PHY_SPEED_100M)
939 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_100_FULL;
941 switch (hw->mac.type) {
943 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_2_5GB_FULL;
944 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_5GB_FULL;
946 case ixgbe_mac_X550EM_x:
947 case ixgbe_mac_X550EM_a:
948 hw->phy.speeds_supported &= ~IXGBE_LINK_SPEED_100_FULL;
958 * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
959 * @hw: pointer to hardware structure
960 * @speed: pointer to link speed
961 * @autoneg: boolean auto-negotiation value
963 s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
964 ixgbe_link_speed *speed,
967 s32 status = IXGBE_SUCCESS;
969 DEBUGFUNC("ixgbe_get_copper_link_capabilities_generic");
972 if (!hw->phy.speeds_supported)
973 status = ixgbe_get_copper_speeds_supported(hw);
975 *speed = hw->phy.speeds_supported;
980 * ixgbe_check_phy_link_tnx - Determine link and speed status
981 * @hw: pointer to hardware structure
983 * Reads the VS1 register to determine if link is up and the current speed for
986 s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
989 s32 status = IXGBE_SUCCESS;
991 u32 max_time_out = 10;
996 DEBUGFUNC("ixgbe_check_phy_link_tnx");
998 /* Initialize speed and link to default case */
1000 *speed = IXGBE_LINK_SPEED_10GB_FULL;
1003 * Check current speed and link status of the PHY register.
1004 * This is a vendor specific register and may have to
1005 * be changed for other copper PHYs.
1007 for (time_out = 0; time_out < max_time_out; time_out++) {
1009 status = hw->phy.ops.read_reg(hw,
1010 IXGBE_MDIO_VENDOR_SPECIFIC_1_STATUS,
1011 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1013 phy_link = phy_data & IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS;
1014 phy_speed = phy_data &
1015 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS;
1016 if (phy_link == IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS) {
1019 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS)
1020 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1029 * ixgbe_setup_phy_link_tnx - Set and restart auto-neg
1030 * @hw: pointer to hardware structure
1032 * Restart auto-negotiation and PHY and waits for completion.
1034 s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
1036 s32 status = IXGBE_SUCCESS;
1037 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
1038 bool autoneg = FALSE;
1039 ixgbe_link_speed speed;
1041 DEBUGFUNC("ixgbe_setup_phy_link_tnx");
1043 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
1045 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
1046 /* Set or unset auto-negotiation 10G advertisement */
1047 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1048 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1051 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
1052 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1053 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
1055 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1056 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1060 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
1061 /* Set or unset auto-negotiation 1G advertisement */
1062 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1063 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1066 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1067 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1068 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1070 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1071 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1075 if (speed & IXGBE_LINK_SPEED_100_FULL) {
1076 /* Set or unset auto-negotiation 100M advertisement */
1077 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1078 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1081 autoneg_reg &= ~IXGBE_MII_100BASE_T_ADVERTISE;
1082 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
1083 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
1085 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1086 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1090 /* Blocked by MNG FW so don't reset PHY */
1091 if (ixgbe_check_reset_blocked(hw))
1094 /* Restart PHY auto-negotiation. */
1095 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
1096 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
1098 autoneg_reg |= IXGBE_MII_RESTART;
1100 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
1101 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
1107 * ixgbe_get_phy_firmware_version_tnx - Gets the PHY Firmware Version
1108 * @hw: pointer to hardware structure
1109 * @firmware_version: pointer to the PHY Firmware Version
1111 s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
1112 u16 *firmware_version)
1116 DEBUGFUNC("ixgbe_get_phy_firmware_version_tnx");
1118 status = hw->phy.ops.read_reg(hw, TNX_FW_REV,
1119 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1126 * ixgbe_get_phy_firmware_version_generic - Gets the PHY Firmware Version
1127 * @hw: pointer to hardware structure
1128 * @firmware_version: pointer to the PHY Firmware Version
1130 s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
1131 u16 *firmware_version)
1135 DEBUGFUNC("ixgbe_get_phy_firmware_version_generic");
1137 status = hw->phy.ops.read_reg(hw, AQ_FW_REV,
1138 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1145 * ixgbe_reset_phy_nl - Performs a PHY reset
1146 * @hw: pointer to hardware structure
1148 s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
1150 u16 phy_offset, control, eword, edata, block_crc;
1151 bool end_data = FALSE;
1152 u16 list_offset, data_offset;
1154 s32 ret_val = IXGBE_SUCCESS;
1157 DEBUGFUNC("ixgbe_reset_phy_nl");
1159 /* Blocked by MNG FW so bail */
1160 if (ixgbe_check_reset_blocked(hw))
1163 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1164 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1166 /* reset the PHY and poll for completion */
1167 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1168 IXGBE_MDIO_PHY_XS_DEV_TYPE,
1169 (phy_data | IXGBE_MDIO_PHY_XS_RESET));
1171 for (i = 0; i < 100; i++) {
1172 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1173 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1174 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) == 0)
1179 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) != 0) {
1180 DEBUGOUT("PHY reset did not complete.\n");
1181 ret_val = IXGBE_ERR_PHY;
1185 /* Get init offsets */
1186 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
1188 if (ret_val != IXGBE_SUCCESS)
1191 ret_val = hw->eeprom.ops.read(hw, data_offset, &block_crc);
1195 * Read control word from PHY init contents offset
1197 ret_val = hw->eeprom.ops.read(hw, data_offset, &eword);
1200 control = (eword & IXGBE_CONTROL_MASK_NL) >>
1201 IXGBE_CONTROL_SHIFT_NL;
1202 edata = eword & IXGBE_DATA_MASK_NL;
1204 case IXGBE_DELAY_NL:
1206 DEBUGOUT1("DELAY: %d MS\n", edata);
1210 DEBUGOUT("DATA:\n");
1212 ret_val = hw->eeprom.ops.read(hw, data_offset,
1217 for (i = 0; i < edata; i++) {
1218 ret_val = hw->eeprom.ops.read(hw, data_offset,
1222 hw->phy.ops.write_reg(hw, phy_offset,
1223 IXGBE_TWINAX_DEV, eword);
1224 DEBUGOUT2("Wrote %4.4x to %4.4x\n", eword,
1230 case IXGBE_CONTROL_NL:
1232 DEBUGOUT("CONTROL:\n");
1233 if (edata == IXGBE_CONTROL_EOL_NL) {
1236 } else if (edata == IXGBE_CONTROL_SOL_NL) {
1239 DEBUGOUT("Bad control value\n");
1240 ret_val = IXGBE_ERR_PHY;
1245 DEBUGOUT("Bad control type\n");
1246 ret_val = IXGBE_ERR_PHY;
1255 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1256 "eeprom read at offset %d failed", data_offset);
1257 return IXGBE_ERR_PHY;
1261 * ixgbe_identify_module_generic - Identifies module type
1262 * @hw: pointer to hardware structure
1264 * Determines HW type and calls appropriate function.
1266 s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw)
1268 s32 status = IXGBE_ERR_SFP_NOT_PRESENT;
1270 DEBUGFUNC("ixgbe_identify_module_generic");
1272 switch (hw->mac.ops.get_media_type(hw)) {
1273 case ixgbe_media_type_fiber:
1274 status = ixgbe_identify_sfp_module_generic(hw);
1277 case ixgbe_media_type_fiber_qsfp:
1278 status = ixgbe_identify_qsfp_module_generic(hw);
1282 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1283 status = IXGBE_ERR_SFP_NOT_PRESENT;
1291 * ixgbe_identify_sfp_module_generic - Identifies SFP modules
1292 * @hw: pointer to hardware structure
1294 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1296 s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
1298 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1300 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1302 u8 comp_codes_1g = 0;
1303 u8 comp_codes_10g = 0;
1304 u8 oui_bytes[3] = {0, 0, 0};
1307 u16 enforce_sfp = 0;
1309 DEBUGFUNC("ixgbe_identify_sfp_module_generic");
1311 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber) {
1312 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1313 status = IXGBE_ERR_SFP_NOT_PRESENT;
1317 /* LAN ID is needed for I2C access */
1318 hw->mac.ops.set_lan_id(hw);
1320 status = hw->phy.ops.read_i2c_eeprom(hw,
1321 IXGBE_SFF_IDENTIFIER,
1324 if (status != IXGBE_SUCCESS)
1325 goto err_read_i2c_eeprom;
1327 if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
1328 hw->phy.type = ixgbe_phy_sfp_unsupported;
1329 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1331 status = hw->phy.ops.read_i2c_eeprom(hw,
1332 IXGBE_SFF_1GBE_COMP_CODES,
1335 if (status != IXGBE_SUCCESS)
1336 goto err_read_i2c_eeprom;
1338 status = hw->phy.ops.read_i2c_eeprom(hw,
1339 IXGBE_SFF_10GBE_COMP_CODES,
1342 if (status != IXGBE_SUCCESS)
1343 goto err_read_i2c_eeprom;
1344 status = hw->phy.ops.read_i2c_eeprom(hw,
1345 IXGBE_SFF_CABLE_TECHNOLOGY,
1348 if (status != IXGBE_SUCCESS)
1349 goto err_read_i2c_eeprom;
1356 * 3 SFP_DA_CORE0 - 82599-specific
1357 * 4 SFP_DA_CORE1 - 82599-specific
1358 * 5 SFP_SR/LR_CORE0 - 82599-specific
1359 * 6 SFP_SR/LR_CORE1 - 82599-specific
1360 * 7 SFP_act_lmt_DA_CORE0 - 82599-specific
1361 * 8 SFP_act_lmt_DA_CORE1 - 82599-specific
1362 * 9 SFP_1g_cu_CORE0 - 82599-specific
1363 * 10 SFP_1g_cu_CORE1 - 82599-specific
1364 * 11 SFP_1g_sx_CORE0 - 82599-specific
1365 * 12 SFP_1g_sx_CORE1 - 82599-specific
1367 if (hw->mac.type == ixgbe_mac_82598EB) {
1368 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1369 hw->phy.sfp_type = ixgbe_sfp_type_da_cu;
1370 else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1371 hw->phy.sfp_type = ixgbe_sfp_type_sr;
1372 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1373 hw->phy.sfp_type = ixgbe_sfp_type_lr;
1375 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1377 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) {
1378 if (hw->bus.lan_id == 0)
1380 ixgbe_sfp_type_da_cu_core0;
1383 ixgbe_sfp_type_da_cu_core1;
1384 } else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) {
1385 hw->phy.ops.read_i2c_eeprom(
1386 hw, IXGBE_SFF_CABLE_SPEC_COMP,
1389 IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING) {
1390 if (hw->bus.lan_id == 0)
1392 ixgbe_sfp_type_da_act_lmt_core0;
1395 ixgbe_sfp_type_da_act_lmt_core1;
1398 ixgbe_sfp_type_unknown;
1400 } else if (comp_codes_10g &
1401 (IXGBE_SFF_10GBASESR_CAPABLE |
1402 IXGBE_SFF_10GBASELR_CAPABLE)) {
1403 if (hw->bus.lan_id == 0)
1405 ixgbe_sfp_type_srlr_core0;
1408 ixgbe_sfp_type_srlr_core1;
1409 } else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {
1410 if (hw->bus.lan_id == 0)
1412 ixgbe_sfp_type_1g_cu_core0;
1415 ixgbe_sfp_type_1g_cu_core1;
1416 } else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) {
1417 if (hw->bus.lan_id == 0)
1419 ixgbe_sfp_type_1g_sx_core0;
1422 ixgbe_sfp_type_1g_sx_core1;
1423 } else if (comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) {
1424 if (hw->bus.lan_id == 0)
1426 ixgbe_sfp_type_1g_lx_core0;
1429 ixgbe_sfp_type_1g_lx_core1;
1431 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1435 if (hw->phy.sfp_type != stored_sfp_type)
1436 hw->phy.sfp_setup_needed = TRUE;
1438 /* Determine if the SFP+ PHY is dual speed or not. */
1439 hw->phy.multispeed_fiber = FALSE;
1440 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1441 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1442 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1443 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1444 hw->phy.multispeed_fiber = TRUE;
1446 /* Determine PHY vendor */
1447 if (hw->phy.type != ixgbe_phy_nl) {
1448 hw->phy.id = identifier;
1449 status = hw->phy.ops.read_i2c_eeprom(hw,
1450 IXGBE_SFF_VENDOR_OUI_BYTE0,
1453 if (status != IXGBE_SUCCESS)
1454 goto err_read_i2c_eeprom;
1456 status = hw->phy.ops.read_i2c_eeprom(hw,
1457 IXGBE_SFF_VENDOR_OUI_BYTE1,
1460 if (status != IXGBE_SUCCESS)
1461 goto err_read_i2c_eeprom;
1463 status = hw->phy.ops.read_i2c_eeprom(hw,
1464 IXGBE_SFF_VENDOR_OUI_BYTE2,
1467 if (status != IXGBE_SUCCESS)
1468 goto err_read_i2c_eeprom;
1471 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1472 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1473 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1475 switch (vendor_oui) {
1476 case IXGBE_SFF_VENDOR_OUI_TYCO:
1477 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1479 ixgbe_phy_sfp_passive_tyco;
1481 case IXGBE_SFF_VENDOR_OUI_FTL:
1482 if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1483 hw->phy.type = ixgbe_phy_sfp_ftl_active;
1485 hw->phy.type = ixgbe_phy_sfp_ftl;
1487 case IXGBE_SFF_VENDOR_OUI_AVAGO:
1488 hw->phy.type = ixgbe_phy_sfp_avago;
1490 case IXGBE_SFF_VENDOR_OUI_INTEL:
1491 hw->phy.type = ixgbe_phy_sfp_intel;
1494 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1496 ixgbe_phy_sfp_passive_unknown;
1497 else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1499 ixgbe_phy_sfp_active_unknown;
1501 hw->phy.type = ixgbe_phy_sfp_unknown;
1506 /* Allow any DA cable vendor */
1507 if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE |
1508 IXGBE_SFF_DA_ACTIVE_CABLE)) {
1509 status = IXGBE_SUCCESS;
1513 /* Verify supported 1G SFP modules */
1514 if (comp_codes_10g == 0 &&
1515 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1516 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1517 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1518 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1519 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1520 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1521 hw->phy.type = ixgbe_phy_sfp_unsupported;
1522 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1526 /* Anything else 82598-based is supported */
1527 if (hw->mac.type == ixgbe_mac_82598EB) {
1528 status = IXGBE_SUCCESS;
1532 ixgbe_get_device_caps(hw, &enforce_sfp);
1533 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP) &&
1534 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1535 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1536 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1537 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1538 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1539 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1540 /* Make sure we're a supported PHY type */
1541 if (hw->phy.type == ixgbe_phy_sfp_intel) {
1542 status = IXGBE_SUCCESS;
1544 if (hw->allow_unsupported_sfp == TRUE) {
1545 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");
1546 status = IXGBE_SUCCESS;
1548 DEBUGOUT("SFP+ module not supported\n");
1550 ixgbe_phy_sfp_unsupported;
1551 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1555 status = IXGBE_SUCCESS;
1562 err_read_i2c_eeprom:
1563 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1564 if (hw->phy.type != ixgbe_phy_nl) {
1566 hw->phy.type = ixgbe_phy_unknown;
1568 return IXGBE_ERR_SFP_NOT_PRESENT;
1572 * ixgbe_get_supported_phy_sfp_layer_generic - Returns physical layer type
1573 * @hw: pointer to hardware structure
1575 * Determines physical layer capabilities of the current SFP.
1577 u64 ixgbe_get_supported_phy_sfp_layer_generic(struct ixgbe_hw *hw)
1579 u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1580 u8 comp_codes_10g = 0;
1581 u8 comp_codes_1g = 0;
1583 DEBUGFUNC("ixgbe_get_supported_phy_sfp_layer_generic");
1585 hw->phy.ops.identify_sfp(hw);
1586 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1587 return physical_layer;
1589 switch (hw->phy.type) {
1590 case ixgbe_phy_sfp_passive_tyco:
1591 case ixgbe_phy_sfp_passive_unknown:
1592 case ixgbe_phy_qsfp_passive_unknown:
1593 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1595 case ixgbe_phy_sfp_ftl_active:
1596 case ixgbe_phy_sfp_active_unknown:
1597 case ixgbe_phy_qsfp_active_unknown:
1598 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA;
1600 case ixgbe_phy_sfp_avago:
1601 case ixgbe_phy_sfp_ftl:
1602 case ixgbe_phy_sfp_intel:
1603 case ixgbe_phy_sfp_unknown:
1604 hw->phy.ops.read_i2c_eeprom(hw,
1605 IXGBE_SFF_1GBE_COMP_CODES, &comp_codes_1g);
1606 hw->phy.ops.read_i2c_eeprom(hw,
1607 IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
1608 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1609 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1610 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1611 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1612 else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE)
1613 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
1614 else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE)
1615 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_SX;
1617 case ixgbe_phy_qsfp_intel:
1618 case ixgbe_phy_qsfp_unknown:
1619 hw->phy.ops.read_i2c_eeprom(hw,
1620 IXGBE_SFF_QSFP_10GBE_COMP, &comp_codes_10g);
1621 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1622 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1623 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1624 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1630 return physical_layer;
1634 * ixgbe_identify_qsfp_module_generic - Identifies QSFP modules
1635 * @hw: pointer to hardware structure
1637 * Searches for and identifies the QSFP module and assigns appropriate PHY type
1639 s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
1641 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1643 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1645 u8 comp_codes_1g = 0;
1646 u8 comp_codes_10g = 0;
1647 u8 oui_bytes[3] = {0, 0, 0};
1648 u16 enforce_sfp = 0;
1650 u8 cable_length = 0;
1652 bool active_cable = FALSE;
1654 DEBUGFUNC("ixgbe_identify_qsfp_module_generic");
1656 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber_qsfp) {
1657 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1658 status = IXGBE_ERR_SFP_NOT_PRESENT;
1662 /* LAN ID is needed for I2C access */
1663 hw->mac.ops.set_lan_id(hw);
1665 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER,
1668 if (status != IXGBE_SUCCESS)
1669 goto err_read_i2c_eeprom;
1671 if (identifier != IXGBE_SFF_IDENTIFIER_QSFP_PLUS) {
1672 hw->phy.type = ixgbe_phy_sfp_unsupported;
1673 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1677 hw->phy.id = identifier;
1679 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_10GBE_COMP,
1682 if (status != IXGBE_SUCCESS)
1683 goto err_read_i2c_eeprom;
1685 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_1GBE_COMP,
1688 if (status != IXGBE_SUCCESS)
1689 goto err_read_i2c_eeprom;
1691 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_PASSIVE_CABLE) {
1692 hw->phy.type = ixgbe_phy_qsfp_passive_unknown;
1693 if (hw->bus.lan_id == 0)
1694 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core0;
1696 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core1;
1697 } else if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1698 IXGBE_SFF_10GBASELR_CAPABLE)) {
1699 if (hw->bus.lan_id == 0)
1700 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core0;
1702 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core1;
1704 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_ACTIVE_CABLE)
1705 active_cable = TRUE;
1707 if (!active_cable) {
1708 /* check for active DA cables that pre-date
1710 hw->phy.ops.read_i2c_eeprom(hw,
1711 IXGBE_SFF_QSFP_CONNECTOR,
1714 hw->phy.ops.read_i2c_eeprom(hw,
1715 IXGBE_SFF_QSFP_CABLE_LENGTH,
1718 hw->phy.ops.read_i2c_eeprom(hw,
1719 IXGBE_SFF_QSFP_DEVICE_TECH,
1723 IXGBE_SFF_QSFP_CONNECTOR_NOT_SEPARABLE) &&
1724 (cable_length > 0) &&
1725 ((device_tech >> 4) ==
1726 IXGBE_SFF_QSFP_TRANSMITER_850NM_VCSEL))
1727 active_cable = TRUE;
1731 hw->phy.type = ixgbe_phy_qsfp_active_unknown;
1732 if (hw->bus.lan_id == 0)
1734 ixgbe_sfp_type_da_act_lmt_core0;
1737 ixgbe_sfp_type_da_act_lmt_core1;
1739 /* unsupported module type */
1740 hw->phy.type = ixgbe_phy_sfp_unsupported;
1741 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1746 if (hw->phy.sfp_type != stored_sfp_type)
1747 hw->phy.sfp_setup_needed = TRUE;
1749 /* Determine if the QSFP+ PHY is dual speed or not. */
1750 hw->phy.multispeed_fiber = FALSE;
1751 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1752 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1753 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1754 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1755 hw->phy.multispeed_fiber = TRUE;
1757 /* Determine PHY vendor for optical modules */
1758 if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1759 IXGBE_SFF_10GBASELR_CAPABLE)) {
1760 status = hw->phy.ops.read_i2c_eeprom(hw,
1761 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE0,
1764 if (status != IXGBE_SUCCESS)
1765 goto err_read_i2c_eeprom;
1767 status = hw->phy.ops.read_i2c_eeprom(hw,
1768 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE1,
1771 if (status != IXGBE_SUCCESS)
1772 goto err_read_i2c_eeprom;
1774 status = hw->phy.ops.read_i2c_eeprom(hw,
1775 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE2,
1778 if (status != IXGBE_SUCCESS)
1779 goto err_read_i2c_eeprom;
1782 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1783 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1784 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1786 if (vendor_oui == IXGBE_SFF_VENDOR_OUI_INTEL)
1787 hw->phy.type = ixgbe_phy_qsfp_intel;
1789 hw->phy.type = ixgbe_phy_qsfp_unknown;
1791 ixgbe_get_device_caps(hw, &enforce_sfp);
1792 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP)) {
1793 /* Make sure we're a supported PHY type */
1794 if (hw->phy.type == ixgbe_phy_qsfp_intel) {
1795 status = IXGBE_SUCCESS;
1797 if (hw->allow_unsupported_sfp == TRUE) {
1798 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");
1799 status = IXGBE_SUCCESS;
1801 DEBUGOUT("QSFP module not supported\n");
1803 ixgbe_phy_sfp_unsupported;
1804 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1808 status = IXGBE_SUCCESS;
1815 err_read_i2c_eeprom:
1816 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1818 hw->phy.type = ixgbe_phy_unknown;
1820 return IXGBE_ERR_SFP_NOT_PRESENT;
1824 * ixgbe_get_sfp_init_sequence_offsets - Provides offset of PHY init sequence
1825 * @hw: pointer to hardware structure
1826 * @list_offset: offset to the SFP ID list
1827 * @data_offset: offset to the SFP data block
1829 * Checks the MAC's EEPROM to see if it supports a given SFP+ module type, if
1830 * so it returns the offsets to the phy init sequence block.
1832 s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
1837 u16 sfp_type = hw->phy.sfp_type;
1839 DEBUGFUNC("ixgbe_get_sfp_init_sequence_offsets");
1841 if (hw->phy.sfp_type == ixgbe_sfp_type_unknown)
1842 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1844 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1845 return IXGBE_ERR_SFP_NOT_PRESENT;
1847 if ((hw->device_id == IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) &&
1848 (hw->phy.sfp_type == ixgbe_sfp_type_da_cu))
1849 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1852 * Limiting active cables and 1G Phys must be initialized as
1855 if (sfp_type == ixgbe_sfp_type_da_act_lmt_core0 ||
1856 sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1857 sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1858 sfp_type == ixgbe_sfp_type_1g_sx_core0)
1859 sfp_type = ixgbe_sfp_type_srlr_core0;
1860 else if (sfp_type == ixgbe_sfp_type_da_act_lmt_core1 ||
1861 sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1862 sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1863 sfp_type == ixgbe_sfp_type_1g_sx_core1)
1864 sfp_type = ixgbe_sfp_type_srlr_core1;
1866 /* Read offset to PHY init contents */
1867 if (hw->eeprom.ops.read(hw, IXGBE_PHY_INIT_OFFSET_NL, list_offset)) {
1868 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1869 "eeprom read at offset %d failed",
1870 IXGBE_PHY_INIT_OFFSET_NL);
1871 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1874 if ((!*list_offset) || (*list_offset == 0xFFFF))
1875 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1877 /* Shift offset to first ID word */
1881 * Find the matching SFP ID in the EEPROM
1882 * and program the init sequence
1884 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1887 while (sfp_id != IXGBE_PHY_INIT_END_NL) {
1888 if (sfp_id == sfp_type) {
1890 if (hw->eeprom.ops.read(hw, *list_offset, data_offset))
1892 if ((!*data_offset) || (*data_offset == 0xFFFF)) {
1893 DEBUGOUT("SFP+ module not supported\n");
1894 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1899 (*list_offset) += 2;
1900 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1905 if (sfp_id == IXGBE_PHY_INIT_END_NL) {
1906 DEBUGOUT("No matching SFP+ module found\n");
1907 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1910 return IXGBE_SUCCESS;
1913 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1914 "eeprom read at offset %d failed", *list_offset);
1915 return IXGBE_ERR_PHY;
1919 * ixgbe_read_i2c_eeprom_generic - Reads 8 bit EEPROM word over I2C interface
1920 * @hw: pointer to hardware structure
1921 * @byte_offset: EEPROM byte offset to read
1922 * @eeprom_data: value read
1924 * Performs byte read operation to SFP module's EEPROM over I2C interface.
1926 s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1929 DEBUGFUNC("ixgbe_read_i2c_eeprom_generic");
1931 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1932 IXGBE_I2C_EEPROM_DEV_ADDR,
1937 * ixgbe_read_i2c_sff8472_generic - Reads 8 bit word over I2C interface
1938 * @hw: pointer to hardware structure
1939 * @byte_offset: byte offset at address 0xA2
1940 * @eeprom_data: value read
1942 * Performs byte read operation to SFP module's SFF-8472 data over I2C
1944 static s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
1947 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1948 IXGBE_I2C_EEPROM_DEV_ADDR2,
1953 * ixgbe_write_i2c_eeprom_generic - Writes 8 bit EEPROM word over I2C interface
1954 * @hw: pointer to hardware structure
1955 * @byte_offset: EEPROM byte offset to write
1956 * @eeprom_data: value to write
1958 * Performs byte write operation to SFP module's EEPROM over I2C interface.
1960 s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1963 DEBUGFUNC("ixgbe_write_i2c_eeprom_generic");
1965 return hw->phy.ops.write_i2c_byte(hw, byte_offset,
1966 IXGBE_I2C_EEPROM_DEV_ADDR,
1971 * ixgbe_is_sfp_probe - Returns TRUE if SFP is being detected
1972 * @hw: pointer to hardware structure
1973 * @offset: eeprom offset to be read
1974 * @addr: I2C address to be read
1976 static bool ixgbe_is_sfp_probe(struct ixgbe_hw *hw, u8 offset, u8 addr)
1978 if (addr == IXGBE_I2C_EEPROM_DEV_ADDR &&
1979 offset == IXGBE_SFF_IDENTIFIER &&
1980 hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1986 * ixgbe_read_i2c_byte_generic_int - Reads 8 bit word over I2C
1987 * @hw: pointer to hardware structure
1988 * @byte_offset: byte offset to read
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);
2066 if (retry < max_retry)
2067 DEBUGOUT("I2C byte read error - Retrying.\n");
2069 DEBUGOUT("I2C byte read error.\n");
2071 } while (retry < max_retry);
2077 * ixgbe_read_i2c_byte_generic - Reads 8 bit word over I2C
2078 * @hw: pointer to hardware structure
2079 * @byte_offset: byte offset to read
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
2098 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2099 * a specified device address.
2101 s32 ixgbe_read_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2102 u8 dev_addr, u8 *data)
2104 return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2109 * ixgbe_write_i2c_byte_generic_int - Writes 8 bit word over I2C
2110 * @hw: pointer to hardware structure
2111 * @byte_offset: byte offset to write
2112 * @data: value to write
2113 * @lock: TRUE if to take and release semaphore
2115 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2116 * a specified device address.
2118 static s32 ixgbe_write_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
2119 u8 dev_addr, u8 data, bool lock)
2124 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2126 DEBUGFUNC("ixgbe_write_i2c_byte_generic");
2128 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) !=
2130 return IXGBE_ERR_SWFW_SYNC;
2133 ixgbe_i2c_start(hw);
2135 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
2136 if (status != IXGBE_SUCCESS)
2139 status = ixgbe_get_i2c_ack(hw);
2140 if (status != IXGBE_SUCCESS)
2143 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
2144 if (status != IXGBE_SUCCESS)
2147 status = ixgbe_get_i2c_ack(hw);
2148 if (status != IXGBE_SUCCESS)
2151 status = ixgbe_clock_out_i2c_byte(hw, data);
2152 if (status != IXGBE_SUCCESS)
2155 status = ixgbe_get_i2c_ack(hw);
2156 if (status != IXGBE_SUCCESS)
2161 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2162 return IXGBE_SUCCESS;
2165 ixgbe_i2c_bus_clear(hw);
2167 if (retry < max_retry)
2168 DEBUGOUT("I2C byte write error - Retrying.\n");
2170 DEBUGOUT("I2C byte write error.\n");
2171 } while (retry < max_retry);
2174 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2180 * ixgbe_write_i2c_byte_generic - Writes 8 bit word over I2C
2181 * @hw: pointer to hardware structure
2182 * @byte_offset: byte offset to write
2183 * @data: value to write
2185 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2186 * a specified device address.
2188 s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
2189 u8 dev_addr, u8 data)
2191 return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2196 * ixgbe_write_i2c_byte_generic_unlocked - Writes 8 bit word over I2C
2197 * @hw: pointer to hardware structure
2198 * @byte_offset: byte offset to write
2199 * @data: value to write
2201 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2202 * a specified device address.
2204 s32 ixgbe_write_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2205 u8 dev_addr, u8 data)
2207 return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2212 * ixgbe_i2c_start - Sets I2C start condition
2213 * @hw: pointer to hardware structure
2215 * Sets I2C start condition (High -> Low on SDA while SCL is High)
2216 * Set bit-bang mode on X550 hardware.
2218 static void ixgbe_i2c_start(struct ixgbe_hw *hw)
2220 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2222 DEBUGFUNC("ixgbe_i2c_start");
2224 i2cctl |= IXGBE_I2C_BB_EN_BY_MAC(hw);
2226 /* Start condition must begin with data and clock high */
2227 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2228 ixgbe_raise_i2c_clk(hw, &i2cctl);
2230 /* Setup time for start condition (4.7us) */
2231 usec_delay(IXGBE_I2C_T_SU_STA);
2233 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2235 /* Hold time for start condition (4us) */
2236 usec_delay(IXGBE_I2C_T_HD_STA);
2238 ixgbe_lower_i2c_clk(hw, &i2cctl);
2240 /* Minimum low period of clock is 4.7 us */
2241 usec_delay(IXGBE_I2C_T_LOW);
2246 * ixgbe_i2c_stop - Sets I2C stop condition
2247 * @hw: pointer to hardware structure
2249 * Sets I2C stop condition (Low -> High on SDA while SCL is High)
2250 * Disables bit-bang mode and negates data output enable on X550
2253 static void ixgbe_i2c_stop(struct ixgbe_hw *hw)
2255 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2256 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2257 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2258 u32 bb_en_bit = IXGBE_I2C_BB_EN_BY_MAC(hw);
2260 DEBUGFUNC("ixgbe_i2c_stop");
2262 /* Stop condition must begin with data low and clock high */
2263 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2264 ixgbe_raise_i2c_clk(hw, &i2cctl);
2266 /* Setup time for stop condition (4us) */
2267 usec_delay(IXGBE_I2C_T_SU_STO);
2269 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2271 /* bus free time between stop and start (4.7us)*/
2272 usec_delay(IXGBE_I2C_T_BUF);
2274 if (bb_en_bit || data_oe_bit || clk_oe_bit) {
2275 i2cctl &= ~bb_en_bit;
2276 i2cctl |= data_oe_bit | clk_oe_bit;
2277 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2278 IXGBE_WRITE_FLUSH(hw);
2283 * ixgbe_clock_in_i2c_byte - Clocks in one byte via I2C
2284 * @hw: pointer to hardware structure
2285 * @data: data byte to clock in
2287 * Clocks in one byte data via I2C data/clock
2289 static s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data)
2294 DEBUGFUNC("ixgbe_clock_in_i2c_byte");
2297 for (i = 7; i >= 0; i--) {
2298 ixgbe_clock_in_i2c_bit(hw, &bit);
2302 return IXGBE_SUCCESS;
2306 * ixgbe_clock_out_i2c_byte - Clocks out one byte via I2C
2307 * @hw: pointer to hardware structure
2308 * @data: data byte clocked out
2310 * Clocks out one byte data via I2C data/clock
2312 static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data)
2314 s32 status = IXGBE_SUCCESS;
2319 DEBUGFUNC("ixgbe_clock_out_i2c_byte");
2321 for (i = 7; i >= 0; i--) {
2322 bit = (data >> i) & 0x1;
2323 status = ixgbe_clock_out_i2c_bit(hw, bit);
2325 if (status != IXGBE_SUCCESS)
2329 /* Release SDA line (set high) */
2330 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2331 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2332 i2cctl |= IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2333 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2334 IXGBE_WRITE_FLUSH(hw);
2340 * ixgbe_get_i2c_ack - Polls for I2C ACK
2341 * @hw: pointer to hardware structure
2343 * Clocks in/out one bit via I2C data/clock
2345 static s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw)
2347 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2348 s32 status = IXGBE_SUCCESS;
2350 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2354 DEBUGFUNC("ixgbe_get_i2c_ack");
2357 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2358 i2cctl |= data_oe_bit;
2359 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2360 IXGBE_WRITE_FLUSH(hw);
2362 ixgbe_raise_i2c_clk(hw, &i2cctl);
2364 /* Minimum high period of clock is 4us */
2365 usec_delay(IXGBE_I2C_T_HIGH);
2367 /* Poll for ACK. Note that ACK in I2C spec is
2368 * transition from 1 to 0 */
2369 for (i = 0; i < timeout; i++) {
2370 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2371 ack = ixgbe_get_i2c_data(hw, &i2cctl);
2379 DEBUGOUT("I2C ack was not received.\n");
2380 status = IXGBE_ERR_I2C;
2383 ixgbe_lower_i2c_clk(hw, &i2cctl);
2385 /* Minimum low period of clock is 4.7 us */
2386 usec_delay(IXGBE_I2C_T_LOW);
2392 * ixgbe_clock_in_i2c_bit - Clocks in one bit via I2C data/clock
2393 * @hw: pointer to hardware structure
2394 * @data: read data value
2396 * Clocks in one bit via I2C data/clock
2398 static s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data)
2400 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2401 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2403 DEBUGFUNC("ixgbe_clock_in_i2c_bit");
2406 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2407 i2cctl |= data_oe_bit;
2408 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2409 IXGBE_WRITE_FLUSH(hw);
2411 ixgbe_raise_i2c_clk(hw, &i2cctl);
2413 /* Minimum high period of clock is 4us */
2414 usec_delay(IXGBE_I2C_T_HIGH);
2416 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2417 *data = ixgbe_get_i2c_data(hw, &i2cctl);
2419 ixgbe_lower_i2c_clk(hw, &i2cctl);
2421 /* Minimum low period of clock is 4.7 us */
2422 usec_delay(IXGBE_I2C_T_LOW);
2424 return IXGBE_SUCCESS;
2428 * ixgbe_clock_out_i2c_bit - Clocks in/out one bit via I2C data/clock
2429 * @hw: pointer to hardware structure
2430 * @data: data value to write
2432 * Clocks out one bit via I2C data/clock
2434 static s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data)
2437 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2439 DEBUGFUNC("ixgbe_clock_out_i2c_bit");
2441 status = ixgbe_set_i2c_data(hw, &i2cctl, data);
2442 if (status == IXGBE_SUCCESS) {
2443 ixgbe_raise_i2c_clk(hw, &i2cctl);
2445 /* Minimum high period of clock is 4us */
2446 usec_delay(IXGBE_I2C_T_HIGH);
2448 ixgbe_lower_i2c_clk(hw, &i2cctl);
2450 /* Minimum low period of clock is 4.7 us.
2451 * This also takes care of the data hold time.
2453 usec_delay(IXGBE_I2C_T_LOW);
2455 status = IXGBE_ERR_I2C;
2456 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2457 "I2C data was not set to %X\n", data);
2464 * ixgbe_raise_i2c_clk - Raises the I2C SCL clock
2465 * @hw: pointer to hardware structure
2466 * @i2cctl: Current value of I2CCTL register
2468 * Raises the I2C clock line '0'->'1'
2469 * Negates the I2C clock output enable on X550 hardware.
2471 static void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2473 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2475 u32 timeout = IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT;
2478 DEBUGFUNC("ixgbe_raise_i2c_clk");
2481 *i2cctl |= clk_oe_bit;
2482 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2485 for (i = 0; i < timeout; i++) {
2486 *i2cctl |= IXGBE_I2C_CLK_OUT_BY_MAC(hw);
2488 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2489 IXGBE_WRITE_FLUSH(hw);
2490 /* SCL rise time (1000ns) */
2491 usec_delay(IXGBE_I2C_T_RISE);
2493 i2cctl_r = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2494 if (i2cctl_r & IXGBE_I2C_CLK_IN_BY_MAC(hw))
2500 * ixgbe_lower_i2c_clk - Lowers the I2C SCL clock
2501 * @hw: pointer to hardware structure
2502 * @i2cctl: Current value of I2CCTL register
2504 * Lowers the I2C clock line '1'->'0'
2505 * Asserts the I2C clock output enable on X550 hardware.
2507 static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2509 DEBUGFUNC("ixgbe_lower_i2c_clk");
2511 *i2cctl &= ~(IXGBE_I2C_CLK_OUT_BY_MAC(hw));
2512 *i2cctl &= ~IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2514 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2515 IXGBE_WRITE_FLUSH(hw);
2517 /* SCL fall time (300ns) */
2518 usec_delay(IXGBE_I2C_T_FALL);
2522 * ixgbe_set_i2c_data - Sets the I2C data bit
2523 * @hw: pointer to hardware structure
2524 * @i2cctl: Current value of I2CCTL register
2525 * @data: I2C data value (0 or 1) to set
2527 * Sets the I2C data bit
2528 * Asserts the I2C data output enable on X550 hardware.
2530 static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data)
2532 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2533 s32 status = IXGBE_SUCCESS;
2535 DEBUGFUNC("ixgbe_set_i2c_data");
2538 *i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2540 *i2cctl &= ~(IXGBE_I2C_DATA_OUT_BY_MAC(hw));
2541 *i2cctl &= ~data_oe_bit;
2543 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2544 IXGBE_WRITE_FLUSH(hw);
2546 /* Data rise/fall (1000ns/300ns) and set-up time (250ns) */
2547 usec_delay(IXGBE_I2C_T_RISE + IXGBE_I2C_T_FALL + IXGBE_I2C_T_SU_DATA);
2549 if (!data) /* Can't verify data in this case */
2550 return IXGBE_SUCCESS;
2552 *i2cctl |= data_oe_bit;
2553 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2554 IXGBE_WRITE_FLUSH(hw);
2557 /* Verify data was set correctly */
2558 *i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2559 if (data != ixgbe_get_i2c_data(hw, i2cctl)) {
2560 status = IXGBE_ERR_I2C;
2561 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2562 "Error - I2C data was not set to %X.\n",
2570 * ixgbe_get_i2c_data - Reads the I2C SDA data bit
2571 * @hw: pointer to hardware structure
2572 * @i2cctl: Current value of I2CCTL register
2574 * Returns the I2C data bit value
2575 * Negates the I2C data output enable on X550 hardware.
2577 static bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl)
2579 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2582 DEBUGFUNC("ixgbe_get_i2c_data");
2585 *i2cctl |= data_oe_bit;
2586 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2587 IXGBE_WRITE_FLUSH(hw);
2588 usec_delay(IXGBE_I2C_T_FALL);
2591 if (*i2cctl & IXGBE_I2C_DATA_IN_BY_MAC(hw))
2600 * ixgbe_i2c_bus_clear - Clears the I2C bus
2601 * @hw: pointer to hardware structure
2603 * Clears the I2C bus by sending nine clock pulses.
2604 * Used when data line is stuck low.
2606 void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw)
2611 DEBUGFUNC("ixgbe_i2c_bus_clear");
2613 ixgbe_i2c_start(hw);
2614 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2616 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2618 for (i = 0; i < 9; i++) {
2619 ixgbe_raise_i2c_clk(hw, &i2cctl);
2621 /* Min high period of clock is 4us */
2622 usec_delay(IXGBE_I2C_T_HIGH);
2624 ixgbe_lower_i2c_clk(hw, &i2cctl);
2626 /* Min low period of clock is 4.7us*/
2627 usec_delay(IXGBE_I2C_T_LOW);
2630 ixgbe_i2c_start(hw);
2632 /* Put the i2c bus back to default state */
2637 * ixgbe_tn_check_overtemp - Checks if an overtemp occurred.
2638 * @hw: pointer to hardware structure
2640 * Checks if the LASI temp alarm status was triggered due to overtemp
2642 s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
2644 s32 status = IXGBE_SUCCESS;
2647 DEBUGFUNC("ixgbe_tn_check_overtemp");
2649 if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
2652 /* Check that the LASI temp alarm status was triggered */
2653 hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
2654 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_data);
2656 if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))
2659 status = IXGBE_ERR_OVERTEMP;
2660 ERROR_REPORT1(IXGBE_ERROR_CAUTION, "Device over temperature");
2666 * ixgbe_set_copper_phy_power - Control power for copper phy
2667 * @hw: pointer to hardware structure
2668 * @on: TRUE for on, FALSE for off
2670 s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on)
2675 if (!on && ixgbe_mng_present(hw))
2678 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2679 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2685 reg &= ~IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2687 if (ixgbe_check_reset_blocked(hw))
2689 reg |= IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2692 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2693 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,