1 /******************************************************************************
3 Copyright (c) 2001-2015, 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 static s32 ixgbe_read_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr,
114 u16 reg, u16 *val, bool lock)
116 u32 swfw_mask = hw->phy.phy_semaphore_mask;
125 if (hw->mac.type >= ixgbe_mac_X550)
127 reg_high = ((reg >> 7) & 0xFE) | 1; /* Indicate read combined */
128 csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
131 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
132 return IXGBE_ERR_SWFW_SYNC;
134 /* Device Address and write indication */
135 if (ixgbe_out_i2c_byte_ack(hw, addr))
137 /* Write bits 14:8 */
138 if (ixgbe_out_i2c_byte_ack(hw, reg_high))
141 if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
144 if (ixgbe_out_i2c_byte_ack(hw, csum))
146 /* Re-start condition */
148 /* Device Address and read indication */
149 if (ixgbe_out_i2c_byte_ack(hw, addr | 1))
152 if (ixgbe_in_i2c_byte_ack(hw, &high_bits))
155 if (ixgbe_in_i2c_byte_ack(hw, &low_bits))
158 if (ixgbe_clock_in_i2c_byte(hw, &csum_byte))
161 if (ixgbe_clock_out_i2c_bit(hw, FALSE))
165 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
166 *val = (high_bits << 8) | low_bits;
170 ixgbe_i2c_bus_clear(hw);
172 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
174 if (retry < max_retry)
175 DEBUGOUT("I2C byte read combined error - Retrying.\n");
177 DEBUGOUT("I2C byte read combined error.\n");
178 } while (retry < max_retry);
180 return IXGBE_ERR_I2C;
184 * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
185 * @hw: pointer to the hardware structure
186 * @addr: I2C bus address to read from
187 * @reg: I2C device register to read from
188 * @val: pointer to location to receive read value
190 * Returns an error code on error.
192 static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
195 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, TRUE);
199 * ixgbe_read_i2c_combined_generic_unlocked - Do I2C read combined operation
200 * @hw: pointer to the hardware structure
201 * @addr: I2C bus address to read from
202 * @reg: I2C device register to read from
203 * @val: pointer to location to receive read value
205 * Returns an error code on error.
208 ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
211 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, FALSE);
215 * ixgbe_write_i2c_combined_generic_int - Perform I2C write combined operation
216 * @hw: pointer to the hardware structure
217 * @addr: I2C bus address to write to
218 * @reg: I2C device register to write to
219 * @val: value to write
220 * @lock: TRUE if to take and release semaphore
222 * Returns an error code on error.
224 static s32 ixgbe_write_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr,
225 u16 reg, u16 val, bool lock)
227 u32 swfw_mask = hw->phy.phy_semaphore_mask;
233 reg_high = (reg >> 7) & 0xFE; /* Indicate write combined */
234 csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
235 csum = ixgbe_ones_comp_byte_add(csum, val >> 8);
236 csum = ixgbe_ones_comp_byte_add(csum, val & 0xFF);
239 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
240 return IXGBE_ERR_SWFW_SYNC;
242 /* Device Address and write indication */
243 if (ixgbe_out_i2c_byte_ack(hw, addr))
245 /* Write bits 14:8 */
246 if (ixgbe_out_i2c_byte_ack(hw, reg_high))
249 if (ixgbe_out_i2c_byte_ack(hw, reg & 0xFF))
251 /* Write data 15:8 */
252 if (ixgbe_out_i2c_byte_ack(hw, val >> 8))
255 if (ixgbe_out_i2c_byte_ack(hw, val & 0xFF))
258 if (ixgbe_out_i2c_byte_ack(hw, csum))
262 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
266 ixgbe_i2c_bus_clear(hw);
268 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
270 if (retry < max_retry)
271 DEBUGOUT("I2C byte write combined error - Retrying.\n");
273 DEBUGOUT("I2C byte write combined error.\n");
274 } while (retry < max_retry);
276 return IXGBE_ERR_I2C;
280 * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
281 * @hw: pointer to the hardware structure
282 * @addr: I2C bus address to write to
283 * @reg: I2C device register to write to
284 * @val: value to write
286 * Returns an error code on error.
288 static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
289 u8 addr, u16 reg, u16 val)
291 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, TRUE);
295 * ixgbe_write_i2c_combined_generic_unlocked - Do I2C write combined operation
296 * @hw: pointer to the hardware structure
297 * @addr: I2C bus address to write to
298 * @reg: I2C device register to write to
299 * @val: value to write
301 * Returns an error code on error.
304 ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
305 u8 addr, u16 reg, u16 val)
307 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, FALSE);
311 * ixgbe_init_phy_ops_generic - Inits PHY function ptrs
312 * @hw: pointer to the hardware structure
314 * Initialize the function pointers.
316 s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw)
318 struct ixgbe_phy_info *phy = &hw->phy;
320 DEBUGFUNC("ixgbe_init_phy_ops_generic");
323 phy->ops.identify = ixgbe_identify_phy_generic;
324 phy->ops.reset = ixgbe_reset_phy_generic;
325 phy->ops.read_reg = ixgbe_read_phy_reg_generic;
326 phy->ops.write_reg = ixgbe_write_phy_reg_generic;
327 phy->ops.read_reg_mdi = ixgbe_read_phy_reg_mdi;
328 phy->ops.write_reg_mdi = ixgbe_write_phy_reg_mdi;
329 phy->ops.setup_link = ixgbe_setup_phy_link_generic;
330 phy->ops.setup_link_speed = ixgbe_setup_phy_link_speed_generic;
331 phy->ops.check_link = NULL;
332 phy->ops.get_firmware_version = ixgbe_get_phy_firmware_version_generic;
333 phy->ops.read_i2c_byte = ixgbe_read_i2c_byte_generic;
334 phy->ops.write_i2c_byte = ixgbe_write_i2c_byte_generic;
335 phy->ops.read_i2c_sff8472 = ixgbe_read_i2c_sff8472_generic;
336 phy->ops.read_i2c_eeprom = ixgbe_read_i2c_eeprom_generic;
337 phy->ops.write_i2c_eeprom = ixgbe_write_i2c_eeprom_generic;
338 phy->ops.i2c_bus_clear = ixgbe_i2c_bus_clear;
339 phy->ops.identify_sfp = ixgbe_identify_module_generic;
340 phy->sfp_type = ixgbe_sfp_type_unknown;
341 phy->ops.read_i2c_combined = ixgbe_read_i2c_combined_generic;
342 phy->ops.write_i2c_combined = ixgbe_write_i2c_combined_generic;
343 phy->ops.read_i2c_combined_unlocked =
344 ixgbe_read_i2c_combined_generic_unlocked;
345 phy->ops.write_i2c_combined_unlocked =
346 ixgbe_write_i2c_combined_generic_unlocked;
347 phy->ops.read_i2c_byte_unlocked = ixgbe_read_i2c_byte_generic_unlocked;
348 phy->ops.write_i2c_byte_unlocked =
349 ixgbe_write_i2c_byte_generic_unlocked;
350 phy->ops.check_overtemp = ixgbe_tn_check_overtemp;
351 return IXGBE_SUCCESS;
355 * ixgbe_identify_phy_generic - Get physical layer module
356 * @hw: pointer to hardware structure
358 * Determines the physical layer module found on the current adapter.
360 s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw)
362 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
366 DEBUGFUNC("ixgbe_identify_phy_generic");
368 if (!hw->phy.phy_semaphore_mask) {
370 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
372 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
375 if (hw->phy.type == ixgbe_phy_unknown) {
376 for (phy_addr = 0; phy_addr < IXGBE_MAX_PHY_ADDR; phy_addr++) {
377 if (ixgbe_validate_phy_addr(hw, phy_addr)) {
378 hw->phy.addr = phy_addr;
379 ixgbe_get_phy_id(hw);
381 ixgbe_get_phy_type_from_id(hw->phy.id);
383 if (hw->phy.type == ixgbe_phy_unknown) {
384 hw->phy.ops.read_reg(hw,
385 IXGBE_MDIO_PHY_EXT_ABILITY,
386 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
389 (IXGBE_MDIO_PHY_10GBASET_ABILITY |
390 IXGBE_MDIO_PHY_1000BASET_ABILITY))
392 ixgbe_phy_cu_unknown;
398 status = IXGBE_SUCCESS;
403 /* Certain media types do not have a phy so an address will not
404 * be found and the code will take this path. Caller has to
405 * decide if it is an error or not.
407 if (status != IXGBE_SUCCESS) {
411 status = IXGBE_SUCCESS;
418 * ixgbe_check_reset_blocked - check status of MNG FW veto bit
419 * @hw: pointer to the hardware structure
421 * This function checks the MMNGC.MNG_VETO bit to see if there are
422 * any constraints on link from manageability. For MAC's that don't
423 * have this bit just return faluse since the link can not be blocked
426 s32 ixgbe_check_reset_blocked(struct ixgbe_hw *hw)
430 DEBUGFUNC("ixgbe_check_reset_blocked");
432 /* If we don't have this bit, it can't be blocking */
433 if (hw->mac.type == ixgbe_mac_82598EB)
436 mmngc = IXGBE_READ_REG(hw, IXGBE_MMNGC);
437 if (mmngc & IXGBE_MMNGC_MNG_VETO) {
438 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE,
439 "MNG_VETO bit detected.\n");
447 * ixgbe_validate_phy_addr - Determines phy address is valid
448 * @hw: pointer to hardware structure
451 bool ixgbe_validate_phy_addr(struct ixgbe_hw *hw, u32 phy_addr)
456 DEBUGFUNC("ixgbe_validate_phy_addr");
458 hw->phy.addr = phy_addr;
459 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
460 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_id);
462 if (phy_id != 0xFFFF && phy_id != 0x0)
469 * ixgbe_get_phy_id - Get the phy type
470 * @hw: pointer to hardware structure
473 s32 ixgbe_get_phy_id(struct ixgbe_hw *hw)
479 DEBUGFUNC("ixgbe_get_phy_id");
481 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
482 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
485 if (status == IXGBE_SUCCESS) {
486 hw->phy.id = (u32)(phy_id_high << 16);
487 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
488 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
490 hw->phy.id |= (u32)(phy_id_low & IXGBE_PHY_REVISION_MASK);
491 hw->phy.revision = (u32)(phy_id_low & ~IXGBE_PHY_REVISION_MASK);
497 * ixgbe_get_phy_type_from_id - Get the phy type
498 * @hw: pointer to hardware structure
501 enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
503 enum ixgbe_phy_type phy_type;
505 DEBUGFUNC("ixgbe_get_phy_type_from_id");
509 phy_type = ixgbe_phy_tn;
515 phy_type = ixgbe_phy_aq;
518 phy_type = ixgbe_phy_qt;
521 phy_type = ixgbe_phy_nl;
524 phy_type = ixgbe_phy_x550em_ext_t;
527 phy_type = ixgbe_phy_unknown;
531 DEBUGOUT1("phy type found is %d\n", phy_type);
536 * ixgbe_reset_phy_generic - Performs a PHY reset
537 * @hw: pointer to hardware structure
539 s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw)
543 s32 status = IXGBE_SUCCESS;
545 DEBUGFUNC("ixgbe_reset_phy_generic");
547 if (hw->phy.type == ixgbe_phy_unknown)
548 status = ixgbe_identify_phy_generic(hw);
550 if (status != IXGBE_SUCCESS || hw->phy.type == ixgbe_phy_none)
553 /* Don't reset PHY if it's shut down due to overtemp. */
554 if (!hw->phy.reset_if_overtemp &&
555 (IXGBE_ERR_OVERTEMP == hw->phy.ops.check_overtemp(hw)))
558 /* Blocked by MNG FW so bail */
559 if (ixgbe_check_reset_blocked(hw))
563 * Perform soft PHY reset to the PHY_XS.
564 * This will cause a soft reset to the PHY
566 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
567 IXGBE_MDIO_PHY_XS_DEV_TYPE,
568 IXGBE_MDIO_PHY_XS_RESET);
571 * Poll for reset bit to self-clear indicating reset is complete.
572 * Some PHYs could take up to 3 seconds to complete and need about
573 * 1.7 usec delay after the reset is complete.
575 for (i = 0; i < 30; i++) {
577 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
578 IXGBE_MDIO_PHY_XS_DEV_TYPE, &ctrl);
579 if (!(ctrl & IXGBE_MDIO_PHY_XS_RESET)) {
585 if (ctrl & IXGBE_MDIO_PHY_XS_RESET) {
586 status = IXGBE_ERR_RESET_FAILED;
587 ERROR_REPORT1(IXGBE_ERROR_POLLING,
588 "PHY reset polling failed to complete.\n");
596 * ixgbe_read_phy_mdi - Reads a value from a specified PHY register without
598 * @hw: pointer to hardware structure
599 * @reg_addr: 32 bit address of PHY register to read
600 * @phy_data: Pointer to read data from PHY register
602 s32 ixgbe_read_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type,
605 u32 i, data, command;
607 /* Setup and write the address cycle command */
608 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
609 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
610 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
611 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
613 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
616 * Check every 10 usec to see if the address cycle completed.
617 * The MDI Command bit will clear when the operation is
620 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
623 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
624 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
629 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
630 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address command did not complete.\n");
631 return IXGBE_ERR_PHY;
635 * Address cycle complete, setup and write the read
638 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
639 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
640 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
641 (IXGBE_MSCA_READ | IXGBE_MSCA_MDI_COMMAND));
643 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
646 * Check every 10 usec to see if the address cycle
647 * completed. The MDI Command bit will clear when the
648 * operation is complete
650 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
653 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
654 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
658 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
659 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY read command didn't complete\n");
660 return IXGBE_ERR_PHY;
664 * Read operation is complete. Get the data
667 data = IXGBE_READ_REG(hw, IXGBE_MSRWD);
668 data >>= IXGBE_MSRWD_READ_DATA_SHIFT;
669 *phy_data = (u16)(data);
671 return IXGBE_SUCCESS;
675 * ixgbe_read_phy_reg_generic - Reads a value from a specified PHY register
676 * using the SWFW lock - this function is needed in most cases
677 * @hw: pointer to hardware structure
678 * @reg_addr: 32 bit address of PHY register to read
679 * @phy_data: Pointer to read data from PHY register
681 s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
682 u32 device_type, u16 *phy_data)
685 u32 gssr = hw->phy.phy_semaphore_mask;
687 DEBUGFUNC("ixgbe_read_phy_reg_generic");
689 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
690 status = ixgbe_read_phy_reg_mdi(hw, reg_addr, device_type,
692 hw->mac.ops.release_swfw_sync(hw, gssr);
694 status = IXGBE_ERR_SWFW_SYNC;
701 * ixgbe_write_phy_reg_mdi - Writes a value to specified PHY register
703 * @hw: pointer to hardware structure
704 * @reg_addr: 32 bit PHY register to write
705 * @device_type: 5 bit device type
706 * @phy_data: Data to write to the PHY register
708 s32 ixgbe_write_phy_reg_mdi(struct ixgbe_hw *hw, u32 reg_addr,
709 u32 device_type, u16 phy_data)
713 /* Put the data in the MDI single read and write data register*/
714 IXGBE_WRITE_REG(hw, IXGBE_MSRWD, (u32)phy_data);
716 /* Setup and write the address cycle command */
717 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
718 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
719 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
720 (IXGBE_MSCA_ADDR_CYCLE | IXGBE_MSCA_MDI_COMMAND));
722 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
725 * Check every 10 usec to see if the address cycle completed.
726 * The MDI Command bit will clear when the operation is
729 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
732 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
733 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
737 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
738 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY address cmd didn't complete\n");
739 return IXGBE_ERR_PHY;
743 * Address cycle complete, setup and write the write
746 command = ((reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT) |
747 (device_type << IXGBE_MSCA_DEV_TYPE_SHIFT) |
748 (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
749 (IXGBE_MSCA_WRITE | IXGBE_MSCA_MDI_COMMAND));
751 IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
754 * Check every 10 usec to see if the address cycle
755 * completed. The MDI Command bit will clear when the
756 * operation is complete
758 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
761 command = IXGBE_READ_REG(hw, IXGBE_MSCA);
762 if ((command & IXGBE_MSCA_MDI_COMMAND) == 0)
766 if ((command & IXGBE_MSCA_MDI_COMMAND) != 0) {
767 ERROR_REPORT1(IXGBE_ERROR_POLLING, "PHY write cmd didn't complete\n");
768 return IXGBE_ERR_PHY;
771 return IXGBE_SUCCESS;
775 * ixgbe_write_phy_reg_generic - Writes a value to specified PHY register
776 * using SWFW lock- this function is needed in most cases
777 * @hw: pointer to hardware structure
778 * @reg_addr: 32 bit PHY register to write
779 * @device_type: 5 bit device type
780 * @phy_data: Data to write to the PHY register
782 s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,
783 u32 device_type, u16 phy_data)
786 u32 gssr = hw->phy.phy_semaphore_mask;
788 DEBUGFUNC("ixgbe_write_phy_reg_generic");
790 if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
791 status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type,
793 hw->mac.ops.release_swfw_sync(hw, gssr);
795 status = IXGBE_ERR_SWFW_SYNC;
802 * ixgbe_setup_phy_link_generic - Set and restart auto-neg
803 * @hw: pointer to hardware structure
805 * Restart auto-negotiation and PHY and waits for completion.
807 s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)
809 s32 status = IXGBE_SUCCESS;
810 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
811 bool autoneg = FALSE;
812 ixgbe_link_speed speed;
814 DEBUGFUNC("ixgbe_setup_phy_link_generic");
816 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
818 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
819 /* Set or unset auto-negotiation 10G advertisement */
820 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
821 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
824 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
825 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
826 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
828 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
829 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
833 if (hw->mac.type == ixgbe_mac_X550) {
834 if (speed & IXGBE_LINK_SPEED_5GB_FULL) {
835 /* Set or unset auto-negotiation 5G advertisement */
836 hw->phy.ops.read_reg(hw,
837 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
838 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
841 autoneg_reg &= ~IXGBE_MII_5GBASE_T_ADVERTISE;
842 if (hw->phy.autoneg_advertised &
843 IXGBE_LINK_SPEED_5GB_FULL)
844 autoneg_reg |= IXGBE_MII_5GBASE_T_ADVERTISE;
846 hw->phy.ops.write_reg(hw,
847 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
848 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
852 if (speed & IXGBE_LINK_SPEED_2_5GB_FULL) {
853 /* Set or unset auto-negotiation 2.5G advertisement */
854 hw->phy.ops.read_reg(hw,
855 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
856 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
859 autoneg_reg &= ~IXGBE_MII_2_5GBASE_T_ADVERTISE;
860 if (hw->phy.autoneg_advertised &
861 IXGBE_LINK_SPEED_2_5GB_FULL)
862 autoneg_reg |= IXGBE_MII_2_5GBASE_T_ADVERTISE;
864 hw->phy.ops.write_reg(hw,
865 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
866 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
871 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
872 /* Set or unset auto-negotiation 1G advertisement */
873 hw->phy.ops.read_reg(hw,
874 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
875 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
878 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE;
879 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
880 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE;
882 hw->phy.ops.write_reg(hw,
883 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
884 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
888 if (speed & IXGBE_LINK_SPEED_100_FULL) {
889 /* Set or unset auto-negotiation 100M advertisement */
890 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
891 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
894 autoneg_reg &= ~(IXGBE_MII_100BASE_T_ADVERTISE |
895 IXGBE_MII_100BASE_T_ADVERTISE_HALF);
896 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
897 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
899 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
900 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
904 /* Blocked by MNG FW so don't reset PHY */
905 if (ixgbe_check_reset_blocked(hw))
908 /* Restart PHY auto-negotiation. */
909 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
910 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
912 autoneg_reg |= IXGBE_MII_RESTART;
914 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
915 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
921 * ixgbe_setup_phy_link_speed_generic - Sets the auto advertised capabilities
922 * @hw: pointer to hardware structure
923 * @speed: new link speed
925 s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,
926 ixgbe_link_speed speed,
927 bool autoneg_wait_to_complete)
929 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
931 DEBUGFUNC("ixgbe_setup_phy_link_speed_generic");
934 * Clear autoneg_advertised and set new values based on input link
937 hw->phy.autoneg_advertised = 0;
939 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
940 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_10GB_FULL;
942 if (speed & IXGBE_LINK_SPEED_5GB_FULL)
943 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_5GB_FULL;
945 if (speed & IXGBE_LINK_SPEED_2_5GB_FULL)
946 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_2_5GB_FULL;
948 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
949 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_1GB_FULL;
951 if (speed & IXGBE_LINK_SPEED_100_FULL)
952 hw->phy.autoneg_advertised |= IXGBE_LINK_SPEED_100_FULL;
954 /* Setup link based on the new speed settings */
955 ixgbe_setup_phy_link(hw);
957 return IXGBE_SUCCESS;
961 * ixgbe_get_copper_speeds_supported - Get copper link speeds from phy
962 * @hw: pointer to hardware structure
964 * Determines the supported link capabilities by reading the PHY auto
965 * negotiation register.
967 static s32 ixgbe_get_copper_speeds_supported(struct ixgbe_hw *hw)
972 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY,
973 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
978 if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G)
979 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_10GB_FULL;
980 if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G)
981 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_1GB_FULL;
982 if (speed_ability & IXGBE_MDIO_PHY_SPEED_100M)
983 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_100_FULL;
985 switch (hw->mac.type) {
987 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_2_5GB_FULL;
988 hw->phy.speeds_supported |= IXGBE_LINK_SPEED_5GB_FULL;
990 case ixgbe_mac_X550EM_x:
991 hw->phy.speeds_supported &= ~IXGBE_LINK_SPEED_100_FULL;
1001 * ixgbe_get_copper_link_capabilities_generic - Determines link capabilities
1002 * @hw: pointer to hardware structure
1003 * @speed: pointer to link speed
1004 * @autoneg: boolean auto-negotiation value
1006 s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,
1007 ixgbe_link_speed *speed,
1010 s32 status = IXGBE_SUCCESS;
1012 DEBUGFUNC("ixgbe_get_copper_link_capabilities_generic");
1015 if (!hw->phy.speeds_supported)
1016 status = ixgbe_get_copper_speeds_supported(hw);
1018 *speed = hw->phy.speeds_supported;
1023 * ixgbe_check_phy_link_tnx - Determine link and speed status
1024 * @hw: pointer to hardware structure
1026 * Reads the VS1 register to determine if link is up and the current speed for
1029 s32 ixgbe_check_phy_link_tnx(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
1032 s32 status = IXGBE_SUCCESS;
1034 u32 max_time_out = 10;
1039 DEBUGFUNC("ixgbe_check_phy_link_tnx");
1041 /* Initialize speed and link to default case */
1043 *speed = IXGBE_LINK_SPEED_10GB_FULL;
1046 * Check current speed and link status of the PHY register.
1047 * This is a vendor specific register and may have to
1048 * be changed for other copper PHYs.
1050 for (time_out = 0; time_out < max_time_out; time_out++) {
1052 status = hw->phy.ops.read_reg(hw,
1053 IXGBE_MDIO_VENDOR_SPECIFIC_1_STATUS,
1054 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1056 phy_link = phy_data & IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS;
1057 phy_speed = phy_data &
1058 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS;
1059 if (phy_link == IXGBE_MDIO_VENDOR_SPECIFIC_1_LINK_STATUS) {
1062 IXGBE_MDIO_VENDOR_SPECIFIC_1_SPEED_STATUS)
1063 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1072 * ixgbe_setup_phy_link_tnx - Set and restart auto-neg
1073 * @hw: pointer to hardware structure
1075 * Restart auto-negotiation and PHY and waits for completion.
1077 s32 ixgbe_setup_phy_link_tnx(struct ixgbe_hw *hw)
1079 s32 status = IXGBE_SUCCESS;
1080 u16 autoneg_reg = IXGBE_MII_AUTONEG_REG;
1081 bool autoneg = FALSE;
1082 ixgbe_link_speed speed;
1084 DEBUGFUNC("ixgbe_setup_phy_link_tnx");
1086 ixgbe_get_copper_link_capabilities_generic(hw, &speed, &autoneg);
1088 if (speed & IXGBE_LINK_SPEED_10GB_FULL) {
1089 /* Set or unset auto-negotiation 10G advertisement */
1090 hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1091 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1094 autoneg_reg &= ~IXGBE_MII_10GBASE_T_ADVERTISE;
1095 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1096 autoneg_reg |= IXGBE_MII_10GBASE_T_ADVERTISE;
1098 hw->phy.ops.write_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
1099 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1103 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
1104 /* Set or unset auto-negotiation 1G advertisement */
1105 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1106 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1109 autoneg_reg &= ~IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1110 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1111 autoneg_reg |= IXGBE_MII_1GBASE_T_ADVERTISE_XNP_TX;
1113 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_XNP_TX_REG,
1114 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1118 if (speed & IXGBE_LINK_SPEED_100_FULL) {
1119 /* Set or unset auto-negotiation 100M advertisement */
1120 hw->phy.ops.read_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1121 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1124 autoneg_reg &= ~IXGBE_MII_100BASE_T_ADVERTISE;
1125 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_100_FULL)
1126 autoneg_reg |= IXGBE_MII_100BASE_T_ADVERTISE;
1128 hw->phy.ops.write_reg(hw, IXGBE_MII_AUTONEG_ADVERTISE_REG,
1129 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1133 /* Blocked by MNG FW so don't reset PHY */
1134 if (ixgbe_check_reset_blocked(hw))
1137 /* Restart PHY auto-negotiation. */
1138 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
1139 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_reg);
1141 autoneg_reg |= IXGBE_MII_RESTART;
1143 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_CONTROL,
1144 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_reg);
1150 * ixgbe_get_phy_firmware_version_tnx - Gets the PHY Firmware Version
1151 * @hw: pointer to hardware structure
1152 * @firmware_version: pointer to the PHY Firmware Version
1154 s32 ixgbe_get_phy_firmware_version_tnx(struct ixgbe_hw *hw,
1155 u16 *firmware_version)
1159 DEBUGFUNC("ixgbe_get_phy_firmware_version_tnx");
1161 status = hw->phy.ops.read_reg(hw, TNX_FW_REV,
1162 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1169 * ixgbe_get_phy_firmware_version_generic - Gets the PHY Firmware Version
1170 * @hw: pointer to hardware structure
1171 * @firmware_version: pointer to the PHY Firmware Version
1173 s32 ixgbe_get_phy_firmware_version_generic(struct ixgbe_hw *hw,
1174 u16 *firmware_version)
1178 DEBUGFUNC("ixgbe_get_phy_firmware_version_generic");
1180 status = hw->phy.ops.read_reg(hw, AQ_FW_REV,
1181 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1188 * ixgbe_reset_phy_nl - Performs a PHY reset
1189 * @hw: pointer to hardware structure
1191 s32 ixgbe_reset_phy_nl(struct ixgbe_hw *hw)
1193 u16 phy_offset, control, eword, edata, block_crc;
1194 bool end_data = FALSE;
1195 u16 list_offset, data_offset;
1197 s32 ret_val = IXGBE_SUCCESS;
1200 DEBUGFUNC("ixgbe_reset_phy_nl");
1202 /* Blocked by MNG FW so bail */
1203 if (ixgbe_check_reset_blocked(hw))
1206 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1207 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1209 /* reset the PHY and poll for completion */
1210 hw->phy.ops.write_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1211 IXGBE_MDIO_PHY_XS_DEV_TYPE,
1212 (phy_data | IXGBE_MDIO_PHY_XS_RESET));
1214 for (i = 0; i < 100; i++) {
1215 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_XS_CONTROL,
1216 IXGBE_MDIO_PHY_XS_DEV_TYPE, &phy_data);
1217 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) == 0)
1222 if ((phy_data & IXGBE_MDIO_PHY_XS_RESET) != 0) {
1223 DEBUGOUT("PHY reset did not complete.\n");
1224 ret_val = IXGBE_ERR_PHY;
1228 /* Get init offsets */
1229 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, &list_offset,
1231 if (ret_val != IXGBE_SUCCESS)
1234 ret_val = hw->eeprom.ops.read(hw, data_offset, &block_crc);
1238 * Read control word from PHY init contents offset
1240 ret_val = hw->eeprom.ops.read(hw, data_offset, &eword);
1243 control = (eword & IXGBE_CONTROL_MASK_NL) >>
1244 IXGBE_CONTROL_SHIFT_NL;
1245 edata = eword & IXGBE_DATA_MASK_NL;
1247 case IXGBE_DELAY_NL:
1249 DEBUGOUT1("DELAY: %d MS\n", edata);
1253 DEBUGOUT("DATA:\n");
1255 ret_val = hw->eeprom.ops.read(hw, data_offset,
1260 for (i = 0; i < edata; i++) {
1261 ret_val = hw->eeprom.ops.read(hw, data_offset,
1265 hw->phy.ops.write_reg(hw, phy_offset,
1266 IXGBE_TWINAX_DEV, eword);
1267 DEBUGOUT2("Wrote %4.4x to %4.4x\n", eword,
1273 case IXGBE_CONTROL_NL:
1275 DEBUGOUT("CONTROL:\n");
1276 if (edata == IXGBE_CONTROL_EOL_NL) {
1279 } else if (edata == IXGBE_CONTROL_SOL_NL) {
1282 DEBUGOUT("Bad control value\n");
1283 ret_val = IXGBE_ERR_PHY;
1288 DEBUGOUT("Bad control type\n");
1289 ret_val = IXGBE_ERR_PHY;
1298 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1299 "eeprom read at offset %d failed", data_offset);
1300 return IXGBE_ERR_PHY;
1304 * ixgbe_identify_module_generic - Identifies module type
1305 * @hw: pointer to hardware structure
1307 * Determines HW type and calls appropriate function.
1309 s32 ixgbe_identify_module_generic(struct ixgbe_hw *hw)
1311 s32 status = IXGBE_ERR_SFP_NOT_PRESENT;
1313 DEBUGFUNC("ixgbe_identify_module_generic");
1315 switch (hw->mac.ops.get_media_type(hw)) {
1316 case ixgbe_media_type_fiber:
1317 status = ixgbe_identify_sfp_module_generic(hw);
1320 case ixgbe_media_type_fiber_qsfp:
1321 status = ixgbe_identify_qsfp_module_generic(hw);
1325 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1326 status = IXGBE_ERR_SFP_NOT_PRESENT;
1334 * ixgbe_identify_sfp_module_generic - Identifies SFP modules
1335 * @hw: pointer to hardware structure
1337 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1339 s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
1341 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1343 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1345 u8 comp_codes_1g = 0;
1346 u8 comp_codes_10g = 0;
1347 u8 oui_bytes[3] = {0, 0, 0};
1350 u16 enforce_sfp = 0;
1352 DEBUGFUNC("ixgbe_identify_sfp_module_generic");
1354 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber) {
1355 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1356 status = IXGBE_ERR_SFP_NOT_PRESENT;
1360 /* LAN ID is needed for I2C access */
1361 hw->mac.ops.set_lan_id(hw);
1363 status = hw->phy.ops.read_i2c_eeprom(hw,
1364 IXGBE_SFF_IDENTIFIER,
1367 if (status != IXGBE_SUCCESS)
1368 goto err_read_i2c_eeprom;
1370 if (identifier != IXGBE_SFF_IDENTIFIER_SFP) {
1371 hw->phy.type = ixgbe_phy_sfp_unsupported;
1372 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1374 status = hw->phy.ops.read_i2c_eeprom(hw,
1375 IXGBE_SFF_1GBE_COMP_CODES,
1378 if (status != IXGBE_SUCCESS)
1379 goto err_read_i2c_eeprom;
1381 status = hw->phy.ops.read_i2c_eeprom(hw,
1382 IXGBE_SFF_10GBE_COMP_CODES,
1385 if (status != IXGBE_SUCCESS)
1386 goto err_read_i2c_eeprom;
1387 status = hw->phy.ops.read_i2c_eeprom(hw,
1388 IXGBE_SFF_CABLE_TECHNOLOGY,
1391 if (status != IXGBE_SUCCESS)
1392 goto err_read_i2c_eeprom;
1399 * 3 SFP_DA_CORE0 - 82599-specific
1400 * 4 SFP_DA_CORE1 - 82599-specific
1401 * 5 SFP_SR/LR_CORE0 - 82599-specific
1402 * 6 SFP_SR/LR_CORE1 - 82599-specific
1403 * 7 SFP_act_lmt_DA_CORE0 - 82599-specific
1404 * 8 SFP_act_lmt_DA_CORE1 - 82599-specific
1405 * 9 SFP_1g_cu_CORE0 - 82599-specific
1406 * 10 SFP_1g_cu_CORE1 - 82599-specific
1407 * 11 SFP_1g_sx_CORE0 - 82599-specific
1408 * 12 SFP_1g_sx_CORE1 - 82599-specific
1410 if (hw->mac.type == ixgbe_mac_82598EB) {
1411 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1412 hw->phy.sfp_type = ixgbe_sfp_type_da_cu;
1413 else if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1414 hw->phy.sfp_type = ixgbe_sfp_type_sr;
1415 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1416 hw->phy.sfp_type = ixgbe_sfp_type_lr;
1418 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1420 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE) {
1421 if (hw->bus.lan_id == 0)
1423 ixgbe_sfp_type_da_cu_core0;
1426 ixgbe_sfp_type_da_cu_core1;
1427 } else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE) {
1428 hw->phy.ops.read_i2c_eeprom(
1429 hw, IXGBE_SFF_CABLE_SPEC_COMP,
1432 IXGBE_SFF_DA_SPEC_ACTIVE_LIMITING) {
1433 if (hw->bus.lan_id == 0)
1435 ixgbe_sfp_type_da_act_lmt_core0;
1438 ixgbe_sfp_type_da_act_lmt_core1;
1441 ixgbe_sfp_type_unknown;
1443 } else if (comp_codes_10g &
1444 (IXGBE_SFF_10GBASESR_CAPABLE |
1445 IXGBE_SFF_10GBASELR_CAPABLE)) {
1446 if (hw->bus.lan_id == 0)
1448 ixgbe_sfp_type_srlr_core0;
1451 ixgbe_sfp_type_srlr_core1;
1452 } else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE) {
1453 if (hw->bus.lan_id == 0)
1455 ixgbe_sfp_type_1g_cu_core0;
1458 ixgbe_sfp_type_1g_cu_core1;
1459 } else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) {
1460 if (hw->bus.lan_id == 0)
1462 ixgbe_sfp_type_1g_sx_core0;
1465 ixgbe_sfp_type_1g_sx_core1;
1466 } else if (comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) {
1467 if (hw->bus.lan_id == 0)
1469 ixgbe_sfp_type_1g_lx_core0;
1472 ixgbe_sfp_type_1g_lx_core1;
1474 hw->phy.sfp_type = ixgbe_sfp_type_unknown;
1478 if (hw->phy.sfp_type != stored_sfp_type)
1479 hw->phy.sfp_setup_needed = TRUE;
1481 /* Determine if the SFP+ PHY is dual speed or not. */
1482 hw->phy.multispeed_fiber = FALSE;
1483 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1484 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1485 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1486 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1487 hw->phy.multispeed_fiber = TRUE;
1489 /* Determine PHY vendor */
1490 if (hw->phy.type != ixgbe_phy_nl) {
1491 hw->phy.id = identifier;
1492 status = hw->phy.ops.read_i2c_eeprom(hw,
1493 IXGBE_SFF_VENDOR_OUI_BYTE0,
1496 if (status != IXGBE_SUCCESS)
1497 goto err_read_i2c_eeprom;
1499 status = hw->phy.ops.read_i2c_eeprom(hw,
1500 IXGBE_SFF_VENDOR_OUI_BYTE1,
1503 if (status != IXGBE_SUCCESS)
1504 goto err_read_i2c_eeprom;
1506 status = hw->phy.ops.read_i2c_eeprom(hw,
1507 IXGBE_SFF_VENDOR_OUI_BYTE2,
1510 if (status != IXGBE_SUCCESS)
1511 goto err_read_i2c_eeprom;
1514 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1515 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1516 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1518 switch (vendor_oui) {
1519 case IXGBE_SFF_VENDOR_OUI_TYCO:
1520 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1522 ixgbe_phy_sfp_passive_tyco;
1524 case IXGBE_SFF_VENDOR_OUI_FTL:
1525 if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1526 hw->phy.type = ixgbe_phy_sfp_ftl_active;
1528 hw->phy.type = ixgbe_phy_sfp_ftl;
1530 case IXGBE_SFF_VENDOR_OUI_AVAGO:
1531 hw->phy.type = ixgbe_phy_sfp_avago;
1533 case IXGBE_SFF_VENDOR_OUI_INTEL:
1534 hw->phy.type = ixgbe_phy_sfp_intel;
1537 if (cable_tech & IXGBE_SFF_DA_PASSIVE_CABLE)
1539 ixgbe_phy_sfp_passive_unknown;
1540 else if (cable_tech & IXGBE_SFF_DA_ACTIVE_CABLE)
1542 ixgbe_phy_sfp_active_unknown;
1544 hw->phy.type = ixgbe_phy_sfp_unknown;
1549 /* Allow any DA cable vendor */
1550 if (cable_tech & (IXGBE_SFF_DA_PASSIVE_CABLE |
1551 IXGBE_SFF_DA_ACTIVE_CABLE)) {
1552 status = IXGBE_SUCCESS;
1556 /* Verify supported 1G SFP modules */
1557 if (comp_codes_10g == 0 &&
1558 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1559 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1560 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1561 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1562 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1563 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1564 hw->phy.type = ixgbe_phy_sfp_unsupported;
1565 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1569 /* Anything else 82598-based is supported */
1570 if (hw->mac.type == ixgbe_mac_82598EB) {
1571 status = IXGBE_SUCCESS;
1575 ixgbe_get_device_caps(hw, &enforce_sfp);
1576 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP) &&
1577 !(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1578 hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1579 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1580 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1581 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1582 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
1583 /* Make sure we're a supported PHY type */
1584 if (hw->phy.type == ixgbe_phy_sfp_intel) {
1585 status = IXGBE_SUCCESS;
1587 if (hw->allow_unsupported_sfp == TRUE) {
1588 EWARN(hw, "WARNING: Intel (R) Network "
1589 "Connections are quality tested "
1590 "using Intel (R) Ethernet Optics."
1591 " Using untested modules is not "
1592 "supported and may cause unstable"
1593 " operation or damage to the "
1594 "module or the adapter. Intel "
1595 "Corporation is not responsible "
1596 "for any harm caused by using "
1597 "untested modules.\n", status);
1598 status = IXGBE_SUCCESS;
1600 DEBUGOUT("SFP+ module not supported\n");
1602 ixgbe_phy_sfp_unsupported;
1603 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1607 status = IXGBE_SUCCESS;
1614 err_read_i2c_eeprom:
1615 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1616 if (hw->phy.type != ixgbe_phy_nl) {
1618 hw->phy.type = ixgbe_phy_unknown;
1620 return IXGBE_ERR_SFP_NOT_PRESENT;
1624 * ixgbe_get_supported_phy_sfp_layer_generic - Returns physical layer type
1625 * @hw: pointer to hardware structure
1627 * Determines physical layer capabilities of the current SFP.
1629 s32 ixgbe_get_supported_phy_sfp_layer_generic(struct ixgbe_hw *hw)
1631 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1632 u8 comp_codes_10g = 0;
1633 u8 comp_codes_1g = 0;
1635 DEBUGFUNC("ixgbe_get_supported_phy_sfp_layer_generic");
1637 hw->phy.ops.identify_sfp(hw);
1638 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1639 return physical_layer;
1641 switch (hw->phy.type) {
1642 case ixgbe_phy_sfp_passive_tyco:
1643 case ixgbe_phy_sfp_passive_unknown:
1644 case ixgbe_phy_qsfp_passive_unknown:
1645 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1647 case ixgbe_phy_sfp_ftl_active:
1648 case ixgbe_phy_sfp_active_unknown:
1649 case ixgbe_phy_qsfp_active_unknown:
1650 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_ACTIVE_DA;
1652 case ixgbe_phy_sfp_avago:
1653 case ixgbe_phy_sfp_ftl:
1654 case ixgbe_phy_sfp_intel:
1655 case ixgbe_phy_sfp_unknown:
1656 hw->phy.ops.read_i2c_eeprom(hw,
1657 IXGBE_SFF_1GBE_COMP_CODES, &comp_codes_1g);
1658 hw->phy.ops.read_i2c_eeprom(hw,
1659 IXGBE_SFF_10GBE_COMP_CODES, &comp_codes_10g);
1660 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1661 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1662 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1663 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1664 else if (comp_codes_1g & IXGBE_SFF_1GBASET_CAPABLE)
1665 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T;
1666 else if (comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE)
1667 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_SX;
1669 case ixgbe_phy_qsfp_intel:
1670 case ixgbe_phy_qsfp_unknown:
1671 hw->phy.ops.read_i2c_eeprom(hw,
1672 IXGBE_SFF_QSFP_10GBE_COMP, &comp_codes_10g);
1673 if (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)
1674 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1675 else if (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)
1676 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1682 return physical_layer;
1686 * ixgbe_identify_qsfp_module_generic - Identifies QSFP modules
1687 * @hw: pointer to hardware structure
1689 * Searches for and identifies the QSFP module and assigns appropriate PHY type
1691 s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
1693 s32 status = IXGBE_ERR_PHY_ADDR_INVALID;
1695 enum ixgbe_sfp_type stored_sfp_type = hw->phy.sfp_type;
1697 u8 comp_codes_1g = 0;
1698 u8 comp_codes_10g = 0;
1699 u8 oui_bytes[3] = {0, 0, 0};
1700 u16 enforce_sfp = 0;
1702 u8 cable_length = 0;
1704 bool active_cable = FALSE;
1706 DEBUGFUNC("ixgbe_identify_qsfp_module_generic");
1708 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_fiber_qsfp) {
1709 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1710 status = IXGBE_ERR_SFP_NOT_PRESENT;
1714 /* LAN ID is needed for I2C access */
1715 hw->mac.ops.set_lan_id(hw);
1717 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER,
1720 if (status != IXGBE_SUCCESS)
1721 goto err_read_i2c_eeprom;
1723 if (identifier != IXGBE_SFF_IDENTIFIER_QSFP_PLUS) {
1724 hw->phy.type = ixgbe_phy_sfp_unsupported;
1725 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1729 hw->phy.id = identifier;
1731 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_10GBE_COMP,
1734 if (status != IXGBE_SUCCESS)
1735 goto err_read_i2c_eeprom;
1737 status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_1GBE_COMP,
1740 if (status != IXGBE_SUCCESS)
1741 goto err_read_i2c_eeprom;
1743 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_PASSIVE_CABLE) {
1744 hw->phy.type = ixgbe_phy_qsfp_passive_unknown;
1745 if (hw->bus.lan_id == 0)
1746 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core0;
1748 hw->phy.sfp_type = ixgbe_sfp_type_da_cu_core1;
1749 } else if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1750 IXGBE_SFF_10GBASELR_CAPABLE)) {
1751 if (hw->bus.lan_id == 0)
1752 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core0;
1754 hw->phy.sfp_type = ixgbe_sfp_type_srlr_core1;
1756 if (comp_codes_10g & IXGBE_SFF_QSFP_DA_ACTIVE_CABLE)
1757 active_cable = TRUE;
1759 if (!active_cable) {
1760 /* check for active DA cables that pre-date
1762 hw->phy.ops.read_i2c_eeprom(hw,
1763 IXGBE_SFF_QSFP_CONNECTOR,
1766 hw->phy.ops.read_i2c_eeprom(hw,
1767 IXGBE_SFF_QSFP_CABLE_LENGTH,
1770 hw->phy.ops.read_i2c_eeprom(hw,
1771 IXGBE_SFF_QSFP_DEVICE_TECH,
1775 IXGBE_SFF_QSFP_CONNECTOR_NOT_SEPARABLE) &&
1776 (cable_length > 0) &&
1777 ((device_tech >> 4) ==
1778 IXGBE_SFF_QSFP_TRANSMITER_850NM_VCSEL))
1779 active_cable = TRUE;
1783 hw->phy.type = ixgbe_phy_qsfp_active_unknown;
1784 if (hw->bus.lan_id == 0)
1786 ixgbe_sfp_type_da_act_lmt_core0;
1789 ixgbe_sfp_type_da_act_lmt_core1;
1791 /* unsupported module type */
1792 hw->phy.type = ixgbe_phy_sfp_unsupported;
1793 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1798 if (hw->phy.sfp_type != stored_sfp_type)
1799 hw->phy.sfp_setup_needed = TRUE;
1801 /* Determine if the QSFP+ PHY is dual speed or not. */
1802 hw->phy.multispeed_fiber = FALSE;
1803 if (((comp_codes_1g & IXGBE_SFF_1GBASESX_CAPABLE) &&
1804 (comp_codes_10g & IXGBE_SFF_10GBASESR_CAPABLE)) ||
1805 ((comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) &&
1806 (comp_codes_10g & IXGBE_SFF_10GBASELR_CAPABLE)))
1807 hw->phy.multispeed_fiber = TRUE;
1809 /* Determine PHY vendor for optical modules */
1810 if (comp_codes_10g & (IXGBE_SFF_10GBASESR_CAPABLE |
1811 IXGBE_SFF_10GBASELR_CAPABLE)) {
1812 status = hw->phy.ops.read_i2c_eeprom(hw,
1813 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE0,
1816 if (status != IXGBE_SUCCESS)
1817 goto err_read_i2c_eeprom;
1819 status = hw->phy.ops.read_i2c_eeprom(hw,
1820 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE1,
1823 if (status != IXGBE_SUCCESS)
1824 goto err_read_i2c_eeprom;
1826 status = hw->phy.ops.read_i2c_eeprom(hw,
1827 IXGBE_SFF_QSFP_VENDOR_OUI_BYTE2,
1830 if (status != IXGBE_SUCCESS)
1831 goto err_read_i2c_eeprom;
1834 ((oui_bytes[0] << IXGBE_SFF_VENDOR_OUI_BYTE0_SHIFT) |
1835 (oui_bytes[1] << IXGBE_SFF_VENDOR_OUI_BYTE1_SHIFT) |
1836 (oui_bytes[2] << IXGBE_SFF_VENDOR_OUI_BYTE2_SHIFT));
1838 if (vendor_oui == IXGBE_SFF_VENDOR_OUI_INTEL)
1839 hw->phy.type = ixgbe_phy_qsfp_intel;
1841 hw->phy.type = ixgbe_phy_qsfp_unknown;
1843 ixgbe_get_device_caps(hw, &enforce_sfp);
1844 if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP)) {
1845 /* Make sure we're a supported PHY type */
1846 if (hw->phy.type == ixgbe_phy_qsfp_intel) {
1847 status = IXGBE_SUCCESS;
1849 if (hw->allow_unsupported_sfp == TRUE) {
1850 EWARN(hw, "WARNING: Intel (R) Network "
1851 "Connections are quality tested "
1852 "using Intel (R) Ethernet Optics."
1853 " Using untested modules is not "
1854 "supported and may cause unstable"
1855 " operation or damage to the "
1856 "module or the adapter. Intel "
1857 "Corporation is not responsible "
1858 "for any harm caused by using "
1859 "untested modules.\n", status);
1860 status = IXGBE_SUCCESS;
1862 DEBUGOUT("QSFP module not supported\n");
1864 ixgbe_phy_sfp_unsupported;
1865 status = IXGBE_ERR_SFP_NOT_SUPPORTED;
1869 status = IXGBE_SUCCESS;
1876 err_read_i2c_eeprom:
1877 hw->phy.sfp_type = ixgbe_sfp_type_not_present;
1879 hw->phy.type = ixgbe_phy_unknown;
1881 return IXGBE_ERR_SFP_NOT_PRESENT;
1886 * ixgbe_get_sfp_init_sequence_offsets - Provides offset of PHY init sequence
1887 * @hw: pointer to hardware structure
1888 * @list_offset: offset to the SFP ID list
1889 * @data_offset: offset to the SFP data block
1891 * Checks the MAC's EEPROM to see if it supports a given SFP+ module type, if
1892 * so it returns the offsets to the phy init sequence block.
1894 s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
1899 u16 sfp_type = hw->phy.sfp_type;
1901 DEBUGFUNC("ixgbe_get_sfp_init_sequence_offsets");
1903 if (hw->phy.sfp_type == ixgbe_sfp_type_unknown)
1904 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1906 if (hw->phy.sfp_type == ixgbe_sfp_type_not_present)
1907 return IXGBE_ERR_SFP_NOT_PRESENT;
1909 if ((hw->device_id == IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) &&
1910 (hw->phy.sfp_type == ixgbe_sfp_type_da_cu))
1911 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1914 * Limiting active cables and 1G Phys must be initialized as
1917 if (sfp_type == ixgbe_sfp_type_da_act_lmt_core0 ||
1918 sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1919 sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
1920 sfp_type == ixgbe_sfp_type_1g_sx_core0)
1921 sfp_type = ixgbe_sfp_type_srlr_core0;
1922 else if (sfp_type == ixgbe_sfp_type_da_act_lmt_core1 ||
1923 sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
1924 sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
1925 sfp_type == ixgbe_sfp_type_1g_sx_core1)
1926 sfp_type = ixgbe_sfp_type_srlr_core1;
1928 /* Read offset to PHY init contents */
1929 if (hw->eeprom.ops.read(hw, IXGBE_PHY_INIT_OFFSET_NL, list_offset)) {
1930 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1931 "eeprom read at offset %d failed",
1932 IXGBE_PHY_INIT_OFFSET_NL);
1933 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1936 if ((!*list_offset) || (*list_offset == 0xFFFF))
1937 return IXGBE_ERR_SFP_NO_INIT_SEQ_PRESENT;
1939 /* Shift offset to first ID word */
1943 * Find the matching SFP ID in the EEPROM
1944 * and program the init sequence
1946 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1949 while (sfp_id != IXGBE_PHY_INIT_END_NL) {
1950 if (sfp_id == sfp_type) {
1952 if (hw->eeprom.ops.read(hw, *list_offset, data_offset))
1954 if ((!*data_offset) || (*data_offset == 0xFFFF)) {
1955 DEBUGOUT("SFP+ module not supported\n");
1956 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1961 (*list_offset) += 2;
1962 if (hw->eeprom.ops.read(hw, *list_offset, &sfp_id))
1967 if (sfp_id == IXGBE_PHY_INIT_END_NL) {
1968 DEBUGOUT("No matching SFP+ module found\n");
1969 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1972 return IXGBE_SUCCESS;
1975 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
1976 "eeprom read at offset %d failed", *list_offset);
1977 return IXGBE_ERR_PHY;
1981 * ixgbe_read_i2c_eeprom_generic - Reads 8 bit EEPROM word over I2C interface
1982 * @hw: pointer to hardware structure
1983 * @byte_offset: EEPROM byte offset to read
1984 * @eeprom_data: value read
1986 * Performs byte read operation to SFP module's EEPROM over I2C interface.
1988 s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
1991 DEBUGFUNC("ixgbe_read_i2c_eeprom_generic");
1993 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
1994 IXGBE_I2C_EEPROM_DEV_ADDR,
1999 * ixgbe_read_i2c_sff8472_generic - Reads 8 bit word over I2C interface
2000 * @hw: pointer to hardware structure
2001 * @byte_offset: byte offset at address 0xA2
2002 * @eeprom_data: value read
2004 * Performs byte read operation to SFP module's SFF-8472 data over I2C
2006 static s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset,
2009 return hw->phy.ops.read_i2c_byte(hw, byte_offset,
2010 IXGBE_I2C_EEPROM_DEV_ADDR2,
2015 * ixgbe_write_i2c_eeprom_generic - Writes 8 bit EEPROM word over I2C interface
2016 * @hw: pointer to hardware structure
2017 * @byte_offset: EEPROM byte offset to write
2018 * @eeprom_data: value to write
2020 * Performs byte write operation to SFP module's EEPROM over I2C interface.
2022 s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
2025 DEBUGFUNC("ixgbe_write_i2c_eeprom_generic");
2027 return hw->phy.ops.write_i2c_byte(hw, byte_offset,
2028 IXGBE_I2C_EEPROM_DEV_ADDR,
2033 * ixgbe_is_sfp_probe - Returns TRUE if SFP is being detected
2034 * @hw: pointer to hardware structure
2035 * @offset: eeprom offset to be read
2036 * @addr: I2C address to be read
2038 static bool ixgbe_is_sfp_probe(struct ixgbe_hw *hw, u8 offset, u8 addr)
2040 if (addr == IXGBE_I2C_EEPROM_DEV_ADDR &&
2041 offset == IXGBE_SFF_IDENTIFIER &&
2042 hw->phy.sfp_type == ixgbe_sfp_type_not_present)
2048 * ixgbe_read_i2c_byte_generic_int - Reads 8 bit word over I2C
2049 * @hw: pointer to hardware structure
2050 * @byte_offset: byte offset to read
2052 * @lock: TRUE if to take and release semaphore
2054 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2055 * a specified device address.
2057 static s32 ixgbe_read_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
2058 u8 dev_addr, u8 *data, bool lock)
2063 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2067 DEBUGFUNC("ixgbe_read_i2c_byte_generic");
2069 if (hw->mac.type >= ixgbe_mac_X550)
2071 if (ixgbe_is_sfp_probe(hw, byte_offset, dev_addr))
2072 max_retry = IXGBE_SFP_DETECT_RETRIES;
2075 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
2076 return IXGBE_ERR_SWFW_SYNC;
2078 ixgbe_i2c_start(hw);
2080 /* Device Address and write indication */
2081 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
2082 if (status != IXGBE_SUCCESS)
2085 status = ixgbe_get_i2c_ack(hw);
2086 if (status != IXGBE_SUCCESS)
2089 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
2090 if (status != IXGBE_SUCCESS)
2093 status = ixgbe_get_i2c_ack(hw);
2094 if (status != IXGBE_SUCCESS)
2097 ixgbe_i2c_start(hw);
2099 /* Device Address and read indication */
2100 status = ixgbe_clock_out_i2c_byte(hw, (dev_addr | 0x1));
2101 if (status != IXGBE_SUCCESS)
2104 status = ixgbe_get_i2c_ack(hw);
2105 if (status != IXGBE_SUCCESS)
2108 status = ixgbe_clock_in_i2c_byte(hw, data);
2109 if (status != IXGBE_SUCCESS)
2112 status = ixgbe_clock_out_i2c_bit(hw, nack);
2113 if (status != IXGBE_SUCCESS)
2118 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2119 return IXGBE_SUCCESS;
2122 ixgbe_i2c_bus_clear(hw);
2124 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2128 if (retry < max_retry)
2129 DEBUGOUT("I2C byte read error - Retrying.\n");
2131 DEBUGOUT("I2C byte read error.\n");
2133 } while (retry < max_retry);
2139 * ixgbe_read_i2c_byte_generic - Reads 8 bit word over I2C
2140 * @hw: pointer to hardware structure
2141 * @byte_offset: byte offset to read
2144 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2145 * a specified device address.
2147 s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
2148 u8 dev_addr, u8 *data)
2150 return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2155 * ixgbe_read_i2c_byte_generic_unlocked - Reads 8 bit word over I2C
2156 * @hw: pointer to hardware structure
2157 * @byte_offset: byte offset to read
2160 * Performs byte read operation to SFP module's EEPROM over I2C interface at
2161 * a specified device address.
2163 s32 ixgbe_read_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2164 u8 dev_addr, u8 *data)
2166 return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2171 * ixgbe_write_i2c_byte_generic_int - Writes 8 bit word over I2C
2172 * @hw: pointer to hardware structure
2173 * @byte_offset: byte offset to write
2174 * @data: value to write
2175 * @lock: TRUE if to take and release semaphore
2177 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2178 * a specified device address.
2180 static s32 ixgbe_write_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
2181 u8 dev_addr, u8 data, bool lock)
2186 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2188 DEBUGFUNC("ixgbe_write_i2c_byte_generic");
2190 if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) !=
2192 return IXGBE_ERR_SWFW_SYNC;
2195 ixgbe_i2c_start(hw);
2197 status = ixgbe_clock_out_i2c_byte(hw, dev_addr);
2198 if (status != IXGBE_SUCCESS)
2201 status = ixgbe_get_i2c_ack(hw);
2202 if (status != IXGBE_SUCCESS)
2205 status = ixgbe_clock_out_i2c_byte(hw, byte_offset);
2206 if (status != IXGBE_SUCCESS)
2209 status = ixgbe_get_i2c_ack(hw);
2210 if (status != IXGBE_SUCCESS)
2213 status = ixgbe_clock_out_i2c_byte(hw, data);
2214 if (status != IXGBE_SUCCESS)
2217 status = ixgbe_get_i2c_ack(hw);
2218 if (status != IXGBE_SUCCESS)
2223 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2224 return IXGBE_SUCCESS;
2227 ixgbe_i2c_bus_clear(hw);
2229 if (retry < max_retry)
2230 DEBUGOUT("I2C byte write error - Retrying.\n");
2232 DEBUGOUT("I2C byte write error.\n");
2233 } while (retry < max_retry);
2236 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2242 * ixgbe_write_i2c_byte_generic - Writes 8 bit word over I2C
2243 * @hw: pointer to hardware structure
2244 * @byte_offset: byte offset to write
2245 * @data: value to write
2247 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2248 * a specified device address.
2250 s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
2251 u8 dev_addr, u8 data)
2253 return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2258 * ixgbe_write_i2c_byte_generic_unlocked - Writes 8 bit word over I2C
2259 * @hw: pointer to hardware structure
2260 * @byte_offset: byte offset to write
2261 * @data: value to write
2263 * Performs byte write operation to SFP module's EEPROM over I2C interface at
2264 * a specified device address.
2266 s32 ixgbe_write_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
2267 u8 dev_addr, u8 data)
2269 return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
2274 * ixgbe_i2c_start - Sets I2C start condition
2275 * @hw: pointer to hardware structure
2277 * Sets I2C start condition (High -> Low on SDA while SCL is High)
2278 * Set bit-bang mode on X550 hardware.
2280 static void ixgbe_i2c_start(struct ixgbe_hw *hw)
2282 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2284 DEBUGFUNC("ixgbe_i2c_start");
2286 i2cctl |= IXGBE_I2C_BB_EN_BY_MAC(hw);
2288 /* Start condition must begin with data and clock high */
2289 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2290 ixgbe_raise_i2c_clk(hw, &i2cctl);
2292 /* Setup time for start condition (4.7us) */
2293 usec_delay(IXGBE_I2C_T_SU_STA);
2295 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2297 /* Hold time for start condition (4us) */
2298 usec_delay(IXGBE_I2C_T_HD_STA);
2300 ixgbe_lower_i2c_clk(hw, &i2cctl);
2302 /* Minimum low period of clock is 4.7 us */
2303 usec_delay(IXGBE_I2C_T_LOW);
2308 * ixgbe_i2c_stop - Sets I2C stop condition
2309 * @hw: pointer to hardware structure
2311 * Sets I2C stop condition (Low -> High on SDA while SCL is High)
2312 * Disables bit-bang mode and negates data output enable on X550
2315 static void ixgbe_i2c_stop(struct ixgbe_hw *hw)
2317 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2318 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2319 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2320 u32 bb_en_bit = IXGBE_I2C_BB_EN_BY_MAC(hw);
2322 DEBUGFUNC("ixgbe_i2c_stop");
2324 /* Stop condition must begin with data low and clock high */
2325 ixgbe_set_i2c_data(hw, &i2cctl, 0);
2326 ixgbe_raise_i2c_clk(hw, &i2cctl);
2328 /* Setup time for stop condition (4us) */
2329 usec_delay(IXGBE_I2C_T_SU_STO);
2331 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2333 /* bus free time between stop and start (4.7us)*/
2334 usec_delay(IXGBE_I2C_T_BUF);
2336 if (bb_en_bit || data_oe_bit || clk_oe_bit) {
2337 i2cctl &= ~bb_en_bit;
2338 i2cctl |= data_oe_bit | clk_oe_bit;
2339 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2340 IXGBE_WRITE_FLUSH(hw);
2345 * ixgbe_clock_in_i2c_byte - Clocks in one byte via I2C
2346 * @hw: pointer to hardware structure
2347 * @data: data byte to clock in
2349 * Clocks in one byte data via I2C data/clock
2351 static s32 ixgbe_clock_in_i2c_byte(struct ixgbe_hw *hw, u8 *data)
2356 DEBUGFUNC("ixgbe_clock_in_i2c_byte");
2359 for (i = 7; i >= 0; i--) {
2360 ixgbe_clock_in_i2c_bit(hw, &bit);
2364 return IXGBE_SUCCESS;
2368 * ixgbe_clock_out_i2c_byte - Clocks out one byte via I2C
2369 * @hw: pointer to hardware structure
2370 * @data: data byte clocked out
2372 * Clocks out one byte data via I2C data/clock
2374 static s32 ixgbe_clock_out_i2c_byte(struct ixgbe_hw *hw, u8 data)
2376 s32 status = IXGBE_SUCCESS;
2381 DEBUGFUNC("ixgbe_clock_out_i2c_byte");
2383 for (i = 7; i >= 0; i--) {
2384 bit = (data >> i) & 0x1;
2385 status = ixgbe_clock_out_i2c_bit(hw, bit);
2387 if (status != IXGBE_SUCCESS)
2391 /* Release SDA line (set high) */
2392 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2393 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2394 i2cctl |= IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2395 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2396 IXGBE_WRITE_FLUSH(hw);
2402 * ixgbe_get_i2c_ack - Polls for I2C ACK
2403 * @hw: pointer to hardware structure
2405 * Clocks in/out one bit via I2C data/clock
2407 static s32 ixgbe_get_i2c_ack(struct ixgbe_hw *hw)
2409 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2410 s32 status = IXGBE_SUCCESS;
2412 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2416 DEBUGFUNC("ixgbe_get_i2c_ack");
2419 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2420 i2cctl |= data_oe_bit;
2421 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2422 IXGBE_WRITE_FLUSH(hw);
2424 ixgbe_raise_i2c_clk(hw, &i2cctl);
2426 /* Minimum high period of clock is 4us */
2427 usec_delay(IXGBE_I2C_T_HIGH);
2429 /* Poll for ACK. Note that ACK in I2C spec is
2430 * transition from 1 to 0 */
2431 for (i = 0; i < timeout; i++) {
2432 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2433 ack = ixgbe_get_i2c_data(hw, &i2cctl);
2441 DEBUGOUT("I2C ack was not received.\n");
2442 status = IXGBE_ERR_I2C;
2445 ixgbe_lower_i2c_clk(hw, &i2cctl);
2447 /* Minimum low period of clock is 4.7 us */
2448 usec_delay(IXGBE_I2C_T_LOW);
2454 * ixgbe_clock_in_i2c_bit - Clocks in one bit via I2C data/clock
2455 * @hw: pointer to hardware structure
2456 * @data: read data value
2458 * Clocks in one bit via I2C data/clock
2460 static s32 ixgbe_clock_in_i2c_bit(struct ixgbe_hw *hw, bool *data)
2462 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2463 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2465 DEBUGFUNC("ixgbe_clock_in_i2c_bit");
2468 i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2469 i2cctl |= data_oe_bit;
2470 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), i2cctl);
2471 IXGBE_WRITE_FLUSH(hw);
2473 ixgbe_raise_i2c_clk(hw, &i2cctl);
2475 /* Minimum high period of clock is 4us */
2476 usec_delay(IXGBE_I2C_T_HIGH);
2478 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2479 *data = ixgbe_get_i2c_data(hw, &i2cctl);
2481 ixgbe_lower_i2c_clk(hw, &i2cctl);
2483 /* Minimum low period of clock is 4.7 us */
2484 usec_delay(IXGBE_I2C_T_LOW);
2486 return IXGBE_SUCCESS;
2490 * ixgbe_clock_out_i2c_bit - Clocks in/out one bit via I2C data/clock
2491 * @hw: pointer to hardware structure
2492 * @data: data value to write
2494 * Clocks out one bit via I2C data/clock
2496 static s32 ixgbe_clock_out_i2c_bit(struct ixgbe_hw *hw, bool data)
2499 u32 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2501 DEBUGFUNC("ixgbe_clock_out_i2c_bit");
2503 status = ixgbe_set_i2c_data(hw, &i2cctl, data);
2504 if (status == IXGBE_SUCCESS) {
2505 ixgbe_raise_i2c_clk(hw, &i2cctl);
2507 /* Minimum high period of clock is 4us */
2508 usec_delay(IXGBE_I2C_T_HIGH);
2510 ixgbe_lower_i2c_clk(hw, &i2cctl);
2512 /* Minimum low period of clock is 4.7 us.
2513 * This also takes care of the data hold time.
2515 usec_delay(IXGBE_I2C_T_LOW);
2517 status = IXGBE_ERR_I2C;
2518 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2519 "I2C data was not set to %X\n", data);
2526 * ixgbe_raise_i2c_clk - Raises the I2C SCL clock
2527 * @hw: pointer to hardware structure
2528 * @i2cctl: Current value of I2CCTL register
2530 * Raises the I2C clock line '0'->'1'
2531 * Negates the I2C clock output enable on X550 hardware.
2533 static void ixgbe_raise_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2535 u32 clk_oe_bit = IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2537 u32 timeout = IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT;
2540 DEBUGFUNC("ixgbe_raise_i2c_clk");
2543 *i2cctl |= clk_oe_bit;
2544 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2547 for (i = 0; i < timeout; i++) {
2548 *i2cctl |= IXGBE_I2C_CLK_OUT_BY_MAC(hw);
2550 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2551 IXGBE_WRITE_FLUSH(hw);
2552 /* SCL rise time (1000ns) */
2553 usec_delay(IXGBE_I2C_T_RISE);
2555 i2cctl_r = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2556 if (i2cctl_r & IXGBE_I2C_CLK_IN_BY_MAC(hw))
2562 * ixgbe_lower_i2c_clk - Lowers the I2C SCL clock
2563 * @hw: pointer to hardware structure
2564 * @i2cctl: Current value of I2CCTL register
2566 * Lowers the I2C clock line '1'->'0'
2567 * Asserts the I2C clock output enable on X550 hardware.
2569 static void ixgbe_lower_i2c_clk(struct ixgbe_hw *hw, u32 *i2cctl)
2571 DEBUGFUNC("ixgbe_lower_i2c_clk");
2573 *i2cctl &= ~(IXGBE_I2C_CLK_OUT_BY_MAC(hw));
2574 *i2cctl &= ~IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw);
2576 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2577 IXGBE_WRITE_FLUSH(hw);
2579 /* SCL fall time (300ns) */
2580 usec_delay(IXGBE_I2C_T_FALL);
2584 * ixgbe_set_i2c_data - Sets the I2C data bit
2585 * @hw: pointer to hardware structure
2586 * @i2cctl: Current value of I2CCTL register
2587 * @data: I2C data value (0 or 1) to set
2589 * Sets the I2C data bit
2590 * Asserts the I2C data output enable on X550 hardware.
2592 static s32 ixgbe_set_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl, bool data)
2594 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2595 s32 status = IXGBE_SUCCESS;
2597 DEBUGFUNC("ixgbe_set_i2c_data");
2600 *i2cctl |= IXGBE_I2C_DATA_OUT_BY_MAC(hw);
2602 *i2cctl &= ~(IXGBE_I2C_DATA_OUT_BY_MAC(hw));
2603 *i2cctl &= ~data_oe_bit;
2605 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2606 IXGBE_WRITE_FLUSH(hw);
2608 /* Data rise/fall (1000ns/300ns) and set-up time (250ns) */
2609 usec_delay(IXGBE_I2C_T_RISE + IXGBE_I2C_T_FALL + IXGBE_I2C_T_SU_DATA);
2611 if (!data) /* Can't verify data in this case */
2612 return IXGBE_SUCCESS;
2614 *i2cctl |= data_oe_bit;
2615 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2616 IXGBE_WRITE_FLUSH(hw);
2619 /* Verify data was set correctly */
2620 *i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2621 if (data != ixgbe_get_i2c_data(hw, i2cctl)) {
2622 status = IXGBE_ERR_I2C;
2623 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
2624 "Error - I2C data was not set to %X.\n",
2632 * ixgbe_get_i2c_data - Reads the I2C SDA data bit
2633 * @hw: pointer to hardware structure
2634 * @i2cctl: Current value of I2CCTL register
2636 * Returns the I2C data bit value
2637 * Negates the I2C data output enable on X550 hardware.
2639 static bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl)
2641 u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw);
2644 DEBUGFUNC("ixgbe_get_i2c_data");
2647 *i2cctl |= data_oe_bit;
2648 IXGBE_WRITE_REG(hw, IXGBE_I2CCTL_BY_MAC(hw), *i2cctl);
2649 IXGBE_WRITE_FLUSH(hw);
2650 usec_delay(IXGBE_I2C_T_FALL);
2653 if (*i2cctl & IXGBE_I2C_DATA_IN_BY_MAC(hw))
2662 * ixgbe_i2c_bus_clear - Clears the I2C bus
2663 * @hw: pointer to hardware structure
2665 * Clears the I2C bus by sending nine clock pulses.
2666 * Used when data line is stuck low.
2668 void ixgbe_i2c_bus_clear(struct ixgbe_hw *hw)
2673 DEBUGFUNC("ixgbe_i2c_bus_clear");
2675 ixgbe_i2c_start(hw);
2676 i2cctl = IXGBE_READ_REG(hw, IXGBE_I2CCTL_BY_MAC(hw));
2678 ixgbe_set_i2c_data(hw, &i2cctl, 1);
2680 for (i = 0; i < 9; i++) {
2681 ixgbe_raise_i2c_clk(hw, &i2cctl);
2683 /* Min high period of clock is 4us */
2684 usec_delay(IXGBE_I2C_T_HIGH);
2686 ixgbe_lower_i2c_clk(hw, &i2cctl);
2688 /* Min low period of clock is 4.7us*/
2689 usec_delay(IXGBE_I2C_T_LOW);
2692 ixgbe_i2c_start(hw);
2694 /* Put the i2c bus back to default state */
2699 * ixgbe_tn_check_overtemp - Checks if an overtemp occurred.
2700 * @hw: pointer to hardware structure
2702 * Checks if the LASI temp alarm status was triggered due to overtemp
2704 s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw)
2706 s32 status = IXGBE_SUCCESS;
2709 DEBUGFUNC("ixgbe_tn_check_overtemp");
2711 if (hw->device_id != IXGBE_DEV_ID_82599_T3_LOM)
2714 /* Check that the LASI temp alarm status was triggered */
2715 hw->phy.ops.read_reg(hw, IXGBE_TN_LASI_STATUS_REG,
2716 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &phy_data);
2718 if (!(phy_data & IXGBE_TN_LASI_STATUS_TEMP_ALARM))
2721 status = IXGBE_ERR_OVERTEMP;
2722 ERROR_REPORT1(IXGBE_ERROR_CAUTION, "Device over temperature");
2728 * ixgbe_set_copper_phy_power - Control power for copper phy
2729 * @hw: pointer to hardware structure
2730 * @on: TRUE for on, FALSE for off
2732 s32 ixgbe_set_copper_phy_power(struct ixgbe_hw *hw, bool on)
2737 if (!on && ixgbe_mng_present(hw))
2740 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2741 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2747 reg &= ~IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2749 if (ixgbe_check_reset_blocked(hw))
2751 reg |= IXGBE_MDIO_PHY_SET_LOW_POWER_MODE;
2754 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
2755 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,