Lines Matching +full:enable +full:- +full:offset
2 SPDX-License-Identifier: BSD-3-Clause
4 Copyright (c) 2001-2020, Intel Corporation
38 static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,
41 static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset,
65 * e1000_init_phy_ops_generic - Initialize PHY function pointers
68 * Setups up the function pointers to no-op functions
72 struct e1000_phy_info *phy = &hw->phy; in e1000_init_phy_ops_generic()
76 phy->ops.init_params = e1000_null_ops_generic; in e1000_init_phy_ops_generic()
77 phy->ops.acquire = e1000_null_ops_generic; in e1000_init_phy_ops_generic()
78 phy->ops.check_polarity = e1000_null_ops_generic; in e1000_init_phy_ops_generic()
79 phy->ops.check_reset_block = e1000_null_ops_generic; in e1000_init_phy_ops_generic()
80 phy->ops.commit = e1000_null_ops_generic; in e1000_init_phy_ops_generic()
81 phy->ops.force_speed_duplex = e1000_null_ops_generic; in e1000_init_phy_ops_generic()
82 phy->ops.get_cfg_done = e1000_null_ops_generic; in e1000_init_phy_ops_generic()
83 phy->ops.get_cable_length = e1000_null_ops_generic; in e1000_init_phy_ops_generic()
84 phy->ops.get_info = e1000_null_ops_generic; in e1000_init_phy_ops_generic()
85 phy->ops.set_page = e1000_null_set_page; in e1000_init_phy_ops_generic()
86 phy->ops.read_reg = e1000_null_read_reg; in e1000_init_phy_ops_generic()
87 phy->ops.read_reg_locked = e1000_null_read_reg; in e1000_init_phy_ops_generic()
88 phy->ops.read_reg_page = e1000_null_read_reg; in e1000_init_phy_ops_generic()
89 phy->ops.release = e1000_null_phy_generic; in e1000_init_phy_ops_generic()
90 phy->ops.reset = e1000_null_ops_generic; in e1000_init_phy_ops_generic()
91 phy->ops.set_d0_lplu_state = e1000_null_lplu_state; in e1000_init_phy_ops_generic()
92 phy->ops.set_d3_lplu_state = e1000_null_lplu_state; in e1000_init_phy_ops_generic()
93 phy->ops.write_reg = e1000_null_write_reg; in e1000_init_phy_ops_generic()
94 phy->ops.write_reg_locked = e1000_null_write_reg; in e1000_init_phy_ops_generic()
95 phy->ops.write_reg_page = e1000_null_write_reg; in e1000_init_phy_ops_generic()
96 phy->ops.power_up = e1000_null_phy_generic; in e1000_init_phy_ops_generic()
97 phy->ops.power_down = e1000_null_phy_generic; in e1000_init_phy_ops_generic()
98 phy->ops.read_i2c_byte = e1000_read_i2c_byte_null; in e1000_init_phy_ops_generic()
99 phy->ops.write_i2c_byte = e1000_write_i2c_byte_null; in e1000_init_phy_ops_generic()
100 phy->ops.cfg_on_link_up = e1000_null_ops_generic; in e1000_init_phy_ops_generic()
104 * e1000_null_set_page - No-op function, return 0
116 * e1000_null_read_reg - No-op function, return 0
118 * @offset: dummy variable
122 u32 E1000_UNUSEDARG offset, u16 E1000_UNUSEDARG *data) in e1000_null_read_reg() argument
129 * e1000_null_phy_generic - No-op function, return void
139 * e1000_null_lplu_state - No-op function, return 0
151 * e1000_null_write_reg - No-op function, return 0
153 * @offset: dummy variable
157 u32 E1000_UNUSEDARG offset, u16 E1000_UNUSEDARG data) in e1000_null_write_reg() argument
164 * e1000_read_i2c_byte_null - No-op function, return 0
166 * @byte_offset: byte offset to write
181 * e1000_write_i2c_byte_null - No-op function, return 0
183 * @byte_offset: byte offset to write
198 * e1000_check_reset_block_generic - Check if PHY reset is blocked
218 * e1000_get_phy_id - Retrieve the PHY ID and revision
226 struct e1000_phy_info *phy = &hw->phy; in e1000_get_phy_id()
233 if (!phy->ops.read_reg) in e1000_get_phy_id()
237 ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id); in e1000_get_phy_id()
241 phy->id = (u32)(phy_id << 16); in e1000_get_phy_id()
243 ret_val = phy->ops.read_reg(hw, PHY_ID2, &phy_id); in e1000_get_phy_id()
247 phy->id |= (u32)(phy_id & PHY_REVISION_MASK); in e1000_get_phy_id()
248 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); in e1000_get_phy_id()
250 if (phy->id != 0 && phy->id != PHY_REVISION_MASK) in e1000_get_phy_id()
260 * e1000_phy_reset_dsp_generic - Reset PHY DSP
271 if (!hw->phy.ops.write_reg) in e1000_phy_reset_dsp_generic()
274 ret_val = hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0xC1); in e1000_phy_reset_dsp_generic()
278 return hw->phy.ops.write_reg(hw, M88E1000_PHY_GEN_CONTROL, 0); in e1000_phy_reset_dsp_generic()
282 * e1000_read_phy_reg_mdic - Read MDI control register
284 * @offset: register offset to be read
287 * Reads the MDI control register in the PHY at offset and stores the
290 s32 e1000_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_mdic() argument
292 struct e1000_phy_info *phy = &hw->phy; in e1000_read_phy_reg_mdic()
297 if (offset > MAX_PHY_REG_ADDRESS) { in e1000_read_phy_reg_mdic()
298 DEBUGOUT1("PHY Address %d is out of range\n", offset); in e1000_read_phy_reg_mdic()
299 return -E1000_ERR_PARAM; in e1000_read_phy_reg_mdic()
302 /* Set up Op-code, Phy Address, and register offset in the MDI in e1000_read_phy_reg_mdic()
306 mdic = ((offset << E1000_MDIC_REG_SHIFT) | in e1000_read_phy_reg_mdic()
307 (phy->addr << E1000_MDIC_PHY_SHIFT) | in e1000_read_phy_reg_mdic()
324 return -E1000_ERR_PHY; in e1000_read_phy_reg_mdic()
328 return -E1000_ERR_PHY; in e1000_read_phy_reg_mdic()
330 if (((mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT) != offset) { in e1000_read_phy_reg_mdic()
331 DEBUGOUT2("MDI Read offset error - requested %d, returned %d\n", in e1000_read_phy_reg_mdic()
332 offset, in e1000_read_phy_reg_mdic()
334 return -E1000_ERR_PHY; in e1000_read_phy_reg_mdic()
341 if (hw->mac.type == e1000_pch2lan) in e1000_read_phy_reg_mdic()
348 * e1000_write_phy_reg_mdic - Write MDI control register
350 * @offset: register offset to write to
351 * @data: data to write to register at offset
353 * Writes data to MDI control register in the PHY at offset.
355 s32 e1000_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_mdic() argument
357 struct e1000_phy_info *phy = &hw->phy; in e1000_write_phy_reg_mdic()
362 if (offset > MAX_PHY_REG_ADDRESS) { in e1000_write_phy_reg_mdic()
363 DEBUGOUT1("PHY Address %d is out of range\n", offset); in e1000_write_phy_reg_mdic()
364 return -E1000_ERR_PARAM; in e1000_write_phy_reg_mdic()
367 /* Set up Op-code, Phy Address, and register offset in the MDI in e1000_write_phy_reg_mdic()
372 (offset << E1000_MDIC_REG_SHIFT) | in e1000_write_phy_reg_mdic()
373 (phy->addr << E1000_MDIC_PHY_SHIFT) | in e1000_write_phy_reg_mdic()
390 return -E1000_ERR_PHY; in e1000_write_phy_reg_mdic()
394 return -E1000_ERR_PHY; in e1000_write_phy_reg_mdic()
396 if (((mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT) != offset) { in e1000_write_phy_reg_mdic()
397 DEBUGOUT2("MDI Write offset error - requested %d, returned %d\n", in e1000_write_phy_reg_mdic()
398 offset, in e1000_write_phy_reg_mdic()
400 return -E1000_ERR_PHY; in e1000_write_phy_reg_mdic()
406 if (hw->mac.type == e1000_pch2lan) in e1000_write_phy_reg_mdic()
413 * e1000_read_phy_reg_i2c - Read PHY register using i2c
415 * @offset: register offset to be read
418 * Reads the PHY register at offset using the i2c interface and stores the
421 s32 e1000_read_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_i2c() argument
423 struct e1000_phy_info *phy = &hw->phy; in e1000_read_phy_reg_i2c()
428 /* Set up Op-code, Phy Address, and register address in the I2CCMD in e1000_read_phy_reg_i2c()
432 i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) | in e1000_read_phy_reg_i2c()
433 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) | in e1000_read_phy_reg_i2c()
447 return -E1000_ERR_PHY; in e1000_read_phy_reg_i2c()
451 return -E1000_ERR_PHY; in e1000_read_phy_reg_i2c()
454 /* Need to byte-swap the 16-bit value. */ in e1000_read_phy_reg_i2c()
461 * e1000_write_phy_reg_i2c - Write PHY register using i2c
463 * @offset: register offset to write to
464 * @data: data to write at register offset
466 * Writes the data to PHY register at the offset using the i2c interface.
468 s32 e1000_write_phy_reg_i2c(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_i2c() argument
470 struct e1000_phy_info *phy = &hw->phy; in e1000_write_phy_reg_i2c()
477 if ((hw->phy.addr == 0) || (hw->phy.addr > 7)) { in e1000_write_phy_reg_i2c()
479 hw->phy.addr); in e1000_write_phy_reg_i2c()
480 return -E1000_ERR_CONFIG; in e1000_write_phy_reg_i2c()
486 /* Set up Op-code, Phy Address, and register address in the I2CCMD in e1000_write_phy_reg_i2c()
490 i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) | in e1000_write_phy_reg_i2c()
491 (phy->addr << E1000_I2CCMD_PHY_ADDR_SHIFT) | in e1000_write_phy_reg_i2c()
506 return -E1000_ERR_PHY; in e1000_write_phy_reg_i2c()
510 return -E1000_ERR_PHY; in e1000_write_phy_reg_i2c()
517 * e1000_read_sfp_data_byte - Reads SFP module data.
519 * @offset: byte location offset to be read
525 * E1000_I2CCMD_SFP_DATA_ADDR(<byte offset>) for SFP module database access
526 * E1000_I2CCMD_SFP_DIAG_ADDR(<byte offset>) for SFP diagnostics parameters
529 s32 e1000_read_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 *data) in e1000_read_sfp_data_byte() argument
537 if (offset > E1000_I2CCMD_SFP_DIAG_ADDR(255)) { in e1000_read_sfp_data_byte()
539 return -E1000_ERR_PHY; in e1000_read_sfp_data_byte()
542 /* Set up Op-code, EEPROM Address,in the I2CCMD in e1000_read_sfp_data_byte()
546 i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) | in e1000_read_sfp_data_byte()
560 return -E1000_ERR_PHY; in e1000_read_sfp_data_byte()
564 return -E1000_ERR_PHY; in e1000_read_sfp_data_byte()
572 * e1000_write_sfp_data_byte - Writes SFP module data.
574 * @offset: byte location offset to write to
580 * E1000_I2CCMD_SFP_DATA_ADDR(<byte offset>) for SFP module database access
581 * E1000_I2CCMD_SFP_DIAG_ADDR(<byte offset>) for SFP diagnostics parameters
584 s32 e1000_write_sfp_data_byte(struct e1000_hw *hw, u16 offset, u8 data) in e1000_write_sfp_data_byte() argument
592 if (offset > E1000_I2CCMD_SFP_DIAG_ADDR(255)) { in e1000_write_sfp_data_byte()
594 return -E1000_ERR_PHY; in e1000_write_sfp_data_byte()
601 /* Set up Op-code, EEPROM Address,in the I2CCMD in e1000_write_sfp_data_byte()
605 i2ccmd = ((offset << E1000_I2CCMD_REG_ADDR_SHIFT) | in e1000_write_sfp_data_byte()
624 i2ccmd = ((offset << in e1000_write_sfp_data_byte()
635 return -E1000_ERR_PHY; in e1000_write_sfp_data_byte()
639 return -E1000_ERR_PHY; in e1000_write_sfp_data_byte()
645 * e1000_read_phy_reg_m88 - Read m88 PHY register
647 * @offset: register offset to be read
650 * Acquires semaphore, if necessary, then reads the PHY register at offset
654 s32 e1000_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_m88() argument
660 if (!hw->phy.ops.acquire) in e1000_read_phy_reg_m88()
663 ret_val = hw->phy.ops.acquire(hw); in e1000_read_phy_reg_m88()
667 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000_read_phy_reg_m88()
670 hw->phy.ops.release(hw); in e1000_read_phy_reg_m88()
676 * e1000_write_phy_reg_m88 - Write m88 PHY register
678 * @offset: register offset to write to
679 * @data: data to write at register offset
682 * at the offset. Release any acquired semaphores before exiting.
684 s32 e1000_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_m88() argument
690 if (!hw->phy.ops.acquire) in e1000_write_phy_reg_m88()
693 ret_val = hw->phy.ops.acquire(hw); in e1000_write_phy_reg_m88()
697 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000_write_phy_reg_m88()
700 hw->phy.ops.release(hw); in e1000_write_phy_reg_m88()
706 * e1000_set_page_igp - Set page as on IGP-like PHY(s)
720 hw->phy.addr = 1; in e1000_set_page_igp()
726 * __e1000_read_phy_reg_igp - Read igp PHY register
728 * @offset: register offset to be read
732 * Acquires semaphore, if necessary, then reads the PHY register at offset
736 static s32 __e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data, in __e1000_read_phy_reg_igp() argument
744 if (!hw->phy.ops.acquire) in __e1000_read_phy_reg_igp()
747 ret_val = hw->phy.ops.acquire(hw); in __e1000_read_phy_reg_igp()
752 if (offset > MAX_PHY_MULTI_PAGE_REG) in __e1000_read_phy_reg_igp()
755 (u16)offset); in __e1000_read_phy_reg_igp()
758 MAX_PHY_REG_ADDRESS & offset, in __e1000_read_phy_reg_igp()
761 hw->phy.ops.release(hw); in __e1000_read_phy_reg_igp()
767 * e1000_read_phy_reg_igp - Read igp PHY register
769 * @offset: register offset to be read
772 * Acquires semaphore then reads the PHY register at offset and stores the
776 s32 e1000_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_igp() argument
778 return __e1000_read_phy_reg_igp(hw, offset, data, false); in e1000_read_phy_reg_igp()
782 * e1000_read_phy_reg_igp_locked - Read igp PHY register
784 * @offset: register offset to be read
787 * Reads the PHY register at offset and stores the retrieved information
790 s32 e1000_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_igp_locked() argument
792 return __e1000_read_phy_reg_igp(hw, offset, data, true); in e1000_read_phy_reg_igp_locked()
796 * e1000_write_phy_reg_igp - Write igp PHY register
798 * @offset: register offset to write to
799 * @data: data to write at register offset
803 * at the offset. Release any acquired semaphores before exiting.
805 static s32 __e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data, in __e1000_write_phy_reg_igp() argument
813 if (!hw->phy.ops.acquire) in __e1000_write_phy_reg_igp()
816 ret_val = hw->phy.ops.acquire(hw); in __e1000_write_phy_reg_igp()
821 if (offset > MAX_PHY_MULTI_PAGE_REG) in __e1000_write_phy_reg_igp()
824 (u16)offset); in __e1000_write_phy_reg_igp()
827 offset, in __e1000_write_phy_reg_igp()
830 hw->phy.ops.release(hw); in __e1000_write_phy_reg_igp()
836 * e1000_write_phy_reg_igp - Write igp PHY register
838 * @offset: register offset to write to
839 * @data: data to write at register offset
842 * at the offset. Release any acquired semaphores before exiting.
844 s32 e1000_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_igp() argument
846 return __e1000_write_phy_reg_igp(hw, offset, data, false); in e1000_write_phy_reg_igp()
850 * e1000_write_phy_reg_igp_locked - Write igp PHY register
852 * @offset: register offset to write to
853 * @data: data to write at register offset
855 * Writes the data to PHY register at the offset.
858 s32 e1000_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_igp_locked() argument
860 return __e1000_write_phy_reg_igp(hw, offset, data, true); in e1000_write_phy_reg_igp_locked()
864 * __e1000_read_kmrn_reg - Read kumeran register
866 * @offset: register offset to be read
870 * Acquires semaphore, if necessary. Then reads the PHY register at offset
874 static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data, in __e1000_read_kmrn_reg() argument
884 if (!hw->phy.ops.acquire) in __e1000_read_kmrn_reg()
887 ret_val = hw->phy.ops.acquire(hw); in __e1000_read_kmrn_reg()
892 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & in __e1000_read_kmrn_reg()
903 hw->phy.ops.release(hw); in __e1000_read_kmrn_reg()
909 * e1000_read_kmrn_reg_generic - Read kumeran register
911 * @offset: register offset to be read
914 * Acquires semaphore then reads the PHY register at offset using the
918 s32 e1000_read_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_kmrn_reg_generic() argument
920 return __e1000_read_kmrn_reg(hw, offset, data, false); in e1000_read_kmrn_reg_generic()
924 * e1000_read_kmrn_reg_locked - Read kumeran register
926 * @offset: register offset to be read
929 * Reads the PHY register at offset using the kumeran interface. The
933 s32 e1000_read_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_kmrn_reg_locked() argument
935 return __e1000_read_kmrn_reg(hw, offset, data, true); in e1000_read_kmrn_reg_locked()
939 * __e1000_write_kmrn_reg - Write kumeran register
941 * @offset: register offset to write to
942 * @data: data to write at register offset
946 * at the offset using the kumeran interface. Release any acquired semaphores
949 static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data, in __e1000_write_kmrn_reg() argument
959 if (!hw->phy.ops.acquire) in __e1000_write_kmrn_reg()
962 ret_val = hw->phy.ops.acquire(hw); in __e1000_write_kmrn_reg()
967 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & in __e1000_write_kmrn_reg()
975 hw->phy.ops.release(hw); in __e1000_write_kmrn_reg()
981 * e1000_write_kmrn_reg_generic - Write kumeran register
983 * @offset: register offset to write to
984 * @data: data to write at register offset
986 * Acquires semaphore then writes the data to the PHY register at the offset
989 s32 e1000_write_kmrn_reg_generic(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_kmrn_reg_generic() argument
991 return __e1000_write_kmrn_reg(hw, offset, data, false); in e1000_write_kmrn_reg_generic()
995 * e1000_write_kmrn_reg_locked - Write kumeran register
997 * @offset: register offset to write to
998 * @data: data to write at register offset
1000 * Write the data to PHY register at the offset using the kumeran interface.
1003 s32 e1000_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_kmrn_reg_locked() argument
1005 return __e1000_write_kmrn_reg(hw, offset, data, true); in e1000_write_kmrn_reg_locked()
1009 * e1000_set_master_slave_mode - Setup PHY for Master/slave mode
1020 ret_val = hw->phy.ops.read_reg(hw, PHY_1000T_CTRL, &phy_data); in e1000_set_master_slave_mode()
1025 hw->phy.original_ms_type = (phy_data & CR_1000T_MS_ENABLE) ? in e1000_set_master_slave_mode()
1030 switch (hw->phy.ms_type) { in e1000_set_master_slave_mode()
1045 return hw->phy.ops.write_reg(hw, PHY_1000T_CTRL, phy_data); in e1000_set_master_slave_mode()
1049 * e1000_copper_link_setup_82577 - Setup 82577 PHY for copper link
1052 * Sets up Carrier-sense on Transmit and downshift values.
1061 if (hw->phy.type == e1000_phy_82580) { in e1000_copper_link_setup_82577()
1062 ret_val = hw->phy.ops.reset(hw); in e1000_copper_link_setup_82577()
1069 /* Enable CRS on Tx. This must be set for half-duplex operation. */ in e1000_copper_link_setup_82577()
1070 ret_val = hw->phy.ops.read_reg(hw, I82577_CFG_REG, &phy_data); in e1000_copper_link_setup_82577()
1076 /* Enable downshift */ in e1000_copper_link_setup_82577()
1079 ret_val = hw->phy.ops.write_reg(hw, I82577_CFG_REG, phy_data); in e1000_copper_link_setup_82577()
1084 ret_val = hw->phy.ops.read_reg(hw, I82577_PHY_CTRL_2, &phy_data); in e1000_copper_link_setup_82577()
1089 * 0 - Auto (default) in e1000_copper_link_setup_82577()
1090 * 1 - MDI mode in e1000_copper_link_setup_82577()
1091 * 2 - MDI-X mode in e1000_copper_link_setup_82577()
1093 switch (hw->phy.mdix) { in e1000_copper_link_setup_82577()
1105 ret_val = hw->phy.ops.write_reg(hw, I82577_PHY_CTRL_2, phy_data); in e1000_copper_link_setup_82577()
1113 * e1000_copper_link_setup_m88 - Setup m88 PHY's for copper link
1116 * Sets up MDI/MDI-X and polarity for m88 PHY's. If necessary, transmit clock
1121 struct e1000_phy_info *phy = &hw->phy; in e1000_copper_link_setup_m88()
1128 /* Enable CRS on Tx. This must be set for half-duplex operation. */ in e1000_copper_link_setup_m88()
1129 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); in e1000_copper_link_setup_m88()
1133 /* For BM PHY this bit is downshift enable */ in e1000_copper_link_setup_m88()
1134 if (phy->type != e1000_phy_bm) in e1000_copper_link_setup_m88()
1138 * MDI/MDI-X = 0 (default) in e1000_copper_link_setup_m88()
1139 * 0 - Auto for all speeds in e1000_copper_link_setup_m88()
1140 * 1 - MDI mode in e1000_copper_link_setup_m88()
1141 * 2 - MDI-X mode in e1000_copper_link_setup_m88()
1142 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) in e1000_copper_link_setup_m88()
1146 switch (phy->mdix) { in e1000_copper_link_setup_m88()
1166 * 0 - Disabled in e1000_copper_link_setup_m88()
1167 * 1 - Enabled in e1000_copper_link_setup_m88()
1170 if (phy->disable_polarity_correction) in e1000_copper_link_setup_m88()
1173 /* Enable downshift on BM (disabled by default) */ in e1000_copper_link_setup_m88()
1174 if (phy->type == e1000_phy_bm) { in e1000_copper_link_setup_m88()
1175 /* For 82574/82583, first disable then enable downshift */ in e1000_copper_link_setup_m88()
1176 if (phy->id == BME1000_E_PHY_ID_R2) { in e1000_copper_link_setup_m88()
1178 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, in e1000_copper_link_setup_m88()
1183 ret_val = phy->ops.commit(hw); in e1000_copper_link_setup_m88()
1193 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); in e1000_copper_link_setup_m88()
1197 if ((phy->type == e1000_phy_m88) && in e1000_copper_link_setup_m88()
1198 (phy->revision < E1000_REVISION_4) && in e1000_copper_link_setup_m88()
1199 (phy->id != BME1000_E_PHY_ID_R2)) { in e1000_copper_link_setup_m88()
1203 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, in e1000_copper_link_setup_m88()
1210 if ((phy->revision == E1000_REVISION_2) && in e1000_copper_link_setup_m88()
1211 (phy->id == M88E1111_I_PHY_ID)) { in e1000_copper_link_setup_m88()
1212 /* 82573L PHY - set the downshift counter to 5x. */ in e1000_copper_link_setup_m88()
1222 ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, in e1000_copper_link_setup_m88()
1228 if ((phy->type == e1000_phy_bm) && (phy->id == BME1000_E_PHY_ID_R2)) { in e1000_copper_link_setup_m88()
1230 ret_val = phy->ops.write_reg(hw, 29, 0x0003); in e1000_copper_link_setup_m88()
1235 ret_val = phy->ops.write_reg(hw, 30, 0x0000); in e1000_copper_link_setup_m88()
1241 ret_val = phy->ops.commit(hw); in e1000_copper_link_setup_m88()
1247 if (phy->type == e1000_phy_82578) { in e1000_copper_link_setup_m88()
1248 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, in e1000_copper_link_setup_m88()
1253 /* 82578 PHY - set the downshift count to 1x. */ in e1000_copper_link_setup_m88()
1256 ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, in e1000_copper_link_setup_m88()
1266 * e1000_copper_link_setup_m88_gen2 - Setup m88 PHY's for copper link
1269 * Sets up MDI/MDI-X and polarity for i347-AT4, m88e1322 and m88e1112 PHY's.
1274 struct e1000_phy_info *phy = &hw->phy; in e1000_copper_link_setup_m88_gen2()
1281 /* Enable CRS on Tx. This must be set for half-duplex operation. */ in e1000_copper_link_setup_m88_gen2()
1282 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); in e1000_copper_link_setup_m88_gen2()
1287 * MDI/MDI-X = 0 (default) in e1000_copper_link_setup_m88_gen2()
1288 * 0 - Auto for all speeds in e1000_copper_link_setup_m88_gen2()
1289 * 1 - MDI mode in e1000_copper_link_setup_m88_gen2()
1290 * 2 - MDI-X mode in e1000_copper_link_setup_m88_gen2()
1291 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) in e1000_copper_link_setup_m88_gen2()
1295 switch (phy->mdix) { in e1000_copper_link_setup_m88_gen2()
1304 if (phy->id != M88E1112_E_PHY_ID) { in e1000_copper_link_setup_m88_gen2()
1319 * 0 - Disabled in e1000_copper_link_setup_m88_gen2()
1320 * 1 - Enabled in e1000_copper_link_setup_m88_gen2()
1323 if (phy->disable_polarity_correction) in e1000_copper_link_setup_m88_gen2()
1326 /* Enable downshift and setting it to X6 */ in e1000_copper_link_setup_m88_gen2()
1327 if (phy->id == M88E1543_E_PHY_ID) { in e1000_copper_link_setup_m88_gen2()
1330 phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); in e1000_copper_link_setup_m88_gen2()
1334 ret_val = phy->ops.commit(hw); in e1000_copper_link_setup_m88_gen2()
1345 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); in e1000_copper_link_setup_m88_gen2()
1350 ret_val = phy->ops.commit(hw); in e1000_copper_link_setup_m88_gen2()
1364 * e1000_copper_link_setup_igp - Setup igp PHY's for copper link
1367 * Sets up LPLU, MDI/MDI-X, polarity, Smartspeed and Master/Slave config for
1372 struct e1000_phy_info *phy = &hw->phy; in e1000_copper_link_setup_igp()
1379 ret_val = hw->phy.ops.reset(hw); in e1000_copper_link_setup_igp()
1391 * non-IGP1 PHYs. in e1000_copper_link_setup_igp()
1393 if (phy->type == e1000_phy_igp) { in e1000_copper_link_setup_igp()
1395 ret_val = hw->phy.ops.set_d3_lplu_state(hw, false); in e1000_copper_link_setup_igp()
1403 if (hw->phy.ops.set_d0_lplu_state) { in e1000_copper_link_setup_igp()
1404 ret_val = hw->phy.ops.set_d0_lplu_state(hw, false); in e1000_copper_link_setup_igp()
1410 /* Configure mdi-mdix settings */ in e1000_copper_link_setup_igp()
1411 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CTRL, &data); in e1000_copper_link_setup_igp()
1417 switch (phy->mdix) { in e1000_copper_link_setup_igp()
1430 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CTRL, data); in e1000_copper_link_setup_igp()
1434 /* set auto-master slave resolution settings */ in e1000_copper_link_setup_igp()
1435 if (hw->mac.autoneg) { in e1000_copper_link_setup_igp()
1437 * should disable SmartSpeed and enable Auto MasterSlave in e1000_copper_link_setup_igp()
1440 if (phy->autoneg_advertised == ADVERTISE_1000_FULL) { in e1000_copper_link_setup_igp()
1442 ret_val = phy->ops.read_reg(hw, in e1000_copper_link_setup_igp()
1449 ret_val = phy->ops.write_reg(hw, in e1000_copper_link_setup_igp()
1456 ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, &data); in e1000_copper_link_setup_igp()
1461 ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, data); in e1000_copper_link_setup_igp()
1473 * e1000_phy_setup_autoneg - Configure PHY for auto-negotiation
1476 * Reads the MII auto-neg advertisement register and/or the 1000T control
1477 * register and if the PHY is already setup for auto-negotiation, then
1479 * the appropriate values for the wanted auto-negotiation.
1483 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_setup_autoneg()
1490 phy->autoneg_advertised &= phy->autoneg_mask; in e1000_phy_setup_autoneg()
1492 /* Read the MII Auto-Neg Advertisement Register (Address 4). */ in e1000_phy_setup_autoneg()
1493 ret_val = phy->ops.read_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg); in e1000_phy_setup_autoneg()
1497 if (phy->autoneg_mask & ADVERTISE_1000_FULL) { in e1000_phy_setup_autoneg()
1498 /* Read the MII 1000Base-T Control Register (Address 9). */ in e1000_phy_setup_autoneg()
1499 ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, in e1000_phy_setup_autoneg()
1512 /* First we clear all the 10/100 mb speed bits in the Auto-Neg in e1000_phy_setup_autoneg()
1514 * the 1000Base-T Control Register (Address 9). in e1000_phy_setup_autoneg()
1522 DEBUGOUT1("autoneg_advertised %x\n", phy->autoneg_advertised); in e1000_phy_setup_autoneg()
1525 if (phy->autoneg_advertised & ADVERTISE_10_HALF) { in e1000_phy_setup_autoneg()
1531 if (phy->autoneg_advertised & ADVERTISE_10_FULL) { in e1000_phy_setup_autoneg()
1537 if (phy->autoneg_advertised & ADVERTISE_100_HALF) { in e1000_phy_setup_autoneg()
1543 if (phy->autoneg_advertised & ADVERTISE_100_FULL) { in e1000_phy_setup_autoneg()
1549 if (phy->autoneg_advertised & ADVERTISE_1000_HALF) in e1000_phy_setup_autoneg()
1553 if (phy->autoneg_advertised & ADVERTISE_1000_FULL) { in e1000_phy_setup_autoneg()
1560 * auto-negotiation is enabled, then software will have to set the in e1000_phy_setup_autoneg()
1561 * "PAUSE" bits to the correct value in the Auto-Negotiation in e1000_phy_setup_autoneg()
1562 * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto- in e1000_phy_setup_autoneg()
1575 switch (hw->fc.current_mode) { in e1000_phy_setup_autoneg()
1578 * software over-ride. in e1000_phy_setup_autoneg()
1584 * disabled, by a software over-ride. in e1000_phy_setup_autoneg()
1596 * disabled, by a software over-ride. in e1000_phy_setup_autoneg()
1603 * over-ride. in e1000_phy_setup_autoneg()
1609 return -E1000_ERR_CONFIG; in e1000_phy_setup_autoneg()
1612 ret_val = phy->ops.write_reg(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg); in e1000_phy_setup_autoneg()
1616 DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); in e1000_phy_setup_autoneg()
1618 if (phy->autoneg_mask & ADVERTISE_1000_FULL) in e1000_phy_setup_autoneg()
1619 ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, in e1000_phy_setup_autoneg()
1626 * e1000_copper_link_autoneg - Setup/Enable autoneg for copper link
1636 struct e1000_phy_info *phy = &hw->phy; in e1000_copper_link_autoneg()
1645 phy->autoneg_advertised &= phy->autoneg_mask; in e1000_copper_link_autoneg()
1650 if (!phy->autoneg_advertised) in e1000_copper_link_autoneg()
1651 phy->autoneg_advertised = phy->autoneg_mask; in e1000_copper_link_autoneg()
1653 DEBUGOUT("Reconfiguring auto-neg advertisement params\n"); in e1000_copper_link_autoneg()
1656 DEBUGOUT("Error Setting up Auto-Negotiation\n"); in e1000_copper_link_autoneg()
1659 DEBUGOUT("Restarting Auto-Neg\n"); in e1000_copper_link_autoneg()
1661 /* Restart auto-negotiation by setting the Auto Neg Enable bit and in e1000_copper_link_autoneg()
1664 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); in e1000_copper_link_autoneg()
1669 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_ctrl); in e1000_copper_link_autoneg()
1673 /* Does the user want to wait for Auto-Neg to complete here, or in e1000_copper_link_autoneg()
1676 if (phy->autoneg_wait_to_complete) { in e1000_copper_link_autoneg()
1684 hw->mac.get_link_status = true; in e1000_copper_link_autoneg()
1690 * e1000_setup_copper_link_generic - Configure copper link settings
1693 * Calls the appropriate function to configure the link for auto-neg or forced
1696 * not established, we return -E1000_ERR_PHY (-2).
1705 if (hw->mac.autoneg) { in e1000_setup_copper_link_generic()
1717 ret_val = hw->phy.ops.force_speed_duplex(hw); in e1000_setup_copper_link_generic()
1734 hw->mac.ops.config_collision_dist(hw); in e1000_setup_copper_link_generic()
1744 * e1000_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY
1748 * auto-crossover to force MDI manually. Waits for link and returns
1749 * successful if link up is successful, else -E1000_ERR_PHY (-2).
1753 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_force_speed_duplex_igp()
1760 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data); in e1000_phy_force_speed_duplex_igp()
1766 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data); in e1000_phy_force_speed_duplex_igp()
1770 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI in e1000_phy_force_speed_duplex_igp()
1773 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CTRL, &phy_data); in e1000_phy_force_speed_duplex_igp()
1780 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CTRL, phy_data); in e1000_phy_force_speed_duplex_igp()
1788 if (phy->autoneg_wait_to_complete) { in e1000_phy_force_speed_duplex_igp()
1808 * e1000_phy_force_speed_duplex_m88 - Force speed/duplex for m88 PHY
1812 * auto-crossover to force MDI manually. Resets the PHY to commit the
1819 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_force_speed_duplex_m88()
1826 /* I210 and I211 devices support Auto-Crossover in forced operation. */ in e1000_phy_force_speed_duplex_m88()
1827 if (phy->type != e1000_phy_i210) { in e1000_phy_force_speed_duplex_m88()
1828 /* Clear Auto-Crossover to force MDI manually. M88E1000 in e1000_phy_force_speed_duplex_m88()
1831 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, in e1000_phy_force_speed_duplex_m88()
1837 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, in e1000_phy_force_speed_duplex_m88()
1845 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data); in e1000_phy_force_speed_duplex_m88()
1851 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data); in e1000_phy_force_speed_duplex_m88()
1856 ret_val = hw->phy.ops.commit(hw); in e1000_phy_force_speed_duplex_m88()
1860 if (phy->autoneg_wait_to_complete) { in e1000_phy_force_speed_duplex_m88()
1871 switch (hw->phy.id) { in e1000_phy_force_speed_duplex_m88()
1881 if (hw->phy.type != e1000_phy_m88) in e1000_phy_force_speed_duplex_m88()
1892 ret_val = phy->ops.write_reg(hw, in e1000_phy_force_speed_duplex_m88()
1910 if (hw->phy.type != e1000_phy_m88) in e1000_phy_force_speed_duplex_m88()
1913 if (hw->phy.id == I347AT4_E_PHY_ID || in e1000_phy_force_speed_duplex_m88()
1914 hw->phy.id == M88E1340M_E_PHY_ID || in e1000_phy_force_speed_duplex_m88()
1915 hw->phy.id == M88E1112_E_PHY_ID) in e1000_phy_force_speed_duplex_m88()
1917 if (hw->phy.id == I210_I_PHY_ID) in e1000_phy_force_speed_duplex_m88()
1919 if ((hw->phy.id == M88E1543_E_PHY_ID) || in e1000_phy_force_speed_duplex_m88()
1920 (hw->phy.id == M88E1512_E_PHY_ID)) in e1000_phy_force_speed_duplex_m88()
1922 ret_val = phy->ops.read_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, &phy_data); in e1000_phy_force_speed_duplex_m88()
1926 /* Resetting the phy means we need to re-force TX_CLK in the in e1000_phy_force_speed_duplex_m88()
1931 ret_val = phy->ops.write_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, phy_data); in e1000_phy_force_speed_duplex_m88()
1935 /* In addition, we must re-enable CRS on Tx for both half and full in e1000_phy_force_speed_duplex_m88()
1938 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); in e1000_phy_force_speed_duplex_m88()
1943 ret_val = phy->ops.write_reg(hw, M88E1000_PHY_SPEC_CTRL, phy_data); in e1000_phy_force_speed_duplex_m88()
1949 * e1000_phy_force_speed_duplex_ife - Force PHY speed & duplex
1958 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_force_speed_duplex_ife()
1965 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &data); in e1000_phy_force_speed_duplex_ife()
1971 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, data); in e1000_phy_force_speed_duplex_ife()
1975 /* Disable MDI-X support for 10/100 */ in e1000_phy_force_speed_duplex_ife()
1976 ret_val = phy->ops.read_reg(hw, IFE_PHY_MDIX_CONTROL, &data); in e1000_phy_force_speed_duplex_ife()
1983 ret_val = phy->ops.write_reg(hw, IFE_PHY_MDIX_CONTROL, data); in e1000_phy_force_speed_duplex_ife()
1991 if (phy->autoneg_wait_to_complete) { in e1000_phy_force_speed_duplex_ife()
2013 * e1000_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex
2019 * disable auto-negotiation, configure duplex, configure speed, configure
2026 struct e1000_mac_info *mac = &hw->mac; in e1000_phy_force_speed_duplex_setup()
2032 hw->fc.current_mode = e1000_fc_none; in e1000_phy_force_speed_duplex_setup()
2046 if (mac->forced_speed_duplex & E1000_ALL_HALF_DUPLEX) { in e1000_phy_force_speed_duplex_setup()
2057 if (mac->forced_speed_duplex & E1000_ALL_100_SPEED) { in e1000_phy_force_speed_duplex_setup()
2068 hw->mac.ops.config_collision_dist(hw); in e1000_phy_force_speed_duplex_setup()
2074 * e1000_set_d3_lplu_state_generic - Sets low power link up state for D3
2076 * @active: boolean used to enable/disable lplu
2082 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU
2089 struct e1000_phy_info *phy = &hw->phy; in e1000_set_d3_lplu_state_generic()
2095 if (!hw->phy.ops.read_reg) in e1000_set_d3_lplu_state_generic()
2098 ret_val = phy->ops.read_reg(hw, IGP02E1000_PHY_POWER_MGMT, &data); in e1000_set_d3_lplu_state_generic()
2104 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT, in e1000_set_d3_lplu_state_generic()
2110 * important. During driver activity we should enable in e1000_set_d3_lplu_state_generic()
2113 if (phy->smart_speed == e1000_smart_speed_on) { in e1000_set_d3_lplu_state_generic()
2114 ret_val = phy->ops.read_reg(hw, in e1000_set_d3_lplu_state_generic()
2121 ret_val = phy->ops.write_reg(hw, in e1000_set_d3_lplu_state_generic()
2126 } else if (phy->smart_speed == e1000_smart_speed_off) { in e1000_set_d3_lplu_state_generic()
2127 ret_val = phy->ops.read_reg(hw, in e1000_set_d3_lplu_state_generic()
2134 ret_val = phy->ops.write_reg(hw, in e1000_set_d3_lplu_state_generic()
2140 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || in e1000_set_d3_lplu_state_generic()
2141 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) || in e1000_set_d3_lplu_state_generic()
2142 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) { in e1000_set_d3_lplu_state_generic()
2144 ret_val = phy->ops.write_reg(hw, IGP02E1000_PHY_POWER_MGMT, in e1000_set_d3_lplu_state_generic()
2150 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG, in e1000_set_d3_lplu_state_generic()
2156 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG, in e1000_set_d3_lplu_state_generic()
2164 * e1000_check_downshift_generic - Checks whether a downshift in speed occurred
2173 struct e1000_phy_info *phy = &hw->phy; in e1000_check_downshift_generic()
2175 u16 phy_data, offset, mask; in e1000_check_downshift_generic() local
2179 switch (phy->type) { in e1000_check_downshift_generic()
2185 offset = M88E1000_PHY_SPEC_STATUS; in e1000_check_downshift_generic()
2191 offset = IGP01E1000_PHY_LINK_HEALTH; in e1000_check_downshift_generic()
2196 phy->speed_downgraded = false; in e1000_check_downshift_generic()
2200 ret_val = phy->ops.read_reg(hw, offset, &phy_data); in e1000_check_downshift_generic()
2203 phy->speed_downgraded = !!(phy_data & mask); in e1000_check_downshift_generic()
2209 * e1000_check_polarity_m88 - Checks the polarity.
2212 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
2218 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_m88()
2224 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &data); in e1000_check_polarity_m88()
2227 phy->cable_polarity = ((data & M88E1000_PSSR_REV_POLARITY) in e1000_check_polarity_m88()
2235 * e1000_check_polarity_igp - Checks the polarity.
2238 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
2245 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_igp()
2247 u16 data, offset, mask; in e1000_check_polarity_igp() local
2254 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_STATUS, &data); in e1000_check_polarity_igp()
2260 offset = IGP01E1000_PHY_PCS_INIT_REG; in e1000_check_polarity_igp()
2266 offset = IGP01E1000_PHY_PORT_STATUS; in e1000_check_polarity_igp()
2270 ret_val = phy->ops.read_reg(hw, offset, &data); in e1000_check_polarity_igp()
2273 phy->cable_polarity = ((data & mask) in e1000_check_polarity_igp()
2281 * e1000_check_polarity_ife - Check cable polarity for IFE PHY
2288 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_ife()
2290 u16 phy_data, offset, mask; in e1000_check_polarity_ife() local
2296 if (phy->polarity_correction) { in e1000_check_polarity_ife()
2297 offset = IFE_PHY_EXTENDED_STATUS_CONTROL; in e1000_check_polarity_ife()
2300 offset = IFE_PHY_SPECIAL_CONTROL; in e1000_check_polarity_ife()
2304 ret_val = phy->ops.read_reg(hw, offset, &phy_data); in e1000_check_polarity_ife()
2307 phy->cable_polarity = ((phy_data & mask) in e1000_check_polarity_ife()
2315 * e1000_wait_autoneg - Wait for auto-neg completion
2318 * Waits for auto-negotiation to complete or for the auto-negotiation time
2328 if (!hw->phy.ops.read_reg) in e1000_wait_autoneg()
2332 for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) { in e1000_wait_autoneg()
2333 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); in e1000_wait_autoneg()
2336 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); in e1000_wait_autoneg()
2344 /* PHY_AUTO_NEG_TIME expiration doesn't guarantee auto-negotiation in e1000_wait_autoneg()
2351 * e1000_phy_has_link_generic - Polls PHY for link
2367 if (!hw->phy.ops.read_reg) in e1000_phy_has_link_generic()
2375 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); in e1000_phy_has_link_generic()
2386 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); in e1000_phy_has_link_generic()
2403 * e1000_get_cable_length_m88 - Determine cable length for m88 PHY
2412 * 1 50 - 80 meters
2413 * 2 80 - 110 meters
2414 * 3 110 - 140 meters
2419 struct e1000_phy_info *phy = &hw->phy; in e1000_get_cable_length_m88()
2425 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); in e1000_get_cable_length_m88()
2432 if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) in e1000_get_cable_length_m88()
2433 return -E1000_ERR_PHY; in e1000_get_cable_length_m88()
2435 phy->min_cable_length = e1000_m88_cable_length_table[index]; in e1000_get_cable_length_m88()
2436 phy->max_cable_length = e1000_m88_cable_length_table[index + 1]; in e1000_get_cable_length_m88()
2438 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; in e1000_get_cable_length_m88()
2445 struct e1000_phy_info *phy = &hw->phy; in e1000_get_cable_length_m88_gen2()
2452 switch (hw->phy.id) { in e1000_get_cable_length_m88_gen2()
2455 ret_val = phy->ops.read_reg(hw, (0x7 << GS40G_PAGE_SHIFT) + in e1000_get_cable_length_m88_gen2()
2456 (I347AT4_PCDL + phy->addr), in e1000_get_cable_length_m88_gen2()
2462 ret_val = phy->ops.read_reg(hw, (0x7 << GS40G_PAGE_SHIFT) + in e1000_get_cable_length_m88_gen2()
2470 phy->min_cable_length = phy_data / (is_cm ? 100 : 1); in e1000_get_cable_length_m88_gen2()
2471 phy->max_cable_length = phy_data / (is_cm ? 100 : 1); in e1000_get_cable_length_m88_gen2()
2472 phy->cable_length = phy_data / (is_cm ? 100 : 1); in e1000_get_cable_length_m88_gen2()
2479 ret_val = phy->ops.read_reg(hw, I347AT4_PAGE_SELECT, in e1000_get_cable_length_m88_gen2()
2484 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 0x07); in e1000_get_cable_length_m88_gen2()
2489 ret_val = phy->ops.read_reg(hw, (I347AT4_PCDL + phy->addr), in e1000_get_cable_length_m88_gen2()
2495 ret_val = phy->ops.read_reg(hw, I347AT4_PCDC, &phy_data2); in e1000_get_cable_length_m88_gen2()
2502 phy->min_cable_length = phy_data / (is_cm ? 100 : 1); in e1000_get_cable_length_m88_gen2()
2503 phy->max_cable_length = phy_data / (is_cm ? 100 : 1); in e1000_get_cable_length_m88_gen2()
2504 phy->cable_length = phy_data / (is_cm ? 100 : 1); in e1000_get_cable_length_m88_gen2()
2507 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, in e1000_get_cable_length_m88_gen2()
2515 ret_val = phy->ops.read_reg(hw, I347AT4_PAGE_SELECT, in e1000_get_cable_length_m88_gen2()
2520 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, 0x05); in e1000_get_cable_length_m88_gen2()
2524 ret_val = phy->ops.read_reg(hw, M88E1112_VCT_DSP_DISTANCE, in e1000_get_cable_length_m88_gen2()
2532 if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) in e1000_get_cable_length_m88_gen2()
2533 return -E1000_ERR_PHY; in e1000_get_cable_length_m88_gen2()
2535 phy->min_cable_length = e1000_m88_cable_length_table[index]; in e1000_get_cable_length_m88_gen2()
2536 phy->max_cable_length = e1000_m88_cable_length_table[index + 1]; in e1000_get_cable_length_m88_gen2()
2538 phy->cable_length = (phy->min_cable_length + in e1000_get_cable_length_m88_gen2()
2539 phy->max_cable_length) / 2; in e1000_get_cable_length_m88_gen2()
2542 ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT, in e1000_get_cable_length_m88_gen2()
2549 return -E1000_ERR_PHY; in e1000_get_cable_length_m88_gen2()
2556 * e1000_get_cable_length_igp_2 - Determine cable length for igp2 PHY
2568 struct e1000_phy_info *phy = &hw->phy; in e1000_get_cable_length_igp_2()
2572 u16 min_agc_index = IGP02E1000_CABLE_LENGTH_TABLE_SIZE - 1; in e1000_get_cable_length_igp_2()
2584 ret_val = phy->ops.read_reg(hw, agc_reg_array[i], &phy_data); in e1000_get_cable_length_igp_2()
2599 return -E1000_ERR_PHY; in e1000_get_cable_length_igp_2()
2612 agc_value -= (e1000_igp_2_cable_length_table[min_agc_index] + in e1000_get_cable_length_igp_2()
2614 agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2); in e1000_get_cable_length_igp_2()
2616 /* Calculate cable length with the error range of +/- 10 meters. */ in e1000_get_cable_length_igp_2()
2617 phy->min_cable_length = (((agc_value - IGP02E1000_AGC_RANGE) > 0) ? in e1000_get_cable_length_igp_2()
2618 (agc_value - IGP02E1000_AGC_RANGE) : 0); in e1000_get_cable_length_igp_2()
2619 phy->max_cable_length = agc_value + IGP02E1000_AGC_RANGE; in e1000_get_cable_length_igp_2()
2621 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; in e1000_get_cable_length_igp_2()
2627 * e1000_get_phy_info_m88 - Retrieve PHY information
2632 * determine the polarity and 10base-T extended distance. Read the PHY
2638 struct e1000_phy_info *phy = &hw->phy; in e1000_get_phy_info_m88()
2645 if (phy->media_type != e1000_media_type_copper) { in e1000_get_phy_info_m88()
2647 return -E1000_ERR_CONFIG; in e1000_get_phy_info_m88()
2656 return -E1000_ERR_CONFIG; in e1000_get_phy_info_m88()
2659 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); in e1000_get_phy_info_m88()
2663 phy->polarity_correction = !!(phy_data & in e1000_get_phy_info_m88()
2670 ret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data); in e1000_get_phy_info_m88()
2674 phy->is_mdix = !!(phy_data & M88E1000_PSSR_MDIX); in e1000_get_phy_info_m88()
2677 ret_val = hw->phy.ops.get_cable_length(hw); in e1000_get_phy_info_m88()
2681 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &phy_data); in e1000_get_phy_info_m88()
2685 phy->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS) in e1000_get_phy_info_m88()
2689 phy->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS) in e1000_get_phy_info_m88()
2694 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000_get_phy_info_m88()
2695 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_m88()
2696 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_m88()
2703 * e1000_get_phy_info_igp - Retrieve igp PHY information
2707 * set/determine 10base-T extended distance and polarity correction. Read
2713 struct e1000_phy_info *phy = &hw->phy; in e1000_get_phy_info_igp()
2726 return -E1000_ERR_CONFIG; in e1000_get_phy_info_igp()
2729 phy->polarity_correction = true; in e1000_get_phy_info_igp()
2735 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_STATUS, &data); in e1000_get_phy_info_igp()
2739 phy->is_mdix = !!(data & IGP01E1000_PSSR_MDIX); in e1000_get_phy_info_igp()
2743 ret_val = phy->ops.get_cable_length(hw); in e1000_get_phy_info_igp()
2747 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &data); in e1000_get_phy_info_igp()
2751 phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS) in e1000_get_phy_info_igp()
2755 phy->remote_rx = (data & SR_1000T_REMOTE_RX_STATUS) in e1000_get_phy_info_igp()
2759 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000_get_phy_info_igp()
2760 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_igp()
2761 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_igp()
2768 * e1000_get_phy_info_ife - Retrieves various IFE PHY states
2775 struct e1000_phy_info *phy = &hw->phy; in e1000_get_phy_info_ife()
2788 return -E1000_ERR_CONFIG; in e1000_get_phy_info_ife()
2791 ret_val = phy->ops.read_reg(hw, IFE_PHY_SPECIAL_CONTROL, &data); in e1000_get_phy_info_ife()
2794 phy->polarity_correction = !(data & IFE_PSC_AUTO_POLARITY_DISABLE); in e1000_get_phy_info_ife()
2796 if (phy->polarity_correction) { in e1000_get_phy_info_ife()
2802 phy->cable_polarity = ((data & IFE_PSC_FORCE_POLARITY) in e1000_get_phy_info_ife()
2807 ret_val = phy->ops.read_reg(hw, IFE_PHY_MDIX_CONTROL, &data); in e1000_get_phy_info_ife()
2811 phy->is_mdix = !!(data & IFE_PMC_MDIX_STATUS); in e1000_get_phy_info_ife()
2814 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000_get_phy_info_ife()
2815 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_ife()
2816 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_ife()
2822 * e1000_phy_sw_reset_generic - PHY software reset
2835 if (!hw->phy.ops.read_reg) in e1000_phy_sw_reset_generic()
2838 ret_val = hw->phy.ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); in e1000_phy_sw_reset_generic()
2843 ret_val = hw->phy.ops.write_reg(hw, PHY_CONTROL, phy_ctrl); in e1000_phy_sw_reset_generic()
2853 * e1000_phy_hw_reset_generic - PHY hardware reset
2863 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_hw_reset_generic()
2869 if (phy->ops.check_reset_block) { in e1000_phy_hw_reset_generic()
2870 ret_val = phy->ops.check_reset_block(hw); in e1000_phy_hw_reset_generic()
2875 ret_val = phy->ops.acquire(hw); in e1000_phy_hw_reset_generic()
2883 usec_delay(phy->reset_delay_us); in e1000_phy_hw_reset_generic()
2890 phy->ops.release(hw); in e1000_phy_hw_reset_generic()
2892 return phy->ops.get_cfg_done(hw); in e1000_phy_hw_reset_generic()
2896 * e1000_get_cfg_done_generic - Generic configuration done
2899 * Generic function to wait 10 milli-seconds for configuration to complete
2912 * e1000_phy_init_script_igp3 - Inits the IGP3 PHY
2922 /* Enable rise/fall, 10-mode work in class-A */ in e1000_phy_init_script_igp3()
2923 hw->phy.ops.write_reg(hw, 0x2F5B, 0x9018); in e1000_phy_init_script_igp3()
2925 hw->phy.ops.write_reg(hw, 0x2F52, 0x0000); in e1000_phy_init_script_igp3()
2927 hw->phy.ops.write_reg(hw, 0x2FB1, 0x8B24); in e1000_phy_init_script_igp3()
2929 hw->phy.ops.write_reg(hw, 0x2FB2, 0xF8F0); in e1000_phy_init_script_igp3()
2931 hw->phy.ops.write_reg(hw, 0x2010, 0x10B0); in e1000_phy_init_script_igp3()
2933 hw->phy.ops.write_reg(hw, 0x2011, 0x0000); in e1000_phy_init_script_igp3()
2935 hw->phy.ops.write_reg(hw, 0x20DD, 0x249A); in e1000_phy_init_script_igp3()
2937 hw->phy.ops.write_reg(hw, 0x20DE, 0x00D3); in e1000_phy_init_script_igp3()
2939 hw->phy.ops.write_reg(hw, 0x28B4, 0x04CE); in e1000_phy_init_script_igp3()
2941 hw->phy.ops.write_reg(hw, 0x2F70, 0x29E4); in e1000_phy_init_script_igp3()
2943 hw->phy.ops.write_reg(hw, 0x0000, 0x0140); in e1000_phy_init_script_igp3()
2945 hw->phy.ops.write_reg(hw, 0x1F30, 0x1606); in e1000_phy_init_script_igp3()
2947 hw->phy.ops.write_reg(hw, 0x1F31, 0xB814); in e1000_phy_init_script_igp3()
2949 hw->phy.ops.write_reg(hw, 0x1F35, 0x002A); in e1000_phy_init_script_igp3()
2950 /* Enable FFE hysteresis */ in e1000_phy_init_script_igp3()
2951 hw->phy.ops.write_reg(hw, 0x1F3E, 0x0067); in e1000_phy_init_script_igp3()
2953 hw->phy.ops.write_reg(hw, 0x1F54, 0x0065); in e1000_phy_init_script_igp3()
2955 hw->phy.ops.write_reg(hw, 0x1F55, 0x002A); in e1000_phy_init_script_igp3()
2957 hw->phy.ops.write_reg(hw, 0x1F56, 0x002A); in e1000_phy_init_script_igp3()
2958 /* Enable Adaptive Clip Threshold */ in e1000_phy_init_script_igp3()
2959 hw->phy.ops.write_reg(hw, 0x1F72, 0x3FB0); in e1000_phy_init_script_igp3()
2961 hw->phy.ops.write_reg(hw, 0x1F76, 0xC0FF); in e1000_phy_init_script_igp3()
2963 hw->phy.ops.write_reg(hw, 0x1F77, 0x1DEC); in e1000_phy_init_script_igp3()
2965 hw->phy.ops.write_reg(hw, 0x1F78, 0xF9EF); in e1000_phy_init_script_igp3()
2967 hw->phy.ops.write_reg(hw, 0x1F79, 0x0210); in e1000_phy_init_script_igp3()
2969 hw->phy.ops.write_reg(hw, 0x1895, 0x0003); in e1000_phy_init_script_igp3()
2971 hw->phy.ops.write_reg(hw, 0x1796, 0x0008); in e1000_phy_init_script_igp3()
2972 /* Change cg_icount + enable integbp for channels BCD */ in e1000_phy_init_script_igp3()
2973 hw->phy.ops.write_reg(hw, 0x1798, 0xD008); in e1000_phy_init_script_igp3()
2974 /* Change cg_icount + enable integbp + change prop_factor_master in e1000_phy_init_script_igp3()
2977 hw->phy.ops.write_reg(hw, 0x1898, 0xD918); in e1000_phy_init_script_igp3()
2979 hw->phy.ops.write_reg(hw, 0x187A, 0x0800); in e1000_phy_init_script_igp3()
2980 /* Enable LPLU and disable AN to 1000 in non-D0a states, in e1000_phy_init_script_igp3()
2981 * Enable SPD+B2B in e1000_phy_init_script_igp3()
2983 hw->phy.ops.write_reg(hw, 0x0019, 0x008D); in e1000_phy_init_script_igp3()
2984 /* Enable restart AN on an1000_dis change */ in e1000_phy_init_script_igp3()
2985 hw->phy.ops.write_reg(hw, 0x001B, 0x2080); in e1000_phy_init_script_igp3()
2986 /* Enable wh_fifo read clock in 10/100 modes */ in e1000_phy_init_script_igp3()
2987 hw->phy.ops.write_reg(hw, 0x0014, 0x0045); in e1000_phy_init_script_igp3()
2989 hw->phy.ops.write_reg(hw, 0x0000, 0x1340); in e1000_phy_init_script_igp3()
2995 * e1000_get_phy_type_from_id - Get PHY type from id
3060 * e1000_determine_phy_address - Determines PHY address.
3073 hw->phy.id = phy_type; in e1000_determine_phy_address()
3076 hw->phy.addr = phy_addr; in e1000_determine_phy_address()
3081 phy_type = e1000_get_phy_type_from_id(hw->phy.id); in e1000_determine_phy_address()
3083 /* If phy_type is valid, break - we found our in e1000_determine_phy_address()
3094 return -E1000_ERR_PHY_TYPE; in e1000_determine_phy_address()
3098 * e1000_get_phy_addr_for_bm_page - Retrieve PHY page address
3115 * e1000_write_phy_reg_bm - Write BM PHY register
3117 * @offset: register offset to write to
3118 * @data: data to write at register offset
3121 * at the offset. Release any acquired semaphores before exiting.
3123 s32 e1000_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_bm() argument
3126 u32 page = offset >> IGP_PAGE_SHIFT; in e1000_write_phy_reg_bm()
3130 ret_val = hw->phy.ops.acquire(hw); in e1000_write_phy_reg_bm()
3136 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, in e1000_write_phy_reg_bm()
3141 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); in e1000_write_phy_reg_bm()
3143 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000_write_phy_reg_bm()
3150 if (hw->phy.addr == 1) { in e1000_write_phy_reg_bm()
3165 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000_write_phy_reg_bm()
3169 hw->phy.ops.release(hw); in e1000_write_phy_reg_bm()
3174 * e1000_read_phy_reg_bm - Read BM PHY register
3176 * @offset: register offset to be read
3179 * Acquires semaphore, if necessary, then reads the PHY register at offset
3183 s32 e1000_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_bm() argument
3186 u32 page = offset >> IGP_PAGE_SHIFT; in e1000_read_phy_reg_bm()
3190 ret_val = hw->phy.ops.acquire(hw); in e1000_read_phy_reg_bm()
3196 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, in e1000_read_phy_reg_bm()
3201 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); in e1000_read_phy_reg_bm()
3203 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000_read_phy_reg_bm()
3210 if (hw->phy.addr == 1) { in e1000_read_phy_reg_bm()
3225 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000_read_phy_reg_bm()
3228 hw->phy.ops.release(hw); in e1000_read_phy_reg_bm()
3233 * e1000_read_phy_reg_bm2 - Read BM PHY register
3235 * @offset: register offset to be read
3238 * Acquires semaphore, if necessary, then reads the PHY register at offset
3242 s32 e1000_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_bm2() argument
3245 u16 page = (u16)(offset >> IGP_PAGE_SHIFT); in e1000_read_phy_reg_bm2()
3249 ret_val = hw->phy.ops.acquire(hw); in e1000_read_phy_reg_bm2()
3255 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, in e1000_read_phy_reg_bm2()
3260 hw->phy.addr = 1; in e1000_read_phy_reg_bm2()
3262 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000_read_phy_reg_bm2()
3271 ret_val = e1000_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000_read_phy_reg_bm2()
3274 hw->phy.ops.release(hw); in e1000_read_phy_reg_bm2()
3279 * e1000_write_phy_reg_bm2 - Write BM PHY register
3281 * @offset: register offset to write to
3282 * @data: data to write at register offset
3285 * at the offset. Release any acquired semaphores before exiting.
3287 s32 e1000_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_bm2() argument
3290 u16 page = (u16)(offset >> IGP_PAGE_SHIFT); in e1000_write_phy_reg_bm2()
3294 ret_val = hw->phy.ops.acquire(hw); in e1000_write_phy_reg_bm2()
3300 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, in e1000_write_phy_reg_bm2()
3305 hw->phy.addr = 1; in e1000_write_phy_reg_bm2()
3307 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000_write_phy_reg_bm2()
3316 ret_val = e1000_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000_write_phy_reg_bm2()
3320 hw->phy.ops.release(hw); in e1000_write_phy_reg_bm2()
3325 * e1000_enable_phy_wakeup_reg_access_bm - enable access to BM wakeup registers
3340 return -E1000_ERR_PARAM; in e1000_enable_phy_wakeup_reg_access_bm()
3343 hw->phy.addr = 1; in e1000_enable_phy_wakeup_reg_access_bm()
3359 /* Enable both PHY wakeup mode and Wakeup register page writes. in e1000_enable_phy_wakeup_reg_access_bm()
3373 /* Select Host Wakeup Registers page - caller now able to write in e1000_enable_phy_wakeup_reg_access_bm()
3380 * e1000_disable_phy_wakeup_reg_access_bm - disable access to BM wakeup regs
3397 return -E1000_ERR_PARAM; in e1000_disable_phy_wakeup_reg_access_bm()
3416 * e1000_access_phy_wakeup_reg_bm - Read/write BM PHY wakeup register
3418 * @offset: register offset to be read or written
3423 * Read the PHY register at offset and store the retrieved information in
3424 * data, or write data to PHY register at offset. Note the procedure to
3438 * is responsible for calls to e1000_[enable|disable]_phy_wakeup_reg_bm()).
3440 static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, in e1000_access_phy_wakeup_reg_bm() argument
3444 u16 reg = BM_PHY_REG_NUM(offset); in e1000_access_phy_wakeup_reg_bm()
3445 u16 page = BM_PHY_REG_PAGE(offset); in e1000_access_phy_wakeup_reg_bm()
3451 if ((hw->mac.type == e1000_pchlan) && in e1000_access_phy_wakeup_reg_bm()
3457 /* Enable access to PHY wakeup registers */ in e1000_access_phy_wakeup_reg_bm()
3460 DEBUGOUT("Could not enable PHY wakeup reg access\n"); in e1000_access_phy_wakeup_reg_bm()
3467 /* Write the Wakeup register page offset value using opcode 0x11 */ in e1000_access_phy_wakeup_reg_bm()
3496 * e1000_power_up_phy_copper - Restore copper link in case of PHY power down
3508 hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg); in e1000_power_up_phy_copper()
3510 hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg); in e1000_power_up_phy_copper()
3514 * e1000_power_down_phy_copper - Restore copper link in case of PHY power down
3526 hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg); in e1000_power_down_phy_copper()
3528 hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg); in e1000_power_down_phy_copper()
3533 * __e1000_read_phy_reg_hv - Read HV PHY register
3535 * @offset: register offset to be read
3540 * Acquires semaphore, if necessary, then reads the PHY register at offset
3544 static s32 __e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data, in __e1000_read_phy_reg_hv() argument
3548 u16 page = BM_PHY_REG_PAGE(offset); in __e1000_read_phy_reg_hv()
3549 u16 reg = BM_PHY_REG_NUM(offset); in __e1000_read_phy_reg_hv()
3550 u32 phy_addr = hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); in __e1000_read_phy_reg_hv()
3555 ret_val = hw->phy.ops.acquire(hw); in __e1000_read_phy_reg_hv()
3561 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, in __e1000_read_phy_reg_hv()
3567 ret_val = e1000_access_phy_debug_regs_hv(hw, offset, in __e1000_read_phy_reg_hv()
3581 hw->phy.addr = phy_addr; in __e1000_read_phy_reg_hv()
3595 hw->phy.ops.release(hw); in __e1000_read_phy_reg_hv()
3601 * e1000_read_phy_reg_hv - Read HV PHY register
3603 * @offset: register offset to be read
3606 * Acquires semaphore then reads the PHY register at offset and stores
3610 s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_hv() argument
3612 return __e1000_read_phy_reg_hv(hw, offset, data, false, false); in e1000_read_phy_reg_hv()
3616 * e1000_read_phy_reg_hv_locked - Read HV PHY register
3618 * @offset: register offset to be read
3621 * Reads the PHY register at offset and stores the retrieved information
3624 s32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_hv_locked() argument
3626 return __e1000_read_phy_reg_hv(hw, offset, data, true, false); in e1000_read_phy_reg_hv_locked()
3630 * e1000_read_phy_reg_page_hv - Read HV PHY register
3632 * @offset: register offset to write to
3633 * @data: data to write at register offset
3635 * Reads the PHY register at offset and stores the retrieved information
3638 s32 e1000_read_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_page_hv() argument
3640 return __e1000_read_phy_reg_hv(hw, offset, data, true, true); in e1000_read_phy_reg_page_hv()
3644 * __e1000_write_phy_reg_hv - Write HV PHY register
3646 * @offset: register offset to write to
3647 * @data: data to write at register offset
3652 * at the offset. Release any acquired semaphores before exiting.
3654 static s32 __e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data, in __e1000_write_phy_reg_hv() argument
3658 u16 page = BM_PHY_REG_PAGE(offset); in __e1000_write_phy_reg_hv()
3659 u16 reg = BM_PHY_REG_NUM(offset); in __e1000_write_phy_reg_hv()
3660 u32 phy_addr = hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); in __e1000_write_phy_reg_hv()
3665 ret_val = hw->phy.ops.acquire(hw); in __e1000_write_phy_reg_hv()
3671 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, in __e1000_write_phy_reg_hv()
3677 ret_val = e1000_access_phy_debug_regs_hv(hw, offset, in __e1000_write_phy_reg_hv()
3689 if ((hw->phy.type == e1000_phy_82578) && in __e1000_write_phy_reg_hv()
3690 (hw->phy.revision >= 1) && in __e1000_write_phy_reg_hv()
3691 (hw->phy.addr == 2) && in __e1000_write_phy_reg_hv()
3707 hw->phy.addr = phy_addr; in __e1000_write_phy_reg_hv()
3722 hw->phy.ops.release(hw); in __e1000_write_phy_reg_hv()
3728 * e1000_write_phy_reg_hv - Write HV PHY register
3730 * @offset: register offset to write to
3731 * @data: data to write at register offset
3733 * Acquires semaphore then writes the data to PHY register at the offset.
3736 s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_hv() argument
3738 return __e1000_write_phy_reg_hv(hw, offset, data, false, false); in e1000_write_phy_reg_hv()
3742 * e1000_write_phy_reg_hv_locked - Write HV PHY register
3744 * @offset: register offset to write to
3745 * @data: data to write at register offset
3747 * Writes the data to PHY register at the offset. Assumes semaphore
3750 s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_hv_locked() argument
3752 return __e1000_write_phy_reg_hv(hw, offset, data, true, false); in e1000_write_phy_reg_hv_locked()
3756 * e1000_write_phy_reg_page_hv - Write HV PHY register
3758 * @offset: register offset to write to
3759 * @data: data to write at register offset
3761 * Writes the data to PHY register at the offset. Assumes semaphore
3764 s32 e1000_write_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_page_hv() argument
3766 return __e1000_write_phy_reg_hv(hw, offset, data, true, true); in e1000_write_phy_reg_page_hv()
3770 * e1000_get_phy_addr_for_hv_page - Get PHY adrress based on page
3784 * e1000_access_phy_debug_regs_hv - Read HV PHY vendor specific high registers
3786 * @offset: register offset to be read or written
3790 * Reads the PHY register at offset and stores the retreived information
3795 static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, in e1000_access_phy_debug_regs_hv() argument
3805 addr_reg = ((hw->phy.type == e1000_phy_82578) ? in e1000_access_phy_debug_regs_hv()
3810 hw->phy.addr = 2; in e1000_access_phy_debug_regs_hv()
3812 /* masking with 0x3F to remove the page from offset */ in e1000_access_phy_debug_regs_hv()
3813 ret_val = e1000_write_phy_reg_mdic(hw, addr_reg, (u16)offset & 0x3F); in e1000_access_phy_debug_regs_hv()
3815 DEBUGOUT("Could not write the Address Offset port register\n"); in e1000_access_phy_debug_regs_hv()
3832 * e1000_link_stall_workaround_hv - Si workaround
3849 if (hw->phy.type != e1000_phy_82578) in e1000_link_stall_workaround_hv()
3853 hw->phy.ops.read_reg(hw, PHY_CONTROL, &data); in e1000_link_stall_workaround_hv()
3858 ret_val = hw->phy.ops.read_reg(hw, BM_CS_STATUS, &data); in e1000_link_stall_workaround_hv()
3872 ret_val = hw->phy.ops.write_reg(hw, HV_MUX_DATA_CTRL, in e1000_link_stall_workaround_hv()
3878 return hw->phy.ops.write_reg(hw, HV_MUX_DATA_CTRL, in e1000_link_stall_workaround_hv()
3883 * e1000_check_polarity_82577 - Checks the polarity.
3886 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
3892 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_82577()
3898 ret_val = phy->ops.read_reg(hw, I82577_PHY_STATUS_2, &data); in e1000_check_polarity_82577()
3901 phy->cable_polarity = ((data & I82577_PHY_STATUS2_REV_POLARITY) in e1000_check_polarity_82577()
3909 * e1000_phy_force_speed_duplex_82577 - Force speed/duplex for I82577 PHY
3916 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_force_speed_duplex_82577()
3923 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_data); in e1000_phy_force_speed_duplex_82577()
3929 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_data); in e1000_phy_force_speed_duplex_82577()
3935 if (phy->autoneg_wait_to_complete) { in e1000_phy_force_speed_duplex_82577()
3955 * e1000_get_phy_info_82577 - Retrieve I82577 PHY information
3959 * set/determine 10base-T extended distance and polarity correction. Read
3965 struct e1000_phy_info *phy = &hw->phy; in e1000_get_phy_info_82577()
3978 return -E1000_ERR_CONFIG; in e1000_get_phy_info_82577()
3981 phy->polarity_correction = true; in e1000_get_phy_info_82577()
3987 ret_val = phy->ops.read_reg(hw, I82577_PHY_STATUS_2, &data); in e1000_get_phy_info_82577()
3991 phy->is_mdix = !!(data & I82577_PHY_STATUS2_MDIX); in e1000_get_phy_info_82577()
3995 ret_val = hw->phy.ops.get_cable_length(hw); in e1000_get_phy_info_82577()
3999 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &data); in e1000_get_phy_info_82577()
4003 phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS) in e1000_get_phy_info_82577()
4007 phy->remote_rx = (data & SR_1000T_REMOTE_RX_STATUS) in e1000_get_phy_info_82577()
4011 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000_get_phy_info_82577()
4012 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_82577()
4013 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_82577()
4020 * e1000_get_cable_length_82577 - Determine cable length for 82577 PHY
4028 struct e1000_phy_info *phy = &hw->phy; in e1000_get_cable_length_82577()
4034 ret_val = phy->ops.read_reg(hw, I82577_PHY_DIAG_STATUS, &phy_data); in e1000_get_cable_length_82577()
4042 return -E1000_ERR_PHY; in e1000_get_cable_length_82577()
4044 phy->cable_length = length; in e1000_get_cable_length_82577()
4050 * e1000_write_phy_reg_gs40g - Write GS40G PHY register
4052 * @offset: register offset to write to
4053 * @data: data to write at register offset
4056 * at the offset. Release any acquired semaphores before exiting.
4058 s32 e1000_write_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_gs40g() argument
4061 u16 page = offset >> GS40G_PAGE_SHIFT; in e1000_write_phy_reg_gs40g()
4065 offset = offset & GS40G_OFFSET_MASK; in e1000_write_phy_reg_gs40g()
4066 ret_val = hw->phy.ops.acquire(hw); in e1000_write_phy_reg_gs40g()
4073 ret_val = e1000_write_phy_reg_mdic(hw, offset, data); in e1000_write_phy_reg_gs40g()
4076 hw->phy.ops.release(hw); in e1000_write_phy_reg_gs40g()
4081 * e1000_read_phy_reg_gs40g - Read GS40G PHY register
4083 * @offset: lower half is register offset to read to
4085 * @data: data to read at register offset
4088 * at the offset. Release any acquired semaphores before exiting.
4090 s32 e1000_read_phy_reg_gs40g(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_gs40g() argument
4093 u16 page = offset >> GS40G_PAGE_SHIFT; in e1000_read_phy_reg_gs40g()
4097 offset = offset & GS40G_OFFSET_MASK; in e1000_read_phy_reg_gs40g()
4098 ret_val = hw->phy.ops.acquire(hw); in e1000_read_phy_reg_gs40g()
4105 ret_val = e1000_read_phy_reg_mdic(hw, offset, data); in e1000_read_phy_reg_gs40g()
4108 hw->phy.ops.release(hw); in e1000_read_phy_reg_gs40g()
4113 * e1000_read_phy_reg_mphy - Read mPHY control register
4118 * Reads the mPHY control register in the PHY at offset and stores the
4132 return -E1000_ERR_PHY; in e1000_read_phy_reg_mphy()
4134 /* Check if mPHY access is disabled and enable it if so */ in e1000_read_phy_reg_mphy()
4140 return -E1000_ERR_PHY; in e1000_read_phy_reg_mphy()
4148 return -E1000_ERR_PHY; in e1000_read_phy_reg_mphy()
4159 return -E1000_ERR_PHY; in e1000_read_phy_reg_mphy()
4166 return -E1000_ERR_PHY; in e1000_read_phy_reg_mphy()
4174 * e1000_write_phy_reg_mphy - Write mPHY control register
4177 * @data: data to write to register at offset
4194 return -E1000_ERR_PHY; in e1000_write_phy_reg_mphy()
4196 /* Check if mPHY access is disabled and enable it if so */ in e1000_write_phy_reg_mphy()
4202 return -E1000_ERR_PHY; in e1000_write_phy_reg_mphy()
4210 return -E1000_ERR_PHY; in e1000_write_phy_reg_mphy()
4224 return -E1000_ERR_PHY; in e1000_write_phy_reg_mphy()
4231 return -E1000_ERR_PHY; in e1000_write_phy_reg_mphy()
4239 * e1000_is_mphy_ready - Check if mPHY control register is not busy
4268 * __e1000_access_xmdio_reg - Read/write XMDIO register
4282 ret_val = hw->phy.ops.write_reg(hw, E1000_MMDAC, dev_addr); in __e1000_access_xmdio_reg()
4286 ret_val = hw->phy.ops.write_reg(hw, E1000_MMDAAD, address); in __e1000_access_xmdio_reg()
4290 ret_val = hw->phy.ops.write_reg(hw, E1000_MMDAC, E1000_MMDAC_FUNC_DATA | in __e1000_access_xmdio_reg()
4296 ret_val = hw->phy.ops.read_reg(hw, E1000_MMDAAD, data); in __e1000_access_xmdio_reg()
4298 ret_val = hw->phy.ops.write_reg(hw, E1000_MMDAAD, *data); in __e1000_access_xmdio_reg()
4303 ret_val = hw->phy.ops.write_reg(hw, E1000_MMDAC, 0); in __e1000_access_xmdio_reg()
4311 * e1000_read_xmdio_reg - Read XMDIO register
4325 * e1000_write_xmdio_reg - Write XMDIO register