Lines Matching +full:page +full:- +full:offset
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2018 Intel Corporation. */
8 static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,
10 static u32 e1000_get_phy_addr_for_hv_page(u32 page);
11 static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset,
37 * e1000e_check_reset_block_generic - Check if PHY reset is blocked
54 * e1000e_get_phy_id - Retrieve the PHY ID and revision
62 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_phy_id()
67 if (!phy->ops.read_reg) in e1000e_get_phy_id()
75 phy->id = (u32)(phy_id << 16); in e1000e_get_phy_id()
81 phy->id |= (u32)(phy_id & PHY_REVISION_MASK); in e1000e_get_phy_id()
82 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); in e1000e_get_phy_id()
84 if (phy->id != 0 && phy->id != PHY_REVISION_MASK) in e1000e_get_phy_id()
94 * e1000e_phy_reset_dsp - Reset PHY DSP
112 hw->phy.retry_enabled = false; in e1000e_disable_phy_retry()
117 hw->phy.retry_enabled = true; in e1000e_enable_phy_retry()
121 * e1000e_read_phy_reg_mdic - Read MDI control register
123 * @offset: register offset to be read
126 * Reads the MDI control register in the PHY at offset and stores the
129 s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_mdic() argument
132 struct e1000_phy_info *phy = &hw->phy; in e1000e_read_phy_reg_mdic()
135 if (offset > MAX_PHY_REG_ADDRESS) { in e1000e_read_phy_reg_mdic()
136 e_dbg("PHY Address %d is out of range\n", offset); in e1000e_read_phy_reg_mdic()
137 return -E1000_ERR_PARAM; in e1000e_read_phy_reg_mdic()
140 retry_max = phy->retry_enabled ? phy->retry_count : 0; in e1000e_read_phy_reg_mdic()
142 /* Set up Op-code, Phy Address, and register offset in the MDI in e1000e_read_phy_reg_mdic()
149 mdic = ((offset << E1000_MDIC_REG_SHIFT) | in e1000e_read_phy_reg_mdic()
150 (phy->addr << E1000_MDIC_PHY_SHIFT) | in e1000e_read_phy_reg_mdic()
167 offset); in e1000e_read_phy_reg_mdic()
171 e_dbg("MDI Read PHY Reg Address %d Error\n", offset); in e1000e_read_phy_reg_mdic()
174 if (FIELD_GET(E1000_MDIC_REG_MASK, mdic) != offset) { in e1000e_read_phy_reg_mdic()
175 e_dbg("MDI Read offset error - requested %d, returned %d\n", in e1000e_read_phy_reg_mdic()
176 offset, FIELD_GET(E1000_MDIC_REG_MASK, mdic)); in e1000e_read_phy_reg_mdic()
183 if (hw->mac.type == e1000_pch2lan) in e1000e_read_phy_reg_mdic()
197 return -E1000_ERR_PHY; in e1000e_read_phy_reg_mdic()
201 * e1000e_write_phy_reg_mdic - Write MDI control register
203 * @offset: register offset to write to
204 * @data: data to write to register at offset
206 * Writes data to MDI control register in the PHY at offset.
208 s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_mdic() argument
211 struct e1000_phy_info *phy = &hw->phy; in e1000e_write_phy_reg_mdic()
214 if (offset > MAX_PHY_REG_ADDRESS) { in e1000e_write_phy_reg_mdic()
215 e_dbg("PHY Address %d is out of range\n", offset); in e1000e_write_phy_reg_mdic()
216 return -E1000_ERR_PARAM; in e1000e_write_phy_reg_mdic()
219 retry_max = phy->retry_enabled ? phy->retry_count : 0; in e1000e_write_phy_reg_mdic()
221 /* Set up Op-code, Phy Address, and register offset in the MDI in e1000e_write_phy_reg_mdic()
229 (offset << E1000_MDIC_REG_SHIFT) | in e1000e_write_phy_reg_mdic()
230 (phy->addr << E1000_MDIC_PHY_SHIFT) | in e1000e_write_phy_reg_mdic()
247 offset); in e1000e_write_phy_reg_mdic()
251 e_dbg("MDI Write PHY Reg Address %d Error\n", offset); in e1000e_write_phy_reg_mdic()
254 if (FIELD_GET(E1000_MDIC_REG_MASK, mdic) != offset) { in e1000e_write_phy_reg_mdic()
255 e_dbg("MDI Write offset error - requested %d, returned %d\n", in e1000e_write_phy_reg_mdic()
256 offset, FIELD_GET(E1000_MDIC_REG_MASK, mdic)); in e1000e_write_phy_reg_mdic()
263 if (hw->mac.type == e1000_pch2lan) in e1000e_write_phy_reg_mdic()
275 return -E1000_ERR_PHY; in e1000e_write_phy_reg_mdic()
279 * e1000e_read_phy_reg_m88 - Read m88 PHY register
281 * @offset: register offset to be read
284 * Acquires semaphore, if necessary, then reads the PHY register at offset
288 s32 e1000e_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_m88() argument
292 ret_val = hw->phy.ops.acquire(hw); in e1000e_read_phy_reg_m88()
296 ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_read_phy_reg_m88()
299 hw->phy.ops.release(hw); in e1000e_read_phy_reg_m88()
305 * e1000e_write_phy_reg_m88 - Write m88 PHY register
307 * @offset: register offset to write to
308 * @data: data to write at register offset
311 * at the offset. Release any acquired semaphores before exiting.
313 s32 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_m88() argument
317 ret_val = hw->phy.ops.acquire(hw); in e1000e_write_phy_reg_m88()
321 ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_write_phy_reg_m88()
324 hw->phy.ops.release(hw); in e1000e_write_phy_reg_m88()
330 * e1000_set_page_igp - Set page as on IGP-like PHY(s)
332 * @page: page to set (shifted left when necessary)
334 * Sets PHY page required for PHY register access. Assumes semaphore is
338 s32 e1000_set_page_igp(struct e1000_hw *hw, u16 page) in e1000_set_page_igp() argument
340 e_dbg("Setting page 0x%x\n", page); in e1000_set_page_igp()
342 hw->phy.addr = 1; in e1000_set_page_igp()
344 return e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, page); in e1000_set_page_igp()
348 * __e1000e_read_phy_reg_igp - Read igp PHY register
350 * @offset: register offset to be read
354 * Acquires semaphore, if necessary, then reads the PHY register at offset
358 static s32 __e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data, in __e1000e_read_phy_reg_igp() argument
364 if (!hw->phy.ops.acquire) in __e1000e_read_phy_reg_igp()
367 ret_val = hw->phy.ops.acquire(hw); in __e1000e_read_phy_reg_igp()
372 if (offset > MAX_PHY_MULTI_PAGE_REG) in __e1000e_read_phy_reg_igp()
375 (u16)offset); in __e1000e_read_phy_reg_igp()
378 MAX_PHY_REG_ADDRESS & offset, in __e1000e_read_phy_reg_igp()
381 hw->phy.ops.release(hw); in __e1000e_read_phy_reg_igp()
387 * e1000e_read_phy_reg_igp - Read igp PHY register
389 * @offset: register offset to be read
392 * Acquires semaphore then reads the PHY register at offset and stores the
396 s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_igp() argument
398 return __e1000e_read_phy_reg_igp(hw, offset, data, false); in e1000e_read_phy_reg_igp()
402 * e1000e_read_phy_reg_igp_locked - Read igp PHY register
404 * @offset: register offset to be read
407 * Reads the PHY register at offset and stores the retrieved information
410 s32 e1000e_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_igp_locked() argument
412 return __e1000e_read_phy_reg_igp(hw, offset, data, true); in e1000e_read_phy_reg_igp_locked()
416 * __e1000e_write_phy_reg_igp - Write igp PHY register
418 * @offset: register offset to write to
419 * @data: data to write at register offset
423 * at the offset. Release any acquired semaphores before exiting.
425 static s32 __e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data, in __e1000e_write_phy_reg_igp() argument
431 if (!hw->phy.ops.acquire) in __e1000e_write_phy_reg_igp()
434 ret_val = hw->phy.ops.acquire(hw); in __e1000e_write_phy_reg_igp()
439 if (offset > MAX_PHY_MULTI_PAGE_REG) in __e1000e_write_phy_reg_igp()
442 (u16)offset); in __e1000e_write_phy_reg_igp()
445 offset, data); in __e1000e_write_phy_reg_igp()
447 hw->phy.ops.release(hw); in __e1000e_write_phy_reg_igp()
453 * e1000e_write_phy_reg_igp - Write igp PHY register
455 * @offset: register offset to write to
456 * @data: data to write at register offset
459 * at the offset. Release any acquired semaphores before exiting.
461 s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_igp() argument
463 return __e1000e_write_phy_reg_igp(hw, offset, data, false); in e1000e_write_phy_reg_igp()
467 * e1000e_write_phy_reg_igp_locked - Write igp PHY register
469 * @offset: register offset to write to
470 * @data: data to write at register offset
472 * Writes the data to PHY register at the offset.
475 s32 e1000e_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_igp_locked() argument
477 return __e1000e_write_phy_reg_igp(hw, offset, data, true); in e1000e_write_phy_reg_igp_locked()
481 * __e1000_read_kmrn_reg - Read kumeran register
483 * @offset: register offset to be read
487 * Acquires semaphore, if necessary. Then reads the PHY register at offset
491 static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data, in __e1000_read_kmrn_reg() argument
499 if (!hw->phy.ops.acquire) in __e1000_read_kmrn_reg()
502 ret_val = hw->phy.ops.acquire(hw); in __e1000_read_kmrn_reg()
507 kmrnctrlsta = FIELD_PREP(E1000_KMRNCTRLSTA_OFFSET, offset) | in __e1000_read_kmrn_reg()
518 hw->phy.ops.release(hw); in __e1000_read_kmrn_reg()
524 * e1000e_read_kmrn_reg - Read kumeran register
526 * @offset: register offset to be read
529 * Acquires semaphore then reads the PHY register at offset using the
533 s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_kmrn_reg() argument
535 return __e1000_read_kmrn_reg(hw, offset, data, false); in e1000e_read_kmrn_reg()
539 * e1000e_read_kmrn_reg_locked - Read kumeran register
541 * @offset: register offset to be read
544 * Reads the PHY register at offset using the kumeran interface. The
548 s32 e1000e_read_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_kmrn_reg_locked() argument
550 return __e1000_read_kmrn_reg(hw, offset, data, true); in e1000e_read_kmrn_reg_locked()
554 * __e1000_write_kmrn_reg - Write kumeran register
556 * @offset: register offset to write to
557 * @data: data to write at register offset
561 * at the offset using the kumeran interface. Release any acquired semaphores
564 static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data, in __e1000_write_kmrn_reg() argument
572 if (!hw->phy.ops.acquire) in __e1000_write_kmrn_reg()
575 ret_val = hw->phy.ops.acquire(hw); in __e1000_write_kmrn_reg()
580 kmrnctrlsta = FIELD_PREP(E1000_KMRNCTRLSTA_OFFSET, offset) | data; in __e1000_write_kmrn_reg()
587 hw->phy.ops.release(hw); in __e1000_write_kmrn_reg()
593 * e1000e_write_kmrn_reg - Write kumeran register
595 * @offset: register offset to write to
596 * @data: data to write at register offset
598 * Acquires semaphore then writes the data to the PHY register at the offset
601 s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_kmrn_reg() argument
603 return __e1000_write_kmrn_reg(hw, offset, data, false); in e1000e_write_kmrn_reg()
607 * e1000e_write_kmrn_reg_locked - Write kumeran register
609 * @offset: register offset to write to
610 * @data: data to write at register offset
612 * Write the data to PHY register at the offset using the kumeran interface.
615 s32 e1000e_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_kmrn_reg_locked() argument
617 return __e1000_write_kmrn_reg(hw, offset, data, true); in e1000e_write_kmrn_reg_locked()
621 * e1000_set_master_slave_mode - Setup PHY for Master/slave mode
637 hw->phy.original_ms_type = (phy_data & CTL1000_ENABLE_MASTER) ? in e1000_set_master_slave_mode()
641 switch (hw->phy.ms_type) { in e1000_set_master_slave_mode()
660 * e1000_copper_link_setup_82577 - Setup 82577 PHY for copper link
663 * Sets up Carrier-sense on Transmit and downshift values.
670 /* Enable CRS on Tx. This must be set for half-duplex operation. */ in e1000_copper_link_setup_82577()
690 * 0 - Auto (default) in e1000_copper_link_setup_82577()
691 * 1 - MDI mode in e1000_copper_link_setup_82577()
692 * 2 - MDI-X mode in e1000_copper_link_setup_82577()
694 switch (hw->phy.mdix) { in e1000_copper_link_setup_82577()
713 * e1000e_copper_link_setup_m88 - Setup m88 PHY's for copper link
716 * Sets up MDI/MDI-X and polarity for m88 PHY's. If necessary, transmit clock
721 struct e1000_phy_info *phy = &hw->phy; in e1000e_copper_link_setup_m88()
725 /* Enable CRS on Tx. This must be set for half-duplex operation. */ in e1000e_copper_link_setup_m88()
731 if (phy->type != e1000_phy_bm) in e1000e_copper_link_setup_m88()
735 * MDI/MDI-X = 0 (default) in e1000e_copper_link_setup_m88()
736 * 0 - Auto for all speeds in e1000e_copper_link_setup_m88()
737 * 1 - MDI mode in e1000e_copper_link_setup_m88()
738 * 2 - MDI-X mode in e1000e_copper_link_setup_m88()
739 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) in e1000e_copper_link_setup_m88()
743 switch (phy->mdix) { in e1000e_copper_link_setup_m88()
762 * 0 - Disabled in e1000e_copper_link_setup_m88()
763 * 1 - Enabled in e1000e_copper_link_setup_m88()
766 if (phy->disable_polarity_correction) in e1000e_copper_link_setup_m88()
770 if (phy->type == e1000_phy_bm) { in e1000e_copper_link_setup_m88()
772 if (phy->id == BME1000_E_PHY_ID_R2) { in e1000e_copper_link_setup_m88()
779 ret_val = phy->ops.commit(hw); in e1000e_copper_link_setup_m88()
793 if ((phy->type == e1000_phy_m88) && in e1000e_copper_link_setup_m88()
794 (phy->revision < E1000_REVISION_4) && in e1000e_copper_link_setup_m88()
795 (phy->id != BME1000_E_PHY_ID_R2)) { in e1000e_copper_link_setup_m88()
805 if ((phy->revision == 2) && (phy->id == M88E1111_I_PHY_ID)) { in e1000e_copper_link_setup_m88()
806 /* 82573L PHY - set the downshift counter to 5x. */ in e1000e_copper_link_setup_m88()
821 if ((phy->type == e1000_phy_bm) && (phy->id == BME1000_E_PHY_ID_R2)) { in e1000e_copper_link_setup_m88()
822 /* Set PHY page 0, register 29 to 0x0003 */ in e1000e_copper_link_setup_m88()
827 /* Set PHY page 0, register 30 to 0x0000 */ in e1000e_copper_link_setup_m88()
834 if (phy->ops.commit) { in e1000e_copper_link_setup_m88()
835 ret_val = phy->ops.commit(hw); in e1000e_copper_link_setup_m88()
842 if (phy->type == e1000_phy_82578) { in e1000e_copper_link_setup_m88()
847 /* 82578 PHY - set the downshift count to 1x. */ in e1000e_copper_link_setup_m88()
859 * e1000e_copper_link_setup_igp - Setup igp PHY's for copper link
862 * Sets up LPLU, MDI/MDI-X, polarity, Smartspeed and Master/Slave config for
867 struct e1000_phy_info *phy = &hw->phy; in e1000e_copper_link_setup_igp()
883 if (hw->phy.ops.set_d0_lplu_state) { in e1000e_copper_link_setup_igp()
884 ret_val = hw->phy.ops.set_d0_lplu_state(hw, false); in e1000e_copper_link_setup_igp()
890 /* Configure mdi-mdix settings */ in e1000e_copper_link_setup_igp()
897 switch (phy->mdix) { in e1000e_copper_link_setup_igp()
913 /* set auto-master slave resolution settings */ in e1000e_copper_link_setup_igp()
914 if (hw->mac.autoneg) { in e1000e_copper_link_setup_igp()
919 if (phy->autoneg_advertised == ADVERTISE_1000_FULL) { in e1000e_copper_link_setup_igp()
950 * e1000_phy_setup_autoneg - Configure PHY for auto-negotiation
953 * Reads the MII auto-neg advertisement register and/or the 1000T control
954 * register and if the PHY is already setup for auto-negotiation, then
956 * the appropriate values for the wanted auto-negotiation.
960 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_setup_autoneg()
965 phy->autoneg_advertised &= phy->autoneg_mask; in e1000_phy_setup_autoneg()
967 /* Read the MII Auto-Neg Advertisement Register (Address 4). */ in e1000_phy_setup_autoneg()
972 if (phy->autoneg_mask & ADVERTISE_1000_FULL) { in e1000_phy_setup_autoneg()
973 /* Read the MII 1000Base-T Control Register (Address 9). */ in e1000_phy_setup_autoneg()
986 /* First we clear all the 10/100 mb speed bits in the Auto-Neg in e1000_phy_setup_autoneg()
988 * the 1000Base-T Control Register (Address 9). in e1000_phy_setup_autoneg()
995 e_dbg("autoneg_advertised %x\n", phy->autoneg_advertised); in e1000_phy_setup_autoneg()
998 if (phy->autoneg_advertised & ADVERTISE_10_HALF) { in e1000_phy_setup_autoneg()
1004 if (phy->autoneg_advertised & ADVERTISE_10_FULL) { in e1000_phy_setup_autoneg()
1010 if (phy->autoneg_advertised & ADVERTISE_100_HALF) { in e1000_phy_setup_autoneg()
1016 if (phy->autoneg_advertised & ADVERTISE_100_FULL) { in e1000_phy_setup_autoneg()
1022 if (phy->autoneg_advertised & ADVERTISE_1000_HALF) in e1000_phy_setup_autoneg()
1026 if (phy->autoneg_advertised & ADVERTISE_1000_FULL) { in e1000_phy_setup_autoneg()
1033 * auto-negotiation is enabled, then software will have to set the in e1000_phy_setup_autoneg()
1034 * "PAUSE" bits to the correct value in the Auto-Negotiation in e1000_phy_setup_autoneg()
1035 * Advertisement Register (MII_ADVERTISE) and re-start auto- in e1000_phy_setup_autoneg()
1048 switch (hw->fc.current_mode) { in e1000_phy_setup_autoneg()
1051 * software over-ride. in e1000_phy_setup_autoneg()
1055 phy->autoneg_advertised &= in e1000_phy_setup_autoneg()
1060 * disabled, by a software over-ride. in e1000_phy_setup_autoneg()
1070 phy->autoneg_advertised |= in e1000_phy_setup_autoneg()
1075 * disabled, by a software over-ride. in e1000_phy_setup_autoneg()
1079 phy->autoneg_advertised |= ADVERTISED_Asym_Pause; in e1000_phy_setup_autoneg()
1080 phy->autoneg_advertised &= ~ADVERTISED_Pause; in e1000_phy_setup_autoneg()
1084 * over-ride. in e1000_phy_setup_autoneg()
1088 phy->autoneg_advertised |= in e1000_phy_setup_autoneg()
1093 return -E1000_ERR_CONFIG; in e1000_phy_setup_autoneg()
1100 e_dbg("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); in e1000_phy_setup_autoneg()
1102 if (phy->autoneg_mask & ADVERTISE_1000_FULL) in e1000_phy_setup_autoneg()
1109 * e1000_copper_link_autoneg - Setup/Enable autoneg for copper link
1119 struct e1000_phy_info *phy = &hw->phy; in e1000_copper_link_autoneg()
1126 phy->autoneg_advertised &= phy->autoneg_mask; in e1000_copper_link_autoneg()
1131 if (!phy->autoneg_advertised) in e1000_copper_link_autoneg()
1132 phy->autoneg_advertised = phy->autoneg_mask; in e1000_copper_link_autoneg()
1134 e_dbg("Reconfiguring auto-neg advertisement params\n"); in e1000_copper_link_autoneg()
1137 e_dbg("Error Setting up Auto-Negotiation\n"); in e1000_copper_link_autoneg()
1140 e_dbg("Restarting Auto-Neg\n"); in e1000_copper_link_autoneg()
1142 /* Restart auto-negotiation by setting the Auto Neg Enable bit and in e1000_copper_link_autoneg()
1154 /* Does the user want to wait for Auto-Neg to complete here, or in e1000_copper_link_autoneg()
1157 if (phy->autoneg_wait_to_complete) { in e1000_copper_link_autoneg()
1165 hw->mac.get_link_status = true; in e1000_copper_link_autoneg()
1171 * e1000e_setup_copper_link - Configure copper link settings
1174 * Calls the appropriate function to configure the link for auto-neg or forced
1177 * not established, we return -E1000_ERR_PHY (-2).
1184 if (hw->mac.autoneg) { in e1000e_setup_copper_link()
1196 ret_val = hw->phy.ops.force_speed_duplex(hw); in e1000e_setup_copper_link()
1213 hw->mac.ops.config_collision_dist(hw); in e1000e_setup_copper_link()
1223 * e1000e_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY
1227 * auto-crossover to force MDI manually. Waits for link and returns
1228 * successful if link up is successful, else -E1000_ERR_PHY (-2).
1232 struct e1000_phy_info *phy = &hw->phy; in e1000e_phy_force_speed_duplex_igp()
1247 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI in e1000e_phy_force_speed_duplex_igp()
1265 if (phy->autoneg_wait_to_complete) { in e1000e_phy_force_speed_duplex_igp()
1285 * e1000e_phy_force_speed_duplex_m88 - Force speed/duplex for m88 PHY
1289 * auto-crossover to force MDI manually. Resets the PHY to commit the
1296 struct e1000_phy_info *phy = &hw->phy; in e1000e_phy_force_speed_duplex_m88()
1301 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI in e1000e_phy_force_speed_duplex_m88()
1326 if (hw->phy.ops.commit) { in e1000e_phy_force_speed_duplex_m88()
1327 ret_val = hw->phy.ops.commit(hw); in e1000e_phy_force_speed_duplex_m88()
1332 if (phy->autoneg_wait_to_complete) { in e1000e_phy_force_speed_duplex_m88()
1341 if (hw->phy.type != e1000_phy_m88) { in e1000e_phy_force_speed_duplex_m88()
1364 if (hw->phy.type != e1000_phy_m88) in e1000e_phy_force_speed_duplex_m88()
1371 /* Resetting the phy means we need to re-force TX_CLK in the in e1000e_phy_force_speed_duplex_m88()
1380 /* In addition, we must re-enable CRS on Tx for both half and full in e1000e_phy_force_speed_duplex_m88()
1394 * e1000_phy_force_speed_duplex_ife - Force PHY speed & duplex
1403 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_force_speed_duplex_ife()
1418 /* Disable MDI-X support for 10/100 */ in e1000_phy_force_speed_duplex_ife()
1434 if (phy->autoneg_wait_to_complete) { in e1000_phy_force_speed_duplex_ife()
1456 * e1000e_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex
1462 * disable auto-negotiation, configure duplex, configure speed, configure
1469 struct e1000_mac_info *mac = &hw->mac; in e1000e_phy_force_speed_duplex_setup()
1473 hw->fc.current_mode = e1000_fc_none; in e1000e_phy_force_speed_duplex_setup()
1487 if (mac->forced_speed_duplex & E1000_ALL_HALF_DUPLEX) { in e1000e_phy_force_speed_duplex_setup()
1498 if (mac->forced_speed_duplex & E1000_ALL_100_SPEED) { in e1000e_phy_force_speed_duplex_setup()
1509 hw->mac.ops.config_collision_dist(hw); in e1000e_phy_force_speed_duplex_setup()
1515 * e1000e_set_d3_lplu_state - Sets low power link up state for D3
1530 struct e1000_phy_info *phy = &hw->phy; in e1000e_set_d3_lplu_state()
1548 if (phy->smart_speed == e1000_smart_speed_on) { in e1000e_set_d3_lplu_state()
1559 } else if (phy->smart_speed == e1000_smart_speed_off) { in e1000e_set_d3_lplu_state()
1571 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || in e1000e_set_d3_lplu_state()
1572 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) || in e1000e_set_d3_lplu_state()
1573 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) { in e1000e_set_d3_lplu_state()
1592 * e1000e_check_downshift - Checks whether a downshift in speed occurred
1601 struct e1000_phy_info *phy = &hw->phy; in e1000e_check_downshift()
1603 u16 phy_data, offset, mask; in e1000e_check_downshift() local
1605 switch (phy->type) { in e1000e_check_downshift()
1610 offset = M88E1000_PHY_SPEC_STATUS; in e1000e_check_downshift()
1615 offset = IGP01E1000_PHY_LINK_HEALTH; in e1000e_check_downshift()
1620 phy->speed_downgraded = false; in e1000e_check_downshift()
1624 ret_val = e1e_rphy(hw, offset, &phy_data); in e1000e_check_downshift()
1627 phy->speed_downgraded = !!(phy_data & mask); in e1000e_check_downshift()
1633 * e1000_check_polarity_m88 - Checks the polarity.
1636 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1642 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_m88()
1649 phy->cable_polarity = ((data & M88E1000_PSSR_REV_POLARITY) in e1000_check_polarity_m88()
1657 * e1000_check_polarity_igp - Checks the polarity.
1660 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1667 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_igp()
1669 u16 data, offset, mask; in e1000_check_polarity_igp() local
1680 offset = IGP01E1000_PHY_PCS_INIT_REG; in e1000_check_polarity_igp()
1686 offset = IGP01E1000_PHY_PORT_STATUS; in e1000_check_polarity_igp()
1690 ret_val = e1e_rphy(hw, offset, &data); in e1000_check_polarity_igp()
1693 phy->cable_polarity = ((data & mask) in e1000_check_polarity_igp()
1701 * e1000_check_polarity_ife - Check cable polarity for IFE PHY
1708 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_ife()
1710 u16 phy_data, offset, mask; in e1000_check_polarity_ife() local
1714 if (phy->polarity_correction) { in e1000_check_polarity_ife()
1715 offset = IFE_PHY_EXTENDED_STATUS_CONTROL; in e1000_check_polarity_ife()
1718 offset = IFE_PHY_SPECIAL_CONTROL; in e1000_check_polarity_ife()
1722 ret_val = e1e_rphy(hw, offset, &phy_data); in e1000_check_polarity_ife()
1725 phy->cable_polarity = ((phy_data & mask) in e1000_check_polarity_ife()
1733 * e1000_wait_autoneg - Wait for auto-neg completion
1736 * Waits for auto-negotiation to complete or for the auto-negotiation time
1745 for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) { in e1000_wait_autoneg()
1757 /* PHY_AUTO_NEG_TIME expiration doesn't guarantee auto-negotiation in e1000_wait_autoneg()
1764 * e1000e_phy_has_link_generic - Polls PHY for link
1812 * e1000e_get_cable_length_m88 - Determine cable length for m88 PHY
1821 * 1 50 - 80 meters
1822 * 2 80 - 110 meters
1823 * 3 110 - 140 meters
1828 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_cable_length_m88()
1838 if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) in e1000e_get_cable_length_m88()
1839 return -E1000_ERR_PHY; in e1000e_get_cable_length_m88()
1841 phy->min_cable_length = e1000_m88_cable_length_table[index]; in e1000e_get_cable_length_m88()
1842 phy->max_cable_length = e1000_m88_cable_length_table[index + 1]; in e1000e_get_cable_length_m88()
1844 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; in e1000e_get_cable_length_m88()
1850 * e1000e_get_cable_length_igp_2 - Determine cable length for igp2 PHY
1862 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_cable_length_igp_2()
1866 u16 min_agc_index = IGP02E1000_CABLE_LENGTH_TABLE_SIZE - 1; in e1000e_get_cable_length_igp_2()
1891 return -E1000_ERR_PHY; in e1000e_get_cable_length_igp_2()
1904 agc_value -= (e1000_igp_2_cable_length_table[min_agc_index] + in e1000e_get_cable_length_igp_2()
1906 agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2); in e1000e_get_cable_length_igp_2()
1908 /* Calculate cable length with the error range of +/- 10 meters. */ in e1000e_get_cable_length_igp_2()
1909 phy->min_cable_length = (((agc_value - IGP02E1000_AGC_RANGE) > 0) ? in e1000e_get_cable_length_igp_2()
1910 (agc_value - IGP02E1000_AGC_RANGE) : 0); in e1000e_get_cable_length_igp_2()
1911 phy->max_cable_length = agc_value + IGP02E1000_AGC_RANGE; in e1000e_get_cable_length_igp_2()
1913 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; in e1000e_get_cable_length_igp_2()
1919 * e1000e_get_phy_info_m88 - Retrieve PHY information
1924 * determine the polarity and 10base-T extended distance. Read the PHY
1930 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_phy_info_m88()
1935 if (phy->media_type != e1000_media_type_copper) { in e1000e_get_phy_info_m88()
1937 return -E1000_ERR_CONFIG; in e1000e_get_phy_info_m88()
1946 return -E1000_ERR_CONFIG; in e1000e_get_phy_info_m88()
1953 phy->polarity_correction = !!(phy_data & in e1000e_get_phy_info_m88()
1964 phy->is_mdix = !!(phy_data & M88E1000_PSSR_MDIX); in e1000e_get_phy_info_m88()
1967 ret_val = hw->phy.ops.get_cable_length(hw); in e1000e_get_phy_info_m88()
1975 phy->local_rx = (phy_data & LPA_1000LOCALRXOK) in e1000e_get_phy_info_m88()
1978 phy->remote_rx = (phy_data & LPA_1000REMRXOK) in e1000e_get_phy_info_m88()
1982 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000e_get_phy_info_m88()
1983 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_m88()
1984 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_m88()
1991 * e1000e_get_phy_info_igp - Retrieve igp PHY information
1995 * set/determine 10base-T extended distance and polarity correction. Read
2001 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_phy_info_igp()
2012 return -E1000_ERR_CONFIG; in e1000e_get_phy_info_igp()
2015 phy->polarity_correction = true; in e1000e_get_phy_info_igp()
2025 phy->is_mdix = !!(data & IGP01E1000_PSSR_MDIX); in e1000e_get_phy_info_igp()
2029 ret_val = phy->ops.get_cable_length(hw); in e1000e_get_phy_info_igp()
2037 phy->local_rx = (data & LPA_1000LOCALRXOK) in e1000e_get_phy_info_igp()
2040 phy->remote_rx = (data & LPA_1000REMRXOK) in e1000e_get_phy_info_igp()
2043 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000e_get_phy_info_igp()
2044 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_igp()
2045 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_igp()
2052 * e1000_get_phy_info_ife - Retrieves various IFE PHY states
2059 struct e1000_phy_info *phy = &hw->phy; in e1000_get_phy_info_ife()
2070 return -E1000_ERR_CONFIG; in e1000_get_phy_info_ife()
2076 phy->polarity_correction = !(data & IFE_PSC_AUTO_POLARITY_DISABLE); in e1000_get_phy_info_ife()
2078 if (phy->polarity_correction) { in e1000_get_phy_info_ife()
2084 phy->cable_polarity = ((data & IFE_PSC_FORCE_POLARITY) in e1000_get_phy_info_ife()
2093 phy->is_mdix = !!(data & IFE_PMC_MDIX_STATUS); in e1000_get_phy_info_ife()
2096 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000_get_phy_info_ife()
2097 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_ife()
2098 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_ife()
2104 * e1000e_phy_sw_reset - PHY software reset
2130 * e1000e_phy_hw_reset_generic - PHY hardware reset
2140 struct e1000_phy_info *phy = &hw->phy; in e1000e_phy_hw_reset_generic()
2144 if (phy->ops.check_reset_block) { in e1000e_phy_hw_reset_generic()
2145 ret_val = phy->ops.check_reset_block(hw); in e1000e_phy_hw_reset_generic()
2150 ret_val = phy->ops.acquire(hw); in e1000e_phy_hw_reset_generic()
2158 udelay(phy->reset_delay_us); in e1000e_phy_hw_reset_generic()
2165 phy->ops.release(hw); in e1000e_phy_hw_reset_generic()
2167 return phy->ops.get_cfg_done(hw); in e1000e_phy_hw_reset_generic()
2171 * e1000e_get_cfg_done_generic - Generic configuration done
2174 * Generic function to wait 10 milli-seconds for configuration to complete
2185 * e1000e_phy_init_script_igp3 - Inits the IGP3 PHY
2195 /* Enable rise/fall, 10-mode work in class-A */ in e1000e_phy_init_script_igp3()
2253 /* Enable LPLU and disable AN to 1000 in non-D0a states, in e1000e_phy_init_script_igp3()
2268 * e1000e_get_phy_type_from_id - Get PHY type from id
2322 * e1000e_determine_phy_address - Determines PHY address.
2335 hw->phy.id = phy_type; in e1000e_determine_phy_address()
2338 hw->phy.addr = phy_addr; in e1000e_determine_phy_address()
2343 phy_type = e1000e_get_phy_type_from_id(hw->phy.id); in e1000e_determine_phy_address()
2345 /* If phy_type is valid, break - we found our in e1000e_determine_phy_address()
2356 return -E1000_ERR_PHY_TYPE; in e1000e_determine_phy_address()
2360 * e1000_get_phy_addr_for_bm_page - Retrieve PHY page address
2361 * @page: page to access
2364 * Returns the phy address for the page requested.
2366 static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg) in e1000_get_phy_addr_for_bm_page() argument
2370 if ((page >= 768) || (page == 0 && reg == 25) || (reg == 31)) in e1000_get_phy_addr_for_bm_page()
2377 * e1000e_write_phy_reg_bm - Write BM PHY register
2379 * @offset: register offset to write to
2380 * @data: data to write at register offset
2383 * at the offset. Release any acquired semaphores before exiting.
2385 s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_bm() argument
2388 u32 page = offset >> IGP_PAGE_SHIFT; in e1000e_write_phy_reg_bm() local
2390 ret_val = hw->phy.ops.acquire(hw); in e1000e_write_phy_reg_bm()
2394 /* Page 800 works differently than the rest so it has its own func */ in e1000e_write_phy_reg_bm()
2395 if (page == BM_WUC_PAGE) { in e1000e_write_phy_reg_bm()
2396 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, in e1000e_write_phy_reg_bm()
2401 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); in e1000e_write_phy_reg_bm()
2403 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000e_write_phy_reg_bm()
2406 /* Page select is register 31 for phy address 1 and 22 for in e1000e_write_phy_reg_bm()
2407 * phy address 2 and 3. Page select is shifted only for in e1000e_write_phy_reg_bm()
2410 if (hw->phy.addr == 1) { in e1000e_write_phy_reg_bm()
2418 /* Page is shifted left, PHY expects (page x 32) */ in e1000e_write_phy_reg_bm()
2420 (page << page_shift)); in e1000e_write_phy_reg_bm()
2425 ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_write_phy_reg_bm()
2429 hw->phy.ops.release(hw); in e1000e_write_phy_reg_bm()
2434 * e1000e_read_phy_reg_bm - Read BM PHY register
2436 * @offset: register offset to be read
2439 * Acquires semaphore, if necessary, then reads the PHY register at offset
2443 s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_bm() argument
2446 u32 page = offset >> IGP_PAGE_SHIFT; in e1000e_read_phy_reg_bm() local
2448 ret_val = hw->phy.ops.acquire(hw); in e1000e_read_phy_reg_bm()
2452 /* Page 800 works differently than the rest so it has its own func */ in e1000e_read_phy_reg_bm()
2453 if (page == BM_WUC_PAGE) { in e1000e_read_phy_reg_bm()
2454 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, in e1000e_read_phy_reg_bm()
2459 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); in e1000e_read_phy_reg_bm()
2461 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000e_read_phy_reg_bm()
2464 /* Page select is register 31 for phy address 1 and 22 for in e1000e_read_phy_reg_bm()
2465 * phy address 2 and 3. Page select is shifted only for in e1000e_read_phy_reg_bm()
2468 if (hw->phy.addr == 1) { in e1000e_read_phy_reg_bm()
2476 /* Page is shifted left, PHY expects (page x 32) */ in e1000e_read_phy_reg_bm()
2478 (page << page_shift)); in e1000e_read_phy_reg_bm()
2483 ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_read_phy_reg_bm()
2486 hw->phy.ops.release(hw); in e1000e_read_phy_reg_bm()
2491 * e1000e_read_phy_reg_bm2 - Read BM PHY register
2493 * @offset: register offset to be read
2496 * Acquires semaphore, if necessary, then reads the PHY register at offset
2500 s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_bm2() argument
2503 u16 page = (u16)(offset >> IGP_PAGE_SHIFT); in e1000e_read_phy_reg_bm2() local
2505 ret_val = hw->phy.ops.acquire(hw); in e1000e_read_phy_reg_bm2()
2509 /* Page 800 works differently than the rest so it has its own func */ in e1000e_read_phy_reg_bm2()
2510 if (page == BM_WUC_PAGE) { in e1000e_read_phy_reg_bm2()
2511 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, in e1000e_read_phy_reg_bm2()
2516 hw->phy.addr = 1; in e1000e_read_phy_reg_bm2()
2518 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000e_read_phy_reg_bm2()
2519 /* Page is shifted left, PHY expects (page x 32) */ in e1000e_read_phy_reg_bm2()
2521 page); in e1000e_read_phy_reg_bm2()
2527 ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_read_phy_reg_bm2()
2530 hw->phy.ops.release(hw); in e1000e_read_phy_reg_bm2()
2535 * e1000e_write_phy_reg_bm2 - Write BM PHY register
2537 * @offset: register offset to write to
2538 * @data: data to write at register offset
2541 * at the offset. Release any acquired semaphores before exiting.
2543 s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_bm2() argument
2546 u16 page = (u16)(offset >> IGP_PAGE_SHIFT); in e1000e_write_phy_reg_bm2() local
2548 ret_val = hw->phy.ops.acquire(hw); in e1000e_write_phy_reg_bm2()
2552 /* Page 800 works differently than the rest so it has its own func */ in e1000e_write_phy_reg_bm2()
2553 if (page == BM_WUC_PAGE) { in e1000e_write_phy_reg_bm2()
2554 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, in e1000e_write_phy_reg_bm2()
2559 hw->phy.addr = 1; in e1000e_write_phy_reg_bm2()
2561 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000e_write_phy_reg_bm2()
2562 /* Page is shifted left, PHY expects (page x 32) */ in e1000e_write_phy_reg_bm2()
2564 page); in e1000e_write_phy_reg_bm2()
2570 ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_write_phy_reg_bm2()
2574 hw->phy.ops.release(hw); in e1000e_write_phy_reg_bm2()
2579 * e1000_enable_phy_wakeup_reg_access_bm - enable access to BM wakeup registers
2591 /* All page select, port ctrl and wakeup registers use phy address 1 */ in e1000_enable_phy_wakeup_reg_access_bm()
2592 hw->phy.addr = 1; in e1000_enable_phy_wakeup_reg_access_bm()
2594 /* Select Port Control Registers page */ in e1000_enable_phy_wakeup_reg_access_bm()
2597 e_dbg("Could not set Port Control page\n"); in e1000_enable_phy_wakeup_reg_access_bm()
2608 /* Enable both PHY wakeup mode and Wakeup register page writes. in e1000_enable_phy_wakeup_reg_access_bm()
2622 /* Select Host Wakeup Registers page - caller now able to write in e1000_enable_phy_wakeup_reg_access_bm()
2623 * registers on the Wakeup registers page in e1000_enable_phy_wakeup_reg_access_bm()
2629 * e1000_disable_phy_wakeup_reg_access_bm - disable access to BM wakeup regs
2643 /* Select Port Control Registers page */ in e1000_disable_phy_wakeup_reg_access_bm()
2646 e_dbg("Could not set Port Control page\n"); in e1000_disable_phy_wakeup_reg_access_bm()
2660 * e1000_access_phy_wakeup_reg_bm - Read/write BM PHY wakeup register
2662 * @offset: register offset to be read or written
2667 * Read the PHY register at offset and store the retrieved information in
2668 * data, or write data to PHY register at offset. Note the procedure to
2671 * 1) Set 769.17.2 (page 769, register 17, bit 2) = 1
2672 * 2) Set page to 800 for host (801 if we were manageability)
2681 * the PHY page is set to BM_WUC_PAGE (i.e. a function in the call stack
2684 static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, in e1000_access_phy_wakeup_reg_bm() argument
2688 u16 reg = BM_PHY_REG_NUM(offset); in e1000_access_phy_wakeup_reg_bm()
2689 u16 page = BM_PHY_REG_PAGE(offset); in e1000_access_phy_wakeup_reg_bm() local
2692 /* Gig must be disabled for MDIO accesses to Host Wakeup reg page */ in e1000_access_phy_wakeup_reg_bm()
2693 if ((hw->mac.type == e1000_pchlan) && in e1000_access_phy_wakeup_reg_bm()
2695 e_dbg("Attempting to access page %d while gig enabled.\n", in e1000_access_phy_wakeup_reg_bm()
2696 page); in e1000_access_phy_wakeup_reg_bm()
2707 e_dbg("Accessing PHY page %d reg 0x%x\n", page, reg); in e1000_access_phy_wakeup_reg_bm()
2709 /* Write the Wakeup register page offset value using opcode 0x11 */ in e1000_access_phy_wakeup_reg_bm()
2712 e_dbg("Could not write address opcode to page %d\n", page); in e1000_access_phy_wakeup_reg_bm()
2717 /* Read the Wakeup register page value using opcode 0x12 */ in e1000_access_phy_wakeup_reg_bm()
2721 /* Write the Wakeup register page value using opcode 0x12 */ in e1000_access_phy_wakeup_reg_bm()
2727 e_dbg("Could not access PHY reg %d.%d\n", page, reg); in e1000_access_phy_wakeup_reg_bm()
2738 * e1000_power_up_phy_copper - Restore copper link in case of PHY power down
2761 * e1000_power_down_phy_copper - Restore copper link in case of PHY power down
2785 * __e1000_read_phy_reg_hv - Read HV PHY register
2787 * @offset: register offset to be read
2792 * Acquires semaphore, if necessary, then reads the PHY register at offset
2796 static s32 __e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data, in __e1000_read_phy_reg_hv() argument
2800 u16 page = BM_PHY_REG_PAGE(offset); in __e1000_read_phy_reg_hv() local
2801 u16 reg = BM_PHY_REG_NUM(offset); in __e1000_read_phy_reg_hv()
2802 u32 phy_addr = hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); in __e1000_read_phy_reg_hv()
2805 ret_val = hw->phy.ops.acquire(hw); in __e1000_read_phy_reg_hv()
2810 /* Page 800 works differently than the rest so it has its own func */ in __e1000_read_phy_reg_hv()
2811 if (page == BM_WUC_PAGE) { in __e1000_read_phy_reg_hv()
2812 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, in __e1000_read_phy_reg_hv()
2817 if (page > 0 && page < HV_INTC_FC_PAGE_START) { in __e1000_read_phy_reg_hv()
2818 ret_val = e1000_access_phy_debug_regs_hv(hw, offset, in __e1000_read_phy_reg_hv()
2824 if (page == HV_INTC_FC_PAGE_START) in __e1000_read_phy_reg_hv()
2825 page = 0; in __e1000_read_phy_reg_hv()
2828 /* Page is shifted left, PHY expects (page x 32) */ in __e1000_read_phy_reg_hv()
2830 (page << IGP_PAGE_SHIFT)); in __e1000_read_phy_reg_hv()
2832 hw->phy.addr = phy_addr; in __e1000_read_phy_reg_hv()
2839 e_dbg("reading PHY page %d (or 0x%x shifted) reg 0x%x\n", page, in __e1000_read_phy_reg_hv()
2840 page << IGP_PAGE_SHIFT, reg); in __e1000_read_phy_reg_hv()
2845 hw->phy.ops.release(hw); in __e1000_read_phy_reg_hv()
2851 * e1000_read_phy_reg_hv - Read HV PHY register
2853 * @offset: register offset to be read
2856 * Acquires semaphore then reads the PHY register at offset and stores
2860 s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_hv() argument
2862 return __e1000_read_phy_reg_hv(hw, offset, data, false, false); in e1000_read_phy_reg_hv()
2866 * e1000_read_phy_reg_hv_locked - Read HV PHY register
2868 * @offset: register offset to be read
2871 * Reads the PHY register at offset and stores the retrieved information
2874 s32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_hv_locked() argument
2876 return __e1000_read_phy_reg_hv(hw, offset, data, true, false); in e1000_read_phy_reg_hv_locked()
2880 * e1000_read_phy_reg_page_hv - Read HV PHY register
2882 * @offset: register offset to write to
2883 * @data: data to write at register offset
2885 * Reads the PHY register at offset and stores the retrieved information
2886 * in data. Assumes semaphore already acquired and page already set.
2888 s32 e1000_read_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_page_hv() argument
2890 return __e1000_read_phy_reg_hv(hw, offset, data, true, true); in e1000_read_phy_reg_page_hv()
2894 * __e1000_write_phy_reg_hv - Write HV PHY register
2896 * @offset: register offset to write to
2897 * @data: data to write at register offset
2902 * at the offset. Release any acquired semaphores before exiting.
2904 static s32 __e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data, in __e1000_write_phy_reg_hv() argument
2908 u16 page = BM_PHY_REG_PAGE(offset); in __e1000_write_phy_reg_hv() local
2909 u16 reg = BM_PHY_REG_NUM(offset); in __e1000_write_phy_reg_hv()
2910 u32 phy_addr = hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); in __e1000_write_phy_reg_hv()
2913 ret_val = hw->phy.ops.acquire(hw); in __e1000_write_phy_reg_hv()
2918 /* Page 800 works differently than the rest so it has its own func */ in __e1000_write_phy_reg_hv()
2919 if (page == BM_WUC_PAGE) { in __e1000_write_phy_reg_hv()
2920 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, in __e1000_write_phy_reg_hv()
2925 if (page > 0 && page < HV_INTC_FC_PAGE_START) { in __e1000_write_phy_reg_hv()
2926 ret_val = e1000_access_phy_debug_regs_hv(hw, offset, in __e1000_write_phy_reg_hv()
2932 if (page == HV_INTC_FC_PAGE_START) in __e1000_write_phy_reg_hv()
2933 page = 0; in __e1000_write_phy_reg_hv()
2938 if ((hw->phy.type == e1000_phy_82578) && in __e1000_write_phy_reg_hv()
2939 (hw->phy.revision >= 1) && in __e1000_write_phy_reg_hv()
2940 (hw->phy.addr == 2) && in __e1000_write_phy_reg_hv()
2952 /* Page is shifted left, PHY expects (page x 32) */ in __e1000_write_phy_reg_hv()
2954 (page << IGP_PAGE_SHIFT)); in __e1000_write_phy_reg_hv()
2956 hw->phy.addr = phy_addr; in __e1000_write_phy_reg_hv()
2963 e_dbg("writing PHY page %d (or 0x%x shifted) reg 0x%x\n", page, in __e1000_write_phy_reg_hv()
2964 page << IGP_PAGE_SHIFT, reg); in __e1000_write_phy_reg_hv()
2971 hw->phy.ops.release(hw); in __e1000_write_phy_reg_hv()
2977 * e1000_write_phy_reg_hv - Write HV PHY register
2979 * @offset: register offset to write to
2980 * @data: data to write at register offset
2982 * Acquires semaphore then writes the data to PHY register at the offset.
2985 s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_hv() argument
2987 return __e1000_write_phy_reg_hv(hw, offset, data, false, false); in e1000_write_phy_reg_hv()
2991 * e1000_write_phy_reg_hv_locked - Write HV PHY register
2993 * @offset: register offset to write to
2994 * @data: data to write at register offset
2996 * Writes the data to PHY register at the offset. Assumes semaphore
2999 s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_hv_locked() argument
3001 return __e1000_write_phy_reg_hv(hw, offset, data, true, false); in e1000_write_phy_reg_hv_locked()
3005 * e1000_write_phy_reg_page_hv - Write HV PHY register
3007 * @offset: register offset to write to
3008 * @data: data to write at register offset
3010 * Writes the data to PHY register at the offset. Assumes semaphore
3011 * already acquired and page already set.
3013 s32 e1000_write_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_page_hv() argument
3015 return __e1000_write_phy_reg_hv(hw, offset, data, true, true); in e1000_write_phy_reg_page_hv()
3019 * e1000_get_phy_addr_for_hv_page - Get PHY address based on page
3020 * @page: page to be accessed
3022 static u32 e1000_get_phy_addr_for_hv_page(u32 page) in e1000_get_phy_addr_for_hv_page() argument
3026 if (page >= HV_INTC_FC_PAGE_START) in e1000_get_phy_addr_for_hv_page()
3033 * e1000_access_phy_debug_regs_hv - Read HV PHY vendor specific high registers
3035 * @offset: register offset to be read or written
3039 * Reads the PHY register at offset and stores the retrieved information
3044 static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, in e1000_access_phy_debug_regs_hv() argument
3052 addr_reg = ((hw->phy.type == e1000_phy_82578) ? in e1000_access_phy_debug_regs_hv()
3057 hw->phy.addr = 2; in e1000_access_phy_debug_regs_hv()
3059 /* masking with 0x3F to remove the page from offset */ in e1000_access_phy_debug_regs_hv()
3060 ret_val = e1000e_write_phy_reg_mdic(hw, addr_reg, (u16)offset & 0x3F); in e1000_access_phy_debug_regs_hv()
3062 e_dbg("Could not write the Address Offset port register\n"); in e1000_access_phy_debug_regs_hv()
3079 * e1000_link_stall_workaround_hv - Si workaround
3094 if (hw->phy.type != e1000_phy_82578) in e1000_link_stall_workaround_hv()
3131 * e1000_check_polarity_82577 - Checks the polarity.
3134 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
3140 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_82577()
3147 phy->cable_polarity = ((data & I82577_PHY_STATUS2_REV_POLARITY) in e1000_check_polarity_82577()
3155 * e1000_phy_force_speed_duplex_82577 - Force speed/duplex for I82577 PHY
3162 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_force_speed_duplex_82577()
3179 if (phy->autoneg_wait_to_complete) { in e1000_phy_force_speed_duplex_82577()
3199 * e1000_get_phy_info_82577 - Retrieve I82577 PHY information
3203 * set/determine 10base-T extended distance and polarity correction. Read
3209 struct e1000_phy_info *phy = &hw->phy; in e1000_get_phy_info_82577()
3220 return -E1000_ERR_CONFIG; in e1000_get_phy_info_82577()
3223 phy->polarity_correction = true; in e1000_get_phy_info_82577()
3233 phy->is_mdix = !!(data & I82577_PHY_STATUS2_MDIX); in e1000_get_phy_info_82577()
3237 ret_val = hw->phy.ops.get_cable_length(hw); in e1000_get_phy_info_82577()
3245 phy->local_rx = (data & LPA_1000LOCALRXOK) in e1000_get_phy_info_82577()
3248 phy->remote_rx = (data & LPA_1000REMRXOK) in e1000_get_phy_info_82577()
3251 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000_get_phy_info_82577()
3252 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_82577()
3253 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_82577()
3260 * e1000_get_cable_length_82577 - Determine cable length for 82577 PHY
3268 struct e1000_phy_info *phy = &hw->phy; in e1000_get_cable_length_82577()
3279 return -E1000_ERR_PHY; in e1000_get_cable_length_82577()
3281 phy->cable_length = length; in e1000_get_cable_length_82577()