1 /*******************************************************************************
3 Copyright (c) 2001-2012, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ***************************************************************************/
34 #include "ixgbe_api.h"
35 #include "ixgbe_common.h"
36 #include "ixgbe_phy.h"
37 #ident "$Id: ixgbe_phy.c,v 1.139 2012/05/24 23:36:12 jtkirshe Exp $"
39 STATIC void ixgbe_i2c_start(struct ixgbe_hw *hw);
40 STATIC void ixgbe_i2c_stop(struct ixgbe_hw *hw);
41 STATIC s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data);
42 STATIC s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data);
43 STATIC s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw);
44 STATIC s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data);
45 STATIC s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data);
46 STATIC void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl);
47 STATIC void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl);
48 STATIC s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data);
49 STATIC bool ixgbe_get_i2c_data(u32 *i2cctl);
50 STATIC s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
54 * ixgbe_init_phy_ops_generic - Inits PHY function ptrs
55 * @hw: pointer to the hardware structure
57 * Initialize the function pointers.
59 s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw)
61 struct ixgbe_phy_info *phy = &hw->phy;
63 DEBUGFUNC("ixgbe_init_phy_ops_generic");
66 phy->ops.identify = &ixgbe_identify_phy_generic;
67 phy->ops.reset = &ixgbe_reset_phy_generic;
68 phy->ops.read_reg = &ixgbe_read_phy_reg_generic;
69 phy->ops.write_reg = &ixgbe_write_phy_reg_generic;
70 phy->ops.read_reg_mdi = &ixgbe_read_phy_reg_mdi;
71 phy->ops.write_reg_mdi = &ixgbe_write_phy_reg_mdi;
72 phy->ops.setup_link = &ixgbe_setup_phy_link_generic;
73 phy->ops.setup_link_speed = &ixgbe_setup_phy_link_speed_generic;
74 phy->ops.check_link = NULL;
75 phy->ops.get_firmware_version = ixgbe_get_phy_firmware_version_generic;
76 phy->ops.read_i2c_byte = &ixgbe_read_i2c_byte_generic;
77 phy->ops.write_i2c_byte = &ixgbe_write_i2c_byte_generic;
78 phy->ops.read_i2c_sff8472 = &ixgbe_read_i2c_sff8472_generic;
79 phy->ops.read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic;
80 phy->ops.write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic;
81 phy->ops.i2c_bus_clear = &ixgbe_i2c_bus_clear;
82 phy->ops.identify_sfp = &ixgbe_identify_module_generic;
83 phy->sfp_type = ixgbe_sfp_type_unknown;
84 phy->ops.check_overtemp = &ixgbe_tn_check_overtemp;
89 * ixgbe_identify_phy_generic - Get physical layer module
90 * @hw: pointer to hardware structure
92 * Determines the physical layer module found on the current adapter.
94 s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
96 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
100 DEBUGFUNC("ixgbe_identify_phy_generic");
102 if (hw->phy.type == ixgbe_phy_unknown) {
103 for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
104 if (ixgbe_validate_phy_addr(hw, phy_addr)) {
105 hw->phy.addr = phy_addr;
106 ixgbe_get_phy_id(hw);
108 ixgbe_get_phy_type_from_id(hw->phy.id);
110 if (hw->phy.type == ixgbe_phy_unknown) {
111 hw->phy.ops.read_reg(hw,
112 IXGBE_MDIO_PHY_EXT_ABILITY,
113 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
116 (IXGBE_MDIO_PHY_10GBASET_ABILITY |
117 IXGBE_MDIO_PHY_1000BASET_ABILITY))
119 ixgbe_phy_cu_unknown;
125 status = IXGBE_SUCCESS;
130 /* Certain media types do not have a phy so an address will not
131 * be found and the code will take this path. Caller has to
132 * decide if it is an error or not.
134 if (status != IXGBE_SUCCESS) {
138 status = IXGBE_SUCCESS;
145 * ixgbe_check_reset_blocked - check status of MNG FW veto bit
146 * @hw: pointer to the hardware structure
148 * This function checks the MMNGC.MNG_VETO bit to see if there are
149 * any constraints on link from manageability. For MAC's that don't
150 * have this bit just return faluse since the link can not be blocked
153 s32 ixgbe_check_reset_blocked(struct ixgbe_hw *hw)
157 DEBUGFUNC("ixgbe_check_reset_blocked");
159 /* If we don't have this bit, it can't be blocking */
160 if (hw->mac.type == ixgbe_mac_82598EB)
163 mmngc = IXGBE_READ_REG(hw, IXGBE_MMNGC);
164 if (mmngc & IXGBE_MMNGC_MNG_VETO) {
165 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE,
166 "MNG_VETO bit detected.\n");
174 * ixgbe_validate_phy_addr - Determines phy address is valid
175 * @hw: pointer to hardware structure
178 bool ixgbe_validate_phy_addr(struct ixgbe_hw *hw, u32 phy_addr)
183 DEBUGFUNC("ixgbe_validate_phy_addr");
185 hw->phy.addr = phy_addr;
186 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
187 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_id);
189 if (phy_id != 0xFFFF && phy_id != 0x0)
196 * ixgbe_get_phy_id - Get the phy type
197 * @hw: pointer to hardware structure
200 s32 ixgbe_get_phy_id(struct ixgbe_hw *hw)
206 DEBUGFUNC("ixgbe_get_phy_id");
208 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
209 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
212 if (status == IXGBE_SUCCESS) {
213 hw->phy.id = (u32)(phy_id_high << 16);
214 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
215 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
217 hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK);
218 hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK);
224 * ixgbe_get_phy_type_from_id - Get the phy type
225 * @hw: pointer to hardware structure
228 enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
230 enum ixgbe_phy_type phy_type;
232 DEBUGFUNC("ixgbe_get_phy_type_from_id");
236 phy_type = ixgbe_phy_tn;
239 phy_type = ixgbe_phy_aq;
242 phy_type = ixgbe_phy_qt;
245 phy_type = ixgbe_phy_nl;
248 phy_type = ixgbe_phy_unknown;
252 DEBUGOUT1("phy type found is %d\n", phy_type);
257 * ixgbe_reset_phy_generic - Performs a PHY reset
258 * @hw: pointer to hardware structure
260 s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
264 s32 status = IXGBE_SUCCESS;
266 DEBUGFUNC("ixgbe_reset_phy_generic");
268 if (hw->phy.type == ixgbe_phy_unknown)
269 status = ixgbe_identify_phy_generic(hw);
271 if (status != IXGBE_SUCCESS || hw->phy.type == ixgbe_phy_none)
274 /* Don't reset PHY if it's shut down due to overtemp. */
275 if (!hw->phy.reset_if_overtemp &&
276 (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
279 /* Blocked by MNG FW so bail */
280 if (ixgbe_check_reset_blocked(hw))
284 * Perform soft PHY reset to the PHY_XS.
285 * This will cause a soft reset to the PHY
287 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
288 IXGBE_MDIO_PHY_XS_DEV_TYPE,
289 IXGBE_MDIO_PHY_XS_RESET);
292 * Poll for reset bit to self-clear indicating reset is complete.
293 * Some PHYs could take up to 3 seconds to complete and need about
294 * 1.7 usec delay after the reset is complete.
296 for (i = 0; i < 30; i++) {
298 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
299 IXGBE_MDIO_PHY_XS_DEV_TYPE, &ctrl);
300 if (!(ctrl & IXGBE_MDIO_PHY_XS_RESET)) {
306 if (ctrl & IXGBE_MDIO_PHY_XS_RESET) {
307 status = IXGBE_ERR_RESET_FAILED;
308 ERROR_REPORT1(IXGBE_ERROR_POLLING,
309 "PHY reset polling failed to complete.\n");
317 * ixgbe_read_phy_mdi - Reads a value from a specified PHY register without
319 * @hw: pointer to hardware structure
320 * @reg_addr: 32 bit address of PHY register to read
321 * @phy_data: Pointer to read data from PHY register
323 s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
326 u32 i, data, command;
328 /* Setup and write the address cycle command */
329 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
330 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
331 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
332 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
334 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
337 * Check every 10 usec to see if the address cycle completed.
338 * The MDI Command bit will clear when the operation is
341 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
344 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
345 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
350 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
351 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address command did not complete.\n");
352 return IXGBE_ERR_PHY;
356 * Address cycle complete, setup and write the read
359 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
360 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
361 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
362 (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND));
364 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
367 * Check every 10 usec to see if the address cycle
368 * completed. The MDI Command bit will clear when the
369 * operation is complete
371 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
374 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
375 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
379 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
380 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY read command didn't complete\n");
381 return IXGBE_ERR_PHY;
385 * Read operation is complete. Get the data
388 data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
389 data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
390 *phy_data = (u16)(data);
392 return IXGBE_SUCCESS;
396 * ixgbe_read_phy_reg_generic - Reads a value from a specified PHY register
397 * using the SWFW lock - this function is needed in most cases
398 * @hw: pointer to hardware structure
399 * @reg_addr: 32 bit address of PHY register to read
400 * @phy_data: Pointer to read data from PHY register
402 s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
403 u32 device_type, u16 *phy_data)
408 DEBUGFUNC("ixgbe_read_phy_reg_generic");
410 if (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)
411 gssr = IXGBE_GSSR_PHY1_SM;
413 gssr = IXGBE_GSSR_PHY0_SM;
415 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
416 status = ixgbe_read_phy_reg_mdi(hw, reg_addr, device_type,
418 hw->mac.ops.release_swfw_sync(hw, gssr);
420 status = IXGBE_ERR_SWFW_SYNC;
427 * ixgbe_write_phy_reg_mdi - Writes a value to specified PHY register
429 * @hw: pointer to hardware structure
430 * @reg_addr: 32 bit PHY register to write
431 * @device_type: 5 bit device type
432 * @phy_data: Data to write to the PHY register
434 s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,
435 u32 device_type, u16 phy_data)
439 /* Put the data in the MDI single read and write data register*/
440 IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
442 /* Setup and write the address cycle command */
443 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
444 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
445 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
446 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
448 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
451 * Check every 10 usec to see if the address cycle completed.
452 * The MDI Command bit will clear when the operation is
455 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
458 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
459 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
463 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
464 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address cmd didn't complete\n");
465 return IXGBE_ERR_PHY;
469 * Address cycle complete, setup and write the write
472 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
473 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
474 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
475 (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND));
477 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
480 * Check every 10 usec to see if the address cycle
481 * completed. The MDI Command bit will clear when the
482 * operation is complete
484 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
487 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
488 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
492 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
493 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY write cmd didn't complete\n");
494 return IXGBE_ERR_PHY;
497 return IXGBE_SUCCESS;
501 * ixgbe_write_phy_reg_generic - Writes a value to specified PHY register
502 * using SWFW lock- this function is needed in most cases
503 * @hw: pointer to hardware structure
504 * @reg_addr: 32 bit PHY register to write
505 * @device_type: 5 bit device type
506 * @phy_data: Data to write to the PHY register
508 s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
509 u32 device_type, u16 phy_data)
514 DEBUGFUNC("ixgbe_write_phy_reg_generic");
516 if (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)
517 gssr = IXGBE_GSSR_PHY1_SM;
519 gssr = IXGBE_GSSR_PHY0_SM;
521 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
522 status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type,
524 hw->mac.ops.release_swfw_sync(hw, gssr);
526 status = IXGBE_ERR_SWFW_SYNC;
533 * ixgbe_setup_phy_link_generic - Set and restart autoneg
534 * @hw: pointer to hardware structure
536 * Restart autonegotiation and PHY and waits for completion.
538 s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
540 s32 status = IXGBE_SUCCESS;
542 u32 max_time_out = 10;
543 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
544 bool autoneg = false;
545 ixgbe_link_speed speed;
547 DEBUGFUNC("ixgbe_setup_phy_link_generic");
549 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
551 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
552 /* Set or unset auto-negotiation 10G advertisement */
553 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
554 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
557 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
558 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
559 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
561 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
562 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
566 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
567 /* Set or unset auto-negotiation 1G advertisement */
568 hw->phy.ops.read_reg(hw,
569 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
570 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
573 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE;
574 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
575 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE;
577 hw->phy.ops.write_reg(hw,
578 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
579 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
583 if (speed & IXGBE_LINK_SPEED_100_FULL) {
584 /* Set or unset auto-negotiation 100M advertisement */
585 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
586 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
589 autoneg_reg &= ~(IXGBE_MII_100BASE_T_ADVERTISE |
590 IXGBE_MII_100BASE_T_ADVERTISE_HALF);
591 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
592 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
594 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
595 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
599 /* Blocked by MNG FW so don't reset PHY */
600 if (ixgbe_check_reset_blocked(hw))
603 /* Restart PHY autonegotiation and wait for completion */
604 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
605 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
607 autoneg_reg |= IXGBE_MII_RESTART;
609 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
610 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
612 /* Wait for autonegotiation to finish */
613 for (time_out = 0; time_out < max_time_out; time_out++) {
615 /* Restart PHY autonegotiation and wait for completion */
616 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
617 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
620 autoneg_reg &= IXGBE_MII_AUTONEG_COMPLETE;
621 if (autoneg_reg == IXGBE_MII_AUTONEG_COMPLETE)
625 if (time_out == max_time_out) {
626 status = IXGBE_ERR_LINK_SETUP;
627 ERROR_REPORT1(IXGBE_ERROR_POLLING,
628 "PHY autonegotiation time out");
635 * ixgbe_setup_phy_link_speed_generic - Sets the auto advertised capabilities
636 * @hw: pointer to hardware structure
637 * @speed: new link speed
639 s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
640 ixgbe_link_speed speed,
641 bool autoneg_wait_to_complete)
643 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
645 DEBUGFUNC("ixgbe_setup_phy_link_speed_generic");
648 * Clear autoneg_advertised and set new values based on input link
651 hw->phy.autoneg_advertised = 0;
653 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
654 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
656 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
657 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
659 if (speed & IXGBE_LINK_SPEED_100_FULL)
660 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
662 /* Setup link based on the new speed settings */
663 hw->phy.ops.setup_link(hw);
665 return IXGBE_SUCCESS;
669 * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
670 * @hw: pointer to hardware structure
671 * @speed: pointer to link speed
672 * @autoneg: boolean auto-negotiation value
674 * Determines the link capabilities by reading the AUTOC register.
676 s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
677 ixgbe_link_speed *speed,
683 DEBUGFUNC("ixgbe_get_copper_link_capabilities_generic");
688 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
689 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
692 if (status == IXGBE_SUCCESS) {
693 if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
694 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
695 if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
696 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
697 if (speed_ability & IXGBE_MDIO_PHY_SPEED_100M)
698 *speed |= IXGBE_LINK_SPEED_100_FULL;
705 * ixgbe_check_phy_link_tnx - Determine link and speed status
706 * @hw: pointer to hardware structure
708 * Reads the VS1 register to determine if link is up and the current speed for
711 s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
714 s32 status = IXGBE_SUCCESS;
716 u32 max_time_out = 10;
721 DEBUGFUNC("ixgbe_check_phy_link_tnx");
723 /* Initialize speed and link to default case */
725 *speed = IXGBE_LINK_SPEED_10GB_FULL;
728 * Check current speed and link status of the PHY register.
729 * This is a vendor specific register and may have to
730 * be changed for other copper PHYs.
732 for (time_out = 0; time_out < max_time_out; time_out++) {
734 status = hw->phy.ops.read_reg(hw,
735 IXGBE_MDIO_VENDOR_SPECIFIC_1_STATUS,
736 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
738 phy_link = phy_data & IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS;
739 phy_speed = phy_data &
740 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS;
741 if (phy_link == IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS) {
744 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS)
745 *speed = IXGBE_LINK_SPEED_1GB_FULL;
754 * ixgbe_setup_phy_link_tnx - Set and restart autoneg
755 * @hw: pointer to hardware structure
757 * Restart autonegotiation and PHY and waits for completion.
759 s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
761 s32 status = IXGBE_SUCCESS;
763 u32 max_time_out = 10;
764 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
765 bool autoneg = false;
766 ixgbe_link_speed speed;
768 DEBUGFUNC("ixgbe_setup_phy_link_tnx");
770 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
772 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
773 /* Set or unset auto-negotiation 10G advertisement */
774 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
775 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
778 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
779 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
780 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
782 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
783 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
787 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
788 /* Set or unset auto-negotiation 1G advertisement */
789 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
790 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
793 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
794 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
795 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
797 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
798 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
802 if (speed & IXGBE_LINK_SPEED_100_FULL) {
803 /* Set or unset auto-negotiation 100M advertisement */
804 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
805 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
808 autoneg_reg &= ~IXGBE_MII_100BASE_T_ADVERTISE;
809 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
810 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
812 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
813 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
817 /* Blocked by MNG FW so don't reset PHY */
818 if (ixgbe_check_reset_blocked(hw))
821 /* Restart PHY autonegotiation and wait for completion */
822 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
823 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
825 autoneg_reg |= IXGBE_MII_RESTART;
827 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
828 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
830 /* Wait for autonegotiation to finish */
831 for (time_out = 0; time_out < max_time_out; time_out++) {
833 /* Restart PHY autonegotiation and wait for completion */
834 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
835 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
838 autoneg_reg &= IXGBE_MII_AUTONEG_COMPLETE;
839 if (autoneg_reg == IXGBE_MII_AUTONEG_COMPLETE)
843 if (time_out == max_time_out) {
844 status = IXGBE_ERR_LINK_SETUP;
845 DEBUGOUT("ixgbe_setup_phy_link_tnx: time out");
852 * ixgbe_get_phy_firmware_version_tnx - Gets the PHY Firmware Version
853 * @hw: pointer to hardware structure
854 * @firmware_version: pointer to the PHY Firmware Version
856 s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
857 u16 *firmware_version)
861 DEBUGFUNC("ixgbe_get_phy_firmware_version_tnx");
863 status = hw->phy.ops.read_reg(hw, TNX_FW_REV,
864 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
871 * ixgbe_get_phy_firmware_version_generic - Gets the PHY Firmware Version
872 * @hw: pointer to hardware structure
873 * @firmware_version: pointer to the PHY Firmware Version
875 s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
876 u16 *firmware_version)
880 DEBUGFUNC("ixgbe_get_phy_firmware_version_generic");
882 status = hw->phy.ops.read_reg(hw, AQ_FW_REV,
883 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
890 * ixgbe_reset_phy_nl - Performs a PHY reset
891 * @hw: pointer to hardware structure
893 s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
895 u16 phy_offset, control, eword, edata, block_crc;
896 bool end_data = false;
897 u16 list_offset, data_offset;
899 s32 ret_val = IXGBE_SUCCESS;
902 DEBUGFUNC("ixgbe_reset_phy_nl");
904 /* Blocked by MNG FW so bail */
905 if (ixgbe_check_reset_blocked(hw))
908 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
909 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
911 /* reset the PHY and poll for completion */
912 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
913 IXGBE_MDIO_PHY_XS_DEV_TYPE,
914 (phy_data | IXGBE_MDIO_PHY_XS_RESET));
916 for (i = 0; i < 100; i++) {
917 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
918 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
919 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) == 0)
924 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) != 0) {
925 DEBUGOUT("PHY reset did not complete.\n");
926 ret_val = IXGBE_ERR_PHY;
930 /* Get init offsets */
931 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
933 if (ret_val != IXGBE_SUCCESS)
936 ret_val = hw->eeprom.ops.read(hw, data_offset, &block_crc);
940 * Read control word from PHY init contents offset
942 ret_val = hw->eeprom.ops.read(hw, data_offset, &eword);
945 control = (eword & IXGBE_CONTROL_MASK_NL) >>
946 IXGBE_CONTROL_SHIFT_NL;
947 edata = eword & IXGBE_DATA_MASK_NL;
951 DEBUGOUT1("DELAY: %d MS\n", edata);
957 ret_val = hw->eeprom.ops.read(hw, data_offset,
962 for (i = 0; i < edata; i++) {
963 ret_val = hw->eeprom.ops.read(hw, data_offset,
967 hw->phy.ops.write_reg(hw, phy_offset,
968 IXGBE_TWINAX_DEV, eword);
969 DEBUGOUT2("Wrote %4.4x to %4.4x\n", eword,
975 case IXGBE_CONTROL_NL:
977 DEBUGOUT("CONTROL:\n");
978 if (edata == IXGBE_CONTROL_EOL_NL) {
981 } else if (edata == IXGBE_CONTROL_SOL_NL) {
984 DEBUGOUT("Bad control value\n");
985 ret_val = IXGBE_ERR_PHY;
990 DEBUGOUT("Bad control type\n");
991 ret_val = IXGBE_ERR_PHY;
1000 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1001 "eeprom read at offset %d failed", data_offset);
1002 return IXGBE_ERR_PHY;
1006 * ixgbe_identify_module_generic - Identifies module type
1007 * @hw: pointer to hardware structure
1009 * Determines HW type and calls appropriate function.
1011 s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw)
1013 s32 status = IXGBE_ERR_SFP_NOT_PRESENT;
1015 DEBUGFUNC("ixgbe_identify_module_generic");
1017 switch (hw->mac.ops.get_media_type(hw)) {
1018 case ixgbe_media_type_fiber:
1019 status = ixgbe_identify_sfp_module_generic(hw);
1024 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1025 status = IXGBE_ERR_SFP_NOT_PRESENT;
1033 * ixgbe_identify_sfp_module_generic - Identifies SFP modules
1034 * @hw: pointer to hardware structure
1036 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1038 s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
1040 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1042 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1044 u8 comp_codes_1g = 0;
1045 u8 comp_codes_10g = 0;
1046 u8 oui_bytes[3] = {0, 0, 0};
1049 u16 enforce_sfp = 0;
1051 DEBUGFUNC("ixgbe_identify_sfp_module_generic");
1053 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber) {
1054 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1055 status = IXGBE_ERR_SFP_NOT_PRESENT;
1059 status = hw->phy.ops.read_i2c_eeprom(hw,
1060 IXGBE_SFF_IDENTIFIER,
1063 if (status != IXGBE_SUCCESS)
1064 goto err_read_i2c_eeprom;
1066 /* LAN ID is needed for sfp_type determination */
1067 hw->mac.ops.set_lan_id(hw);
1069 if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
1070 hw->phy.type = ixgbe_phy_sfp_unsupported;
1071 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1073 status = hw->phy.ops.read_i2c_eeprom(hw,
1074 IXGBE_SFF_1GBE_COMP_CODES,
1077 if (status != IXGBE_SUCCESS)
1078 goto err_read_i2c_eeprom;
1080 status = hw->phy.ops.read_i2c_eeprom(hw,
1081 IXGBE_SFF_10GBE_COMP_CODES,
1084 if (status != IXGBE_SUCCESS)
1085 goto err_read_i2c_eeprom;
1086 status = hw->phy.ops.read_i2c_eeprom(hw,
1087 IXGBE_SFF_CABLE_TECHNOLOGY,
1090 if (status != IXGBE_SUCCESS)
1091 goto err_read_i2c_eeprom;
1098 * 3 SFP_DA_CORE0 - 82599-specific
1099 * 4 SFP_DA_CORE1 - 82599-specific
1100 * 5 SFP_SR/LR_CORE0 - 82599-specific
1101 * 6 SFP_SR/LR_CORE1 - 82599-specific
1102 * 7 SFP_act_lmt_DA_CORE0 - 82599-specific
1103 * 8 SFP_act_lmt_DA_CORE1 - 82599-specific
1104 * 9 SFP_1g_cu_CORE0 - 82599-specific
1105 * 10 SFP_1g_cu_CORE1 - 82599-specific
1106 * 11 SFP_1g_sx_CORE0 - 82599-specific
1107 * 12 SFP_1g_sx_CORE1 - 82599-specific
1109 if (hw->mac.type == ixgbe_mac_82598EB) {
1110 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1111 hw->phy.sfp_type = ixgbe_sfp_type_da_cu;
1112 else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1113 hw->phy.sfp_type = ixgbe_sfp_type_sr;
1114 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1115 hw->phy.sfp_type = ixgbe_sfp_type_lr;
1117 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1118 } else if (hw->mac.type == ixgbe_mac_82599EB) {
1119 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) {
1120 if (hw->bus.lan_id == 0)
1122 ixgbe_sfp_type_da_cu_core0;
1125 ixgbe_sfp_type_da_cu_core1;
1126 } else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) {
1127 hw->phy.ops.read_i2c_eeprom(
1128 hw, IXGBE_SFF_CABLE_SPEC_COMP,
1131 IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING) {
1132 if (hw->bus.lan_id == 0)
1134 ixgbe_sfp_type_da_act_lmt_core0;
1137 ixgbe_sfp_type_da_act_lmt_core1;
1140 ixgbe_sfp_type_unknown;
1142 } else if (comp_codes_10g &
1143 (IXGBE_SFF_10GBASESR_CAPABLE |
1144 IXGBE_SFF_10GBASELR_CAPABLE)) {
1145 if (hw->bus.lan_id == 0)
1147 ixgbe_sfp_type_srlr_core0;
1150 ixgbe_sfp_type_srlr_core1;
1151 #ifdef SUPPORT_10GBASE_ER
1152 } else if (comp_codes_10g &
1153 IXGBE_SFF_10GBASEER_CAPABLE) {
1154 if (hw->bus.lan_id == 0)
1156 ixgbe_sfp_type_er_core0;
1159 ixgbe_sfp_type_er_core1;
1160 #endif /* SUPPORT_10GBASE_ER */
1161 } else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {
1162 if (hw->bus.lan_id == 0)
1164 ixgbe_sfp_type_1g_cu_core0;
1167 ixgbe_sfp_type_1g_cu_core1;
1168 } else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) {
1169 if (hw->bus.lan_id == 0)
1171 ixgbe_sfp_type_1g_sx_core0;
1174 ixgbe_sfp_type_1g_sx_core1;
1175 #ifdef SUPPORT_1000BASE_LX
1176 } else if (comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) {
1177 if (hw->bus.lan_id == 0)
1179 ixgbe_sfp_type_1g_lx_core0;
1182 ixgbe_sfp_type_1g_lx_core1;
1183 #endif /* SUPPORT_1000BASE_LX */
1185 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1189 if (hw->phy.sfp_type != stored_sfp_type)
1190 hw->phy.sfp_setup_needed = true;
1192 /* Determine if the SFP+ PHY is dual speed or not. */
1193 hw->phy.multispeed_fiber = false;
1194 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1195 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1196 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1197 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1198 hw->phy.multispeed_fiber = true;
1200 /* Determine PHY vendor */
1201 if (hw->phy.type != ixgbe_phy_nl) {
1202 hw->phy.id = identifier;
1203 status = hw->phy.ops.read_i2c_eeprom(hw,
1204 IXGBE_SFF_VENDOR_OUI_BYTE0,
1207 if (status != IXGBE_SUCCESS)
1208 goto err_read_i2c_eeprom;
1210 status = hw->phy.ops.read_i2c_eeprom(hw,
1211 IXGBE_SFF_VENDOR_OUI_BYTE1,
1214 if (status != IXGBE_SUCCESS)
1215 goto err_read_i2c_eeprom;
1217 status = hw->phy.ops.read_i2c_eeprom(hw,
1218 IXGBE_SFF_VENDOR_OUI_BYTE2,
1221 if (status != IXGBE_SUCCESS)
1222 goto err_read_i2c_eeprom;
1225 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1226 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1227 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1229 switch (vendor_oui) {
1230 case IXGBE_SFF_VENDOR_OUI_TYCO:
1231 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1233 ixgbe_phy_sfp_passive_tyco;
1235 case IXGBE_SFF_VENDOR_OUI_FTL:
1236 if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1237 hw->phy.type = ixgbe_phy_sfp_ftl_active;
1239 hw->phy.type = ixgbe_phy_sfp_ftl;
1241 case IXGBE_SFF_VENDOR_OUI_AVAGO:
1242 hw->phy.type = ixgbe_phy_sfp_avago;
1244 case IXGBE_SFF_VENDOR_OUI_INTEL:
1245 hw->phy.type = ixgbe_phy_sfp_intel;
1248 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1250 ixgbe_phy_sfp_passive_unknown;
1251 else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1253 ixgbe_phy_sfp_active_unknown;
1255 hw->phy.type = ixgbe_phy_sfp_unknown;
1260 /* Allow any DA cable vendor */
1261 if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE |
1262 IXGBE_SFF_DA_ACTIVE_CABLE)) {
1263 status = IXGBE_SUCCESS;
1267 /* Verify supported 1G SFP modules */
1268 if (comp_codes_10g == 0 &&
1269 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1270 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1271 #ifdef SUPPORT_1000BASE_LX
1272 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1273 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1275 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1276 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1277 hw->phy.type = ixgbe_phy_sfp_unsupported;
1278 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1282 /* Anything else 82598-based is supported */
1283 if (hw->mac.type == ixgbe_mac_82598EB) {
1284 status = IXGBE_SUCCESS;
1288 ixgbe_get_device_caps(hw, &enforce_sfp);
1289 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP) &&
1290 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1291 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1292 #ifdef SUPPORT_1000BASE_LX
1293 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1294 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1296 #ifdef SUPPORT_10GBASE_ER
1297 hw->phy.sfp_type == ixgbe_sfp_type_er_core0 ||
1298 hw->phy.sfp_type == ixgbe_sfp_type_er_core1 ||
1300 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1301 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1302 /* Make sure we're a supported PHY type */
1303 if (hw->phy.type == ixgbe_phy_sfp_intel) {
1304 status = IXGBE_SUCCESS;
1306 if (hw->allow_unsupported_sfp == true) {
1307 EWARN(hw, "WARNING: Intel (R) Network "
1308 "Connections are quality tested "
1309 "using Intel (R) Ethernet Optics."
1310 " Using untested modules is not "
1311 "supported and may cause unstable"
1312 " operation or damage to the "
1313 "module or the adapter. Intel "
1314 "Corporation is not responsible "
1315 "for any harm caused by using "
1316 "untested modules.\n", status);
1317 status = IXGBE_SUCCESS;
1319 DEBUGOUT("SFP+ module not supported\n");
1321 ixgbe_phy_sfp_unsupported;
1322 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1326 status = IXGBE_SUCCESS;
1333 err_read_i2c_eeprom:
1334 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1335 if (hw->phy.type != ixgbe_phy_nl) {
1337 hw->phy.type = ixgbe_phy_unknown;
1339 return IXGBE_ERR_SFP_NOT_PRESENT;
1345 * ixgbe_get_sfp_init_sequence_offsets - Provides offset of PHY init sequence
1346 * @hw: pointer to hardware structure
1347 * @list_offset: offset to the SFP ID list
1348 * @data_offset: offset to the SFP data block
1350 * Checks the MAC's EEPROM to see if it supports a given SFP+ module type, if
1351 * so it returns the offsets to the phy init sequence block.
1353 s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
1358 u16 sfp_type = hw->phy.sfp_type;
1360 DEBUGFUNC("ixgbe_get_sfp_init_sequence_offsets");
1362 if (hw->phy.sfp_type == ixgbe_sfp_type_unknown)
1363 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1365 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1366 return IXGBE_ERR_SFP_NOT_PRESENT;
1368 if ((hw->device_id == IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) &&
1369 (hw->phy.sfp_type == ixgbe_sfp_type_da_cu))
1370 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1373 * Limiting active cables and 1G Phys must be initialized as
1376 if (sfp_type == ixgbe_sfp_type_da_act_lmt_core0 ||
1377 #ifdef SUPPORT_10GBASE_ER
1378 sfp_type == ixgbe_sfp_type_er_core0 ||
1379 #endif /* SUPPORT_10GBASE_ER */
1380 #ifdef SUPPORT_1000BASE_LX
1381 sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1382 #endif /* SUPPORT_1000BASE_LX */
1383 sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1384 sfp_type == ixgbe_sfp_type_1g_sx_core0)
1385 sfp_type = ixgbe_sfp_type_srlr_core0;
1386 else if (sfp_type == ixgbe_sfp_type_da_act_lmt_core1 ||
1387 #ifdef SUPPORT_10GBASE_ER
1388 sfp_type == ixgbe_sfp_type_er_core1 ||
1389 #endif /* SUPPORT_10GBASE_ER */
1390 #ifdef SUPPORT_1000BASE_LX
1391 sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1392 #endif /* SUPPORT_1000BASE_LX */
1393 sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1394 sfp_type == ixgbe_sfp_type_1g_sx_core1)
1395 sfp_type = ixgbe_sfp_type_srlr_core1;
1397 /* Read offset to PHY init contents */
1398 if (hw->eeprom.ops.read(hw, IXGBE_PHY_INIT_OFFSET_NL, list_offset)) {
1399 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1400 "eeprom read at offset %d failed",
1401 IXGBE_PHY_INIT_OFFSET_NL);
1402 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1405 if ((!*list_offset) || (*list_offset == 0xFFFF))
1406 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1408 /* Shift offset to first ID word */
1412 * Find the matching SFP ID in the EEPROM
1413 * and program the init sequence
1415 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1418 while (sfp_id != IXGBE_PHY_INIT_END_NL) {
1419 if (sfp_id == sfp_type) {
1421 if (hw->eeprom.ops.read(hw, *list_offset, data_offset))
1423 if ((!*data_offset) || (*data_offset == 0xFFFF)) {
1424 DEBUGOUT("SFP+ module not supported\n");
1425 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1430 (*list_offset) += 2;
1431 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1436 if (sfp_id == IXGBE_PHY_INIT_END_NL) {
1437 DEBUGOUT("No matching SFP+ module found\n");
1438 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1441 return IXGBE_SUCCESS;
1444 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1445 "eeprom read at offset %d failed", *list_offset);
1446 return IXGBE_ERR_PHY;
1450 * ixgbe_read_i2c_eeprom_generic - Reads 8 bit EEPROM word over I2C interface
1451 * @hw: pointer to hardware structure
1452 * @byte_offset: EEPROM byte offset to read
1453 * @eeprom_data: value read
1455 * Performs byte read operation to SFP module's EEPROM over I2C interface.
1457 s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1460 DEBUGFUNC("ixgbe_read_i2c_eeprom_generic");
1462 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1463 IXGBE_I2C_EEPROM_DEV_ADDR,
1468 * ixgbe_read_i2c_sff8472_generic - Reads 8 bit word over I2C interface
1469 * @hw: pointer to hardware structure
1470 * @byte_offset: byte offset at address 0xA2
1471 * @eeprom_data: value read
1473 * Performs byte read operation to SFP module's SFF-8472 data over I2C
1475 STATIC s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
1478 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1479 IXGBE_I2C_EEPROM_DEV_ADDR2,
1484 * ixgbe_write_i2c_eeprom_generic - Writes 8 bit EEPROM word over I2C interface
1485 * @hw: pointer to hardware structure
1486 * @byte_offset: EEPROM byte offset to write
1487 * @eeprom_data: value to write
1489 * Performs byte write operation to SFP module's EEPROM over I2C interface.
1491 s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1494 DEBUGFUNC("ixgbe_write_i2c_eeprom_generic");
1496 return hw->phy.ops.write_i2c_byte(hw, byte_offset,
1497 IXGBE_I2C_EEPROM_DEV_ADDR,
1502 * ixgbe_read_i2c_byte_generic - Reads 8 bit word over I2C
1503 * @hw: pointer to hardware structure
1504 * @byte_offset: byte offset to read
1507 * Performs byte read operation to SFP module's EEPROM over I2C interface at
1508 * a specified device address.
1510 s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
1511 u8 dev_addr, u8 *data)
1513 s32 status = IXGBE_SUCCESS;
1520 DEBUGFUNC("ixgbe_read_i2c_byte_generic");
1522 if (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)
1523 swfw_mask = IXGBE_GSSR_PHY1_SM;
1525 swfw_mask = IXGBE_GSSR_PHY0_SM;
1528 if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask)
1530 status = IXGBE_ERR_SWFW_SYNC;
1534 ixgbe_i2c_start(hw);
1536 /* Device Address and write indication */
1537 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
1538 if (status != IXGBE_SUCCESS)
1541 status = ixgbe_get_i2c_ack(hw);
1542 if (status != IXGBE_SUCCESS)
1545 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
1546 if (status != IXGBE_SUCCESS)
1549 status = ixgbe_get_i2c_ack(hw);
1550 if (status != IXGBE_SUCCESS)
1553 ixgbe_i2c_start(hw);
1555 /* Device Address and read indication */
1556 status = ixgbe_clock_out_i2c_byte(hw, (dev_addr | 0x1));
1557 if (status != IXGBE_SUCCESS)
1560 status = ixgbe_get_i2c_ack(hw);
1561 if (status != IXGBE_SUCCESS)
1564 status = ixgbe_clock_in_i2c_byte(hw, data);
1565 if (status != IXGBE_SUCCESS)
1568 status = ixgbe_clock_out_i2c_bit(hw, nack);
1569 if (status != IXGBE_SUCCESS)
1576 ixgbe_i2c_bus_clear(hw);
1577 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
1580 if (retry < max_retry)
1581 DEBUGOUT("I2C byte read error - Retrying.\n");
1583 DEBUGOUT("I2C byte read error.\n");
1585 } while (retry < max_retry);
1587 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
1594 * ixgbe_write_i2c_byte_generic - Writes 8 bit word over I2C
1595 * @hw: pointer to hardware structure
1596 * @byte_offset: byte offset to write
1597 * @data: value to write
1599 * Performs byte write operation to SFP module's EEPROM over I2C interface at
1600 * a specified device address.
1602 s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
1603 u8 dev_addr, u8 data)
1605 s32 status = IXGBE_SUCCESS;
1610 DEBUGFUNC("ixgbe_write_i2c_byte_generic");
1612 if (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)
1613 swfw_mask = IXGBE_GSSR_PHY1_SM;
1615 swfw_mask = IXGBE_GSSR_PHY0_SM;
1617 if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) != IXGBE_SUCCESS) {
1618 status = IXGBE_ERR_SWFW_SYNC;
1619 goto write_byte_out;
1623 ixgbe_i2c_start(hw);
1625 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
1626 if (status != IXGBE_SUCCESS)
1629 status = ixgbe_get_i2c_ack(hw);
1630 if (status != IXGBE_SUCCESS)
1633 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
1634 if (status != IXGBE_SUCCESS)
1637 status = ixgbe_get_i2c_ack(hw);
1638 if (status != IXGBE_SUCCESS)
1641 status = ixgbe_clock_out_i2c_byte(hw, data);
1642 if (status != IXGBE_SUCCESS)
1645 status = ixgbe_get_i2c_ack(hw);
1646 if (status != IXGBE_SUCCESS)
1653 ixgbe_i2c_bus_clear(hw);
1655 if (retry < max_retry)
1656 DEBUGOUT("I2C byte write error - Retrying.\n");
1658 DEBUGOUT("I2C byte write error.\n");
1659 } while (retry < max_retry);
1661 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
1668 * ixgbe_i2c_start - Sets I2C start condition
1669 * @hw: pointer to hardware structure
1671 * Sets I2C start condition (High -> Low on SDA while SCL is High)
1673 STATIC void ixgbe_i2c_start(struct ixgbe_hw *hw)
1675 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
1677 DEBUGFUNC("ixgbe_i2c_start");
1679 /* Start condition must begin with data and clock high */
1680 ixgbe_set_i2c_data(hw, &i2cctl, 1);
1681 ixgbe_raise_i2c_clk(hw, &i2cctl);
1683 /* Setup time for start condition (4.7us) */
1684 usec_delay(IXGBE_I2C_T_SU_STA);
1686 ixgbe_set_i2c_data(hw, &i2cctl, 0);
1688 /* Hold time for start condition (4us) */
1689 usec_delay(IXGBE_I2C_T_HD_STA);
1691 ixgbe_lower_i2c_clk(hw, &i2cctl);
1693 /* Minimum low period of clock is 4.7 us */
1694 usec_delay(IXGBE_I2C_T_LOW);
1699 * ixgbe_i2c_stop - Sets I2C stop condition
1700 * @hw: pointer to hardware structure
1702 * Sets I2C stop condition (Low -> High on SDA while SCL is High)
1704 STATIC void ixgbe_i2c_stop(struct ixgbe_hw *hw)
1706 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
1708 DEBUGFUNC("ixgbe_i2c_stop");
1710 /* Stop condition must begin with data low and clock high */
1711 ixgbe_set_i2c_data(hw, &i2cctl, 0);
1712 ixgbe_raise_i2c_clk(hw, &i2cctl);
1714 /* Setup time for stop condition (4us) */
1715 usec_delay(IXGBE_I2C_T_SU_STO);
1717 ixgbe_set_i2c_data(hw, &i2cctl, 1);
1719 /* bus free time between stop and start (4.7us)*/
1720 usec_delay(IXGBE_I2C_T_BUF);
1724 * ixgbe_clock_in_i2c_byte - Clocks in one byte via I2C
1725 * @hw: pointer to hardware structure
1726 * @data: data byte to clock in
1728 * Clocks in one byte data via I2C data/clock
1730 STATIC s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data)
1735 DEBUGFUNC("ixgbe_clock_in_i2c_byte");
1737 for (i = 7; i >= 0; i--) {
1738 ixgbe_clock_in_i2c_bit(hw, &bit);
1742 return IXGBE_SUCCESS;
1746 * ixgbe_clock_out_i2c_byte - Clocks out one byte via I2C
1747 * @hw: pointer to hardware structure
1748 * @data: data byte clocked out
1750 * Clocks out one byte data via I2C data/clock
1752 STATIC s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data)
1754 s32 status = IXGBE_SUCCESS;
1759 DEBUGFUNC("ixgbe_clock_out_i2c_byte");
1761 for (i = 7; i >= 0; i--) {
1762 bit = (data >> i) & 0x1;
1763 status = ixgbe_clock_out_i2c_bit(hw, bit);
1765 if (status != IXGBE_SUCCESS)
1769 /* Release SDA line (set high) */
1770 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
1771 i2cctl |= IXGBE_I2C_DATA_OUT;
1772 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL, i2cctl);
1773 IXGBE_WRITE_FLUSH(hw);
1779 * ixgbe_get_i2c_ack - Polls for I2C ACK
1780 * @hw: pointer to hardware structure
1782 * Clocks in/out one bit via I2C data/clock
1784 STATIC s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw)
1786 s32 status = IXGBE_SUCCESS;
1788 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
1792 DEBUGFUNC("ixgbe_get_i2c_ack");
1794 ixgbe_raise_i2c_clk(hw, &i2cctl);
1797 /* Minimum high period of clock is 4us */
1798 usec_delay(IXGBE_I2C_T_HIGH);
1800 /* Poll for ACK. Note that ACK in I2C spec is
1801 * transition from 1 to 0 */
1802 for (i = 0; i < timeout; i++) {
1803 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
1804 ack = ixgbe_get_i2c_data(&i2cctl);
1812 ERROR_REPORT1(IXGBE_ERROR_POLLING,
1813 "I2C ack was not received.\n");
1814 status = IXGBE_ERR_I2C;
1817 ixgbe_lower_i2c_clk(hw, &i2cctl);
1819 /* Minimum low period of clock is 4.7 us */
1820 usec_delay(IXGBE_I2C_T_LOW);
1826 * ixgbe_clock_in_i2c_bit - Clocks in one bit via I2C data/clock
1827 * @hw: pointer to hardware structure
1828 * @data: read data value
1830 * Clocks in one bit via I2C data/clock
1832 STATIC s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data)
1834 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
1836 DEBUGFUNC("ixgbe_clock_in_i2c_bit");
1838 ixgbe_raise_i2c_clk(hw, &i2cctl);
1840 /* Minimum high period of clock is 4us */
1841 usec_delay(IXGBE_I2C_T_HIGH);
1843 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
1844 *data = ixgbe_get_i2c_data(&i2cctl);
1846 ixgbe_lower_i2c_clk(hw, &i2cctl);
1848 /* Minimum low period of clock is 4.7 us */
1849 usec_delay(IXGBE_I2C_T_LOW);
1851 return IXGBE_SUCCESS;
1855 * ixgbe_clock_out_i2c_bit - Clocks in/out one bit via I2C data/clock
1856 * @hw: pointer to hardware structure
1857 * @data: data value to write
1859 * Clocks out one bit via I2C data/clock
1861 STATIC s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data)
1864 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
1866 DEBUGFUNC("ixgbe_clock_out_i2c_bit");
1868 status = ixgbe_set_i2c_data(hw, &i2cctl, data);
1869 if (status == IXGBE_SUCCESS) {
1870 ixgbe_raise_i2c_clk(hw, &i2cctl);
1872 /* Minimum high period of clock is 4us */
1873 usec_delay(IXGBE_I2C_T_HIGH);
1875 ixgbe_lower_i2c_clk(hw, &i2cctl);
1877 /* Minimum low period of clock is 4.7 us.
1878 * This also takes care of the data hold time.
1880 usec_delay(IXGBE_I2C_T_LOW);
1882 status = IXGBE_ERR_I2C;
1883 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1884 "I2C data was not set to %X\n", data);
1890 * ixgbe_raise_i2c_clk - Raises the I2C SCL clock
1891 * @hw: pointer to hardware structure
1892 * @i2cctl: Current value of I2CCTL register
1894 * Raises the I2C clock line '0'->'1'
1896 STATIC void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
1899 u32 timeout = IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT;
1902 DEBUGFUNC("ixgbe_raise_i2c_clk");
1904 for (i = 0; i < timeout; i++) {
1905 *i2cctl |= IXGBE_I2C_CLK_OUT;
1907 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL, *i2cctl);
1908 IXGBE_WRITE_FLUSH(hw);
1909 /* SCL rise time (1000ns) */
1910 usec_delay(IXGBE_I2C_T_RISE);
1912 i2cctl_r = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
1913 if (i2cctl_r & IXGBE_I2C_CLK_IN)
1919 * ixgbe_lower_i2c_clk - Lowers the I2C SCL clock
1920 * @hw: pointer to hardware structure
1921 * @i2cctl: Current value of I2CCTL register
1923 * Lowers the I2C clock line '1'->'0'
1925 STATIC void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
1928 DEBUGFUNC("ixgbe_lower_i2c_clk");
1930 *i2cctl &= ~IXGBE_I2C_CLK_OUT;
1932 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL, *i2cctl);
1933 IXGBE_WRITE_FLUSH(hw);
1935 /* SCL fall time (300ns) */
1936 usec_delay(IXGBE_I2C_T_FALL);
1940 * ixgbe_set_i2c_data - Sets the I2C data bit
1941 * @hw: pointer to hardware structure
1942 * @i2cctl: Current value of I2CCTL register
1943 * @data: I2C data value (0 or 1) to set
1945 * Sets the I2C data bit
1947 STATIC s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data)
1949 s32 status = IXGBE_SUCCESS;
1951 DEBUGFUNC("ixgbe_set_i2c_data");
1954 *i2cctl |= IXGBE_I2C_DATA_OUT;
1956 *i2cctl &= ~IXGBE_I2C_DATA_OUT;
1958 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL, *i2cctl);
1959 IXGBE_WRITE_FLUSH(hw);
1961 /* Data rise/fall (1000ns/300ns) and set-up time (250ns) */
1962 usec_delay(IXGBE_I2C_T_RISE + IXGBE_I2C_T_FALL + IXGBE_I2C_T_SU_DATA);
1964 /* Verify data was set correctly */
1965 *i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
1966 if (data != ixgbe_get_i2c_data(i2cctl)) {
1967 status = IXGBE_ERR_I2C;
1968 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1969 "Error - I2C data was not set to %X.\n",
1977 * ixgbe_get_i2c_data - Reads the I2C SDA data bit
1978 * @hw: pointer to hardware structure
1979 * @i2cctl: Current value of I2CCTL register
1981 * Returns the I2C data bit value
1983 STATIC bool ixgbe_get_i2c_data(u32 *i2cctl)
1987 DEBUGFUNC("ixgbe_get_i2c_data");
1989 if (*i2cctl & IXGBE_I2C_DATA_IN)
1998 * ixgbe_i2c_bus_clear - Clears the I2C bus
1999 * @hw: pointer to hardware structure
2001 * Clears the I2C bus by sending nine clock pulses.
2002 * Used when data line is stuck low.
2004 void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw)
2006 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL);
2009 DEBUGFUNC("ixgbe_i2c_bus_clear");
2011 ixgbe_i2c_start(hw);
2013 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2015 for (i = 0; i < 9; i++) {
2016 ixgbe_raise_i2c_clk(hw, &i2cctl);
2018 /* Min high period of clock is 4us */
2019 usec_delay(IXGBE_I2C_T_HIGH);
2021 ixgbe_lower_i2c_clk(hw, &i2cctl);
2023 /* Min low period of clock is 4.7us*/
2024 usec_delay(IXGBE_I2C_T_LOW);
2027 ixgbe_i2c_start(hw);
2029 /* Put the i2c bus back to default state */
2034 * ixgbe_tn_check_overtemp - Checks if an overtemp occurred.
2035 * @hw: pointer to hardware structure
2037 * Checks if the LASI temp alarm status was triggered due to overtemp
2039 s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
2041 s32 status = IXGBE_SUCCESS;
2044 DEBUGFUNC("ixgbe_tn_check_overtemp");
2046 if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
2049 /* Check that the LASI temp alarm status was triggered */
2050 hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
2051 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_data);
2053 if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))
2056 status = IXGBE_ERR_OVERTEMP;
2057 ERROR_REPORT1(IXGBE_ERROR_CAUTION, "Device over temperature");