1 /******************************************************************************
3 Copyright (c) 2001-2017, 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 ******************************************************************************/
35 #include "ixgbe_api.h"
36 #include "ixgbe_common.h"
37 #include "ixgbe_phy.h"
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(struct ixgbe_hw *hw, u32 *i2cctl);
50 static s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
54 * ixgbe_out_i2c_byte_ack - Send I2C byte with ack
55 * @hw: pointer to the hardware structure
58 * Returns an error code on error.
60 static s32 ixgbe_out_i2c_byte_ack(struct ixgbe_hw *hw, u8 byte)
64 status = ixgbe_clock_out_i2c_byte(hw, byte);
67 return ixgbe_get_i2c_ack(hw);
71 * ixgbe_in_i2c_byte_ack - Receive an I2C byte and send ack
72 * @hw: pointer to the hardware structure
73 * @byte: pointer to a u8 to receive the byte
75 * Returns an error code on error.
77 static s32 ixgbe_in_i2c_byte_ack(struct ixgbe_hw *hw, u8 *byte)
81 status = ixgbe_clock_in_i2c_byte(hw, byte);
85 return ixgbe_clock_out_i2c_bit(hw, FALSE);
89 * ixgbe_ones_comp_byte_add - Perform one's complement addition
93 * Returns one's complement 8-bit sum.
95 static u8 ixgbe_ones_comp_byte_add(u8 add1, u8 add2)
97 u16 sum = add1 + add2;
99 sum = (sum & 0xFF) + (sum >> 8);
104 * ixgbe_read_i2c_combined_generic_int - Perform I2C read combined operation
105 * @hw: pointer to the hardware structure
106 * @addr: I2C bus address to read from
107 * @reg: I2C device register to read from
108 * @val: pointer to location to receive read value
109 * @lock: TRUE if to take and release semaphore
111 * Returns an error code on error.
113 s32 ixgbe_read_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr, u16 reg,
116 u32 swfw_mask = hw->phy.phy_semaphore_mask;
125 reg_high = ((reg >> 7) & 0xFE) | 1; /* Indicate read combined */
126 csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
129 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
130 return IXGBE_ERR_SWFW_SYNC;
132 /* Device Address and write indication */
133 if (ixgbe_out_i2c_byte_ack(hw, addr))
135 /* Write bits 14:8 */
136 if (ixgbe_out_i2c_byte_ack(hw, reg_high))
139 if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
142 if (ixgbe_out_i2c_byte_ack(hw, csum))
144 /* Re-start condition */
146 /* Device Address and read indication */
147 if (ixgbe_out_i2c_byte_ack(hw, addr | 1))
150 if (ixgbe_in_i2c_byte_ack(hw, &high_bits))
153 if (ixgbe_in_i2c_byte_ack(hw, &low_bits))
156 if (ixgbe_clock_in_i2c_byte(hw, &csum_byte))
159 if (ixgbe_clock_out_i2c_bit(hw, FALSE))
163 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
164 *val = (high_bits << 8) | low_bits;
168 ixgbe_i2c_bus_clear(hw);
170 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
172 if (retry < max_retry)
173 DEBUGOUT("I2C byte read combined error - Retrying.\n");
175 DEBUGOUT("I2C byte read combined error.\n");
176 } while (retry < max_retry);
178 return IXGBE_ERR_I2C;
182 * ixgbe_write_i2c_combined_generic_int - Perform I2C write combined operation
183 * @hw: pointer to the hardware structure
184 * @addr: I2C bus address to write to
185 * @reg: I2C device register to write to
186 * @val: value to write
187 * @lock: TRUE if to take and release semaphore
189 * Returns an error code on error.
191 s32 ixgbe_write_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr, u16 reg,
194 u32 swfw_mask = hw->phy.phy_semaphore_mask;
200 reg_high = (reg >> 7) & 0xFE; /* Indicate write combined */
201 csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
202 csum = ixgbe_ones_comp_byte_add(csum, val >> 8);
203 csum = ixgbe_ones_comp_byte_add(csum, val & 0xFF);
206 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
207 return IXGBE_ERR_SWFW_SYNC;
209 /* Device Address and write indication */
210 if (ixgbe_out_i2c_byte_ack(hw, addr))
212 /* Write bits 14:8 */
213 if (ixgbe_out_i2c_byte_ack(hw, reg_high))
216 if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
218 /* Write data 15:8 */
219 if (ixgbe_out_i2c_byte_ack(hw, val >> 8))
222 if (ixgbe_out_i2c_byte_ack(hw, val & 0xFF))
225 if (ixgbe_out_i2c_byte_ack(hw, csum))
229 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
233 ixgbe_i2c_bus_clear(hw);
235 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
237 if (retry < max_retry)
238 DEBUGOUT("I2C byte write combined error - Retrying.\n");
240 DEBUGOUT("I2C byte write combined error.\n");
241 } while (retry < max_retry);
243 return IXGBE_ERR_I2C;
247 * ixgbe_init_phy_ops_generic - Inits PHY function ptrs
248 * @hw: pointer to the hardware structure
250 * Initialize the function pointers.
252 s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw)
254 struct ixgbe_phy_info *phy = &hw->phy;
256 DEBUGFUNC("ixgbe_init_phy_ops_generic");
259 phy->ops.identify = ixgbe_identify_phy_generic;
260 phy->ops.reset = ixgbe_reset_phy_generic;
261 phy->ops.read_reg = ixgbe_read_phy_reg_generic;
262 phy->ops.write_reg = ixgbe_write_phy_reg_generic;
263 phy->ops.read_reg_mdi = ixgbe_read_phy_reg_mdi;
264 phy->ops.write_reg_mdi = ixgbe_write_phy_reg_mdi;
265 phy->ops.setup_link = ixgbe_setup_phy_link_generic;
266 phy->ops.setup_link_speed = ixgbe_setup_phy_link_speed_generic;
267 phy->ops.check_link = NULL;
268 phy->ops.get_firmware_version = ixgbe_get_phy_firmware_version_generic;
269 phy->ops.read_i2c_byte = ixgbe_read_i2c_byte_generic;
270 phy->ops.write_i2c_byte = ixgbe_write_i2c_byte_generic;
271 phy->ops.read_i2c_sff8472 = ixgbe_read_i2c_sff8472_generic;
272 phy->ops.read_i2c_eeprom = ixgbe_read_i2c_eeprom_generic;
273 phy->ops.write_i2c_eeprom = ixgbe_write_i2c_eeprom_generic;
274 phy->ops.i2c_bus_clear = ixgbe_i2c_bus_clear;
275 phy->ops.identify_sfp = ixgbe_identify_module_generic;
276 phy->sfp_type = ixgbe_sfp_type_unknown;
277 phy->ops.read_i2c_byte_unlocked = ixgbe_read_i2c_byte_generic_unlocked;
278 phy->ops.write_i2c_byte_unlocked =
279 ixgbe_write_i2c_byte_generic_unlocked;
280 phy->ops.check_overtemp = ixgbe_tn_check_overtemp;
281 return IXGBE_SUCCESS;
285 * ixgbe_probe_phy - Probe a single address for a PHY
286 * @hw: pointer to hardware structure
287 * @phy_addr: PHY address to probe
289 * Returns TRUE if PHY found
291 static bool ixgbe_probe_phy(struct ixgbe_hw *hw, u16 phy_addr)
295 if (!ixgbe_validate_phy_addr(hw, phy_addr)) {
296 DEBUGOUT1("Unable to validate PHY address 0x%04X\n",
301 if (ixgbe_get_phy_id(hw))
304 hw->phy.type = ixgbe_get_phy_type_from_id(hw->phy.id);
306 if (hw->phy.type == ixgbe_phy_unknown) {
307 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
308 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &ext_ability);
310 (IXGBE_MDIO_PHY_10GBASET_ABILITY |
311 IXGBE_MDIO_PHY_1000BASET_ABILITY))
312 hw->phy.type = ixgbe_phy_cu_unknown;
314 hw->phy.type = ixgbe_phy_generic;
321 * ixgbe_identify_phy_generic - Get physical layer module
322 * @hw: pointer to hardware structure
324 * Determines the physical layer module found on the current adapter.
326 s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
328 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
331 DEBUGFUNC("ixgbe_identify_phy_generic");
333 if (!hw->phy.phy_semaphore_mask) {
335 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
337 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
340 if (hw->phy.type != ixgbe_phy_unknown)
341 return IXGBE_SUCCESS;
343 if (hw->phy.nw_mng_if_sel) {
344 phy_addr = (hw->phy.nw_mng_if_sel &
345 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
346 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
347 if (ixgbe_probe_phy(hw, phy_addr))
348 return IXGBE_SUCCESS;
350 return IXGBE_ERR_PHY_ADDR_INVALID;
353 for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
354 if (ixgbe_probe_phy(hw, phy_addr)) {
355 status = IXGBE_SUCCESS;
360 /* Certain media types do not have a phy so an address will not
361 * be found and the code will take this path. Caller has to
362 * decide if it is an error or not.
364 if (status != IXGBE_SUCCESS)
371 * ixgbe_check_reset_blocked - check status of MNG FW veto bit
372 * @hw: pointer to the hardware structure
374 * This function checks the MMNGC.MNG_VETO bit to see if there are
375 * any constraints on link from manageability. For MAC's that don't
376 * have this bit just return faluse since the link can not be blocked
379 s32 ixgbe_check_reset_blocked(struct ixgbe_hw *hw)
383 DEBUGFUNC("ixgbe_check_reset_blocked");
385 /* If we don't have this bit, it can't be blocking */
386 if (hw->mac.type == ixgbe_mac_82598EB)
389 mmngc = IXGBE_READ_REG(hw, IXGBE_MMNGC);
390 if (mmngc & IXGBE_MMNGC_MNG_VETO) {
391 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE,
392 "MNG_VETO bit detected.\n");
400 * ixgbe_validate_phy_addr - Determines phy address is valid
401 * @hw: pointer to hardware structure
404 bool ixgbe_validate_phy_addr(struct ixgbe_hw *hw, u32 phy_addr)
409 DEBUGFUNC("ixgbe_validate_phy_addr");
411 hw->phy.addr = phy_addr;
412 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
413 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_id);
415 if (phy_id != 0xFFFF && phy_id != 0x0)
418 DEBUGOUT1("PHY ID HIGH is 0x%04X\n", phy_id);
424 * ixgbe_get_phy_id - Get the phy type
425 * @hw: pointer to hardware structure
428 s32 ixgbe_get_phy_id(struct ixgbe_hw *hw)
434 DEBUGFUNC("ixgbe_get_phy_id");
436 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
437 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
440 if (status == IXGBE_SUCCESS) {
441 hw->phy.id = (u32)(phy_id_high << 16);
442 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
443 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
445 hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK);
446 hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK);
448 DEBUGOUT2("PHY_ID_HIGH 0x%04X, PHY_ID_LOW 0x%04X\n",
449 phy_id_high, phy_id_low);
455 * ixgbe_get_phy_type_from_id - Get the phy type
456 * @phy_id: PHY ID information
459 enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
461 enum ixgbe_phy_type phy_type;
463 DEBUGFUNC("ixgbe_get_phy_type_from_id");
467 phy_type = ixgbe_phy_tn;
472 phy_type = ixgbe_phy_aq;
475 phy_type = ixgbe_phy_qt;
478 phy_type = ixgbe_phy_nl;
482 phy_type = ixgbe_phy_x550em_ext_t;
485 phy_type = ixgbe_phy_unknown;
492 * ixgbe_reset_phy_generic - Performs a PHY reset
493 * @hw: pointer to hardware structure
495 s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
499 s32 status = IXGBE_SUCCESS;
501 DEBUGFUNC("ixgbe_reset_phy_generic");
503 if (hw->phy.type == ixgbe_phy_unknown)
504 status = ixgbe_identify_phy_generic(hw);
506 if (status != IXGBE_SUCCESS || hw->phy.type == ixgbe_phy_none)
509 /* Don't reset PHY if it's shut down due to overtemp. */
510 if (!hw->phy.reset_if_overtemp &&
511 (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
514 /* Blocked by MNG FW so bail */
515 if (ixgbe_check_reset_blocked(hw))
519 * Perform soft PHY reset to the PHY_XS.
520 * This will cause a soft reset to the PHY
522 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
523 IXGBE_MDIO_PHY_XS_DEV_TYPE,
524 IXGBE_MDIO_PHY_XS_RESET);
527 * Poll for reset bit to self-clear indicating reset is complete.
528 * Some PHYs could take up to 3 seconds to complete and need about
529 * 1.7 usec delay after the reset is complete.
531 for (i = 0; i < 30; i++) {
533 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
534 status = hw->phy.ops.read_reg(hw,
535 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
536 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
538 if (status != IXGBE_SUCCESS)
541 if (ctrl & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
546 status = hw->phy.ops.read_reg(hw,
547 IXGBE_MDIO_PHY_XS_CONTROL,
548 IXGBE_MDIO_PHY_XS_DEV_TYPE,
550 if (status != IXGBE_SUCCESS)
553 if (!(ctrl & IXGBE_MDIO_PHY_XS_RESET)) {
560 if (ctrl & IXGBE_MDIO_PHY_XS_RESET) {
561 status = IXGBE_ERR_RESET_FAILED;
562 ERROR_REPORT1(IXGBE_ERROR_POLLING,
563 "PHY reset polling failed to complete.\n");
571 * ixgbe_read_phy_mdi - Reads a value from a specified PHY register without
573 * @hw: pointer to hardware structure
574 * @reg_addr: 32 bit address of PHY register to read
575 * @phy_data: Pointer to read data from PHY register
577 s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
580 u32 i, data, command;
582 /* Setup and write the address cycle command */
583 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
584 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
585 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
586 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
588 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
591 * Check every 10 usec to see if the address cycle completed.
592 * The MDI Command bit will clear when the operation is
595 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
598 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
599 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
604 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
605 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address command did not complete.\n");
606 DEBUGOUT("PHY address command did not complete, returning IXGBE_ERR_PHY\n");
607 return IXGBE_ERR_PHY;
611 * Address cycle complete, setup and write the read
614 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
615 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
616 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
617 (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND));
619 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
622 * Check every 10 usec to see if the address cycle
623 * completed. The MDI Command bit will clear when the
624 * operation is complete
626 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
629 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
630 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
634 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
635 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY read command didn't complete\n");
636 DEBUGOUT("PHY read command didn't complete, returning IXGBE_ERR_PHY\n");
637 return IXGBE_ERR_PHY;
641 * Read operation is complete. Get the data
644 data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
645 data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
646 *phy_data = (u16)(data);
648 return IXGBE_SUCCESS;
652 * ixgbe_read_phy_reg_generic - Reads a value from a specified PHY register
653 * using the SWFW lock - this function is needed in most cases
654 * @hw: pointer to hardware structure
655 * @reg_addr: 32 bit address of PHY register to read
656 * @phy_data: Pointer to read data from PHY register
658 s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
659 u32 device_type, u16 *phy_data)
662 u32 gssr = hw->phy.phy_semaphore_mask;
664 DEBUGFUNC("ixgbe_read_phy_reg_generic");
666 if (hw->mac.ops.acquire_swfw_sync(hw, gssr))
667 return IXGBE_ERR_SWFW_SYNC;
669 status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
671 hw->mac.ops.release_swfw_sync(hw, gssr);
677 * ixgbe_write_phy_reg_mdi - Writes a value to specified PHY register
679 * @hw: pointer to hardware structure
680 * @reg_addr: 32 bit PHY register to write
681 * @device_type: 5 bit device type
682 * @phy_data: Data to write to the PHY register
684 s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,
685 u32 device_type, u16 phy_data)
689 /* Put the data in the MDI single read and write data register*/
690 IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
692 /* Setup and write the address cycle command */
693 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
694 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
695 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
696 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
698 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
701 * Check every 10 usec to see if the address cycle completed.
702 * The MDI Command bit will clear when the operation is
705 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
708 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
709 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
713 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
714 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address cmd didn't complete\n");
715 return IXGBE_ERR_PHY;
719 * Address cycle complete, setup and write the write
722 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
723 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
724 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
725 (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND));
727 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
730 * Check every 10 usec to see if the address cycle
731 * completed. The MDI Command bit will clear when the
732 * operation is complete
734 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
737 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
738 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
742 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
743 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY write cmd didn't complete\n");
744 return IXGBE_ERR_PHY;
747 return IXGBE_SUCCESS;
751 * ixgbe_write_phy_reg_generic - Writes a value to specified PHY register
752 * using SWFW lock- this function is needed in most cases
753 * @hw: pointer to hardware structure
754 * @reg_addr: 32 bit PHY register to write
755 * @device_type: 5 bit device type
756 * @phy_data: Data to write to the PHY register
758 s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
759 u32 device_type, u16 phy_data)
762 u32 gssr = hw->phy.phy_semaphore_mask;
764 DEBUGFUNC("ixgbe_write_phy_reg_generic");
766 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
767 status = hw->phy.ops.write_reg_mdi(hw, reg_addr, device_type,
769 hw->mac.ops.release_swfw_sync(hw, gssr);
771 status = IXGBE_ERR_SWFW_SYNC;
778 * ixgbe_setup_phy_link_generic - Set and restart auto-neg
779 * @hw: pointer to hardware structure
781 * Restart auto-negotiation and PHY and waits for completion.
783 s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
785 s32 status = IXGBE_SUCCESS;
786 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
787 bool autoneg = FALSE;
788 ixgbe_link_speed speed;
790 DEBUGFUNC("ixgbe_setup_phy_link_generic");
792 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
794 /* Set or unset auto-negotiation 10G advertisement */
795 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
796 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
799 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
800 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL) &&
801 (speed & IXGBE_LINK_SPEED_10GB_FULL))
802 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
804 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
805 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
808 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
809 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
812 if (hw->mac.type == ixgbe_mac_X550) {
813 /* Set or unset auto-negotiation 5G advertisement */
814 autoneg_reg &= ~IXGBE_MII_5GBASE_T_ADVERTISE;
815 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_5GB_FULL) &&
816 (speed & IXGBE_LINK_SPEED_5GB_FULL))
817 autoneg_reg |= IXGBE_MII_5GBASE_T_ADVERTISE;
819 /* Set or unset auto-negotiation 2.5G advertisement */
820 autoneg_reg &= ~IXGBE_MII_2_5GBASE_T_ADVERTISE;
821 if ((hw->phy.autoneg_advertised &
822 IXGBE_LINK_SPEED_2_5GB_FULL) &&
823 (speed & IXGBE_LINK_SPEED_2_5GB_FULL))
824 autoneg_reg |= IXGBE_MII_2_5GBASE_T_ADVERTISE;
827 /* Set or unset auto-negotiation 1G advertisement */
828 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE;
829 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL) &&
830 (speed & IXGBE_LINK_SPEED_1GB_FULL))
831 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE;
833 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
834 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
837 /* Set or unset auto-negotiation 100M advertisement */
838 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
839 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
842 autoneg_reg &= ~(IXGBE_MII_100BASE_T_ADVERTISE |
843 IXGBE_MII_100BASE_T_ADVERTISE_HALF);
844 if ((hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL) &&
845 (speed & IXGBE_LINK_SPEED_100_FULL))
846 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
848 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
849 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
852 /* Blocked by MNG FW so don't reset PHY */
853 if (ixgbe_check_reset_blocked(hw))
856 /* Restart PHY auto-negotiation. */
857 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
858 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
860 autoneg_reg |= IXGBE_MII_RESTART;
862 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
863 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
869 * ixgbe_setup_phy_link_speed_generic - Sets the auto advertised capabilities
870 * @hw: pointer to hardware structure
871 * @speed: new link speed
873 s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
874 ixgbe_link_speed speed,
875 bool autoneg_wait_to_complete)
877 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
879 DEBUGFUNC("ixgbe_setup_phy_link_speed_generic");
882 * Clear autoneg_advertised and set new values based on input link
885 hw->phy.autoneg_advertised = 0;
887 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
888 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
890 if (speed & IXGBE_LINK_SPEED_5GB_FULL)
891 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_5GB_FULL;
893 if (speed & IXGBE_LINK_SPEED_2_5GB_FULL)
894 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_2_5GB_FULL;
896 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
897 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
899 if (speed & IXGBE_LINK_SPEED_100_FULL)
900 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
902 if (speed & IXGBE_LINK_SPEED_10_FULL)
903 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10_FULL;
905 /* Setup link based on the new speed settings */
906 ixgbe_setup_phy_link(hw);
908 return IXGBE_SUCCESS;
912 * ixgbe_get_copper_speeds_supported - Get copper link speeds from phy
913 * @hw: pointer to hardware structure
915 * Determines the supported link capabilities by reading the PHY auto
916 * negotiation register.
918 static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
923 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
924 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
929 if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
930 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
931 if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
932 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
933 if (speed_ability & IXGBE_MDIO_PHY_SPEED_100M)
934 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_100_FULL;
936 switch (hw->mac.type) {
938 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_2_5GB_FULL;
939 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_5GB_FULL;
941 case ixgbe_mac_X550EM_x:
942 case ixgbe_mac_X550EM_a:
943 hw->phy.speeds_supported &= ~IXGBE_LINK_SPEED_100_FULL;
953 * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
954 * @hw: pointer to hardware structure
955 * @speed: pointer to link speed
956 * @autoneg: boolean auto-negotiation value
958 s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
959 ixgbe_link_speed *speed,
962 s32 status = IXGBE_SUCCESS;
964 DEBUGFUNC("ixgbe_get_copper_link_capabilities_generic");
967 if (!hw->phy.speeds_supported)
968 status = ixgbe_get_copper_speeds_supported(hw);
970 *speed = hw->phy.speeds_supported;
975 * ixgbe_check_phy_link_tnx - Determine link and speed status
976 * @hw: pointer to hardware structure
978 * Reads the VS1 register to determine if link is up and the current speed for
981 s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
984 s32 status = IXGBE_SUCCESS;
986 u32 max_time_out = 10;
991 DEBUGFUNC("ixgbe_check_phy_link_tnx");
993 /* Initialize speed and link to default case */
995 *speed = IXGBE_LINK_SPEED_10GB_FULL;
998 * Check current speed and link status of the PHY register.
999 * This is a vendor specific register and may have to
1000 * be changed for other copper PHYs.
1002 for (time_out = 0; time_out < max_time_out; time_out++) {
1004 status = hw->phy.ops.read_reg(hw,
1005 IXGBE_MDIO_VENDOR_SPECIFIC_1_STATUS,
1006 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1008 phy_link = phy_data & IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS;
1009 phy_speed = phy_data &
1010 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS;
1011 if (phy_link == IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS) {
1014 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS)
1015 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1024 * ixgbe_setup_phy_link_tnx - Set and restart auto-neg
1025 * @hw: pointer to hardware structure
1027 * Restart auto-negotiation and PHY and waits for completion.
1029 s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
1031 s32 status = IXGBE_SUCCESS;
1032 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
1033 bool autoneg = FALSE;
1034 ixgbe_link_speed speed;
1036 DEBUGFUNC("ixgbe_setup_phy_link_tnx");
1038 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
1040 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
1041 /* Set or unset auto-negotiation 10G advertisement */
1042 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1043 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1046 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
1047 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1048 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
1050 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1051 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1055 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
1056 /* Set or unset auto-negotiation 1G advertisement */
1057 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1058 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1061 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1062 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1063 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1065 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1066 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1070 if (speed & IXGBE_LINK_SPEED_100_FULL) {
1071 /* Set or unset auto-negotiation 100M advertisement */
1072 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1073 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1076 autoneg_reg &= ~IXGBE_MII_100BASE_T_ADVERTISE;
1077 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
1078 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
1080 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1081 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1085 /* Blocked by MNG FW so don't reset PHY */
1086 if (ixgbe_check_reset_blocked(hw))
1089 /* Restart PHY auto-negotiation. */
1090 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
1091 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
1093 autoneg_reg |= IXGBE_MII_RESTART;
1095 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
1096 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
1102 * ixgbe_get_phy_firmware_version_tnx - Gets the PHY Firmware Version
1103 * @hw: pointer to hardware structure
1104 * @firmware_version: pointer to the PHY Firmware Version
1106 s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
1107 u16 *firmware_version)
1111 DEBUGFUNC("ixgbe_get_phy_firmware_version_tnx");
1113 status = hw->phy.ops.read_reg(hw, TNX_FW_REV,
1114 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1121 * ixgbe_get_phy_firmware_version_generic - Gets the PHY Firmware Version
1122 * @hw: pointer to hardware structure
1123 * @firmware_version: pointer to the PHY Firmware Version
1125 s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
1126 u16 *firmware_version)
1130 DEBUGFUNC("ixgbe_get_phy_firmware_version_generic");
1132 status = hw->phy.ops.read_reg(hw, AQ_FW_REV,
1133 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1140 * ixgbe_reset_phy_nl - Performs a PHY reset
1141 * @hw: pointer to hardware structure
1143 s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
1145 u16 phy_offset, control, eword, edata, block_crc;
1146 bool end_data = FALSE;
1147 u16 list_offset, data_offset;
1149 s32 ret_val = IXGBE_SUCCESS;
1152 DEBUGFUNC("ixgbe_reset_phy_nl");
1154 /* Blocked by MNG FW so bail */
1155 if (ixgbe_check_reset_blocked(hw))
1158 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1159 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1161 /* reset the PHY and poll for completion */
1162 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1163 IXGBE_MDIO_PHY_XS_DEV_TYPE,
1164 (phy_data | IXGBE_MDIO_PHY_XS_RESET));
1166 for (i = 0; i < 100; i++) {
1167 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1168 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1169 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) == 0)
1174 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) != 0) {
1175 DEBUGOUT("PHY reset did not complete.\n");
1176 ret_val = IXGBE_ERR_PHY;
1180 /* Get init offsets */
1181 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
1183 if (ret_val != IXGBE_SUCCESS)
1186 ret_val = hw->eeprom.ops.read(hw, data_offset, &block_crc);
1190 * Read control word from PHY init contents offset
1192 ret_val = hw->eeprom.ops.read(hw, data_offset, &eword);
1195 control = (eword & IXGBE_CONTROL_MASK_NL) >>
1196 IXGBE_CONTROL_SHIFT_NL;
1197 edata = eword & IXGBE_DATA_MASK_NL;
1199 case IXGBE_DELAY_NL:
1201 DEBUGOUT1("DELAY: %d MS\n", edata);
1205 DEBUGOUT("DATA:\n");
1207 ret_val = hw->eeprom.ops.read(hw, data_offset,
1212 for (i = 0; i < edata; i++) {
1213 ret_val = hw->eeprom.ops.read(hw, data_offset,
1217 hw->phy.ops.write_reg(hw, phy_offset,
1218 IXGBE_TWINAX_DEV, eword);
1219 DEBUGOUT2("Wrote %4.4x to %4.4x\n", eword,
1225 case IXGBE_CONTROL_NL:
1227 DEBUGOUT("CONTROL:\n");
1228 if (edata == IXGBE_CONTROL_EOL_NL) {
1231 } else if (edata == IXGBE_CONTROL_SOL_NL) {
1234 DEBUGOUT("Bad control value\n");
1235 ret_val = IXGBE_ERR_PHY;
1240 DEBUGOUT("Bad control type\n");
1241 ret_val = IXGBE_ERR_PHY;
1250 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1251 "eeprom read at offset %d failed", data_offset);
1252 return IXGBE_ERR_PHY;
1256 * ixgbe_identify_module_generic - Identifies module type
1257 * @hw: pointer to hardware structure
1259 * Determines HW type and calls appropriate function.
1261 s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw)
1263 s32 status = IXGBE_ERR_SFP_NOT_PRESENT;
1265 DEBUGFUNC("ixgbe_identify_module_generic");
1267 switch (hw->mac.ops.get_media_type(hw)) {
1268 case ixgbe_media_type_fiber:
1269 status = ixgbe_identify_sfp_module_generic(hw);
1272 case ixgbe_media_type_fiber_qsfp:
1273 status = ixgbe_identify_qsfp_module_generic(hw);
1277 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1278 status = IXGBE_ERR_SFP_NOT_PRESENT;
1286 * ixgbe_identify_sfp_module_generic - Identifies SFP modules
1287 * @hw: pointer to hardware structure
1289 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1291 s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
1293 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1295 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1297 u8 comp_codes_1g = 0;
1298 u8 comp_codes_10g = 0;
1299 u8 oui_bytes[3] = {0, 0, 0};
1302 u16 enforce_sfp = 0;
1304 DEBUGFUNC("ixgbe_identify_sfp_module_generic");
1306 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber) {
1307 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1308 status = IXGBE_ERR_SFP_NOT_PRESENT;
1312 /* LAN ID is needed for I2C access */
1313 hw->mac.ops.set_lan_id(hw);
1315 status = hw->phy.ops.read_i2c_eeprom(hw,
1316 IXGBE_SFF_IDENTIFIER,
1319 if (status != IXGBE_SUCCESS)
1320 goto err_read_i2c_eeprom;
1322 if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
1323 hw->phy.type = ixgbe_phy_sfp_unsupported;
1324 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1326 status = hw->phy.ops.read_i2c_eeprom(hw,
1327 IXGBE_SFF_1GBE_COMP_CODES,
1330 if (status != IXGBE_SUCCESS)
1331 goto err_read_i2c_eeprom;
1333 status = hw->phy.ops.read_i2c_eeprom(hw,
1334 IXGBE_SFF_10GBE_COMP_CODES,
1337 if (status != IXGBE_SUCCESS)
1338 goto err_read_i2c_eeprom;
1339 status = hw->phy.ops.read_i2c_eeprom(hw,
1340 IXGBE_SFF_CABLE_TECHNOLOGY,
1343 if (status != IXGBE_SUCCESS)
1344 goto err_read_i2c_eeprom;
1351 * 3 SFP_DA_CORE0 - 82599-specific
1352 * 4 SFP_DA_CORE1 - 82599-specific
1353 * 5 SFP_SR/LR_CORE0 - 82599-specific
1354 * 6 SFP_SR/LR_CORE1 - 82599-specific
1355 * 7 SFP_act_lmt_DA_CORE0 - 82599-specific
1356 * 8 SFP_act_lmt_DA_CORE1 - 82599-specific
1357 * 9 SFP_1g_cu_CORE0 - 82599-specific
1358 * 10 SFP_1g_cu_CORE1 - 82599-specific
1359 * 11 SFP_1g_sx_CORE0 - 82599-specific
1360 * 12 SFP_1g_sx_CORE1 - 82599-specific
1362 if (hw->mac.type == ixgbe_mac_82598EB) {
1363 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1364 hw->phy.sfp_type = ixgbe_sfp_type_da_cu;
1365 else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1366 hw->phy.sfp_type = ixgbe_sfp_type_sr;
1367 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1368 hw->phy.sfp_type = ixgbe_sfp_type_lr;
1370 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1372 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) {
1373 if (hw->bus.lan_id == 0)
1375 ixgbe_sfp_type_da_cu_core0;
1378 ixgbe_sfp_type_da_cu_core1;
1379 } else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) {
1380 hw->phy.ops.read_i2c_eeprom(
1381 hw, IXGBE_SFF_CABLE_SPEC_COMP,
1384 IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING) {
1385 if (hw->bus.lan_id == 0)
1387 ixgbe_sfp_type_da_act_lmt_core0;
1390 ixgbe_sfp_type_da_act_lmt_core1;
1393 ixgbe_sfp_type_unknown;
1395 } else if (comp_codes_10g &
1396 (IXGBE_SFF_10GBASESR_CAPABLE |
1397 IXGBE_SFF_10GBASELR_CAPABLE)) {
1398 if (hw->bus.lan_id == 0)
1400 ixgbe_sfp_type_srlr_core0;
1403 ixgbe_sfp_type_srlr_core1;
1404 } else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {
1405 if (hw->bus.lan_id == 0)
1407 ixgbe_sfp_type_1g_cu_core0;
1410 ixgbe_sfp_type_1g_cu_core1;
1411 } else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) {
1412 if (hw->bus.lan_id == 0)
1414 ixgbe_sfp_type_1g_sx_core0;
1417 ixgbe_sfp_type_1g_sx_core1;
1418 } else if (comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) {
1419 if (hw->bus.lan_id == 0)
1421 ixgbe_sfp_type_1g_lx_core0;
1424 ixgbe_sfp_type_1g_lx_core1;
1426 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1430 if (hw->phy.sfp_type != stored_sfp_type)
1431 hw->phy.sfp_setup_needed = TRUE;
1433 /* Determine if the SFP+ PHY is dual speed or not. */
1434 hw->phy.multispeed_fiber = FALSE;
1435 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1436 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1437 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1438 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1439 hw->phy.multispeed_fiber = TRUE;
1441 /* Determine PHY vendor */
1442 if (hw->phy.type != ixgbe_phy_nl) {
1443 hw->phy.id = identifier;
1444 status = hw->phy.ops.read_i2c_eeprom(hw,
1445 IXGBE_SFF_VENDOR_OUI_BYTE0,
1448 if (status != IXGBE_SUCCESS)
1449 goto err_read_i2c_eeprom;
1451 status = hw->phy.ops.read_i2c_eeprom(hw,
1452 IXGBE_SFF_VENDOR_OUI_BYTE1,
1455 if (status != IXGBE_SUCCESS)
1456 goto err_read_i2c_eeprom;
1458 status = hw->phy.ops.read_i2c_eeprom(hw,
1459 IXGBE_SFF_VENDOR_OUI_BYTE2,
1462 if (status != IXGBE_SUCCESS)
1463 goto err_read_i2c_eeprom;
1466 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1467 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1468 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1470 switch (vendor_oui) {
1471 case IXGBE_SFF_VENDOR_OUI_TYCO:
1472 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1474 ixgbe_phy_sfp_passive_tyco;
1476 case IXGBE_SFF_VENDOR_OUI_FTL:
1477 if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1478 hw->phy.type = ixgbe_phy_sfp_ftl_active;
1480 hw->phy.type = ixgbe_phy_sfp_ftl;
1482 case IXGBE_SFF_VENDOR_OUI_AVAGO:
1483 hw->phy.type = ixgbe_phy_sfp_avago;
1485 case IXGBE_SFF_VENDOR_OUI_INTEL:
1486 hw->phy.type = ixgbe_phy_sfp_intel;
1489 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1491 ixgbe_phy_sfp_passive_unknown;
1492 else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1494 ixgbe_phy_sfp_active_unknown;
1496 hw->phy.type = ixgbe_phy_sfp_unknown;
1501 /* Allow any DA cable vendor */
1502 if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE |
1503 IXGBE_SFF_DA_ACTIVE_CABLE)) {
1504 status = IXGBE_SUCCESS;
1508 /* Verify supported 1G SFP modules */
1509 if (comp_codes_10g == 0 &&
1510 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1511 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1512 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1513 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1514 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1515 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1516 hw->phy.type = ixgbe_phy_sfp_unsupported;
1517 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1521 /* Anything else 82598-based is supported */
1522 if (hw->mac.type == ixgbe_mac_82598EB) {
1523 status = IXGBE_SUCCESS;
1527 ixgbe_get_device_caps(hw, &enforce_sfp);
1528 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP) &&
1529 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1530 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1531 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1532 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1533 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1534 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1535 /* Make sure we're a supported PHY type */
1536 if (hw->phy.type == ixgbe_phy_sfp_intel) {
1537 status = IXGBE_SUCCESS;
1539 if (hw->allow_unsupported_sfp == TRUE) {
1540 EWARN(hw, "WARNING: Intel (R) Network "
1541 "Connections are quality tested "
1542 "using Intel (R) Ethernet Optics."
1543 " Using untested modules is not "
1544 "supported and may cause unstable"
1545 " operation or damage to the "
1546 "module or the adapter. Intel "
1547 "Corporation is not responsible "
1548 "for any harm caused by using "
1549 "untested modules.\n", status);
1550 status = IXGBE_SUCCESS;
1552 DEBUGOUT("SFP+ module not supported\n");
1554 ixgbe_phy_sfp_unsupported;
1555 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1559 status = IXGBE_SUCCESS;
1566 err_read_i2c_eeprom:
1567 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1568 if (hw->phy.type != ixgbe_phy_nl) {
1570 hw->phy.type = ixgbe_phy_unknown;
1572 return IXGBE_ERR_SFP_NOT_PRESENT;
1576 * ixgbe_get_supported_phy_sfp_layer_generic - Returns physical layer type
1577 * @hw: pointer to hardware structure
1579 * Determines physical layer capabilities of the current SFP.
1581 s32 ixgbe_get_supported_phy_sfp_layer_generic(struct ixgbe_hw *hw)
1583 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1584 u8 comp_codes_10g = 0;
1585 u8 comp_codes_1g = 0;
1587 DEBUGFUNC("ixgbe_get_supported_phy_sfp_layer_generic");
1589 hw->phy.ops.identify_sfp(hw);
1590 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1591 return physical_layer;
1593 switch (hw->phy.type) {
1594 case ixgbe_phy_sfp_passive_tyco:
1595 case ixgbe_phy_sfp_passive_unknown:
1596 case ixgbe_phy_qsfp_passive_unknown:
1597 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1599 case ixgbe_phy_sfp_ftl_active:
1600 case ixgbe_phy_sfp_active_unknown:
1601 case ixgbe_phy_qsfp_active_unknown:
1602 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA;
1604 case ixgbe_phy_sfp_avago:
1605 case ixgbe_phy_sfp_ftl:
1606 case ixgbe_phy_sfp_intel:
1607 case ixgbe_phy_sfp_unknown:
1608 hw->phy.ops.read_i2c_eeprom(hw,
1609 IXGBE_SFF_1GBE_COMP_CODES, &comp_codes_1g);
1610 hw->phy.ops.read_i2c_eeprom(hw,
1611 IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
1612 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1613 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1614 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1615 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1616 else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE)
1617 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
1618 else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE)
1619 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_SX;
1621 case ixgbe_phy_qsfp_intel:
1622 case ixgbe_phy_qsfp_unknown:
1623 hw->phy.ops.read_i2c_eeprom(hw,
1624 IXGBE_SFF_QSFP_10GBE_COMP, &comp_codes_10g);
1625 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1626 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1627 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1628 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1634 return physical_layer;
1638 * ixgbe_identify_qsfp_module_generic - Identifies QSFP modules
1639 * @hw: pointer to hardware structure
1641 * Searches for and identifies the QSFP module and assigns appropriate PHY type
1643 s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
1645 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1647 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1649 u8 comp_codes_1g = 0;
1650 u8 comp_codes_10g = 0;
1651 u8 oui_bytes[3] = {0, 0, 0};
1652 u16 enforce_sfp = 0;
1654 u8 cable_length = 0;
1656 bool active_cable = FALSE;
1658 DEBUGFUNC("ixgbe_identify_qsfp_module_generic");
1660 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber_qsfp) {
1661 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1662 status = IXGBE_ERR_SFP_NOT_PRESENT;
1666 /* LAN ID is needed for I2C access */
1667 hw->mac.ops.set_lan_id(hw);
1669 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER,
1672 if (status != IXGBE_SUCCESS)
1673 goto err_read_i2c_eeprom;
1675 if (identifier != IXGBE_SFF_IDENTIFIER_QSFP_PLUS) {
1676 hw->phy.type = ixgbe_phy_sfp_unsupported;
1677 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1681 hw->phy.id = identifier;
1683 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_10GBE_COMP,
1686 if (status != IXGBE_SUCCESS)
1687 goto err_read_i2c_eeprom;
1689 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_1GBE_COMP,
1692 if (status != IXGBE_SUCCESS)
1693 goto err_read_i2c_eeprom;
1695 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_PASSIVE_CABLE) {
1696 hw->phy.type = ixgbe_phy_qsfp_passive_unknown;
1697 if (hw->bus.lan_id == 0)
1698 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core0;
1700 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core1;
1701 } else if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1702 IXGBE_SFF_10GBASELR_CAPABLE)) {
1703 if (hw->bus.lan_id == 0)
1704 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core0;
1706 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core1;
1708 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_ACTIVE_CABLE)
1709 active_cable = TRUE;
1711 if (!active_cable) {
1712 /* check for active DA cables that pre-date
1714 hw->phy.ops.read_i2c_eeprom(hw,
1715 IXGBE_SFF_QSFP_CONNECTOR,
1718 hw->phy.ops.read_i2c_eeprom(hw,
1719 IXGBE_SFF_QSFP_CABLE_LENGTH,
1722 hw->phy.ops.read_i2c_eeprom(hw,
1723 IXGBE_SFF_QSFP_DEVICE_TECH,
1727 IXGBE_SFF_QSFP_CONNECTOR_NOT_SEPARABLE) &&
1728 (cable_length > 0) &&
1729 ((device_tech >> 4) ==
1730 IXGBE_SFF_QSFP_TRANSMITER_850NM_VCSEL))
1731 active_cable = TRUE;
1735 hw->phy.type = ixgbe_phy_qsfp_active_unknown;
1736 if (hw->bus.lan_id == 0)
1738 ixgbe_sfp_type_da_act_lmt_core0;
1741 ixgbe_sfp_type_da_act_lmt_core1;
1743 /* unsupported module type */
1744 hw->phy.type = ixgbe_phy_sfp_unsupported;
1745 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1750 if (hw->phy.sfp_type != stored_sfp_type)
1751 hw->phy.sfp_setup_needed = TRUE;
1753 /* Determine if the QSFP+ PHY is dual speed or not. */
1754 hw->phy.multispeed_fiber = FALSE;
1755 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1756 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1757 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1758 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1759 hw->phy.multispeed_fiber = TRUE;
1761 /* Determine PHY vendor for optical modules */
1762 if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1763 IXGBE_SFF_10GBASELR_CAPABLE)) {
1764 status = hw->phy.ops.read_i2c_eeprom(hw,
1765 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE0,
1768 if (status != IXGBE_SUCCESS)
1769 goto err_read_i2c_eeprom;
1771 status = hw->phy.ops.read_i2c_eeprom(hw,
1772 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE1,
1775 if (status != IXGBE_SUCCESS)
1776 goto err_read_i2c_eeprom;
1778 status = hw->phy.ops.read_i2c_eeprom(hw,
1779 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE2,
1782 if (status != IXGBE_SUCCESS)
1783 goto err_read_i2c_eeprom;
1786 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1787 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1788 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1790 if (vendor_oui == IXGBE_SFF_VENDOR_OUI_INTEL)
1791 hw->phy.type = ixgbe_phy_qsfp_intel;
1793 hw->phy.type = ixgbe_phy_qsfp_unknown;
1795 ixgbe_get_device_caps(hw, &enforce_sfp);
1796 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP)) {
1797 /* Make sure we're a supported PHY type */
1798 if (hw->phy.type == ixgbe_phy_qsfp_intel) {
1799 status = IXGBE_SUCCESS;
1801 if (hw->allow_unsupported_sfp == TRUE) {
1802 EWARN(hw, "WARNING: Intel (R) Network "
1803 "Connections are quality tested "
1804 "using Intel (R) Ethernet Optics."
1805 " Using untested modules is not "
1806 "supported and may cause unstable"
1807 " operation or damage to the "
1808 "module or the adapter. Intel "
1809 "Corporation is not responsible "
1810 "for any harm caused by using "
1811 "untested modules.\n", status);
1812 status = IXGBE_SUCCESS;
1814 DEBUGOUT("QSFP module not supported\n");
1816 ixgbe_phy_sfp_unsupported;
1817 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1821 status = IXGBE_SUCCESS;
1828 err_read_i2c_eeprom:
1829 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1831 hw->phy.type = ixgbe_phy_unknown;
1833 return IXGBE_ERR_SFP_NOT_PRESENT;
1838 * ixgbe_get_sfp_init_sequence_offsets - Provides offset of PHY init sequence
1839 * @hw: pointer to hardware structure
1840 * @list_offset: offset to the SFP ID list
1841 * @data_offset: offset to the SFP data block
1843 * Checks the MAC's EEPROM to see if it supports a given SFP+ module type, if
1844 * so it returns the offsets to the phy init sequence block.
1846 s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
1851 u16 sfp_type = hw->phy.sfp_type;
1853 DEBUGFUNC("ixgbe_get_sfp_init_sequence_offsets");
1855 if (hw->phy.sfp_type == ixgbe_sfp_type_unknown)
1856 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1858 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1859 return IXGBE_ERR_SFP_NOT_PRESENT;
1861 if ((hw->device_id == IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) &&
1862 (hw->phy.sfp_type == ixgbe_sfp_type_da_cu))
1863 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1866 * Limiting active cables and 1G Phys must be initialized as
1869 if (sfp_type == ixgbe_sfp_type_da_act_lmt_core0 ||
1870 sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1871 sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1872 sfp_type == ixgbe_sfp_type_1g_sx_core0)
1873 sfp_type = ixgbe_sfp_type_srlr_core0;
1874 else if (sfp_type == ixgbe_sfp_type_da_act_lmt_core1 ||
1875 sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1876 sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1877 sfp_type == ixgbe_sfp_type_1g_sx_core1)
1878 sfp_type = ixgbe_sfp_type_srlr_core1;
1880 /* Read offset to PHY init contents */
1881 if (hw->eeprom.ops.read(hw, IXGBE_PHY_INIT_OFFSET_NL, list_offset)) {
1882 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1883 "eeprom read at offset %d failed",
1884 IXGBE_PHY_INIT_OFFSET_NL);
1885 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1888 if ((!*list_offset) || (*list_offset == 0xFFFF))
1889 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1891 /* Shift offset to first ID word */
1895 * Find the matching SFP ID in the EEPROM
1896 * and program the init sequence
1898 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1901 while (sfp_id != IXGBE_PHY_INIT_END_NL) {
1902 if (sfp_id == sfp_type) {
1904 if (hw->eeprom.ops.read(hw, *list_offset, data_offset))
1906 if ((!*data_offset) || (*data_offset == 0xFFFF)) {
1907 DEBUGOUT("SFP+ module not supported\n");
1908 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1913 (*list_offset) += 2;
1914 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1919 if (sfp_id == IXGBE_PHY_INIT_END_NL) {
1920 DEBUGOUT("No matching SFP+ module found\n");
1921 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1924 return IXGBE_SUCCESS;
1927 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1928 "eeprom read at offset %d failed", *list_offset);
1929 return IXGBE_ERR_PHY;
1933 * ixgbe_read_i2c_eeprom_generic - Reads 8 bit EEPROM word over I2C interface
1934 * @hw: pointer to hardware structure
1935 * @byte_offset: EEPROM byte offset to read
1936 * @eeprom_data: value read
1938 * Performs byte read operation to SFP module's EEPROM over I2C interface.
1940 s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1943 DEBUGFUNC("ixgbe_read_i2c_eeprom_generic");
1945 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1946 IXGBE_I2C_EEPROM_DEV_ADDR,
1951 * ixgbe_read_i2c_sff8472_generic - Reads 8 bit word over I2C interface
1952 * @hw: pointer to hardware structure
1953 * @byte_offset: byte offset at address 0xA2
1954 * @eeprom_data: value read
1956 * Performs byte read operation to SFP module's SFF-8472 data over I2C
1958 static s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
1961 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1962 IXGBE_I2C_EEPROM_DEV_ADDR2,
1967 * ixgbe_write_i2c_eeprom_generic - Writes 8 bit EEPROM word over I2C interface
1968 * @hw: pointer to hardware structure
1969 * @byte_offset: EEPROM byte offset to write
1970 * @eeprom_data: value to write
1972 * Performs byte write operation to SFP module's EEPROM over I2C interface.
1974 s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1977 DEBUGFUNC("ixgbe_write_i2c_eeprom_generic");
1979 return hw->phy.ops.write_i2c_byte(hw, byte_offset,
1980 IXGBE_I2C_EEPROM_DEV_ADDR,
1985 * ixgbe_is_sfp_probe - Returns TRUE if SFP is being detected
1986 * @hw: pointer to hardware structure
1987 * @offset: eeprom offset to be read
1988 * @addr: I2C address to be read
1990 static bool ixgbe_is_sfp_probe(struct ixgbe_hw *hw, u8 offset, u8 addr)
1992 if (addr == IXGBE_I2C_EEPROM_DEV_ADDR &&
1993 offset == IXGBE_SFF_IDENTIFIER &&
1994 hw->phy.sfp_type == ixgbe_sfp_type_not_present)
2000 * ixgbe_read_i2c_byte_generic_int - Reads 8 bit word over I2C
2001 * @hw: pointer to hardware structure
2002 * @byte_offset: byte offset to read
2004 * @lock: TRUE if to take and release semaphore
2006 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2007 * a specified device address.
2009 static s32 ixgbe_read_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
2010 u8 dev_addr, u8 *data, bool lock)
2015 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2019 DEBUGFUNC("ixgbe_read_i2c_byte_generic");
2021 if (hw->mac.type >= ixgbe_mac_X550)
2023 if (ixgbe_is_sfp_probe(hw, byte_offset, dev_addr))
2024 max_retry = IXGBE_SFP_DETECT_RETRIES;
2027 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
2028 return IXGBE_ERR_SWFW_SYNC;
2030 ixgbe_i2c_start(hw);
2032 /* Device Address and write indication */
2033 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
2034 if (status != IXGBE_SUCCESS)
2037 status = ixgbe_get_i2c_ack(hw);
2038 if (status != IXGBE_SUCCESS)
2041 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
2042 if (status != IXGBE_SUCCESS)
2045 status = ixgbe_get_i2c_ack(hw);
2046 if (status != IXGBE_SUCCESS)
2049 ixgbe_i2c_start(hw);
2051 /* Device Address and read indication */
2052 status = ixgbe_clock_out_i2c_byte(hw, (dev_addr | 0x1));
2053 if (status != IXGBE_SUCCESS)
2056 status = ixgbe_get_i2c_ack(hw);
2057 if (status != IXGBE_SUCCESS)
2060 status = ixgbe_clock_in_i2c_byte(hw, data);
2061 if (status != IXGBE_SUCCESS)
2064 status = ixgbe_clock_out_i2c_bit(hw, nack);
2065 if (status != IXGBE_SUCCESS)
2070 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2071 return IXGBE_SUCCESS;
2074 ixgbe_i2c_bus_clear(hw);
2076 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2080 if (retry < max_retry)
2081 DEBUGOUT("I2C byte read error - Retrying.\n");
2083 DEBUGOUT("I2C byte read error.\n");
2085 } while (retry < max_retry);
2091 * ixgbe_read_i2c_byte_generic - Reads 8 bit word over I2C
2092 * @hw: pointer to hardware structure
2093 * @byte_offset: byte offset to read
2096 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2097 * a specified device address.
2099 s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
2100 u8 dev_addr, u8 *data)
2102 return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2107 * ixgbe_read_i2c_byte_generic_unlocked - Reads 8 bit word over I2C
2108 * @hw: pointer to hardware structure
2109 * @byte_offset: byte offset to read
2112 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2113 * a specified device address.
2115 s32 ixgbe_read_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2116 u8 dev_addr, u8 *data)
2118 return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2123 * ixgbe_write_i2c_byte_generic_int - Writes 8 bit word over I2C
2124 * @hw: pointer to hardware structure
2125 * @byte_offset: byte offset to write
2126 * @data: value to write
2127 * @lock: TRUE if to take and release semaphore
2129 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2130 * a specified device address.
2132 static s32 ixgbe_write_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
2133 u8 dev_addr, u8 data, bool lock)
2138 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2140 DEBUGFUNC("ixgbe_write_i2c_byte_generic");
2142 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) !=
2144 return IXGBE_ERR_SWFW_SYNC;
2147 ixgbe_i2c_start(hw);
2149 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
2150 if (status != IXGBE_SUCCESS)
2153 status = ixgbe_get_i2c_ack(hw);
2154 if (status != IXGBE_SUCCESS)
2157 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
2158 if (status != IXGBE_SUCCESS)
2161 status = ixgbe_get_i2c_ack(hw);
2162 if (status != IXGBE_SUCCESS)
2165 status = ixgbe_clock_out_i2c_byte(hw, data);
2166 if (status != IXGBE_SUCCESS)
2169 status = ixgbe_get_i2c_ack(hw);
2170 if (status != IXGBE_SUCCESS)
2175 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2176 return IXGBE_SUCCESS;
2179 ixgbe_i2c_bus_clear(hw);
2181 if (retry < max_retry)
2182 DEBUGOUT("I2C byte write error - Retrying.\n");
2184 DEBUGOUT("I2C byte write error.\n");
2185 } while (retry < max_retry);
2188 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2194 * ixgbe_write_i2c_byte_generic - Writes 8 bit word over I2C
2195 * @hw: pointer to hardware structure
2196 * @byte_offset: byte offset to write
2197 * @data: value to write
2199 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2200 * a specified device address.
2202 s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
2203 u8 dev_addr, u8 data)
2205 return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2210 * ixgbe_write_i2c_byte_generic_unlocked - Writes 8 bit word over I2C
2211 * @hw: pointer to hardware structure
2212 * @byte_offset: byte offset to write
2213 * @data: value to write
2215 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2216 * a specified device address.
2218 s32 ixgbe_write_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2219 u8 dev_addr, u8 data)
2221 return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2226 * ixgbe_i2c_start - Sets I2C start condition
2227 * @hw: pointer to hardware structure
2229 * Sets I2C start condition (High -> Low on SDA while SCL is High)
2230 * Set bit-bang mode on X550 hardware.
2232 static void ixgbe_i2c_start(struct ixgbe_hw *hw)
2234 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2236 DEBUGFUNC("ixgbe_i2c_start");
2238 i2cctl |= IXGBE_I2C_BB_EN_BY_MAC(hw);
2240 /* Start condition must begin with data and clock high */
2241 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2242 ixgbe_raise_i2c_clk(hw, &i2cctl);
2244 /* Setup time for start condition (4.7us) */
2245 usec_delay(IXGBE_I2C_T_SU_STA);
2247 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2249 /* Hold time for start condition (4us) */
2250 usec_delay(IXGBE_I2C_T_HD_STA);
2252 ixgbe_lower_i2c_clk(hw, &i2cctl);
2254 /* Minimum low period of clock is 4.7 us */
2255 usec_delay(IXGBE_I2C_T_LOW);
2260 * ixgbe_i2c_stop - Sets I2C stop condition
2261 * @hw: pointer to hardware structure
2263 * Sets I2C stop condition (Low -> High on SDA while SCL is High)
2264 * Disables bit-bang mode and negates data output enable on X550
2267 static void ixgbe_i2c_stop(struct ixgbe_hw *hw)
2269 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2270 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2271 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2272 u32 bb_en_bit = IXGBE_I2C_BB_EN_BY_MAC(hw);
2274 DEBUGFUNC("ixgbe_i2c_stop");
2276 /* Stop condition must begin with data low and clock high */
2277 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2278 ixgbe_raise_i2c_clk(hw, &i2cctl);
2280 /* Setup time for stop condition (4us) */
2281 usec_delay(IXGBE_I2C_T_SU_STO);
2283 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2285 /* bus free time between stop and start (4.7us)*/
2286 usec_delay(IXGBE_I2C_T_BUF);
2288 if (bb_en_bit || data_oe_bit || clk_oe_bit) {
2289 i2cctl &= ~bb_en_bit;
2290 i2cctl |= data_oe_bit | clk_oe_bit;
2291 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2292 IXGBE_WRITE_FLUSH(hw);
2297 * ixgbe_clock_in_i2c_byte - Clocks in one byte via I2C
2298 * @hw: pointer to hardware structure
2299 * @data: data byte to clock in
2301 * Clocks in one byte data via I2C data/clock
2303 static s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data)
2308 DEBUGFUNC("ixgbe_clock_in_i2c_byte");
2311 for (i = 7; i >= 0; i--) {
2312 ixgbe_clock_in_i2c_bit(hw, &bit);
2316 return IXGBE_SUCCESS;
2320 * ixgbe_clock_out_i2c_byte - Clocks out one byte via I2C
2321 * @hw: pointer to hardware structure
2322 * @data: data byte clocked out
2324 * Clocks out one byte data via I2C data/clock
2326 static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data)
2328 s32 status = IXGBE_SUCCESS;
2333 DEBUGFUNC("ixgbe_clock_out_i2c_byte");
2335 for (i = 7; i >= 0; i--) {
2336 bit = (data >> i) & 0x1;
2337 status = ixgbe_clock_out_i2c_bit(hw, bit);
2339 if (status != IXGBE_SUCCESS)
2343 /* Release SDA line (set high) */
2344 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2345 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2346 i2cctl |= IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2347 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2348 IXGBE_WRITE_FLUSH(hw);
2354 * ixgbe_get_i2c_ack - Polls for I2C ACK
2355 * @hw: pointer to hardware structure
2357 * Clocks in/out one bit via I2C data/clock
2359 static s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw)
2361 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2362 s32 status = IXGBE_SUCCESS;
2364 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2368 DEBUGFUNC("ixgbe_get_i2c_ack");
2371 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2372 i2cctl |= data_oe_bit;
2373 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2374 IXGBE_WRITE_FLUSH(hw);
2376 ixgbe_raise_i2c_clk(hw, &i2cctl);
2378 /* Minimum high period of clock is 4us */
2379 usec_delay(IXGBE_I2C_T_HIGH);
2381 /* Poll for ACK. Note that ACK in I2C spec is
2382 * transition from 1 to 0 */
2383 for (i = 0; i < timeout; i++) {
2384 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2385 ack = ixgbe_get_i2c_data(hw, &i2cctl);
2393 DEBUGOUT("I2C ack was not received.\n");
2394 status = IXGBE_ERR_I2C;
2397 ixgbe_lower_i2c_clk(hw, &i2cctl);
2399 /* Minimum low period of clock is 4.7 us */
2400 usec_delay(IXGBE_I2C_T_LOW);
2406 * ixgbe_clock_in_i2c_bit - Clocks in one bit via I2C data/clock
2407 * @hw: pointer to hardware structure
2408 * @data: read data value
2410 * Clocks in one bit via I2C data/clock
2412 static s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data)
2414 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2415 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2417 DEBUGFUNC("ixgbe_clock_in_i2c_bit");
2420 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2421 i2cctl |= data_oe_bit;
2422 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2423 IXGBE_WRITE_FLUSH(hw);
2425 ixgbe_raise_i2c_clk(hw, &i2cctl);
2427 /* Minimum high period of clock is 4us */
2428 usec_delay(IXGBE_I2C_T_HIGH);
2430 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2431 *data = ixgbe_get_i2c_data(hw, &i2cctl);
2433 ixgbe_lower_i2c_clk(hw, &i2cctl);
2435 /* Minimum low period of clock is 4.7 us */
2436 usec_delay(IXGBE_I2C_T_LOW);
2438 return IXGBE_SUCCESS;
2442 * ixgbe_clock_out_i2c_bit - Clocks in/out one bit via I2C data/clock
2443 * @hw: pointer to hardware structure
2444 * @data: data value to write
2446 * Clocks out one bit via I2C data/clock
2448 static s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data)
2451 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2453 DEBUGFUNC("ixgbe_clock_out_i2c_bit");
2455 status = ixgbe_set_i2c_data(hw, &i2cctl, data);
2456 if (status == IXGBE_SUCCESS) {
2457 ixgbe_raise_i2c_clk(hw, &i2cctl);
2459 /* Minimum high period of clock is 4us */
2460 usec_delay(IXGBE_I2C_T_HIGH);
2462 ixgbe_lower_i2c_clk(hw, &i2cctl);
2464 /* Minimum low period of clock is 4.7 us.
2465 * This also takes care of the data hold time.
2467 usec_delay(IXGBE_I2C_T_LOW);
2469 status = IXGBE_ERR_I2C;
2470 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2471 "I2C data was not set to %X\n", data);
2478 * ixgbe_raise_i2c_clk - Raises the I2C SCL clock
2479 * @hw: pointer to hardware structure
2480 * @i2cctl: Current value of I2CCTL register
2482 * Raises the I2C clock line '0'->'1'
2483 * Negates the I2C clock output enable on X550 hardware.
2485 static void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2487 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2489 u32 timeout = IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT;
2492 DEBUGFUNC("ixgbe_raise_i2c_clk");
2495 *i2cctl |= clk_oe_bit;
2496 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2499 for (i = 0; i < timeout; i++) {
2500 *i2cctl |= IXGBE_I2C_CLK_OUT_BY_MAC(hw);
2502 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2503 IXGBE_WRITE_FLUSH(hw);
2504 /* SCL rise time (1000ns) */
2505 usec_delay(IXGBE_I2C_T_RISE);
2507 i2cctl_r = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2508 if (i2cctl_r & IXGBE_I2C_CLK_IN_BY_MAC(hw))
2514 * ixgbe_lower_i2c_clk - Lowers the I2C SCL clock
2515 * @hw: pointer to hardware structure
2516 * @i2cctl: Current value of I2CCTL register
2518 * Lowers the I2C clock line '1'->'0'
2519 * Asserts the I2C clock output enable on X550 hardware.
2521 static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2523 DEBUGFUNC("ixgbe_lower_i2c_clk");
2525 *i2cctl &= ~(IXGBE_I2C_CLK_OUT_BY_MAC(hw));
2526 *i2cctl &= ~IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2528 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2529 IXGBE_WRITE_FLUSH(hw);
2531 /* SCL fall time (300ns) */
2532 usec_delay(IXGBE_I2C_T_FALL);
2536 * ixgbe_set_i2c_data - Sets the I2C data bit
2537 * @hw: pointer to hardware structure
2538 * @i2cctl: Current value of I2CCTL register
2539 * @data: I2C data value (0 or 1) to set
2541 * Sets the I2C data bit
2542 * Asserts the I2C data output enable on X550 hardware.
2544 static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data)
2546 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2547 s32 status = IXGBE_SUCCESS;
2549 DEBUGFUNC("ixgbe_set_i2c_data");
2552 *i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2554 *i2cctl &= ~(IXGBE_I2C_DATA_OUT_BY_MAC(hw));
2555 *i2cctl &= ~data_oe_bit;
2557 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2558 IXGBE_WRITE_FLUSH(hw);
2560 /* Data rise/fall (1000ns/300ns) and set-up time (250ns) */
2561 usec_delay(IXGBE_I2C_T_RISE + IXGBE_I2C_T_FALL + IXGBE_I2C_T_SU_DATA);
2563 if (!data) /* Can't verify data in this case */
2564 return IXGBE_SUCCESS;
2566 *i2cctl |= data_oe_bit;
2567 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2568 IXGBE_WRITE_FLUSH(hw);
2571 /* Verify data was set correctly */
2572 *i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2573 if (data != ixgbe_get_i2c_data(hw, i2cctl)) {
2574 status = IXGBE_ERR_I2C;
2575 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2576 "Error - I2C data was not set to %X.\n",
2584 * ixgbe_get_i2c_data - Reads the I2C SDA data bit
2585 * @hw: pointer to hardware structure
2586 * @i2cctl: Current value of I2CCTL register
2588 * Returns the I2C data bit value
2589 * Negates the I2C data output enable on X550 hardware.
2591 static bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl)
2593 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2596 DEBUGFUNC("ixgbe_get_i2c_data");
2599 *i2cctl |= data_oe_bit;
2600 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2601 IXGBE_WRITE_FLUSH(hw);
2602 usec_delay(IXGBE_I2C_T_FALL);
2605 if (*i2cctl & IXGBE_I2C_DATA_IN_BY_MAC(hw))
2614 * ixgbe_i2c_bus_clear - Clears the I2C bus
2615 * @hw: pointer to hardware structure
2617 * Clears the I2C bus by sending nine clock pulses.
2618 * Used when data line is stuck low.
2620 void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw)
2625 DEBUGFUNC("ixgbe_i2c_bus_clear");
2627 ixgbe_i2c_start(hw);
2628 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2630 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2632 for (i = 0; i < 9; i++) {
2633 ixgbe_raise_i2c_clk(hw, &i2cctl);
2635 /* Min high period of clock is 4us */
2636 usec_delay(IXGBE_I2C_T_HIGH);
2638 ixgbe_lower_i2c_clk(hw, &i2cctl);
2640 /* Min low period of clock is 4.7us*/
2641 usec_delay(IXGBE_I2C_T_LOW);
2644 ixgbe_i2c_start(hw);
2646 /* Put the i2c bus back to default state */
2651 * ixgbe_tn_check_overtemp - Checks if an overtemp occurred.
2652 * @hw: pointer to hardware structure
2654 * Checks if the LASI temp alarm status was triggered due to overtemp
2656 s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
2658 s32 status = IXGBE_SUCCESS;
2661 DEBUGFUNC("ixgbe_tn_check_overtemp");
2663 if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
2666 /* Check that the LASI temp alarm status was triggered */
2667 hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
2668 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_data);
2670 if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))
2673 status = IXGBE_ERR_OVERTEMP;
2674 ERROR_REPORT1(IXGBE_ERROR_CAUTION, "Device over temperature");
2680 * ixgbe_set_copper_phy_power - Control power for copper phy
2681 * @hw: pointer to hardware structure
2682 * @on: TRUE for on, FALSE for off
2684 s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on)
2689 if (!on && ixgbe_mng_present(hw))
2692 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2693 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2699 reg &= ~IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2701 if (ixgbe_check_reset_blocked(hw))
2703 reg |= IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2706 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2707 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,