Lines Matching +full:page +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2018 Intel Corporation. */
7 static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,
9 static u32 e1000_get_phy_addr_for_hv_page(u32 page);
10 static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset,
36 * e1000e_check_reset_block_generic - Check if PHY reset is blocked
53 * e1000e_get_phy_id - Retrieve the PHY ID and revision
61 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_phy_id()
66 if (!phy->ops.read_reg) in e1000e_get_phy_id()
74 phy->id = (u32)(phy_id << 16); in e1000e_get_phy_id()
80 phy->id |= (u32)(phy_id & PHY_REVISION_MASK); in e1000e_get_phy_id()
81 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); in e1000e_get_phy_id()
83 if (phy->id != 0 && phy->id != PHY_REVISION_MASK) in e1000e_get_phy_id()
93 * e1000e_phy_reset_dsp - Reset PHY DSP
110 * e1000e_read_phy_reg_mdic - Read MDI control register
112 * @offset: register offset to be read
115 * Reads the MDI control register in the PHY at offset and stores the
118 s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_mdic() argument
120 struct e1000_phy_info *phy = &hw->phy; in e1000e_read_phy_reg_mdic()
123 if (offset > MAX_PHY_REG_ADDRESS) { in e1000e_read_phy_reg_mdic()
124 e_dbg("PHY Address %d is out of range\n", offset); in e1000e_read_phy_reg_mdic()
125 return -E1000_ERR_PARAM; in e1000e_read_phy_reg_mdic()
128 /* Set up Op-code, Phy Address, and register offset in the MDI in e1000e_read_phy_reg_mdic()
132 mdic = ((offset << E1000_MDIC_REG_SHIFT) | in e1000e_read_phy_reg_mdic()
133 (phy->addr << E1000_MDIC_PHY_SHIFT) | in e1000e_read_phy_reg_mdic()
149 e_dbg("MDI Read PHY Reg Address %d did not complete\n", offset); in e1000e_read_phy_reg_mdic()
150 return -E1000_ERR_PHY; in e1000e_read_phy_reg_mdic()
153 e_dbg("MDI Read PHY Reg Address %d Error\n", offset); in e1000e_read_phy_reg_mdic()
154 return -E1000_ERR_PHY; in e1000e_read_phy_reg_mdic()
156 if (((mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT) != offset) { in e1000e_read_phy_reg_mdic()
157 e_dbg("MDI Read offset error - requested %d, returned %d\n", in e1000e_read_phy_reg_mdic()
158 offset, in e1000e_read_phy_reg_mdic()
160 return -E1000_ERR_PHY; in e1000e_read_phy_reg_mdic()
167 if (hw->mac.type == e1000_pch2lan) in e1000e_read_phy_reg_mdic()
174 * e1000e_write_phy_reg_mdic - Write MDI control register
176 * @offset: register offset to write to
177 * @data: data to write to register at offset
179 * Writes data to MDI control register in the PHY at offset.
181 s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_mdic() argument
183 struct e1000_phy_info *phy = &hw->phy; in e1000e_write_phy_reg_mdic()
186 if (offset > MAX_PHY_REG_ADDRESS) { in e1000e_write_phy_reg_mdic()
187 e_dbg("PHY Address %d is out of range\n", offset); in e1000e_write_phy_reg_mdic()
188 return -E1000_ERR_PARAM; in e1000e_write_phy_reg_mdic()
191 /* Set up Op-code, Phy Address, and register offset in the MDI in e1000e_write_phy_reg_mdic()
196 (offset << E1000_MDIC_REG_SHIFT) | in e1000e_write_phy_reg_mdic()
197 (phy->addr << E1000_MDIC_PHY_SHIFT) | in e1000e_write_phy_reg_mdic()
213 e_dbg("MDI Write PHY Reg Address %d did not complete\n", offset); in e1000e_write_phy_reg_mdic()
214 return -E1000_ERR_PHY; in e1000e_write_phy_reg_mdic()
217 e_dbg("MDI Write PHY Red Address %d Error\n", offset); in e1000e_write_phy_reg_mdic()
218 return -E1000_ERR_PHY; in e1000e_write_phy_reg_mdic()
220 if (((mdic & E1000_MDIC_REG_MASK) >> E1000_MDIC_REG_SHIFT) != offset) { in e1000e_write_phy_reg_mdic()
221 e_dbg("MDI Write offset error - requested %d, returned %d\n", in e1000e_write_phy_reg_mdic()
222 offset, in e1000e_write_phy_reg_mdic()
224 return -E1000_ERR_PHY; in e1000e_write_phy_reg_mdic()
230 if (hw->mac.type == e1000_pch2lan) in e1000e_write_phy_reg_mdic()
237 * e1000e_read_phy_reg_m88 - Read m88 PHY register
239 * @offset: register offset to be read
242 * Acquires semaphore, if necessary, then reads the PHY register at offset
246 s32 e1000e_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_m88() argument
250 ret_val = hw->phy.ops.acquire(hw); in e1000e_read_phy_reg_m88()
254 ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_read_phy_reg_m88()
257 hw->phy.ops.release(hw); in e1000e_read_phy_reg_m88()
263 * e1000e_write_phy_reg_m88 - Write m88 PHY register
265 * @offset: register offset to write to
266 * @data: data to write at register offset
269 * at the offset. Release any acquired semaphores before exiting.
271 s32 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_m88() argument
275 ret_val = hw->phy.ops.acquire(hw); in e1000e_write_phy_reg_m88()
279 ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_write_phy_reg_m88()
282 hw->phy.ops.release(hw); in e1000e_write_phy_reg_m88()
288 * e1000_set_page_igp - Set page as on IGP-like PHY(s)
290 * @page: page to set (shifted left when necessary)
292 * Sets PHY page required for PHY register access. Assumes semaphore is
296 s32 e1000_set_page_igp(struct e1000_hw *hw, u16 page) in e1000_set_page_igp() argument
298 e_dbg("Setting page 0x%x\n", page); in e1000_set_page_igp()
300 hw->phy.addr = 1; in e1000_set_page_igp()
302 return e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, page); in e1000_set_page_igp()
306 * __e1000e_read_phy_reg_igp - Read igp PHY register
308 * @offset: register offset to be read
312 * Acquires semaphore, if necessary, then reads the PHY register at offset
316 static s32 __e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data, in __e1000e_read_phy_reg_igp() argument
322 if (!hw->phy.ops.acquire) in __e1000e_read_phy_reg_igp()
325 ret_val = hw->phy.ops.acquire(hw); in __e1000e_read_phy_reg_igp()
330 if (offset > MAX_PHY_MULTI_PAGE_REG) in __e1000e_read_phy_reg_igp()
333 (u16)offset); in __e1000e_read_phy_reg_igp()
336 MAX_PHY_REG_ADDRESS & offset, in __e1000e_read_phy_reg_igp()
339 hw->phy.ops.release(hw); in __e1000e_read_phy_reg_igp()
345 * e1000e_read_phy_reg_igp - Read igp PHY register
347 * @offset: register offset to be read
350 * Acquires semaphore then reads the PHY register at offset and stores the
354 s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_igp() argument
356 return __e1000e_read_phy_reg_igp(hw, offset, data, false); in e1000e_read_phy_reg_igp()
360 * e1000e_read_phy_reg_igp_locked - Read igp PHY register
362 * @offset: register offset to be read
365 * Reads the PHY register at offset and stores the retrieved information
368 s32 e1000e_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_igp_locked() argument
370 return __e1000e_read_phy_reg_igp(hw, offset, data, true); in e1000e_read_phy_reg_igp_locked()
374 * __e1000e_write_phy_reg_igp - Write igp PHY register
376 * @offset: register offset to write to
377 * @data: data to write at register offset
381 * at the offset. Release any acquired semaphores before exiting.
383 static s32 __e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data, in __e1000e_write_phy_reg_igp() argument
389 if (!hw->phy.ops.acquire) in __e1000e_write_phy_reg_igp()
392 ret_val = hw->phy.ops.acquire(hw); in __e1000e_write_phy_reg_igp()
397 if (offset > MAX_PHY_MULTI_PAGE_REG) in __e1000e_write_phy_reg_igp()
400 (u16)offset); in __e1000e_write_phy_reg_igp()
403 offset, data); in __e1000e_write_phy_reg_igp()
405 hw->phy.ops.release(hw); in __e1000e_write_phy_reg_igp()
411 * e1000e_write_phy_reg_igp - Write igp PHY register
413 * @offset: register offset to write to
414 * @data: data to write at register offset
417 * at the offset. Release any acquired semaphores before exiting.
419 s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_igp() argument
421 return __e1000e_write_phy_reg_igp(hw, offset, data, false); in e1000e_write_phy_reg_igp()
425 * e1000e_write_phy_reg_igp_locked - Write igp PHY register
427 * @offset: register offset to write to
428 * @data: data to write at register offset
430 * Writes the data to PHY register at the offset.
433 s32 e1000e_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_igp_locked() argument
435 return __e1000e_write_phy_reg_igp(hw, offset, data, true); in e1000e_write_phy_reg_igp_locked()
439 * __e1000_read_kmrn_reg - Read kumeran register
441 * @offset: register offset to be read
445 * Acquires semaphore, if necessary. Then reads the PHY register at offset
449 static s32 __e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data, in __e1000_read_kmrn_reg() argument
457 if (!hw->phy.ops.acquire) in __e1000_read_kmrn_reg()
460 ret_val = hw->phy.ops.acquire(hw); in __e1000_read_kmrn_reg()
465 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & in __e1000_read_kmrn_reg()
476 hw->phy.ops.release(hw); in __e1000_read_kmrn_reg()
482 * e1000e_read_kmrn_reg - Read kumeran register
484 * @offset: register offset to be read
487 * Acquires semaphore then reads the PHY register at offset using the
491 s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_kmrn_reg() argument
493 return __e1000_read_kmrn_reg(hw, offset, data, false); in e1000e_read_kmrn_reg()
497 * e1000e_read_kmrn_reg_locked - Read kumeran register
499 * @offset: register offset to be read
502 * Reads the PHY register at offset using the kumeran interface. The
506 s32 e1000e_read_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_kmrn_reg_locked() argument
508 return __e1000_read_kmrn_reg(hw, offset, data, true); in e1000e_read_kmrn_reg_locked()
512 * __e1000_write_kmrn_reg - Write kumeran register
514 * @offset: register offset to write to
515 * @data: data to write at register offset
519 * at the offset using the kumeran interface. Release any acquired semaphores
522 static s32 __e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data, in __e1000_write_kmrn_reg() argument
530 if (!hw->phy.ops.acquire) in __e1000_write_kmrn_reg()
533 ret_val = hw->phy.ops.acquire(hw); in __e1000_write_kmrn_reg()
538 kmrnctrlsta = ((offset << E1000_KMRNCTRLSTA_OFFSET_SHIFT) & in __e1000_write_kmrn_reg()
546 hw->phy.ops.release(hw); in __e1000_write_kmrn_reg()
552 * e1000e_write_kmrn_reg - Write kumeran register
554 * @offset: register offset to write to
555 * @data: data to write at register offset
557 * Acquires semaphore then writes the data to the PHY register at the offset
560 s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_kmrn_reg() argument
562 return __e1000_write_kmrn_reg(hw, offset, data, false); in e1000e_write_kmrn_reg()
566 * e1000e_write_kmrn_reg_locked - Write kumeran register
568 * @offset: register offset to write to
569 * @data: data to write at register offset
571 * Write the data to PHY register at the offset using the kumeran interface.
574 s32 e1000e_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_kmrn_reg_locked() argument
576 return __e1000_write_kmrn_reg(hw, offset, data, true); in e1000e_write_kmrn_reg_locked()
580 * e1000_set_master_slave_mode - Setup PHY for Master/slave mode
596 hw->phy.original_ms_type = (phy_data & CTL1000_ENABLE_MASTER) ? in e1000_set_master_slave_mode()
600 switch (hw->phy.ms_type) { in e1000_set_master_slave_mode()
619 * e1000_copper_link_setup_82577 - Setup 82577 PHY for copper link
622 * Sets up Carrier-sense on Transmit and downshift values.
629 /* Enable CRS on Tx. This must be set for half-duplex operation. */ in e1000_copper_link_setup_82577()
649 * 0 - Auto (default) in e1000_copper_link_setup_82577()
650 * 1 - MDI mode in e1000_copper_link_setup_82577()
651 * 2 - MDI-X mode in e1000_copper_link_setup_82577()
653 switch (hw->phy.mdix) { in e1000_copper_link_setup_82577()
672 * e1000e_copper_link_setup_m88 - Setup m88 PHY's for copper link
675 * Sets up MDI/MDI-X and polarity for m88 PHY's. If necessary, transmit clock
680 struct e1000_phy_info *phy = &hw->phy; in e1000e_copper_link_setup_m88()
684 /* Enable CRS on Tx. This must be set for half-duplex operation. */ in e1000e_copper_link_setup_m88()
690 if (phy->type != e1000_phy_bm) in e1000e_copper_link_setup_m88()
694 * MDI/MDI-X = 0 (default) in e1000e_copper_link_setup_m88()
695 * 0 - Auto for all speeds in e1000e_copper_link_setup_m88()
696 * 1 - MDI mode in e1000e_copper_link_setup_m88()
697 * 2 - MDI-X mode in e1000e_copper_link_setup_m88()
698 * 3 - Auto for 1000Base-T only (MDI-X for 10/100Base-T modes) in e1000e_copper_link_setup_m88()
702 switch (phy->mdix) { in e1000e_copper_link_setup_m88()
721 * 0 - Disabled in e1000e_copper_link_setup_m88()
722 * 1 - Enabled in e1000e_copper_link_setup_m88()
725 if (phy->disable_polarity_correction) in e1000e_copper_link_setup_m88()
729 if (phy->type == e1000_phy_bm) { in e1000e_copper_link_setup_m88()
731 if (phy->id == BME1000_E_PHY_ID_R2) { in e1000e_copper_link_setup_m88()
738 ret_val = phy->ops.commit(hw); in e1000e_copper_link_setup_m88()
752 if ((phy->type == e1000_phy_m88) && in e1000e_copper_link_setup_m88()
753 (phy->revision < E1000_REVISION_4) && in e1000e_copper_link_setup_m88()
754 (phy->id != BME1000_E_PHY_ID_R2)) { in e1000e_copper_link_setup_m88()
764 if ((phy->revision == 2) && (phy->id == M88E1111_I_PHY_ID)) { in e1000e_copper_link_setup_m88()
765 /* 82573L PHY - set the downshift counter to 5x. */ in e1000e_copper_link_setup_m88()
780 if ((phy->type == e1000_phy_bm) && (phy->id == BME1000_E_PHY_ID_R2)) { in e1000e_copper_link_setup_m88()
781 /* Set PHY page 0, register 29 to 0x0003 */ in e1000e_copper_link_setup_m88()
786 /* Set PHY page 0, register 30 to 0x0000 */ in e1000e_copper_link_setup_m88()
793 if (phy->ops.commit) { in e1000e_copper_link_setup_m88()
794 ret_val = phy->ops.commit(hw); in e1000e_copper_link_setup_m88()
801 if (phy->type == e1000_phy_82578) { in e1000e_copper_link_setup_m88()
806 /* 82578 PHY - set the downshift count to 1x. */ in e1000e_copper_link_setup_m88()
818 * e1000e_copper_link_setup_igp - Setup igp PHY's for copper link
821 * Sets up LPLU, MDI/MDI-X, polarity, Smartspeed and Master/Slave config for
826 struct e1000_phy_info *phy = &hw->phy; in e1000e_copper_link_setup_igp()
842 if (hw->phy.ops.set_d0_lplu_state) { in e1000e_copper_link_setup_igp()
843 ret_val = hw->phy.ops.set_d0_lplu_state(hw, false); in e1000e_copper_link_setup_igp()
849 /* Configure mdi-mdix settings */ in e1000e_copper_link_setup_igp()
856 switch (phy->mdix) { in e1000e_copper_link_setup_igp()
872 /* set auto-master slave resolution settings */ in e1000e_copper_link_setup_igp()
873 if (hw->mac.autoneg) { in e1000e_copper_link_setup_igp()
878 if (phy->autoneg_advertised == ADVERTISE_1000_FULL) { in e1000e_copper_link_setup_igp()
909 * e1000_phy_setup_autoneg - Configure PHY for auto-negotiation
912 * Reads the MII auto-neg advertisement register and/or the 1000T control
913 * register and if the PHY is already setup for auto-negotiation, then
915 * the appropriate values for the wanted auto-negotiation.
919 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_setup_autoneg()
924 phy->autoneg_advertised &= phy->autoneg_mask; in e1000_phy_setup_autoneg()
926 /* Read the MII Auto-Neg Advertisement Register (Address 4). */ in e1000_phy_setup_autoneg()
931 if (phy->autoneg_mask & ADVERTISE_1000_FULL) { in e1000_phy_setup_autoneg()
932 /* Read the MII 1000Base-T Control Register (Address 9). */ in e1000_phy_setup_autoneg()
945 /* First we clear all the 10/100 mb speed bits in the Auto-Neg in e1000_phy_setup_autoneg()
947 * the 1000Base-T Control Register (Address 9). in e1000_phy_setup_autoneg()
954 e_dbg("autoneg_advertised %x\n", phy->autoneg_advertised); in e1000_phy_setup_autoneg()
957 if (phy->autoneg_advertised & ADVERTISE_10_HALF) { in e1000_phy_setup_autoneg()
963 if (phy->autoneg_advertised & ADVERTISE_10_FULL) { in e1000_phy_setup_autoneg()
969 if (phy->autoneg_advertised & ADVERTISE_100_HALF) { in e1000_phy_setup_autoneg()
975 if (phy->autoneg_advertised & ADVERTISE_100_FULL) { in e1000_phy_setup_autoneg()
981 if (phy->autoneg_advertised & ADVERTISE_1000_HALF) in e1000_phy_setup_autoneg()
985 if (phy->autoneg_advertised & ADVERTISE_1000_FULL) { in e1000_phy_setup_autoneg()
992 * auto-negotiation is enabled, then software will have to set the in e1000_phy_setup_autoneg()
993 * "PAUSE" bits to the correct value in the Auto-Negotiation in e1000_phy_setup_autoneg()
994 * Advertisement Register (MII_ADVERTISE) and re-start auto- in e1000_phy_setup_autoneg()
1007 switch (hw->fc.current_mode) { in e1000_phy_setup_autoneg()
1010 * software over-ride. in e1000_phy_setup_autoneg()
1017 * disabled, by a software over-ride. in e1000_phy_setup_autoneg()
1030 * disabled, by a software over-ride. in e1000_phy_setup_autoneg()
1037 * over-ride. in e1000_phy_setup_autoneg()
1044 return -E1000_ERR_CONFIG; in e1000_phy_setup_autoneg()
1051 e_dbg("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); in e1000_phy_setup_autoneg()
1053 if (phy->autoneg_mask & ADVERTISE_1000_FULL) in e1000_phy_setup_autoneg()
1060 * e1000_copper_link_autoneg - Setup/Enable autoneg for copper link
1070 struct e1000_phy_info *phy = &hw->phy; in e1000_copper_link_autoneg()
1077 phy->autoneg_advertised &= phy->autoneg_mask; in e1000_copper_link_autoneg()
1082 if (!phy->autoneg_advertised) in e1000_copper_link_autoneg()
1083 phy->autoneg_advertised = phy->autoneg_mask; in e1000_copper_link_autoneg()
1085 e_dbg("Reconfiguring auto-neg advertisement params\n"); in e1000_copper_link_autoneg()
1088 e_dbg("Error Setting up Auto-Negotiation\n"); in e1000_copper_link_autoneg()
1091 e_dbg("Restarting Auto-Neg\n"); in e1000_copper_link_autoneg()
1093 /* Restart auto-negotiation by setting the Auto Neg Enable bit and in e1000_copper_link_autoneg()
1105 /* Does the user want to wait for Auto-Neg to complete here, or in e1000_copper_link_autoneg()
1108 if (phy->autoneg_wait_to_complete) { in e1000_copper_link_autoneg()
1116 hw->mac.get_link_status = true; in e1000_copper_link_autoneg()
1122 * e1000e_setup_copper_link - Configure copper link settings
1125 * Calls the appropriate function to configure the link for auto-neg or forced
1128 * not established, we return -E1000_ERR_PHY (-2).
1135 if (hw->mac.autoneg) { in e1000e_setup_copper_link()
1147 ret_val = hw->phy.ops.force_speed_duplex(hw); in e1000e_setup_copper_link()
1164 hw->mac.ops.config_collision_dist(hw); in e1000e_setup_copper_link()
1174 * e1000e_phy_force_speed_duplex_igp - Force speed/duplex for igp PHY
1178 * auto-crossover to force MDI manually. Waits for link and returns
1179 * successful if link up is successful, else -E1000_ERR_PHY (-2).
1183 struct e1000_phy_info *phy = &hw->phy; in e1000e_phy_force_speed_duplex_igp()
1198 /* Clear Auto-Crossover to force MDI manually. IGP requires MDI in e1000e_phy_force_speed_duplex_igp()
1216 if (phy->autoneg_wait_to_complete) { in e1000e_phy_force_speed_duplex_igp()
1236 * e1000e_phy_force_speed_duplex_m88 - Force speed/duplex for m88 PHY
1240 * auto-crossover to force MDI manually. Resets the PHY to commit the
1247 struct e1000_phy_info *phy = &hw->phy; in e1000e_phy_force_speed_duplex_m88()
1252 /* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI in e1000e_phy_force_speed_duplex_m88()
1277 if (hw->phy.ops.commit) { in e1000e_phy_force_speed_duplex_m88()
1278 ret_val = hw->phy.ops.commit(hw); in e1000e_phy_force_speed_duplex_m88()
1283 if (phy->autoneg_wait_to_complete) { in e1000e_phy_force_speed_duplex_m88()
1292 if (hw->phy.type != e1000_phy_m88) { in e1000e_phy_force_speed_duplex_m88()
1315 if (hw->phy.type != e1000_phy_m88) in e1000e_phy_force_speed_duplex_m88()
1322 /* Resetting the phy means we need to re-force TX_CLK in the in e1000e_phy_force_speed_duplex_m88()
1331 /* In addition, we must re-enable CRS on Tx for both half and full in e1000e_phy_force_speed_duplex_m88()
1345 * e1000_phy_force_speed_duplex_ife - Force PHY speed & duplex
1354 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_force_speed_duplex_ife()
1369 /* Disable MDI-X support for 10/100 */ in e1000_phy_force_speed_duplex_ife()
1385 if (phy->autoneg_wait_to_complete) { in e1000_phy_force_speed_duplex_ife()
1407 * e1000e_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex
1413 * disable auto-negotiation, configure duplex, configure speed, configure
1420 struct e1000_mac_info *mac = &hw->mac; in e1000e_phy_force_speed_duplex_setup()
1424 hw->fc.current_mode = e1000_fc_none; in e1000e_phy_force_speed_duplex_setup()
1438 if (mac->forced_speed_duplex & E1000_ALL_HALF_DUPLEX) { in e1000e_phy_force_speed_duplex_setup()
1449 if (mac->forced_speed_duplex & E1000_ALL_100_SPEED) { in e1000e_phy_force_speed_duplex_setup()
1460 hw->mac.ops.config_collision_dist(hw); in e1000e_phy_force_speed_duplex_setup()
1466 * e1000e_set_d3_lplu_state - Sets low power link up state for D3
1481 struct e1000_phy_info *phy = &hw->phy; in e1000e_set_d3_lplu_state()
1499 if (phy->smart_speed == e1000_smart_speed_on) { in e1000e_set_d3_lplu_state()
1510 } else if (phy->smart_speed == e1000_smart_speed_off) { in e1000e_set_d3_lplu_state()
1522 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || in e1000e_set_d3_lplu_state()
1523 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) || in e1000e_set_d3_lplu_state()
1524 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) { in e1000e_set_d3_lplu_state()
1543 * e1000e_check_downshift - Checks whether a downshift in speed occurred
1552 struct e1000_phy_info *phy = &hw->phy; in e1000e_check_downshift()
1554 u16 phy_data, offset, mask; in e1000e_check_downshift() local
1556 switch (phy->type) { in e1000e_check_downshift()
1561 offset = M88E1000_PHY_SPEC_STATUS; in e1000e_check_downshift()
1566 offset = IGP01E1000_PHY_LINK_HEALTH; in e1000e_check_downshift()
1571 phy->speed_downgraded = false; in e1000e_check_downshift()
1575 ret_val = e1e_rphy(hw, offset, &phy_data); in e1000e_check_downshift()
1578 phy->speed_downgraded = !!(phy_data & mask); in e1000e_check_downshift()
1584 * e1000_check_polarity_m88 - Checks the polarity.
1587 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1593 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_m88()
1600 phy->cable_polarity = ((data & M88E1000_PSSR_REV_POLARITY) in e1000_check_polarity_m88()
1608 * e1000_check_polarity_igp - Checks the polarity.
1611 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
1618 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_igp()
1620 u16 data, offset, mask; in e1000_check_polarity_igp() local
1631 offset = IGP01E1000_PHY_PCS_INIT_REG; in e1000_check_polarity_igp()
1637 offset = IGP01E1000_PHY_PORT_STATUS; in e1000_check_polarity_igp()
1641 ret_val = e1e_rphy(hw, offset, &data); in e1000_check_polarity_igp()
1644 phy->cable_polarity = ((data & mask) in e1000_check_polarity_igp()
1652 * e1000_check_polarity_ife - Check cable polarity for IFE PHY
1659 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_ife()
1661 u16 phy_data, offset, mask; in e1000_check_polarity_ife() local
1665 if (phy->polarity_correction) { in e1000_check_polarity_ife()
1666 offset = IFE_PHY_EXTENDED_STATUS_CONTROL; in e1000_check_polarity_ife()
1669 offset = IFE_PHY_SPECIAL_CONTROL; in e1000_check_polarity_ife()
1673 ret_val = e1e_rphy(hw, offset, &phy_data); in e1000_check_polarity_ife()
1676 phy->cable_polarity = ((phy_data & mask) in e1000_check_polarity_ife()
1684 * e1000_wait_autoneg - Wait for auto-neg completion
1687 * Waits for auto-negotiation to complete or for the auto-negotiation time
1696 for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) { in e1000_wait_autoneg()
1708 /* PHY_AUTO_NEG_TIME expiration doesn't guarantee auto-negotiation in e1000_wait_autoneg()
1715 * e1000e_phy_has_link_generic - Polls PHY for link
1763 * e1000e_get_cable_length_m88 - Determine cable length for m88 PHY
1772 * 1 50 - 80 meters
1773 * 2 80 - 110 meters
1774 * 3 110 - 140 meters
1779 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_cable_length_m88()
1790 if (index >= M88E1000_CABLE_LENGTH_TABLE_SIZE - 1) in e1000e_get_cable_length_m88()
1791 return -E1000_ERR_PHY; in e1000e_get_cable_length_m88()
1793 phy->min_cable_length = e1000_m88_cable_length_table[index]; in e1000e_get_cable_length_m88()
1794 phy->max_cable_length = e1000_m88_cable_length_table[index + 1]; in e1000e_get_cable_length_m88()
1796 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; in e1000e_get_cable_length_m88()
1802 * e1000e_get_cable_length_igp_2 - Determine cable length for igp2 PHY
1814 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_cable_length_igp_2()
1818 u16 min_agc_index = IGP02E1000_CABLE_LENGTH_TABLE_SIZE - 1; in e1000e_get_cable_length_igp_2()
1843 return -E1000_ERR_PHY; in e1000e_get_cable_length_igp_2()
1856 agc_value -= (e1000_igp_2_cable_length_table[min_agc_index] + in e1000e_get_cable_length_igp_2()
1858 agc_value /= (IGP02E1000_PHY_CHANNEL_NUM - 2); in e1000e_get_cable_length_igp_2()
1860 /* Calculate cable length with the error range of +/- 10 meters. */ in e1000e_get_cable_length_igp_2()
1861 phy->min_cable_length = (((agc_value - IGP02E1000_AGC_RANGE) > 0) ? in e1000e_get_cable_length_igp_2()
1862 (agc_value - IGP02E1000_AGC_RANGE) : 0); in e1000e_get_cable_length_igp_2()
1863 phy->max_cable_length = agc_value + IGP02E1000_AGC_RANGE; in e1000e_get_cable_length_igp_2()
1865 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2; in e1000e_get_cable_length_igp_2()
1871 * e1000e_get_phy_info_m88 - Retrieve PHY information
1876 * determine the polarity and 10base-T extended distance. Read the PHY
1882 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_phy_info_m88()
1887 if (phy->media_type != e1000_media_type_copper) { in e1000e_get_phy_info_m88()
1889 return -E1000_ERR_CONFIG; in e1000e_get_phy_info_m88()
1898 return -E1000_ERR_CONFIG; in e1000e_get_phy_info_m88()
1905 phy->polarity_correction = !!(phy_data & in e1000e_get_phy_info_m88()
1916 phy->is_mdix = !!(phy_data & M88E1000_PSSR_MDIX); in e1000e_get_phy_info_m88()
1919 ret_val = hw->phy.ops.get_cable_length(hw); in e1000e_get_phy_info_m88()
1927 phy->local_rx = (phy_data & LPA_1000LOCALRXOK) in e1000e_get_phy_info_m88()
1930 phy->remote_rx = (phy_data & LPA_1000REMRXOK) in e1000e_get_phy_info_m88()
1934 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000e_get_phy_info_m88()
1935 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_m88()
1936 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_m88()
1943 * e1000e_get_phy_info_igp - Retrieve igp PHY information
1947 * set/determine 10base-T extended distance and polarity correction. Read
1953 struct e1000_phy_info *phy = &hw->phy; in e1000e_get_phy_info_igp()
1964 return -E1000_ERR_CONFIG; in e1000e_get_phy_info_igp()
1967 phy->polarity_correction = true; in e1000e_get_phy_info_igp()
1977 phy->is_mdix = !!(data & IGP01E1000_PSSR_MDIX); in e1000e_get_phy_info_igp()
1981 ret_val = phy->ops.get_cable_length(hw); in e1000e_get_phy_info_igp()
1989 phy->local_rx = (data & LPA_1000LOCALRXOK) in e1000e_get_phy_info_igp()
1992 phy->remote_rx = (data & LPA_1000REMRXOK) in e1000e_get_phy_info_igp()
1995 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000e_get_phy_info_igp()
1996 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_igp()
1997 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000e_get_phy_info_igp()
2004 * e1000_get_phy_info_ife - Retrieves various IFE PHY states
2011 struct e1000_phy_info *phy = &hw->phy; in e1000_get_phy_info_ife()
2022 return -E1000_ERR_CONFIG; in e1000_get_phy_info_ife()
2028 phy->polarity_correction = !(data & IFE_PSC_AUTO_POLARITY_DISABLE); in e1000_get_phy_info_ife()
2030 if (phy->polarity_correction) { in e1000_get_phy_info_ife()
2036 phy->cable_polarity = ((data & IFE_PSC_FORCE_POLARITY) in e1000_get_phy_info_ife()
2045 phy->is_mdix = !!(data & IFE_PMC_MDIX_STATUS); in e1000_get_phy_info_ife()
2048 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000_get_phy_info_ife()
2049 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_ife()
2050 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_ife()
2056 * e1000e_phy_sw_reset - PHY software reset
2082 * e1000e_phy_hw_reset_generic - PHY hardware reset
2092 struct e1000_phy_info *phy = &hw->phy; in e1000e_phy_hw_reset_generic()
2096 if (phy->ops.check_reset_block) { in e1000e_phy_hw_reset_generic()
2097 ret_val = phy->ops.check_reset_block(hw); in e1000e_phy_hw_reset_generic()
2102 ret_val = phy->ops.acquire(hw); in e1000e_phy_hw_reset_generic()
2110 udelay(phy->reset_delay_us); in e1000e_phy_hw_reset_generic()
2117 phy->ops.release(hw); in e1000e_phy_hw_reset_generic()
2119 return phy->ops.get_cfg_done(hw); in e1000e_phy_hw_reset_generic()
2123 * e1000e_get_cfg_done_generic - Generic configuration done
2126 * Generic function to wait 10 milli-seconds for configuration to complete
2137 * e1000e_phy_init_script_igp3 - Inits the IGP3 PHY
2147 /* Enable rise/fall, 10-mode work in class-A */ in e1000e_phy_init_script_igp3()
2205 /* Enable LPLU and disable AN to 1000 in non-D0a states, in e1000e_phy_init_script_igp3()
2220 * e1000e_get_phy_type_from_id - Get PHY type from id
2274 * e1000e_determine_phy_address - Determines PHY address.
2287 hw->phy.id = phy_type; in e1000e_determine_phy_address()
2290 hw->phy.addr = phy_addr; in e1000e_determine_phy_address()
2295 phy_type = e1000e_get_phy_type_from_id(hw->phy.id); in e1000e_determine_phy_address()
2297 /* If phy_type is valid, break - we found our in e1000e_determine_phy_address()
2308 return -E1000_ERR_PHY_TYPE; in e1000e_determine_phy_address()
2312 * e1000_get_phy_addr_for_bm_page - Retrieve PHY page address
2313 * @page: page to access
2316 * Returns the phy address for the page requested.
2318 static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg) in e1000_get_phy_addr_for_bm_page() argument
2322 if ((page >= 768) || (page == 0 && reg == 25) || (reg == 31)) in e1000_get_phy_addr_for_bm_page()
2329 * e1000e_write_phy_reg_bm - Write BM PHY register
2331 * @offset: register offset to write to
2332 * @data: data to write at register offset
2335 * at the offset. Release any acquired semaphores before exiting.
2337 s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_bm() argument
2340 u32 page = offset >> IGP_PAGE_SHIFT; in e1000e_write_phy_reg_bm() local
2342 ret_val = hw->phy.ops.acquire(hw); in e1000e_write_phy_reg_bm()
2346 /* Page 800 works differently than the rest so it has its own func */ in e1000e_write_phy_reg_bm()
2347 if (page == BM_WUC_PAGE) { in e1000e_write_phy_reg_bm()
2348 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, in e1000e_write_phy_reg_bm()
2353 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); in e1000e_write_phy_reg_bm()
2355 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000e_write_phy_reg_bm()
2358 /* Page select is register 31 for phy address 1 and 22 for in e1000e_write_phy_reg_bm()
2359 * phy address 2 and 3. Page select is shifted only for in e1000e_write_phy_reg_bm()
2362 if (hw->phy.addr == 1) { in e1000e_write_phy_reg_bm()
2370 /* Page is shifted left, PHY expects (page x 32) */ in e1000e_write_phy_reg_bm()
2372 (page << page_shift)); in e1000e_write_phy_reg_bm()
2377 ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_write_phy_reg_bm()
2381 hw->phy.ops.release(hw); in e1000e_write_phy_reg_bm()
2386 * e1000e_read_phy_reg_bm - Read BM PHY register
2388 * @offset: register offset to be read
2391 * Acquires semaphore, if necessary, then reads the PHY register at offset
2395 s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_bm() argument
2398 u32 page = offset >> IGP_PAGE_SHIFT; in e1000e_read_phy_reg_bm() local
2400 ret_val = hw->phy.ops.acquire(hw); in e1000e_read_phy_reg_bm()
2404 /* Page 800 works differently than the rest so it has its own func */ in e1000e_read_phy_reg_bm()
2405 if (page == BM_WUC_PAGE) { in e1000e_read_phy_reg_bm()
2406 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, in e1000e_read_phy_reg_bm()
2411 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset); in e1000e_read_phy_reg_bm()
2413 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000e_read_phy_reg_bm()
2416 /* Page select is register 31 for phy address 1 and 22 for in e1000e_read_phy_reg_bm()
2417 * phy address 2 and 3. Page select is shifted only for in e1000e_read_phy_reg_bm()
2420 if (hw->phy.addr == 1) { in e1000e_read_phy_reg_bm()
2428 /* Page is shifted left, PHY expects (page x 32) */ in e1000e_read_phy_reg_bm()
2430 (page << page_shift)); in e1000e_read_phy_reg_bm()
2435 ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_read_phy_reg_bm()
2438 hw->phy.ops.release(hw); in e1000e_read_phy_reg_bm()
2443 * e1000e_read_phy_reg_bm2 - Read BM PHY register
2445 * @offset: register offset to be read
2448 * Acquires semaphore, if necessary, then reads the PHY register at offset
2452 s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data) in e1000e_read_phy_reg_bm2() argument
2455 u16 page = (u16)(offset >> IGP_PAGE_SHIFT); in e1000e_read_phy_reg_bm2() local
2457 ret_val = hw->phy.ops.acquire(hw); in e1000e_read_phy_reg_bm2()
2461 /* Page 800 works differently than the rest so it has its own func */ in e1000e_read_phy_reg_bm2()
2462 if (page == BM_WUC_PAGE) { in e1000e_read_phy_reg_bm2()
2463 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, in e1000e_read_phy_reg_bm2()
2468 hw->phy.addr = 1; in e1000e_read_phy_reg_bm2()
2470 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000e_read_phy_reg_bm2()
2471 /* Page is shifted left, PHY expects (page x 32) */ in e1000e_read_phy_reg_bm2()
2473 page); in e1000e_read_phy_reg_bm2()
2479 ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_read_phy_reg_bm2()
2482 hw->phy.ops.release(hw); in e1000e_read_phy_reg_bm2()
2487 * e1000e_write_phy_reg_bm2 - Write BM PHY register
2489 * @offset: register offset to write to
2490 * @data: data to write at register offset
2493 * at the offset. Release any acquired semaphores before exiting.
2495 s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data) in e1000e_write_phy_reg_bm2() argument
2498 u16 page = (u16)(offset >> IGP_PAGE_SHIFT); in e1000e_write_phy_reg_bm2() local
2500 ret_val = hw->phy.ops.acquire(hw); in e1000e_write_phy_reg_bm2()
2504 /* Page 800 works differently than the rest so it has its own func */ in e1000e_write_phy_reg_bm2()
2505 if (page == BM_WUC_PAGE) { in e1000e_write_phy_reg_bm2()
2506 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, in e1000e_write_phy_reg_bm2()
2511 hw->phy.addr = 1; in e1000e_write_phy_reg_bm2()
2513 if (offset > MAX_PHY_MULTI_PAGE_REG) { in e1000e_write_phy_reg_bm2()
2514 /* Page is shifted left, PHY expects (page x 32) */ in e1000e_write_phy_reg_bm2()
2516 page); in e1000e_write_phy_reg_bm2()
2522 ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset, in e1000e_write_phy_reg_bm2()
2526 hw->phy.ops.release(hw); in e1000e_write_phy_reg_bm2()
2531 * e1000_enable_phy_wakeup_reg_access_bm - enable access to BM wakeup registers
2543 /* All page select, port ctrl and wakeup registers use phy address 1 */ in e1000_enable_phy_wakeup_reg_access_bm()
2544 hw->phy.addr = 1; in e1000_enable_phy_wakeup_reg_access_bm()
2546 /* Select Port Control Registers page */ in e1000_enable_phy_wakeup_reg_access_bm()
2549 e_dbg("Could not set Port Control page\n"); in e1000_enable_phy_wakeup_reg_access_bm()
2560 /* Enable both PHY wakeup mode and Wakeup register page writes. in e1000_enable_phy_wakeup_reg_access_bm()
2574 /* Select Host Wakeup Registers page - caller now able to write in e1000_enable_phy_wakeup_reg_access_bm()
2575 * registers on the Wakeup registers page in e1000_enable_phy_wakeup_reg_access_bm()
2581 * e1000_disable_phy_wakeup_reg_access_bm - disable access to BM wakeup regs
2595 /* Select Port Control Registers page */ in e1000_disable_phy_wakeup_reg_access_bm()
2598 e_dbg("Could not set Port Control page\n"); in e1000_disable_phy_wakeup_reg_access_bm()
2612 * e1000_access_phy_wakeup_reg_bm - Read/write BM PHY wakeup register
2614 * @offset: register offset to be read or written
2619 * Read the PHY register at offset and store the retrieved information in
2620 * data, or write data to PHY register at offset. Note the procedure to
2623 * 1) Set 769.17.2 (page 769, register 17, bit 2) = 1
2624 * 2) Set page to 800 for host (801 if we were manageability)
2633 * the PHY page is set to BM_WUC_PAGE (i.e. a function in the call stack
2636 static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset, in e1000_access_phy_wakeup_reg_bm() argument
2640 u16 reg = BM_PHY_REG_NUM(offset); in e1000_access_phy_wakeup_reg_bm()
2641 u16 page = BM_PHY_REG_PAGE(offset); in e1000_access_phy_wakeup_reg_bm() local
2644 /* Gig must be disabled for MDIO accesses to Host Wakeup reg page */ in e1000_access_phy_wakeup_reg_bm()
2645 if ((hw->mac.type == e1000_pchlan) && in e1000_access_phy_wakeup_reg_bm()
2647 e_dbg("Attempting to access page %d while gig enabled.\n", in e1000_access_phy_wakeup_reg_bm()
2648 page); in e1000_access_phy_wakeup_reg_bm()
2659 e_dbg("Accessing PHY page %d reg 0x%x\n", page, reg); in e1000_access_phy_wakeup_reg_bm()
2661 /* Write the Wakeup register page offset value using opcode 0x11 */ in e1000_access_phy_wakeup_reg_bm()
2664 e_dbg("Could not write address opcode to page %d\n", page); in e1000_access_phy_wakeup_reg_bm()
2669 /* Read the Wakeup register page value using opcode 0x12 */ in e1000_access_phy_wakeup_reg_bm()
2673 /* Write the Wakeup register page value using opcode 0x12 */ in e1000_access_phy_wakeup_reg_bm()
2679 e_dbg("Could not access PHY reg %d.%d\n", page, reg); in e1000_access_phy_wakeup_reg_bm()
2690 * e1000_power_up_phy_copper - Restore copper link in case of PHY power down
2713 * e1000_power_down_phy_copper - Restore copper link in case of PHY power down
2737 * __e1000_read_phy_reg_hv - Read HV PHY register
2739 * @offset: register offset to be read
2744 * Acquires semaphore, if necessary, then reads the PHY register at offset
2748 static s32 __e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data, in __e1000_read_phy_reg_hv() argument
2752 u16 page = BM_PHY_REG_PAGE(offset); in __e1000_read_phy_reg_hv() local
2753 u16 reg = BM_PHY_REG_NUM(offset); in __e1000_read_phy_reg_hv()
2754 u32 phy_addr = hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); in __e1000_read_phy_reg_hv()
2757 ret_val = hw->phy.ops.acquire(hw); in __e1000_read_phy_reg_hv()
2762 /* Page 800 works differently than the rest so it has its own func */ in __e1000_read_phy_reg_hv()
2763 if (page == BM_WUC_PAGE) { in __e1000_read_phy_reg_hv()
2764 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data, in __e1000_read_phy_reg_hv()
2769 if (page > 0 && page < HV_INTC_FC_PAGE_START) { in __e1000_read_phy_reg_hv()
2770 ret_val = e1000_access_phy_debug_regs_hv(hw, offset, in __e1000_read_phy_reg_hv()
2776 if (page == HV_INTC_FC_PAGE_START) in __e1000_read_phy_reg_hv()
2777 page = 0; in __e1000_read_phy_reg_hv()
2780 /* Page is shifted left, PHY expects (page x 32) */ in __e1000_read_phy_reg_hv()
2782 (page << IGP_PAGE_SHIFT)); in __e1000_read_phy_reg_hv()
2784 hw->phy.addr = phy_addr; in __e1000_read_phy_reg_hv()
2791 e_dbg("reading PHY page %d (or 0x%x shifted) reg 0x%x\n", page, in __e1000_read_phy_reg_hv()
2792 page << IGP_PAGE_SHIFT, reg); in __e1000_read_phy_reg_hv()
2797 hw->phy.ops.release(hw); in __e1000_read_phy_reg_hv()
2803 * e1000_read_phy_reg_hv - Read HV PHY register
2805 * @offset: register offset to be read
2808 * Acquires semaphore then reads the PHY register at offset and stores
2812 s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_hv() argument
2814 return __e1000_read_phy_reg_hv(hw, offset, data, false, false); in e1000_read_phy_reg_hv()
2818 * e1000_read_phy_reg_hv_locked - Read HV PHY register
2820 * @offset: register offset to be read
2823 * Reads the PHY register at offset and stores the retrieved information
2826 s32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_hv_locked() argument
2828 return __e1000_read_phy_reg_hv(hw, offset, data, true, false); in e1000_read_phy_reg_hv_locked()
2832 * e1000_read_phy_reg_page_hv - Read HV PHY register
2834 * @offset: register offset to write to
2835 * @data: data to write at register offset
2837 * Reads the PHY register at offset and stores the retrieved information
2838 * in data. Assumes semaphore already acquired and page already set.
2840 s32 e1000_read_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, u16 *data) in e1000_read_phy_reg_page_hv() argument
2842 return __e1000_read_phy_reg_hv(hw, offset, data, true, true); in e1000_read_phy_reg_page_hv()
2846 * __e1000_write_phy_reg_hv - Write HV PHY register
2848 * @offset: register offset to write to
2849 * @data: data to write at register offset
2854 * at the offset. Release any acquired semaphores before exiting.
2856 static s32 __e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data, in __e1000_write_phy_reg_hv() argument
2860 u16 page = BM_PHY_REG_PAGE(offset); in __e1000_write_phy_reg_hv() local
2861 u16 reg = BM_PHY_REG_NUM(offset); in __e1000_write_phy_reg_hv()
2862 u32 phy_addr = hw->phy.addr = e1000_get_phy_addr_for_hv_page(page); in __e1000_write_phy_reg_hv()
2865 ret_val = hw->phy.ops.acquire(hw); in __e1000_write_phy_reg_hv()
2870 /* Page 800 works differently than the rest so it has its own func */ in __e1000_write_phy_reg_hv()
2871 if (page == BM_WUC_PAGE) { in __e1000_write_phy_reg_hv()
2872 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data, in __e1000_write_phy_reg_hv()
2877 if (page > 0 && page < HV_INTC_FC_PAGE_START) { in __e1000_write_phy_reg_hv()
2878 ret_val = e1000_access_phy_debug_regs_hv(hw, offset, in __e1000_write_phy_reg_hv()
2884 if (page == HV_INTC_FC_PAGE_START) in __e1000_write_phy_reg_hv()
2885 page = 0; in __e1000_write_phy_reg_hv()
2890 if ((hw->phy.type == e1000_phy_82578) && in __e1000_write_phy_reg_hv()
2891 (hw->phy.revision >= 1) && in __e1000_write_phy_reg_hv()
2892 (hw->phy.addr == 2) && in __e1000_write_phy_reg_hv()
2904 /* Page is shifted left, PHY expects (page x 32) */ in __e1000_write_phy_reg_hv()
2906 (page << IGP_PAGE_SHIFT)); in __e1000_write_phy_reg_hv()
2908 hw->phy.addr = phy_addr; in __e1000_write_phy_reg_hv()
2915 e_dbg("writing PHY page %d (or 0x%x shifted) reg 0x%x\n", page, in __e1000_write_phy_reg_hv()
2916 page << IGP_PAGE_SHIFT, reg); in __e1000_write_phy_reg_hv()
2923 hw->phy.ops.release(hw); in __e1000_write_phy_reg_hv()
2929 * e1000_write_phy_reg_hv - Write HV PHY register
2931 * @offset: register offset to write to
2932 * @data: data to write at register offset
2934 * Acquires semaphore then writes the data to PHY register at the offset.
2937 s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_hv() argument
2939 return __e1000_write_phy_reg_hv(hw, offset, data, false, false); in e1000_write_phy_reg_hv()
2943 * e1000_write_phy_reg_hv_locked - Write HV PHY register
2945 * @offset: register offset to write to
2946 * @data: data to write at register offset
2948 * Writes the data to PHY register at the offset. Assumes semaphore
2951 s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_hv_locked() argument
2953 return __e1000_write_phy_reg_hv(hw, offset, data, true, false); in e1000_write_phy_reg_hv_locked()
2957 * e1000_write_phy_reg_page_hv - Write HV PHY register
2959 * @offset: register offset to write to
2960 * @data: data to write at register offset
2962 * Writes the data to PHY register at the offset. Assumes semaphore
2963 * already acquired and page already set.
2965 s32 e1000_write_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, u16 data) in e1000_write_phy_reg_page_hv() argument
2967 return __e1000_write_phy_reg_hv(hw, offset, data, true, true); in e1000_write_phy_reg_page_hv()
2971 * e1000_get_phy_addr_for_hv_page - Get PHY address based on page
2972 * @page: page to be accessed
2974 static u32 e1000_get_phy_addr_for_hv_page(u32 page) in e1000_get_phy_addr_for_hv_page() argument
2978 if (page >= HV_INTC_FC_PAGE_START) in e1000_get_phy_addr_for_hv_page()
2985 * e1000_access_phy_debug_regs_hv - Read HV PHY vendor specific high registers
2987 * @offset: register offset to be read or written
2991 * Reads the PHY register at offset and stores the retrieved information
2996 static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, in e1000_access_phy_debug_regs_hv() argument
3004 addr_reg = ((hw->phy.type == e1000_phy_82578) ? in e1000_access_phy_debug_regs_hv()
3009 hw->phy.addr = 2; in e1000_access_phy_debug_regs_hv()
3011 /* masking with 0x3F to remove the page from offset */ in e1000_access_phy_debug_regs_hv()
3012 ret_val = e1000e_write_phy_reg_mdic(hw, addr_reg, (u16)offset & 0x3F); in e1000_access_phy_debug_regs_hv()
3014 e_dbg("Could not write the Address Offset port register\n"); in e1000_access_phy_debug_regs_hv()
3031 * e1000_link_stall_workaround_hv - Si workaround
3046 if (hw->phy.type != e1000_phy_82578) in e1000_link_stall_workaround_hv()
3083 * e1000_check_polarity_82577 - Checks the polarity.
3086 * Success returns 0, Failure returns -E1000_ERR_PHY (-2)
3092 struct e1000_phy_info *phy = &hw->phy; in e1000_check_polarity_82577()
3099 phy->cable_polarity = ((data & I82577_PHY_STATUS2_REV_POLARITY) in e1000_check_polarity_82577()
3107 * e1000_phy_force_speed_duplex_82577 - Force speed/duplex for I82577 PHY
3114 struct e1000_phy_info *phy = &hw->phy; in e1000_phy_force_speed_duplex_82577()
3131 if (phy->autoneg_wait_to_complete) { in e1000_phy_force_speed_duplex_82577()
3151 * e1000_get_phy_info_82577 - Retrieve I82577 PHY information
3155 * set/determine 10base-T extended distance and polarity correction. Read
3161 struct e1000_phy_info *phy = &hw->phy; in e1000_get_phy_info_82577()
3172 return -E1000_ERR_CONFIG; in e1000_get_phy_info_82577()
3175 phy->polarity_correction = true; in e1000_get_phy_info_82577()
3185 phy->is_mdix = !!(data & I82577_PHY_STATUS2_MDIX); in e1000_get_phy_info_82577()
3189 ret_val = hw->phy.ops.get_cable_length(hw); in e1000_get_phy_info_82577()
3197 phy->local_rx = (data & LPA_1000LOCALRXOK) in e1000_get_phy_info_82577()
3200 phy->remote_rx = (data & LPA_1000REMRXOK) in e1000_get_phy_info_82577()
3203 phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; in e1000_get_phy_info_82577()
3204 phy->local_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_82577()
3205 phy->remote_rx = e1000_1000t_rx_status_undefined; in e1000_get_phy_info_82577()
3212 * e1000_get_cable_length_82577 - Determine cable length for 82577 PHY
3220 struct e1000_phy_info *phy = &hw->phy; in e1000_get_cable_length_82577()
3232 return -E1000_ERR_PHY; in e1000_get_cable_length_82577()
3234 phy->cable_length = length; in e1000_get_cable_length_82577()