// SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2018 Intel Corporation */ #include <linux/bitfield.h> #include "igc_phy.h" /** * igc_check_reset_block - Check if PHY reset is blocked * @hw: pointer to the HW structure * * Read the PHY management control register and check whether a PHY reset * is blocked. If a reset is not blocked return 0, otherwise * return IGC_ERR_BLK_PHY_RESET (12). */ s32 igc_check_reset_block(struct igc_hw *hw) { … } /** * igc_get_phy_id - Retrieve the PHY ID and revision * @hw: pointer to the HW structure * * Reads the PHY registers and stores the PHY ID and possibly the PHY * revision in the hardware structure. */ s32 igc_get_phy_id(struct igc_hw *hw) { … } /** * igc_phy_has_link - Polls PHY for link * @hw: pointer to the HW structure * @iterations: number of times to poll for link * @usec_interval: delay between polling attempts * @success: pointer to whether polling was successful or not * * Polls the PHY status register for link, 'iterations' number of times. */ s32 igc_phy_has_link(struct igc_hw *hw, u32 iterations, u32 usec_interval, bool *success) { … } /** * igc_power_up_phy_copper - Restore copper link in case of PHY power down * @hw: pointer to the HW structure * * In the case of a PHY power down to save power, or to turn off link during a * driver unload, restore the link to previous settings. */ void igc_power_up_phy_copper(struct igc_hw *hw) { … } /** * igc_power_down_phy_copper - Power down copper PHY * @hw: pointer to the HW structure * * Power down PHY to save power when interface is down and wake on lan * is not enabled. */ void igc_power_down_phy_copper(struct igc_hw *hw) { … } /** * igc_check_downshift - Checks whether a downshift in speed occurred * @hw: pointer to the HW structure * * A downshift is detected by querying the PHY link health. */ void igc_check_downshift(struct igc_hw *hw) { … } /** * igc_phy_hw_reset - PHY hardware reset * @hw: pointer to the HW structure * * Verify the reset block is not blocking us from resetting. Acquire * semaphore (if necessary) and read/set/write the device control reset * bit in the PHY. Wait the appropriate delay time for the device to * reset and release the semaphore (if necessary). */ s32 igc_phy_hw_reset(struct igc_hw *hw) { … } /** * igc_phy_setup_autoneg - Configure PHY for auto-negotiation * @hw: pointer to the HW structure * * Reads the MII auto-neg advertisement register and/or the 1000T control * register and if the PHY is already setup for auto-negotiation, then * return successful. Otherwise, setup advertisement and flow control to * the appropriate values for the wanted auto-negotiation. */ static s32 igc_phy_setup_autoneg(struct igc_hw *hw) { … } /** * igc_wait_autoneg - Wait for auto-neg completion * @hw: pointer to the HW structure * * Waits for auto-negotiation to complete or for the auto-negotiation time * limit to expire, which ever happens first. */ static s32 igc_wait_autoneg(struct igc_hw *hw) { … } /** * igc_copper_link_autoneg - Setup/Enable autoneg for copper link * @hw: pointer to the HW structure * * Performs initial bounds checking on autoneg advertisement parameter, then * configure to advertise the full capability. Setup the PHY to autoneg * and restart the negotiation process between the link partner. If * autoneg_wait_to_complete, then wait for autoneg to complete before exiting. */ static s32 igc_copper_link_autoneg(struct igc_hw *hw) { … } /** * igc_setup_copper_link - Configure copper link settings * @hw: pointer to the HW structure * * Calls the appropriate function to configure the link for auto-neg or forced * speed and duplex. Then we check for link, once link is established calls * to configure collision distance and flow control are called. If link is * not established, we return -IGC_ERR_PHY (-2). */ s32 igc_setup_copper_link(struct igc_hw *hw) { … } /** * igc_read_phy_reg_mdic - Read MDI control register * @hw: pointer to the HW structure * @offset: register offset to be read * @data: pointer to the read data * * Reads the MDI control register in the PHY at offset and stores the * information read to data. */ static s32 igc_read_phy_reg_mdic(struct igc_hw *hw, u32 offset, u16 *data) { … } /** * igc_write_phy_reg_mdic - Write MDI control register * @hw: pointer to the HW structure * @offset: register offset to write to * @data: data to write to register at offset * * Writes data to MDI control register in the PHY at offset. */ static s32 igc_write_phy_reg_mdic(struct igc_hw *hw, u32 offset, u16 data) { … } /** * __igc_access_xmdio_reg - Read/write XMDIO register * @hw: pointer to the HW structure * @address: XMDIO address to program * @dev_addr: device address to program * @data: pointer to value to read/write from/to the XMDIO address * @read: boolean flag to indicate read or write */ static s32 __igc_access_xmdio_reg(struct igc_hw *hw, u16 address, u8 dev_addr, u16 *data, bool read) { … } /** * igc_read_xmdio_reg - Read XMDIO register * @hw: pointer to the HW structure * @addr: XMDIO address to program * @dev_addr: device address to program * @data: value to be read from the EMI address */ static s32 igc_read_xmdio_reg(struct igc_hw *hw, u16 addr, u8 dev_addr, u16 *data) { … } /** * igc_write_xmdio_reg - Write XMDIO register * @hw: pointer to the HW structure * @addr: XMDIO address to program * @dev_addr: device address to program * @data: value to be written to the XMDIO address */ static s32 igc_write_xmdio_reg(struct igc_hw *hw, u16 addr, u8 dev_addr, u16 data) { … } /** * igc_write_phy_reg_gpy - Write GPY PHY register * @hw: pointer to the HW structure * @offset: register offset to write to * @data: data to write at register offset * * Acquires semaphore, if necessary, then writes the data to PHY register * at the offset. Release any acquired semaphores before exiting. */ s32 igc_write_phy_reg_gpy(struct igc_hw *hw, u32 offset, u16 data) { … } /** * igc_read_phy_reg_gpy - Read GPY PHY register * @hw: pointer to the HW structure * @offset: lower half is register offset to read to * upper half is MMD to use. * @data: data to read at register offset * * Acquires semaphore, if necessary, then reads the data in the PHY register * at the offset. Release any acquired semaphores before exiting. */ s32 igc_read_phy_reg_gpy(struct igc_hw *hw, u32 offset, u16 *data) { … } /** * igc_read_phy_fw_version - Read gPHY firmware version * @hw: pointer to the HW structure */ u16 igc_read_phy_fw_version(struct igc_hw *hw) { … }