Lines Matching +full:read +full:- +full:out
1 // SPDX-License-Identifier: GPL-2.0
7 * igc_check_reset_block - Check if PHY reset is blocked
10 * Read the PHY management control register and check whether a PHY reset
25 * igc_get_phy_id - Retrieve the PHY ID and revision
33 struct igc_phy_info *phy = &hw->phy; in igc_get_phy_id()
37 ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id); in igc_get_phy_id()
39 goto out; in igc_get_phy_id()
41 phy->id = (u32)(phy_id << 16); in igc_get_phy_id()
43 ret_val = phy->ops.read_reg(hw, PHY_ID2, &phy_id); in igc_get_phy_id()
45 goto out; in igc_get_phy_id()
47 phy->id |= (u32)(phy_id & PHY_REVISION_MASK); in igc_get_phy_id()
48 phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); in igc_get_phy_id()
50 out: in igc_get_phy_id()
55 * igc_phy_has_link - Polls PHY for link
70 /* Some PHYs require the PHY_STATUS register to be read in igc_phy_has_link()
74 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); in igc_phy_has_link()
76 /* If the first read fails, another entity may have in igc_phy_has_link()
85 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); in igc_phy_has_link()
102 * igc_power_up_phy_copper - Restore copper link in case of PHY power down
113 hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg); in igc_power_up_phy_copper()
115 hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg); in igc_power_up_phy_copper()
119 * igc_power_down_phy_copper - Power down copper PHY
130 hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg); in igc_power_down_phy_copper()
133 /* Temporary workaround - should be removed when PHY will implement in igc_power_down_phy_copper()
136 /* hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg);*/ in igc_power_down_phy_copper()
141 * igc_check_downshift - Checks whether a downshift in speed occurred
150 struct igc_phy_info *phy = &hw->phy; in igc_check_downshift()
153 switch (phy->type) { in igc_check_downshift()
157 phy->speed_downgraded = false; in igc_check_downshift()
165 * igc_phy_hw_reset - PHY hardware reset
169 * semaphore (if necessary) and read/set/write the device control reset
175 struct igc_phy_info *phy = &hw->phy; in igc_phy_hw_reset()
183 goto out; in igc_phy_hw_reset()
186 ret_val = phy->ops.acquire(hw); in igc_phy_hw_reset()
188 goto out; in igc_phy_hw_reset()
196 udelay(phy->reset_delay_us); in igc_phy_hw_reset()
205 timeout--; in igc_phy_hw_reset()
214 phy->ops.release(hw); in igc_phy_hw_reset()
216 out: in igc_phy_hw_reset()
221 * igc_phy_setup_autoneg - Configure PHY for auto-negotiation
224 * Reads the MII auto-neg advertisement register and/or the 1000T control
225 * register and if the PHY is already setup for auto-negotiation, then
227 * the appropriate values for the wanted auto-negotiation.
231 struct igc_phy_info *phy = &hw->phy; in igc_phy_setup_autoneg()
237 phy->autoneg_advertised &= phy->autoneg_mask; in igc_phy_setup_autoneg()
239 /* Read the MII Auto-Neg Advertisement Register (Address 4). */ in igc_phy_setup_autoneg()
240 ret_val = phy->ops.read_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg); in igc_phy_setup_autoneg()
244 if (phy->autoneg_mask & ADVERTISE_1000_FULL) { in igc_phy_setup_autoneg()
245 /* Read the MII 1000Base-T Control Register (Address 9). */ in igc_phy_setup_autoneg()
246 ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, in igc_phy_setup_autoneg()
252 if (phy->autoneg_mask & ADVERTISE_2500_FULL) { in igc_phy_setup_autoneg()
253 /* Read the MULTI GBT AN Control Register - reg 7.32 */ in igc_phy_setup_autoneg()
254 ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK << in igc_phy_setup_autoneg()
270 /* First we clear all the 10/100 mb speed bits in the Auto-Neg in igc_phy_setup_autoneg()
272 * the 1000Base-T Control Register (Address 9). in igc_phy_setup_autoneg()
280 hw_dbg("autoneg_advertised %x\n", phy->autoneg_advertised); in igc_phy_setup_autoneg()
283 if (phy->autoneg_advertised & ADVERTISE_10_HALF) { in igc_phy_setup_autoneg()
289 if (phy->autoneg_advertised & ADVERTISE_10_FULL) { in igc_phy_setup_autoneg()
295 if (phy->autoneg_advertised & ADVERTISE_100_HALF) { in igc_phy_setup_autoneg()
301 if (phy->autoneg_advertised & ADVERTISE_100_FULL) { in igc_phy_setup_autoneg()
307 if (phy->autoneg_advertised & ADVERTISE_1000_HALF) in igc_phy_setup_autoneg()
311 if (phy->autoneg_advertised & ADVERTISE_1000_FULL) { in igc_phy_setup_autoneg()
317 if (phy->autoneg_advertised & ADVERTISE_2500_HALF) in igc_phy_setup_autoneg()
321 if (phy->autoneg_advertised & ADVERTISE_2500_FULL) { in igc_phy_setup_autoneg()
330 * auto-negotiation is enabled, then software will have to set the in igc_phy_setup_autoneg()
331 * "PAUSE" bits to the correct value in the Auto-Negotiation in igc_phy_setup_autoneg()
332 * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto- in igc_phy_setup_autoneg()
345 switch (hw->fc.current_mode) { in igc_phy_setup_autoneg()
348 * software over-ride. in igc_phy_setup_autoneg()
354 * disabled, by a software over-ride. in igc_phy_setup_autoneg()
366 * disabled, by a software over-ride. in igc_phy_setup_autoneg()
373 * over-ride. in igc_phy_setup_autoneg()
379 return -IGC_ERR_CONFIG; in igc_phy_setup_autoneg()
382 ret_val = phy->ops.write_reg(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg); in igc_phy_setup_autoneg()
386 hw_dbg("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); in igc_phy_setup_autoneg()
388 if (phy->autoneg_mask & ADVERTISE_1000_FULL) in igc_phy_setup_autoneg()
389 ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, in igc_phy_setup_autoneg()
392 if (phy->autoneg_mask & ADVERTISE_2500_FULL) in igc_phy_setup_autoneg()
393 ret_val = phy->ops.write_reg(hw, in igc_phy_setup_autoneg()
403 * igc_wait_autoneg - Wait for auto-neg completion
406 * Waits for auto-negotiation to complete or for the auto-negotiation time
415 for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) { in igc_wait_autoneg()
416 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); in igc_wait_autoneg()
419 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); in igc_wait_autoneg()
427 /* PHY_AUTO_NEG_TIME expiration doesn't guarantee auto-negotiation in igc_wait_autoneg()
434 * igc_copper_link_autoneg - Setup/Enable autoneg for copper link
444 struct igc_phy_info *phy = &hw->phy; in igc_copper_link_autoneg()
451 phy->autoneg_advertised &= phy->autoneg_mask; in igc_copper_link_autoneg()
456 if (phy->autoneg_advertised == 0) in igc_copper_link_autoneg()
457 phy->autoneg_advertised = phy->autoneg_mask; in igc_copper_link_autoneg()
459 hw_dbg("Reconfiguring auto-neg advertisement params\n"); in igc_copper_link_autoneg()
462 hw_dbg("Error Setting up Auto-Negotiation\n"); in igc_copper_link_autoneg()
463 goto out; in igc_copper_link_autoneg()
465 hw_dbg("Restarting Auto-Neg\n"); in igc_copper_link_autoneg()
467 /* Restart auto-negotiation by setting the Auto Neg Enable bit and in igc_copper_link_autoneg()
470 ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); in igc_copper_link_autoneg()
472 goto out; in igc_copper_link_autoneg()
475 ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_ctrl); in igc_copper_link_autoneg()
477 goto out; in igc_copper_link_autoneg()
479 /* Does the user want to wait for Auto-Neg to complete here, or in igc_copper_link_autoneg()
482 if (phy->autoneg_wait_to_complete) { in igc_copper_link_autoneg()
486 goto out; in igc_copper_link_autoneg()
490 hw->mac.get_link_status = true; in igc_copper_link_autoneg()
492 out: in igc_copper_link_autoneg()
497 * igc_setup_copper_link - Configure copper link settings
500 * Calls the appropriate function to configure the link for auto-neg or forced
503 * not established, we return -IGC_ERR_PHY (-2).
510 if (hw->mac.autoneg) { in igc_setup_copper_link()
516 goto out; in igc_setup_copper_link()
522 ret_val = hw->phy.ops.force_speed_duplex(hw); in igc_setup_copper_link()
525 goto out; in igc_setup_copper_link()
534 goto out; in igc_setup_copper_link()
544 out: in igc_setup_copper_link()
549 * igc_read_phy_reg_mdic - Read MDI control register
551 * @offset: register offset to be read
552 * @data: pointer to the read data
555 * information read to data.
559 struct igc_phy_info *phy = &hw->phy; in igc_read_phy_reg_mdic()
564 hw_dbg("PHY Address %d is out of range\n", offset); in igc_read_phy_reg_mdic()
565 ret_val = -IGC_ERR_PARAM; in igc_read_phy_reg_mdic()
566 goto out; in igc_read_phy_reg_mdic()
569 /* Set up Op-code, Phy Address, and register offset in the MDI in igc_read_phy_reg_mdic()
574 (phy->addr << IGC_MDIC_PHY_SHIFT) | in igc_read_phy_reg_mdic()
579 /* Poll the ready bit to see if the MDI read completed in igc_read_phy_reg_mdic()
580 * Increasing the time out as testing showed failures with in igc_read_phy_reg_mdic()
581 * the lower time out in igc_read_phy_reg_mdic()
590 hw_dbg("MDI Read did not complete\n"); in igc_read_phy_reg_mdic()
591 ret_val = -IGC_ERR_PHY; in igc_read_phy_reg_mdic()
592 goto out; in igc_read_phy_reg_mdic()
596 ret_val = -IGC_ERR_PHY; in igc_read_phy_reg_mdic()
597 goto out; in igc_read_phy_reg_mdic()
601 out: in igc_read_phy_reg_mdic()
606 * igc_write_phy_reg_mdic - Write MDI control register
615 struct igc_phy_info *phy = &hw->phy; in igc_write_phy_reg_mdic()
620 hw_dbg("PHY Address %d is out of range\n", offset); in igc_write_phy_reg_mdic()
621 ret_val = -IGC_ERR_PARAM; in igc_write_phy_reg_mdic()
622 goto out; in igc_write_phy_reg_mdic()
625 /* Set up Op-code, Phy Address, and register offset in the MDI in igc_write_phy_reg_mdic()
631 (phy->addr << IGC_MDIC_PHY_SHIFT) | in igc_write_phy_reg_mdic()
636 /* Poll the ready bit to see if the MDI read completed in igc_write_phy_reg_mdic()
637 * Increasing the time out as testing showed failures with in igc_write_phy_reg_mdic()
638 * the lower time out in igc_write_phy_reg_mdic()
648 ret_val = -IGC_ERR_PHY; in igc_write_phy_reg_mdic()
649 goto out; in igc_write_phy_reg_mdic()
653 ret_val = -IGC_ERR_PHY; in igc_write_phy_reg_mdic()
654 goto out; in igc_write_phy_reg_mdic()
657 out: in igc_write_phy_reg_mdic()
662 * __igc_access_xmdio_reg - Read/write XMDIO register
666 * @data: pointer to value to read/write from/to the XMDIO address
667 * @read: boolean flag to indicate read or write
670 u8 dev_addr, u16 *data, bool read) in __igc_access_xmdio_reg() argument
674 ret_val = hw->phy.ops.write_reg(hw, IGC_MMDAC, dev_addr); in __igc_access_xmdio_reg()
678 ret_val = hw->phy.ops.write_reg(hw, IGC_MMDAAD, address); in __igc_access_xmdio_reg()
682 ret_val = hw->phy.ops.write_reg(hw, IGC_MMDAC, IGC_MMDAC_FUNC_DATA | in __igc_access_xmdio_reg()
687 if (read) in __igc_access_xmdio_reg()
688 ret_val = hw->phy.ops.read_reg(hw, IGC_MMDAAD, data); in __igc_access_xmdio_reg()
690 ret_val = hw->phy.ops.write_reg(hw, IGC_MMDAAD, *data); in __igc_access_xmdio_reg()
695 ret_val = hw->phy.ops.write_reg(hw, IGC_MMDAC, 0); in __igc_access_xmdio_reg()
703 * igc_read_xmdio_reg - Read XMDIO register
707 * @data: value to be read from the EMI address
716 * igc_write_xmdio_reg - Write XMDIO register
729 * igc_write_phy_reg_gpy - Write GPY PHY register
745 ret_val = hw->phy.ops.acquire(hw); in igc_write_phy_reg_gpy()
751 hw->phy.ops.release(hw); in igc_write_phy_reg_gpy()
761 * igc_read_phy_reg_gpy - Read GPY PHY register
763 * @offset: lower half is register offset to read to
765 * @data: data to read at register offset
778 ret_val = hw->phy.ops.acquire(hw); in igc_read_phy_reg_gpy()
784 hw->phy.ops.release(hw); in igc_read_phy_reg_gpy()
794 * igc_read_phy_fw_version - Read gPHY firmware version
799 struct igc_phy_info *phy = &hw->phy; in igc_read_phy_fw_version()
804 ret_val = phy->ops.read_reg(hw, IGC_GPHY_VERSION, &gphy_version); in igc_read_phy_fw_version()
806 hw_dbg("igc_phy: read wrong gphy version\n"); in igc_read_phy_fw_version()