diff --git a/sys/dev/igc/igc_i225.c b/sys/dev/igc/igc_i225.c index 95d7d1536184..91d221cee06b 100644 --- a/sys/dev/igc/igc_i225.c +++ b/sys/dev/igc/igc_i225.c @@ -1,1225 +1,1216 @@ /*- * Copyright 2021 Intel Corp * Copyright 2021 Rubicon Communications, LLC (Netgate) * SPDX-License-Identifier: BSD-3-Clause */ #include __FBSDID("$FreeBSD$"); #include "igc_api.h" static s32 igc_init_nvm_params_i225(struct igc_hw *hw); static s32 igc_init_mac_params_i225(struct igc_hw *hw); static s32 igc_init_phy_params_i225(struct igc_hw *hw); static s32 igc_reset_hw_i225(struct igc_hw *hw); static s32 igc_acquire_nvm_i225(struct igc_hw *hw); static void igc_release_nvm_i225(struct igc_hw *hw); static s32 igc_get_hw_semaphore_i225(struct igc_hw *hw); static s32 __igc_write_nvm_srwr(struct igc_hw *hw, u16 offset, u16 words, u16 *data); static s32 igc_pool_flash_update_done_i225(struct igc_hw *hw); /** * igc_init_nvm_params_i225 - Init NVM func ptrs. * @hw: pointer to the HW structure **/ static s32 igc_init_nvm_params_i225(struct igc_hw *hw) { struct igc_nvm_info *nvm = &hw->nvm; u32 eecd = IGC_READ_REG(hw, IGC_EECD); u16 size; DEBUGFUNC("igc_init_nvm_params_i225"); size = (u16)((eecd & IGC_EECD_SIZE_EX_MASK) >> IGC_EECD_SIZE_EX_SHIFT); /* * Added to a constant, "size" becomes the left-shift value * for setting word_size. */ size += NVM_WORD_SIZE_BASE_SHIFT; /* Just in case size is out of range, cap it to the largest * EEPROM size supported */ if (size > 15) size = 15; nvm->word_size = 1 << size; nvm->opcode_bits = 8; nvm->delay_usec = 1; nvm->type = igc_nvm_eeprom_spi; nvm->page_size = eecd & IGC_EECD_ADDR_BITS ? 32 : 8; nvm->address_bits = eecd & IGC_EECD_ADDR_BITS ? 16 : 8; if (nvm->word_size == (1 << 15)) nvm->page_size = 128; nvm->ops.acquire = igc_acquire_nvm_i225; nvm->ops.release = igc_release_nvm_i225; if (igc_get_flash_presence_i225(hw)) { hw->nvm.type = igc_nvm_flash_hw; nvm->ops.read = igc_read_nvm_srrd_i225; nvm->ops.write = igc_write_nvm_srwr_i225; nvm->ops.validate = igc_validate_nvm_checksum_i225; nvm->ops.update = igc_update_nvm_checksum_i225; } else { hw->nvm.type = igc_nvm_invm; nvm->ops.write = igc_null_write_nvm; nvm->ops.validate = igc_null_ops_generic; nvm->ops.update = igc_null_ops_generic; } return IGC_SUCCESS; } /** * igc_init_mac_params_i225 - Init MAC func ptrs. * @hw: pointer to the HW structure **/ static s32 igc_init_mac_params_i225(struct igc_hw *hw) { struct igc_mac_info *mac = &hw->mac; struct igc_dev_spec_i225 *dev_spec = &hw->dev_spec._i225; DEBUGFUNC("igc_init_mac_params_i225"); /* Initialize function pointer */ igc_init_mac_ops_generic(hw); /* Set media type */ hw->phy.media_type = igc_media_type_copper; /* Set mta register count */ mac->mta_reg_count = 128; /* Set rar entry count */ mac->rar_entry_count = IGC_RAR_ENTRIES_BASE; /* reset */ mac->ops.reset_hw = igc_reset_hw_i225; /* hw initialization */ mac->ops.init_hw = igc_init_hw_i225; /* link setup */ mac->ops.setup_link = igc_setup_link_generic; /* check for link */ mac->ops.check_for_link = igc_check_for_link_i225; /* link info */ mac->ops.get_link_up_info = igc_get_speed_and_duplex_copper_generic; /* acquire SW_FW sync */ mac->ops.acquire_swfw_sync = igc_acquire_swfw_sync_i225; /* release SW_FW sync */ mac->ops.release_swfw_sync = igc_release_swfw_sync_i225; /* Allow a single clear of the SW semaphore on I225 */ dev_spec->clear_semaphore_once = true; mac->ops.setup_physical_interface = igc_setup_copper_link_i225; /* Set if part includes ASF firmware */ mac->asf_firmware_present = true; /* multicast address update */ mac->ops.update_mc_addr_list = igc_update_mc_addr_list_generic; mac->ops.write_vfta = igc_write_vfta_generic; return IGC_SUCCESS; } /** * igc_init_phy_params_i225 - Init PHY func ptrs. * @hw: pointer to the HW structure **/ static s32 igc_init_phy_params_i225(struct igc_hw *hw) { struct igc_phy_info *phy = &hw->phy; s32 ret_val = IGC_SUCCESS; DEBUGFUNC("igc_init_phy_params_i225"); if (hw->phy.media_type != igc_media_type_copper) { phy->type = igc_phy_none; goto out; } phy->ops.power_up = igc_power_up_phy_copper; phy->ops.power_down = igc_power_down_phy_copper_base; phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT_2500; phy->reset_delay_us = 100; phy->ops.acquire = igc_acquire_phy_base; phy->ops.check_reset_block = igc_check_reset_block_generic; phy->ops.release = igc_release_phy_base; phy->ops.reset = igc_phy_hw_reset_generic; phy->ops.read_reg = igc_read_phy_reg_gpy; phy->ops.write_reg = igc_write_phy_reg_gpy; /* Make sure the PHY is in a good state. Several people have reported * firmware leaving the PHY's page select register set to something * other than the default of zero, which causes the PHY ID read to * access something other than the intended register. */ ret_val = hw->phy.ops.reset(hw); if (ret_val) goto out; ret_val = igc_get_phy_id(hw); - /* Verify phy id and set remaining function pointers */ - switch (phy->id) { - case I225_I_PHY_ID: - default: - phy->type = igc_phy_i225; - phy->ops.set_d0_lplu_state = igc_set_d0_lplu_state_i225; - phy->ops.set_d3_lplu_state = igc_set_d3_lplu_state_i225; - /* TODO - complete with GPY PHY information */ - break; - } + phy->type = igc_phy_i225; out: return ret_val; } /** * igc_reset_hw_i225 - Reset hardware * @hw: pointer to the HW structure * * This resets the hardware into a known state. **/ static s32 igc_reset_hw_i225(struct igc_hw *hw) { u32 ctrl; s32 ret_val; DEBUGFUNC("igc_reset_hw_i225"); /* * Prevent the PCI-E bus from sticking if there is no TLP connection * on the last TLP read/write transaction when MAC is reset. */ ret_val = igc_disable_pcie_master_generic(hw); if (ret_val) DEBUGOUT("PCI-E Master disable polling has failed.\n"); DEBUGOUT("Masking off all interrupts\n"); IGC_WRITE_REG(hw, IGC_IMC, 0xffffffff); IGC_WRITE_REG(hw, IGC_RCTL, 0); IGC_WRITE_REG(hw, IGC_TCTL, IGC_TCTL_PSP); IGC_WRITE_FLUSH(hw); msec_delay(10); ctrl = IGC_READ_REG(hw, IGC_CTRL); DEBUGOUT("Issuing a global reset to MAC\n"); IGC_WRITE_REG(hw, IGC_CTRL, ctrl | IGC_CTRL_DEV_RST); ret_val = igc_get_auto_rd_done_generic(hw); if (ret_val) { /* * When auto config read does not complete, do not * return with an error. This can happen in situations * where there is no eeprom and prevents getting link. */ DEBUGOUT("Auto Read Done did not complete\n"); } /* Clear any pending interrupt events. */ IGC_WRITE_REG(hw, IGC_IMC, 0xffffffff); IGC_READ_REG(hw, IGC_ICR); /* Install any alternate MAC address into RAR0 */ ret_val = igc_check_alt_mac_addr_generic(hw); return ret_val; } /* igc_acquire_nvm_i225 - Request for access to EEPROM * @hw: pointer to the HW structure * * Acquire the necessary semaphores for exclusive access to the EEPROM. * Set the EEPROM access request bit and wait for EEPROM access grant bit. * Return successful if access grant bit set, else clear the request for * EEPROM access and return -IGC_ERR_NVM (-1). */ static s32 igc_acquire_nvm_i225(struct igc_hw *hw) { s32 ret_val; DEBUGFUNC("igc_acquire_nvm_i225"); ret_val = igc_acquire_swfw_sync_i225(hw, IGC_SWFW_EEP_SM); return ret_val; } /* igc_release_nvm_i225 - Release exclusive access to EEPROM * @hw: pointer to the HW structure * * Stop any current commands to the EEPROM and clear the EEPROM request bit, * then release the semaphores acquired. */ static void igc_release_nvm_i225(struct igc_hw *hw) { DEBUGFUNC("igc_release_nvm_i225"); igc_release_swfw_sync_i225(hw, IGC_SWFW_EEP_SM); } /* igc_acquire_swfw_sync_i225 - Acquire SW/FW semaphore * @hw: pointer to the HW structure * @mask: specifies which semaphore to acquire * * Acquire the SW/FW semaphore to access the PHY or NVM. The mask * will also specify which port we're acquiring the lock for. */ s32 igc_acquire_swfw_sync_i225(struct igc_hw *hw, u16 mask) { u32 swfw_sync; u32 swmask = mask; u32 fwmask = mask << 16; s32 ret_val = IGC_SUCCESS; s32 i = 0, timeout = 200; /* FIXME: find real value to use here */ DEBUGFUNC("igc_acquire_swfw_sync_i225"); while (i < timeout) { if (igc_get_hw_semaphore_i225(hw)) { ret_val = -IGC_ERR_SWFW_SYNC; goto out; } swfw_sync = IGC_READ_REG(hw, IGC_SW_FW_SYNC); if (!(swfw_sync & (fwmask | swmask))) break; /* Firmware currently using resource (fwmask) * or other software thread using resource (swmask) */ igc_put_hw_semaphore_generic(hw); msec_delay_irq(5); i++; } if (i == timeout) { DEBUGOUT("Driver can't access resource, SW_FW_SYNC timeout.\n"); ret_val = -IGC_ERR_SWFW_SYNC; goto out; } swfw_sync |= swmask; IGC_WRITE_REG(hw, IGC_SW_FW_SYNC, swfw_sync); igc_put_hw_semaphore_generic(hw); out: return ret_val; } /* igc_release_swfw_sync_i225 - Release SW/FW semaphore * @hw: pointer to the HW structure * @mask: specifies which semaphore to acquire * * Release the SW/FW semaphore used to access the PHY or NVM. The mask * will also specify which port we're releasing the lock for. */ void igc_release_swfw_sync_i225(struct igc_hw *hw, u16 mask) { u32 swfw_sync; DEBUGFUNC("igc_release_swfw_sync_i225"); while (igc_get_hw_semaphore_i225(hw) != IGC_SUCCESS) ; /* Empty */ swfw_sync = IGC_READ_REG(hw, IGC_SW_FW_SYNC); swfw_sync &= ~mask; IGC_WRITE_REG(hw, IGC_SW_FW_SYNC, swfw_sync); igc_put_hw_semaphore_generic(hw); } /* * igc_setup_copper_link_i225 - Configure copper link settings * @hw: pointer to the HW structure * * Configures 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. */ s32 igc_setup_copper_link_i225(struct igc_hw *hw) { u32 phpm_reg; s32 ret_val; u32 ctrl; DEBUGFUNC("igc_setup_copper_link_i225"); ctrl = IGC_READ_REG(hw, IGC_CTRL); ctrl |= IGC_CTRL_SLU; ctrl &= ~(IGC_CTRL_FRCSPD | IGC_CTRL_FRCDPX); IGC_WRITE_REG(hw, IGC_CTRL, ctrl); phpm_reg = IGC_READ_REG(hw, IGC_I225_PHPM); phpm_reg &= ~IGC_I225_PHPM_GO_LINKD; IGC_WRITE_REG(hw, IGC_I225_PHPM, phpm_reg); ret_val = igc_setup_copper_link_generic(hw); return ret_val; } /* igc_get_hw_semaphore_i225 - Acquire hardware semaphore * @hw: pointer to the HW structure * * Acquire the HW semaphore to access the PHY or NVM */ static s32 igc_get_hw_semaphore_i225(struct igc_hw *hw) { u32 swsm; s32 timeout = hw->nvm.word_size + 1; s32 i = 0; DEBUGFUNC("igc_get_hw_semaphore_i225"); /* Get the SW semaphore */ while (i < timeout) { swsm = IGC_READ_REG(hw, IGC_SWSM); if (!(swsm & IGC_SWSM_SMBI)) break; usec_delay(50); i++; } if (i == timeout) { /* In rare circumstances, the SW semaphore may already be held * unintentionally. Clear the semaphore once before giving up. */ if (hw->dev_spec._i225.clear_semaphore_once) { hw->dev_spec._i225.clear_semaphore_once = false; igc_put_hw_semaphore_generic(hw); for (i = 0; i < timeout; i++) { swsm = IGC_READ_REG(hw, IGC_SWSM); if (!(swsm & IGC_SWSM_SMBI)) break; usec_delay(50); } } /* If we do not have the semaphore here, we have to give up. */ if (i == timeout) { DEBUGOUT("Driver can't access device -\n"); DEBUGOUT("SMBI bit is set.\n"); return -IGC_ERR_NVM; } } /* Get the FW semaphore. */ for (i = 0; i < timeout; i++) { swsm = IGC_READ_REG(hw, IGC_SWSM); IGC_WRITE_REG(hw, IGC_SWSM, swsm | IGC_SWSM_SWESMBI); /* Semaphore acquired if bit latched */ if (IGC_READ_REG(hw, IGC_SWSM) & IGC_SWSM_SWESMBI) break; usec_delay(50); } if (i == timeout) { /* Release semaphores */ igc_put_hw_semaphore_generic(hw); DEBUGOUT("Driver can't access the NVM\n"); return -IGC_ERR_NVM; } return IGC_SUCCESS; } /* igc_read_nvm_srrd_i225 - Reads Shadow Ram using EERD register * @hw: pointer to the HW structure * @offset: offset of word in the Shadow Ram to read * @words: number of words to read * @data: word read from the Shadow Ram * * Reads a 16 bit word from the Shadow Ram using the EERD register. * Uses necessary synchronization semaphores. */ s32 igc_read_nvm_srrd_i225(struct igc_hw *hw, u16 offset, u16 words, u16 *data) { s32 status = IGC_SUCCESS; u16 i, count; DEBUGFUNC("igc_read_nvm_srrd_i225"); /* We cannot hold synchronization semaphores for too long, * because of forceful takeover procedure. However it is more efficient * to read in bursts than synchronizing access for each word. */ for (i = 0; i < words; i += IGC_EERD_EEWR_MAX_COUNT) { count = (words - i) / IGC_EERD_EEWR_MAX_COUNT > 0 ? IGC_EERD_EEWR_MAX_COUNT : (words - i); if (hw->nvm.ops.acquire(hw) == IGC_SUCCESS) { status = igc_read_nvm_eerd(hw, offset, count, data + i); hw->nvm.ops.release(hw); } else { status = IGC_ERR_SWFW_SYNC; } if (status != IGC_SUCCESS) break; } return status; } /* igc_write_nvm_srwr_i225 - Write to Shadow RAM using EEWR * @hw: pointer to the HW structure * @offset: offset within the Shadow RAM to be written to * @words: number of words to write * @data: 16 bit word(s) to be written to the Shadow RAM * * Writes data to Shadow RAM at offset using EEWR register. * * If igc_update_nvm_checksum is not called after this function , the * data will not be committed to FLASH and also Shadow RAM will most likely * contain an invalid checksum. * * If error code is returned, data and Shadow RAM may be inconsistent - buffer * partially written. */ s32 igc_write_nvm_srwr_i225(struct igc_hw *hw, u16 offset, u16 words, u16 *data) { s32 status = IGC_SUCCESS; u16 i, count; DEBUGFUNC("igc_write_nvm_srwr_i225"); /* We cannot hold synchronization semaphores for too long, * because of forceful takeover procedure. However it is more efficient * to write in bursts than synchronizing access for each word. */ for (i = 0; i < words; i += IGC_EERD_EEWR_MAX_COUNT) { count = (words - i) / IGC_EERD_EEWR_MAX_COUNT > 0 ? IGC_EERD_EEWR_MAX_COUNT : (words - i); if (hw->nvm.ops.acquire(hw) == IGC_SUCCESS) { status = __igc_write_nvm_srwr(hw, offset, count, data + i); hw->nvm.ops.release(hw); } else { status = IGC_ERR_SWFW_SYNC; } if (status != IGC_SUCCESS) break; } return status; } /* __igc_write_nvm_srwr - Write to Shadow Ram using EEWR * @hw: pointer to the HW structure * @offset: offset within the Shadow Ram to be written to * @words: number of words to write * @data: 16 bit word(s) to be written to the Shadow Ram * * Writes data to Shadow Ram at offset using EEWR register. * * If igc_update_nvm_checksum is not called after this function , the * Shadow Ram will most likely contain an invalid checksum. */ static s32 __igc_write_nvm_srwr(struct igc_hw *hw, u16 offset, u16 words, u16 *data) { struct igc_nvm_info *nvm = &hw->nvm; u32 i, k, eewr = 0; u32 attempts = 100000; s32 ret_val = IGC_SUCCESS; DEBUGFUNC("__igc_write_nvm_srwr"); /* A check for invalid values: offset too large, too many words, * too many words for the offset, and not enough words. */ if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || (words == 0)) { DEBUGOUT("nvm parameter(s) out of bounds\n"); ret_val = -IGC_ERR_NVM; goto out; } for (i = 0; i < words; i++) { eewr = ((offset + i) << IGC_NVM_RW_ADDR_SHIFT) | (data[i] << IGC_NVM_RW_REG_DATA) | IGC_NVM_RW_REG_START; IGC_WRITE_REG(hw, IGC_SRWR, eewr); for (k = 0; k < attempts; k++) { if (IGC_NVM_RW_REG_DONE & IGC_READ_REG(hw, IGC_SRWR)) { ret_val = IGC_SUCCESS; break; } usec_delay(5); } if (ret_val != IGC_SUCCESS) { DEBUGOUT("Shadow RAM write EEWR timed out\n"); break; } } out: return ret_val; } /* igc_validate_nvm_checksum_i225 - Validate EEPROM checksum * @hw: pointer to the HW structure * * Calculates the EEPROM checksum by reading/adding each word of the EEPROM * and then verifies that the sum of the EEPROM is equal to 0xBABA. */ s32 igc_validate_nvm_checksum_i225(struct igc_hw *hw) { s32 status = IGC_SUCCESS; s32 (*read_op_ptr)(struct igc_hw *, u16, u16, u16 *); DEBUGFUNC("igc_validate_nvm_checksum_i225"); if (hw->nvm.ops.acquire(hw) == IGC_SUCCESS) { /* Replace the read function with semaphore grabbing with * the one that skips this for a while. * We have semaphore taken already here. */ read_op_ptr = hw->nvm.ops.read; hw->nvm.ops.read = igc_read_nvm_eerd; status = igc_validate_nvm_checksum_generic(hw); /* Revert original read operation. */ hw->nvm.ops.read = read_op_ptr; hw->nvm.ops.release(hw); } else { status = IGC_ERR_SWFW_SYNC; } return status; } /* igc_update_nvm_checksum_i225 - Update EEPROM checksum * @hw: pointer to the HW structure * * Updates the EEPROM checksum by reading/adding each word of the EEPROM * up to the checksum. Then calculates the EEPROM checksum and writes the * value to the EEPROM. Next commit EEPROM data onto the Flash. */ s32 igc_update_nvm_checksum_i225(struct igc_hw *hw) { s32 ret_val; u16 checksum = 0; u16 i, nvm_data; DEBUGFUNC("igc_update_nvm_checksum_i225"); /* Read the first word from the EEPROM. If this times out or fails, do * not continue or we could be in for a very long wait while every * EEPROM read fails */ ret_val = igc_read_nvm_eerd(hw, 0, 1, &nvm_data); if (ret_val != IGC_SUCCESS) { DEBUGOUT("EEPROM read failed\n"); goto out; } if (hw->nvm.ops.acquire(hw) == IGC_SUCCESS) { /* Do not use hw->nvm.ops.write, hw->nvm.ops.read * because we do not want to take the synchronization * semaphores twice here. */ for (i = 0; i < NVM_CHECKSUM_REG; i++) { ret_val = igc_read_nvm_eerd(hw, i, 1, &nvm_data); if (ret_val) { hw->nvm.ops.release(hw); DEBUGOUT("NVM Read Error while updating\n"); DEBUGOUT("checksum.\n"); goto out; } checksum += nvm_data; } checksum = (u16)NVM_SUM - checksum; ret_val = __igc_write_nvm_srwr(hw, NVM_CHECKSUM_REG, 1, &checksum); if (ret_val != IGC_SUCCESS) { hw->nvm.ops.release(hw); DEBUGOUT("NVM Write Error while updating checksum.\n"); goto out; } hw->nvm.ops.release(hw); ret_val = igc_update_flash_i225(hw); } else { ret_val = IGC_ERR_SWFW_SYNC; } out: return ret_val; } /* igc_get_flash_presence_i225 - Check if flash device is detected. * @hw: pointer to the HW structure */ bool igc_get_flash_presence_i225(struct igc_hw *hw) { u32 eec = 0; bool ret_val = false; DEBUGFUNC("igc_get_flash_presence_i225"); eec = IGC_READ_REG(hw, IGC_EECD); if (eec & IGC_EECD_FLASH_DETECTED_I225) ret_val = true; return ret_val; } /* igc_set_flsw_flash_burst_counter_i225 - sets FLSW NVM Burst * Counter in FLSWCNT register. * * @hw: pointer to the HW structure * @burst_counter: size in bytes of the Flash burst to read or write */ s32 igc_set_flsw_flash_burst_counter_i225(struct igc_hw *hw, u32 burst_counter) { s32 ret_val = IGC_SUCCESS; DEBUGFUNC("igc_set_flsw_flash_burst_counter_i225"); /* Validate input data */ if (burst_counter < IGC_I225_SHADOW_RAM_SIZE) { /* Write FLSWCNT - burst counter */ IGC_WRITE_REG(hw, IGC_I225_FLSWCNT, burst_counter); } else { ret_val = IGC_ERR_INVALID_ARGUMENT; } return ret_val; } /* igc_write_erase_flash_command_i225 - write/erase to a sector * region on a given address. * * @hw: pointer to the HW structure * @opcode: opcode to be used for the write command * @address: the offset to write into the FLASH image */ s32 igc_write_erase_flash_command_i225(struct igc_hw *hw, u32 opcode, u32 address) { u32 flswctl = 0; s32 timeout = IGC_NVM_GRANT_ATTEMPTS; s32 ret_val = IGC_SUCCESS; DEBUGFUNC("igc_write_erase_flash_command_i225"); flswctl = IGC_READ_REG(hw, IGC_I225_FLSWCTL); /* Polling done bit on FLSWCTL register */ while (timeout) { if (flswctl & IGC_FLSWCTL_DONE) break; usec_delay(5); flswctl = IGC_READ_REG(hw, IGC_I225_FLSWCTL); timeout--; } if (!timeout) { DEBUGOUT("Flash transaction was not done\n"); return -IGC_ERR_NVM; } /* Build and issue command on FLSWCTL register */ flswctl = address | opcode; IGC_WRITE_REG(hw, IGC_I225_FLSWCTL, flswctl); /* Check if issued command is valid on FLSWCTL register */ flswctl = IGC_READ_REG(hw, IGC_I225_FLSWCTL); if (!(flswctl & IGC_FLSWCTL_CMDV)) { DEBUGOUT("Write flash command failed\n"); ret_val = IGC_ERR_INVALID_ARGUMENT; } return ret_val; } /* igc_update_flash_i225 - Commit EEPROM to the flash * if fw_valid_bit is set, FW is active. setting FLUPD bit in EEC * register makes the FW load the internal shadow RAM into the flash. * Otherwise, fw_valid_bit is 0. if FL_SECU.block_prtotected_sw = 0 * then FW is not active so the SW is responsible shadow RAM dump. * * @hw: pointer to the HW structure */ s32 igc_update_flash_i225(struct igc_hw *hw) { u16 current_offset_data = 0; u32 block_sw_protect = 1; u16 base_address = 0x0; u32 i, fw_valid_bit; u16 current_offset; s32 ret_val = 0; u32 flup; DEBUGFUNC("igc_update_flash_i225"); block_sw_protect = IGC_READ_REG(hw, IGC_I225_FLSECU) & IGC_FLSECU_BLK_SW_ACCESS_I225; fw_valid_bit = IGC_READ_REG(hw, IGC_FWSM) & IGC_FWSM_FW_VALID_I225; if (fw_valid_bit) { ret_val = igc_pool_flash_update_done_i225(hw); if (ret_val == -IGC_ERR_NVM) { DEBUGOUT("Flash update time out\n"); goto out; } flup = IGC_READ_REG(hw, IGC_EECD) | IGC_EECD_FLUPD_I225; IGC_WRITE_REG(hw, IGC_EECD, flup); ret_val = igc_pool_flash_update_done_i225(hw); if (ret_val == IGC_SUCCESS) DEBUGOUT("Flash update complete\n"); else DEBUGOUT("Flash update time out\n"); } else if (!block_sw_protect) { /* FW is not active and security protection is disabled. * therefore, SW is in charge of shadow RAM dump. * Check which sector is valid. if sector 0 is valid, * base address remains 0x0. otherwise, sector 1 is * valid and it's base address is 0x1000 */ if (IGC_READ_REG(hw, IGC_EECD) & IGC_EECD_SEC1VAL_I225) base_address = 0x1000; /* Valid sector erase */ ret_val = igc_write_erase_flash_command_i225(hw, IGC_I225_ERASE_CMD_OPCODE, base_address); if (!ret_val) { DEBUGOUT("Sector erase failed\n"); goto out; } current_offset = base_address; /* Write */ for (i = 0; i < IGC_I225_SHADOW_RAM_SIZE / 2; i++) { /* Set burst write length */ ret_val = igc_set_flsw_flash_burst_counter_i225(hw, 0x2); if (ret_val != IGC_SUCCESS) break; /* Set address and opcode */ ret_val = igc_write_erase_flash_command_i225(hw, IGC_I225_WRITE_CMD_OPCODE, 2 * current_offset); if (ret_val != IGC_SUCCESS) break; ret_val = igc_read_nvm_eerd(hw, current_offset, 1, ¤t_offset_data); if (ret_val) { DEBUGOUT("Failed to read from EEPROM\n"); goto out; } /* Write CurrentOffseData to FLSWDATA register */ IGC_WRITE_REG(hw, IGC_I225_FLSWDATA, current_offset_data); current_offset++; /* Wait till operation has finished */ ret_val = igc_poll_eerd_eewr_done(hw, IGC_NVM_POLL_READ); if (ret_val) break; usec_delay(1000); } } out: return ret_val; } /* igc_pool_flash_update_done_i225 - Pool FLUDONE status. * @hw: pointer to the HW structure */ s32 igc_pool_flash_update_done_i225(struct igc_hw *hw) { s32 ret_val = -IGC_ERR_NVM; u32 i, reg; DEBUGFUNC("igc_pool_flash_update_done_i225"); for (i = 0; i < IGC_FLUDONE_ATTEMPTS; i++) { reg = IGC_READ_REG(hw, IGC_EECD); if (reg & IGC_EECD_FLUDONE_I225) { ret_val = IGC_SUCCESS; break; } usec_delay(5); } return ret_val; } /* igc_set_ltr_i225 - Set Latency Tolerance Reporting thresholds. * @hw: pointer to the HW structure * @link: bool indicating link status * * Set the LTR thresholds based on the link speed (Mbps), EEE, and DMAC * settings, otherwise specify that there is no LTR requirement. */ static s32 igc_set_ltr_i225(struct igc_hw *hw, bool link) { u16 speed, duplex; u32 tw_system, ltrc, ltrv, ltr_min, ltr_max, scale_min, scale_max; s32 size; DEBUGFUNC("igc_set_ltr_i225"); /* If we do not have link, LTR thresholds are zero. */ if (link) { hw->mac.ops.get_link_up_info(hw, &speed, &duplex); /* Check if using copper interface with EEE enabled or if the * link speed is 10 Mbps. */ if ((hw->phy.media_type == igc_media_type_copper) && !(hw->dev_spec._i225.eee_disable) && (speed != SPEED_10)) { /* EEE enabled, so send LTRMAX threshold. */ ltrc = IGC_READ_REG(hw, IGC_LTRC) | IGC_LTRC_EEEMS_EN; IGC_WRITE_REG(hw, IGC_LTRC, ltrc); /* Calculate tw_system (nsec). */ if (speed == SPEED_100) { tw_system = ((IGC_READ_REG(hw, IGC_EEE_SU) & IGC_TW_SYSTEM_100_MASK) >> IGC_TW_SYSTEM_100_SHIFT) * 500; } else { tw_system = (IGC_READ_REG(hw, IGC_EEE_SU) & IGC_TW_SYSTEM_1000_MASK) * 500; } } else { tw_system = 0; } /* Get the Rx packet buffer size. */ size = IGC_READ_REG(hw, IGC_RXPBS) & IGC_RXPBS_SIZE_I225_MASK; /* Calculations vary based on DMAC settings. */ if (IGC_READ_REG(hw, IGC_DMACR) & IGC_DMACR_DMAC_EN) { size -= (IGC_READ_REG(hw, IGC_DMACR) & IGC_DMACR_DMACTHR_MASK) >> IGC_DMACR_DMACTHR_SHIFT; /* Convert size to bits. */ size *= 1024 * 8; } else { /* Convert size to bytes, subtract the MTU, and then * convert the size to bits. */ size *= 1024; size -= hw->dev_spec._i225.mtu; size *= 8; } if (size < 0) { DEBUGOUT1("Invalid effective Rx buffer size %d\n", size); return -IGC_ERR_CONFIG; } /* Calculate the thresholds. Since speed is in Mbps, simplify * the calculation by multiplying size/speed by 1000 for result * to be in nsec before dividing by the scale in nsec. Set the * scale such that the LTR threshold fits in the register. */ ltr_min = (1000 * size) / speed; ltr_max = ltr_min + tw_system; scale_min = (ltr_min / 1024) < 1024 ? IGC_LTRMINV_SCALE_1024 : IGC_LTRMINV_SCALE_32768; scale_max = (ltr_max / 1024) < 1024 ? IGC_LTRMAXV_SCALE_1024 : IGC_LTRMAXV_SCALE_32768; ltr_min /= scale_min == IGC_LTRMINV_SCALE_1024 ? 1024 : 32768; ltr_max /= scale_max == IGC_LTRMAXV_SCALE_1024 ? 1024 : 32768; /* Only write the LTR thresholds if they differ from before. */ ltrv = IGC_READ_REG(hw, IGC_LTRMINV); if (ltr_min != (ltrv & IGC_LTRMINV_LTRV_MASK)) { ltrv = IGC_LTRMINV_LSNP_REQ | ltr_min | (scale_min << IGC_LTRMINV_SCALE_SHIFT); IGC_WRITE_REG(hw, IGC_LTRMINV, ltrv); } ltrv = IGC_READ_REG(hw, IGC_LTRMAXV); if (ltr_max != (ltrv & IGC_LTRMAXV_LTRV_MASK)) { ltrv = IGC_LTRMAXV_LSNP_REQ | ltr_max | (scale_min << IGC_LTRMAXV_SCALE_SHIFT); IGC_WRITE_REG(hw, IGC_LTRMAXV, ltrv); } } return IGC_SUCCESS; } /* igc_check_for_link_i225 - Check for link * @hw: pointer to the HW structure * * Checks to see of the link status of the hardware has changed. If a * change in link status has been detected, then we read the PHY registers * to get the current speed/duplex if link exists. */ s32 igc_check_for_link_i225(struct igc_hw *hw) { struct igc_mac_info *mac = &hw->mac; s32 ret_val; bool link = false; DEBUGFUNC("igc_check_for_link_i225"); /* We only want to go out to the PHY registers to see if * Auto-Neg has completed and/or if our link status has * changed. The get_link_status flag is set upon receiving * a Link Status Change or Rx Sequence Error interrupt. */ if (!mac->get_link_status) { ret_val = IGC_SUCCESS; goto out; } /* First we want to see if the MII Status Register reports * link. If so, then we want to get the current speed/duplex * of the PHY. */ ret_val = igc_phy_has_link_generic(hw, 1, 0, &link); if (ret_val) goto out; if (!link) goto out; /* No link detected */ /* First we want to see if the MII Status Register reports * link. If so, then we want to get the current speed/duplex * of the PHY. */ ret_val = igc_phy_has_link_generic(hw, 1, 0, &link); if (ret_val) goto out; if (!link) goto out; /* No link detected */ mac->get_link_status = false; /* Check if there was DownShift, must be checked * immediately after link-up */ igc_check_downshift_generic(hw); /* If we are forcing speed/duplex, then we simply return since * we have already determined whether we have link or not. */ if (!mac->autoneg) goto out; /* Auto-Neg is enabled. Auto Speed Detection takes care * of MAC speed/duplex configuration. So we only need to * configure Collision Distance in the MAC. */ mac->ops.config_collision_dist(hw); /* Configure Flow Control now that Auto-Neg has completed. * First, we need to restore the desired flow control * settings because we may have had to re-autoneg with a * different link partner. */ ret_val = igc_config_fc_after_link_up_generic(hw); if (ret_val) DEBUGOUT("Error configuring flow control\n"); out: /* Now that we are aware of our link settings, we can set the LTR * thresholds. */ ret_val = igc_set_ltr_i225(hw, link); return ret_val; } /* igc_init_function_pointers_i225 - Init func ptrs. * @hw: pointer to the HW structure * * Called to initialize all function pointers and parameters. */ void igc_init_function_pointers_i225(struct igc_hw *hw) { igc_init_mac_ops_generic(hw); igc_init_phy_ops_generic(hw); igc_init_nvm_ops_generic(hw); hw->mac.ops.init_params = igc_init_mac_params_i225; hw->nvm.ops.init_params = igc_init_nvm_params_i225; hw->phy.ops.init_params = igc_init_phy_params_i225; } /* igc_init_hw_i225 - Init hw for I225 * @hw: pointer to the HW structure * * Called to initialize hw for i225 hw family. */ s32 igc_init_hw_i225(struct igc_hw *hw) { s32 ret_val; DEBUGFUNC("igc_init_hw_i225"); ret_val = igc_init_hw_base(hw); return ret_val; } /* * igc_set_d0_lplu_state_i225 - Set Low-Power-Link-Up (LPLU) D0 state * @hw: pointer to the HW structure * @active: true to enable LPLU, false to disable * * Note: since I225 does not actually support LPLU, this function * simply enables/disables 1G and 2.5G speeds in D0. */ s32 igc_set_d0_lplu_state_i225(struct igc_hw *hw, bool active) { u32 data; DEBUGFUNC("igc_set_d0_lplu_state_i225"); data = IGC_READ_REG(hw, IGC_I225_PHPM); if (active) { data |= IGC_I225_PHPM_DIS_1000; data |= IGC_I225_PHPM_DIS_2500; } else { data &= ~IGC_I225_PHPM_DIS_1000; data &= ~IGC_I225_PHPM_DIS_2500; } IGC_WRITE_REG(hw, IGC_I225_PHPM, data); return IGC_SUCCESS; } /* * igc_set_d3_lplu_state_i225 - Set Low-Power-Link-Up (LPLU) D3 state * @hw: pointer to the HW structure * @active: true to enable LPLU, false to disable * * Note: since I225 does not actually support LPLU, this function * simply enables/disables 100M, 1G and 2.5G speeds in D3. */ s32 igc_set_d3_lplu_state_i225(struct igc_hw *hw, bool active) { u32 data; DEBUGFUNC("igc_set_d3_lplu_state_i225"); data = IGC_READ_REG(hw, IGC_I225_PHPM); if (active) { data |= IGC_I225_PHPM_DIS_100_D3; data |= IGC_I225_PHPM_DIS_1000_D3; data |= IGC_I225_PHPM_DIS_2500_D3; } else { data &= ~IGC_I225_PHPM_DIS_100_D3; data &= ~IGC_I225_PHPM_DIS_1000_D3; data &= ~IGC_I225_PHPM_DIS_2500_D3; } IGC_WRITE_REG(hw, IGC_I225_PHPM, data); return IGC_SUCCESS; } /** * igc_set_eee_i225 - Enable/disable EEE support * @hw: pointer to the HW structure * @adv2p5G: boolean flag enabling 2.5G EEE advertisement * @adv1G: boolean flag enabling 1G EEE advertisement * @adv100M: boolean flag enabling 100M EEE advertisement * * Enable/disable EEE based on setting in dev_spec structure. * **/ s32 igc_set_eee_i225(struct igc_hw *hw, bool adv2p5G, bool adv1G, bool adv100M) { u32 ipcnfg, eeer; DEBUGFUNC("igc_set_eee_i225"); if (hw->mac.type != igc_i225 || hw->phy.media_type != igc_media_type_copper) goto out; ipcnfg = IGC_READ_REG(hw, IGC_IPCNFG); eeer = IGC_READ_REG(hw, IGC_EEER); /* enable or disable per user setting */ if (!(hw->dev_spec._i225.eee_disable)) { u32 eee_su = IGC_READ_REG(hw, IGC_EEE_SU); if (adv100M) ipcnfg |= IGC_IPCNFG_EEE_100M_AN; else ipcnfg &= ~IGC_IPCNFG_EEE_100M_AN; if (adv1G) ipcnfg |= IGC_IPCNFG_EEE_1G_AN; else ipcnfg &= ~IGC_IPCNFG_EEE_1G_AN; if (adv2p5G) ipcnfg |= IGC_IPCNFG_EEE_2_5G_AN; else ipcnfg &= ~IGC_IPCNFG_EEE_2_5G_AN; eeer |= (IGC_EEER_TX_LPI_EN | IGC_EEER_RX_LPI_EN | IGC_EEER_LPI_FC); /* This bit should not be set in normal operation. */ if (eee_su & IGC_EEE_SU_LPI_CLK_STP) DEBUGOUT("LPI Clock Stop Bit should not be set!\n"); } else { ipcnfg &= ~(IGC_IPCNFG_EEE_2_5G_AN | IGC_IPCNFG_EEE_1G_AN | IGC_IPCNFG_EEE_100M_AN); eeer &= ~(IGC_EEER_TX_LPI_EN | IGC_EEER_RX_LPI_EN | IGC_EEER_LPI_FC); } IGC_WRITE_REG(hw, IGC_IPCNFG, ipcnfg); IGC_WRITE_REG(hw, IGC_EEER, eeer); IGC_READ_REG(hw, IGC_IPCNFG); IGC_READ_REG(hw, IGC_EEER); out: return IGC_SUCCESS; } diff --git a/sys/dev/igc/igc_phy.c b/sys/dev/igc/igc_phy.c index a6823ddf7bac..d2ae7effbb41 100644 --- a/sys/dev/igc/igc_phy.c +++ b/sys/dev/igc/igc_phy.c @@ -1,1076 +1,1074 @@ /*- * Copyright 2021 Intel Corp * Copyright 2021 Rubicon Communications, LLC (Netgate) * SPDX-License-Identifier: BSD-3-Clause */ #include __FBSDID("$FreeBSD$"); #include "igc_api.h" static s32 igc_wait_autoneg(struct igc_hw *hw); /** * igc_init_phy_ops_generic - Initialize PHY function pointers * @hw: pointer to the HW structure * * Setups up the function pointers to no-op functions **/ void igc_init_phy_ops_generic(struct igc_hw *hw) { struct igc_phy_info *phy = &hw->phy; DEBUGFUNC("igc_init_phy_ops_generic"); /* Initialize function pointers */ phy->ops.init_params = igc_null_ops_generic; phy->ops.acquire = igc_null_ops_generic; phy->ops.check_reset_block = igc_null_ops_generic; phy->ops.force_speed_duplex = igc_null_ops_generic; phy->ops.get_info = igc_null_ops_generic; phy->ops.set_page = igc_null_set_page; phy->ops.read_reg = igc_null_read_reg; phy->ops.read_reg_locked = igc_null_read_reg; phy->ops.read_reg_page = igc_null_read_reg; phy->ops.release = igc_null_phy_generic; phy->ops.reset = igc_null_ops_generic; phy->ops.set_d0_lplu_state = igc_null_lplu_state; phy->ops.set_d3_lplu_state = igc_null_lplu_state; phy->ops.write_reg = igc_null_write_reg; phy->ops.write_reg_locked = igc_null_write_reg; phy->ops.write_reg_page = igc_null_write_reg; phy->ops.power_up = igc_null_phy_generic; phy->ops.power_down = igc_null_phy_generic; } /** * igc_null_set_page - No-op function, return 0 * @hw: pointer to the HW structure * @data: dummy variable **/ s32 igc_null_set_page(struct igc_hw IGC_UNUSEDARG *hw, u16 IGC_UNUSEDARG data) { DEBUGFUNC("igc_null_set_page"); return IGC_SUCCESS; } /** * igc_null_read_reg - No-op function, return 0 * @hw: pointer to the HW structure * @offset: dummy variable * @data: dummy variable **/ s32 igc_null_read_reg(struct igc_hw IGC_UNUSEDARG *hw, u32 IGC_UNUSEDARG offset, u16 IGC_UNUSEDARG *data) { DEBUGFUNC("igc_null_read_reg"); return IGC_SUCCESS; } /** * igc_null_phy_generic - No-op function, return void * @hw: pointer to the HW structure **/ void igc_null_phy_generic(struct igc_hw IGC_UNUSEDARG *hw) { DEBUGFUNC("igc_null_phy_generic"); return; } /** * igc_null_lplu_state - No-op function, return 0 * @hw: pointer to the HW structure * @active: dummy variable **/ s32 igc_null_lplu_state(struct igc_hw IGC_UNUSEDARG *hw, bool IGC_UNUSEDARG active) { DEBUGFUNC("igc_null_lplu_state"); return IGC_SUCCESS; } /** * igc_null_write_reg - No-op function, return 0 * @hw: pointer to the HW structure * @offset: dummy variable * @data: dummy variable **/ s32 igc_null_write_reg(struct igc_hw IGC_UNUSEDARG *hw, u32 IGC_UNUSEDARG offset, u16 IGC_UNUSEDARG data) { DEBUGFUNC("igc_null_write_reg"); return IGC_SUCCESS; } /** * igc_check_reset_block_generic - 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 IGC_SUCCESS, otherwise * return IGC_BLK_PHY_RESET (12). **/ s32 igc_check_reset_block_generic(struct igc_hw *hw) { u32 manc; DEBUGFUNC("igc_check_reset_block"); manc = IGC_READ_REG(hw, IGC_MANC); return (manc & IGC_MANC_BLK_PHY_RST_ON_IDE) ? IGC_BLK_PHY_RESET : IGC_SUCCESS; } /** * 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) { struct igc_phy_info *phy = &hw->phy; s32 ret_val = IGC_SUCCESS; u16 phy_id; DEBUGFUNC("igc_get_phy_id"); if (!phy->ops.read_reg) return IGC_SUCCESS; ret_val = phy->ops.read_reg(hw, PHY_ID1, &phy_id); if (ret_val) return ret_val; phy->id = (u32)(phy_id << 16); usec_delay(200); ret_val = phy->ops.read_reg(hw, PHY_ID2, &phy_id); if (ret_val) return ret_val; phy->id |= (u32)(phy_id & PHY_REVISION_MASK); phy->revision = (u32)(phy_id & ~PHY_REVISION_MASK); return IGC_SUCCESS; } /** * 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. **/ s32 igc_read_phy_reg_mdic(struct igc_hw *hw, u32 offset, u16 *data) { struct igc_phy_info *phy = &hw->phy; u32 i, mdic = 0; DEBUGFUNC("igc_read_phy_reg_mdic"); if (offset > MAX_PHY_REG_ADDRESS) { DEBUGOUT1("PHY Address %d is out of range\n", offset); return -IGC_ERR_PARAM; } /* Set up Op-code, Phy Address, and register offset in the MDI * Control register. The MAC will take care of interfacing with the * PHY to retrieve the desired data. */ mdic = ((offset << IGC_MDIC_REG_SHIFT) | (phy->addr << IGC_MDIC_PHY_SHIFT) | (IGC_MDIC_OP_READ)); IGC_WRITE_REG(hw, IGC_MDIC, mdic); /* Poll the ready bit to see if the MDI read completed * Increasing the time out as testing showed failures with * the lower time out */ for (i = 0; i < (IGC_GEN_POLL_TIMEOUT * 3); i++) { usec_delay_irq(50); mdic = IGC_READ_REG(hw, IGC_MDIC); if (mdic & IGC_MDIC_READY) break; } if (!(mdic & IGC_MDIC_READY)) { DEBUGOUT("MDI Read did not complete\n"); return -IGC_ERR_PHY; } if (mdic & IGC_MDIC_ERROR) { DEBUGOUT("MDI Error\n"); return -IGC_ERR_PHY; } if (((mdic & IGC_MDIC_REG_MASK) >> IGC_MDIC_REG_SHIFT) != offset) { DEBUGOUT2("MDI Read offset error - requested %d, returned %d\n", offset, (mdic & IGC_MDIC_REG_MASK) >> IGC_MDIC_REG_SHIFT); return -IGC_ERR_PHY; } *data = (u16) mdic; return IGC_SUCCESS; } /** * 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. **/ s32 igc_write_phy_reg_mdic(struct igc_hw *hw, u32 offset, u16 data) { struct igc_phy_info *phy = &hw->phy; u32 i, mdic = 0; DEBUGFUNC("igc_write_phy_reg_mdic"); if (offset > MAX_PHY_REG_ADDRESS) { DEBUGOUT1("PHY Address %d is out of range\n", offset); return -IGC_ERR_PARAM; } /* Set up Op-code, Phy Address, and register offset in the MDI * Control register. The MAC will take care of interfacing with the * PHY to retrieve the desired data. */ mdic = (((u32)data) | (offset << IGC_MDIC_REG_SHIFT) | (phy->addr << IGC_MDIC_PHY_SHIFT) | (IGC_MDIC_OP_WRITE)); IGC_WRITE_REG(hw, IGC_MDIC, mdic); /* Poll the ready bit to see if the MDI read completed * Increasing the time out as testing showed failures with * the lower time out */ for (i = 0; i < (IGC_GEN_POLL_TIMEOUT * 3); i++) { usec_delay_irq(50); mdic = IGC_READ_REG(hw, IGC_MDIC); if (mdic & IGC_MDIC_READY) break; } if (!(mdic & IGC_MDIC_READY)) { DEBUGOUT("MDI Write did not complete\n"); return -IGC_ERR_PHY; } if (mdic & IGC_MDIC_ERROR) { DEBUGOUT("MDI Error\n"); return -IGC_ERR_PHY; } if (((mdic & IGC_MDIC_REG_MASK) >> IGC_MDIC_REG_SHIFT) != offset) { DEBUGOUT2("MDI Write offset error - requested %d, returned %d\n", offset, (mdic & IGC_MDIC_REG_MASK) >> IGC_MDIC_REG_SHIFT); return -IGC_ERR_PHY; } return IGC_SUCCESS; } /** * 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) { struct igc_phy_info *phy = &hw->phy; s32 ret_val; u16 mii_autoneg_adv_reg; u16 mii_1000t_ctrl_reg = 0; u16 aneg_multigbt_an_ctrl = 0; DEBUGFUNC("igc_phy_setup_autoneg"); phy->autoneg_advertised &= phy->autoneg_mask; /* Read the MII Auto-Neg Advertisement Register (Address 4). */ ret_val = phy->ops.read_reg(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg); if (ret_val) return ret_val; if (phy->autoneg_mask & ADVERTISE_1000_FULL) { /* Read the MII 1000Base-T Control Register (Address 9). */ ret_val = phy->ops.read_reg(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg); if (ret_val) return ret_val; } - if ((phy->autoneg_mask & ADVERTISE_2500_FULL) && - hw->phy.id == I225_I_PHY_ID) { + if (phy->autoneg_mask & ADVERTISE_2500_FULL) { /* Read the MULTI GBT AN Control Register - reg 7.32 */ ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK << MMD_DEVADDR_SHIFT) | ANEG_MULTIGBT_AN_CTRL, &aneg_multigbt_an_ctrl); if (ret_val) return ret_val; } /* Need to parse both autoneg_advertised and fc and set up * the appropriate PHY registers. First we will parse for * autoneg_advertised software override. Since we can advertise * a plethora of combinations, we need to check each bit * individually. */ /* First we clear all the 10/100 mb speed bits in the Auto-Neg * Advertisement Register (Address 4) and the 1000 mb speed bits in * the 1000Base-T Control Register (Address 9). */ mii_autoneg_adv_reg &= ~(NWAY_AR_100TX_FD_CAPS | NWAY_AR_100TX_HD_CAPS | NWAY_AR_10T_FD_CAPS | NWAY_AR_10T_HD_CAPS); mii_1000t_ctrl_reg &= ~(CR_1000T_HD_CAPS | CR_1000T_FD_CAPS); DEBUGOUT1("autoneg_advertised %x\n", phy->autoneg_advertised); /* Do we want to advertise 10 Mb Half Duplex? */ if (phy->autoneg_advertised & ADVERTISE_10_HALF) { DEBUGOUT("Advertise 10mb Half duplex\n"); mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS; } /* Do we want to advertise 10 Mb Full Duplex? */ if (phy->autoneg_advertised & ADVERTISE_10_FULL) { DEBUGOUT("Advertise 10mb Full duplex\n"); mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS; } /* Do we want to advertise 100 Mb Half Duplex? */ if (phy->autoneg_advertised & ADVERTISE_100_HALF) { DEBUGOUT("Advertise 100mb Half duplex\n"); mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS; } /* Do we want to advertise 100 Mb Full Duplex? */ if (phy->autoneg_advertised & ADVERTISE_100_FULL) { DEBUGOUT("Advertise 100mb Full duplex\n"); mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS; } /* We do not allow the Phy to advertise 1000 Mb Half Duplex */ if (phy->autoneg_advertised & ADVERTISE_1000_HALF) DEBUGOUT("Advertise 1000mb Half duplex request denied!\n"); /* Do we want to advertise 1000 Mb Full Duplex? */ if (phy->autoneg_advertised & ADVERTISE_1000_FULL) { DEBUGOUT("Advertise 1000mb Full duplex\n"); mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS; } /* We do not allow the Phy to advertise 2500 Mb Half Duplex */ if (phy->autoneg_advertised & ADVERTISE_2500_HALF) DEBUGOUT("Advertise 2500mb Half duplex request denied!\n"); /* Do we want to advertise 2500 Mb Full Duplex? */ if (phy->autoneg_advertised & ADVERTISE_2500_FULL) { DEBUGOUT("Advertise 2500mb Full duplex\n"); aneg_multigbt_an_ctrl |= CR_2500T_FD_CAPS; } else { aneg_multigbt_an_ctrl &= ~CR_2500T_FD_CAPS; } /* Check for a software override of the flow control settings, and * setup the PHY advertisement registers accordingly. If * auto-negotiation is enabled, then software will have to set the * "PAUSE" bits to the correct value in the Auto-Negotiation * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto- * negotiation. * * The possible values of the "fc" parameter are: * 0: Flow control is completely disabled * 1: Rx flow control is enabled (we can receive pause frames * but not send pause frames). * 2: Tx flow control is enabled (we can send pause frames * but we do not support receiving pause frames). * 3: Both Rx and Tx flow control (symmetric) are enabled. * other: No software override. The flow control configuration * in the EEPROM is used. */ switch (hw->fc.current_mode) { case igc_fc_none: /* Flow control (Rx & Tx) is completely disabled by a * software over-ride. */ mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE); break; case igc_fc_rx_pause: /* Rx Flow control is enabled, and Tx Flow control is * disabled, by a software over-ride. * * Since there really isn't a way to advertise that we are * capable of Rx Pause ONLY, we will advertise that we * support both symmetric and asymmetric Rx PAUSE. Later * (in igc_config_fc_after_link_up) we will disable the * hw's ability to send PAUSE frames. */ mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE); break; case igc_fc_tx_pause: /* Tx Flow control is enabled, and Rx Flow control is * disabled, by a software over-ride. */ mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR; mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE; break; case igc_fc_full: /* Flow control (both Rx and Tx) is enabled by a software * over-ride. */ mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE); break; default: DEBUGOUT("Flow control param set incorrectly\n"); return -IGC_ERR_CONFIG; } ret_val = phy->ops.write_reg(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg); if (ret_val) return ret_val; DEBUGOUT1("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg); if (phy->autoneg_mask & ADVERTISE_1000_FULL) ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg); - if ((phy->autoneg_mask & ADVERTISE_2500_FULL) && - hw->phy.id == I225_I_PHY_ID) + if (phy->autoneg_mask & ADVERTISE_2500_FULL) ret_val = phy->ops.write_reg(hw, (STANDARD_AN_REG_MASK << MMD_DEVADDR_SHIFT) | ANEG_MULTIGBT_AN_CTRL, aneg_multigbt_an_ctrl); return ret_val; } /** * 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) { struct igc_phy_info *phy = &hw->phy; s32 ret_val; u16 phy_ctrl; DEBUGFUNC("igc_copper_link_autoneg"); /* Perform some bounds checking on the autoneg advertisement * parameter. */ phy->autoneg_advertised &= phy->autoneg_mask; /* If autoneg_advertised is zero, we assume it was not defaulted * by the calling code so we set to advertise full capability. */ if (!phy->autoneg_advertised) phy->autoneg_advertised = phy->autoneg_mask; DEBUGOUT("Reconfiguring auto-neg advertisement params\n"); ret_val = igc_phy_setup_autoneg(hw); if (ret_val) { DEBUGOUT("Error Setting up Auto-Negotiation\n"); return ret_val; } DEBUGOUT("Restarting Auto-Neg\n"); /* Restart auto-negotiation by setting the Auto Neg Enable bit and * the Auto Neg Restart bit in the PHY control register. */ ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &phy_ctrl); if (ret_val) return ret_val; phy_ctrl |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG); ret_val = phy->ops.write_reg(hw, PHY_CONTROL, phy_ctrl); if (ret_val) return ret_val; /* Does the user want to wait for Auto-Neg to complete here, or * check at a later time (for example, callback routine). */ if (phy->autoneg_wait_to_complete) { ret_val = igc_wait_autoneg(hw); if (ret_val) { DEBUGOUT("Error while waiting for autoneg to complete\n"); return ret_val; } } hw->mac.get_link_status = true; return ret_val; } /** * igc_setup_copper_link_generic - 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_generic(struct igc_hw *hw) { s32 ret_val; bool link; DEBUGFUNC("igc_setup_copper_link_generic"); if (hw->mac.autoneg) { /* Setup autoneg and flow control advertisement and perform * autonegotiation. */ ret_val = igc_copper_link_autoneg(hw); if (ret_val) return ret_val; } else { /* PHY will be set to 10H, 10F, 100H or 100F * depending on user settings. */ DEBUGOUT("Forcing Speed and Duplex\n"); ret_val = hw->phy.ops.force_speed_duplex(hw); if (ret_val) { DEBUGOUT("Error Forcing Speed and Duplex\n"); return ret_val; } } /* Check link status. Wait up to 100 microseconds for link to become * valid. */ ret_val = igc_phy_has_link_generic(hw, COPPER_LINK_UP_LIMIT, 10, &link); if (ret_val) return ret_val; if (link) { DEBUGOUT("Valid link established!!!\n"); hw->mac.ops.config_collision_dist(hw); ret_val = igc_config_fc_after_link_up_generic(hw); } else { DEBUGOUT("Unable to establish link!!!\n"); } return ret_val; } /** * igc_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex * @hw: pointer to the HW structure * @phy_ctrl: pointer to current value of PHY_CONTROL * * Forces speed and duplex on the PHY by doing the following: disable flow * control, force speed/duplex on the MAC, disable auto speed detection, * disable auto-negotiation, configure duplex, configure speed, configure * the collision distance, write configuration to CTRL register. The * caller must write to the PHY_CONTROL register for these settings to * take affect. **/ void igc_phy_force_speed_duplex_setup(struct igc_hw *hw, u16 *phy_ctrl) { struct igc_mac_info *mac = &hw->mac; u32 ctrl; DEBUGFUNC("igc_phy_force_speed_duplex_setup"); /* Turn off flow control when forcing speed/duplex */ hw->fc.current_mode = igc_fc_none; /* Force speed/duplex on the mac */ ctrl = IGC_READ_REG(hw, IGC_CTRL); ctrl |= (IGC_CTRL_FRCSPD | IGC_CTRL_FRCDPX); ctrl &= ~IGC_CTRL_SPD_SEL; /* Disable Auto Speed Detection */ ctrl &= ~IGC_CTRL_ASDE; /* Disable autoneg on the phy */ *phy_ctrl &= ~MII_CR_AUTO_NEG_EN; /* Forcing Full or Half Duplex? */ if (mac->forced_speed_duplex & IGC_ALL_HALF_DUPLEX) { ctrl &= ~IGC_CTRL_FD; *phy_ctrl &= ~MII_CR_FULL_DUPLEX; DEBUGOUT("Half Duplex\n"); } else { ctrl |= IGC_CTRL_FD; *phy_ctrl |= MII_CR_FULL_DUPLEX; DEBUGOUT("Full Duplex\n"); } /* Forcing 10mb or 100mb? */ if (mac->forced_speed_duplex & IGC_ALL_100_SPEED) { ctrl |= IGC_CTRL_SPD_100; *phy_ctrl |= MII_CR_SPEED_100; *phy_ctrl &= ~MII_CR_SPEED_1000; DEBUGOUT("Forcing 100mb\n"); } else { ctrl &= ~(IGC_CTRL_SPD_1000 | IGC_CTRL_SPD_100); *phy_ctrl &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100); DEBUGOUT("Forcing 10mb\n"); } hw->mac.ops.config_collision_dist(hw); IGC_WRITE_REG(hw, IGC_CTRL, ctrl); } /** * igc_set_d3_lplu_state_generic - Sets low power link up state for D3 * @hw: pointer to the HW structure * @active: boolean used to enable/disable lplu * * Success returns 0, Failure returns 1 * * The low power link up (lplu) state is set to the power management level D3 * and SmartSpeed is disabled when active is true, else clear lplu for D3 * and enable Smartspeed. LPLU and Smartspeed are mutually exclusive. LPLU * is used during Dx states where the power conservation is most important. * During driver activity, SmartSpeed should be enabled so performance is * maintained. **/ s32 igc_set_d3_lplu_state_generic(struct igc_hw *hw, bool active) { struct igc_phy_info *phy = &hw->phy; s32 ret_val; u16 data; DEBUGFUNC("igc_set_d3_lplu_state_generic"); if (!hw->phy.ops.read_reg) return IGC_SUCCESS; ret_val = phy->ops.read_reg(hw, IGP02IGC_PHY_POWER_MGMT, &data); if (ret_val) return ret_val; if (!active) { data &= ~IGP02IGC_PM_D3_LPLU; ret_val = phy->ops.write_reg(hw, IGP02IGC_PHY_POWER_MGMT, data); if (ret_val) return ret_val; /* LPLU and SmartSpeed are mutually exclusive. LPLU is used * during Dx states where the power conservation is most * important. During driver activity we should enable * SmartSpeed, so performance is maintained. */ if (phy->smart_speed == igc_smart_speed_on) { ret_val = phy->ops.read_reg(hw, IGP01IGC_PHY_PORT_CONFIG, &data); if (ret_val) return ret_val; data |= IGP01IGC_PSCFR_SMART_SPEED; ret_val = phy->ops.write_reg(hw, IGP01IGC_PHY_PORT_CONFIG, data); if (ret_val) return ret_val; } else if (phy->smart_speed == igc_smart_speed_off) { ret_val = phy->ops.read_reg(hw, IGP01IGC_PHY_PORT_CONFIG, &data); if (ret_val) return ret_val; data &= ~IGP01IGC_PSCFR_SMART_SPEED; ret_val = phy->ops.write_reg(hw, IGP01IGC_PHY_PORT_CONFIG, data); if (ret_val) return ret_val; } } else if ((phy->autoneg_advertised == IGC_ALL_SPEED_DUPLEX) || (phy->autoneg_advertised == IGC_ALL_NOT_GIG) || (phy->autoneg_advertised == IGC_ALL_10_SPEED)) { data |= IGP02IGC_PM_D3_LPLU; ret_val = phy->ops.write_reg(hw, IGP02IGC_PHY_POWER_MGMT, data); if (ret_val) return ret_val; /* When LPLU is enabled, we should disable SmartSpeed */ ret_val = phy->ops.read_reg(hw, IGP01IGC_PHY_PORT_CONFIG, &data); if (ret_val) return ret_val; data &= ~IGP01IGC_PSCFR_SMART_SPEED; ret_val = phy->ops.write_reg(hw, IGP01IGC_PHY_PORT_CONFIG, data); } return ret_val; } /** * igc_check_downshift_generic - Checks whether a downshift in speed occurred * @hw: pointer to the HW structure * * Success returns 0, Failure returns 1 * * A downshift is detected by querying the PHY link health. **/ s32 igc_check_downshift_generic(struct igc_hw *hw) { struct igc_phy_info *phy = &hw->phy; s32 ret_val; DEBUGFUNC("igc_check_downshift_generic"); switch (phy->type) { case igc_phy_i225: default: /* speed downshift not supported */ phy->speed_downgraded = false; return IGC_SUCCESS; } return ret_val; } /** * 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) { s32 ret_val = IGC_SUCCESS; u16 i, phy_status; DEBUGFUNC("igc_wait_autoneg"); if (!hw->phy.ops.read_reg) return IGC_SUCCESS; /* Break after autoneg completes or PHY_AUTO_NEG_LIMIT expires. */ for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) { ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); if (ret_val) break; ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); if (ret_val) break; if (phy_status & MII_SR_AUTONEG_COMPLETE) break; msec_delay(100); } /* PHY_AUTO_NEG_TIME expiration doesn't guarantee auto-negotiation * has completed. */ return ret_val; } /** * igc_phy_has_link_generic - 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_generic(struct igc_hw *hw, u32 iterations, u32 usec_interval, bool *success) { s32 ret_val = IGC_SUCCESS; u16 i, phy_status; DEBUGFUNC("igc_phy_has_link_generic"); if (!hw->phy.ops.read_reg) return IGC_SUCCESS; for (i = 0; i < iterations; i++) { /* Some PHYs require the PHY_STATUS register to be read * twice due to the link bit being sticky. No harm doing * it across the board. */ ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); if (ret_val) { /* If the first read fails, another entity may have * ownership of the resources, wait and try again to * see if they have relinquished the resources yet. */ if (usec_interval >= 1000) msec_delay(usec_interval/1000); else usec_delay(usec_interval); } ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); if (ret_val) break; if (phy_status & MII_SR_LINK_STATUS) break; if (usec_interval >= 1000) msec_delay(usec_interval/1000); else usec_delay(usec_interval); } *success = (i < iterations); return ret_val; } /** * igc_phy_hw_reset_generic - 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_generic(struct igc_hw *hw) { struct igc_phy_info *phy = &hw->phy; s32 ret_val; u32 ctrl, timeout = 10000, phpm = 0; DEBUGFUNC("igc_phy_hw_reset_generic"); if (phy->ops.check_reset_block) { ret_val = phy->ops.check_reset_block(hw); if (ret_val) return IGC_SUCCESS; } ret_val = phy->ops.acquire(hw); if (ret_val) return ret_val; phpm = IGC_READ_REG(hw, IGC_I225_PHPM); ctrl = IGC_READ_REG(hw, IGC_CTRL); IGC_WRITE_REG(hw, IGC_CTRL, ctrl | IGC_CTRL_PHY_RST); IGC_WRITE_FLUSH(hw); usec_delay(phy->reset_delay_us); IGC_WRITE_REG(hw, IGC_CTRL, ctrl); IGC_WRITE_FLUSH(hw); usec_delay(150); do { phpm = IGC_READ_REG(hw, IGC_I225_PHPM); timeout--; usec_delay(1); } while (!(phpm & IGC_I225_PHPM_RST_COMPL) && timeout); if (!timeout) DEBUGOUT("Timeout expired after a phy reset\n"); phy->ops.release(hw); return ret_val; } /** * 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, or wake on lan is not enabled, restore the link to previous * settings. **/ void igc_power_up_phy_copper(struct igc_hw *hw) { u16 mii_reg = 0; /* The PHY will retain its settings across a power down/up cycle */ hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg); mii_reg &= ~MII_CR_POWER_DOWN; hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg); usec_delay(300); } /** * igc_power_down_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, or wake on lan is not enabled, restore the link to previous * settings. **/ void igc_power_down_phy_copper(struct igc_hw *hw) { u16 mii_reg = 0; /* The PHY will retain its settings across a power down/up cycle */ hw->phy.ops.read_reg(hw, PHY_CONTROL, &mii_reg); mii_reg |= MII_CR_POWER_DOWN; hw->phy.ops.write_reg(hw, PHY_CONTROL, mii_reg); msec_delay(1); } /** * 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) { s32 ret_val; u8 dev_addr = (offset & GPY_MMD_MASK) >> GPY_MMD_SHIFT; DEBUGFUNC("igc_write_phy_reg_gpy"); offset = offset & GPY_REG_MASK; if (!dev_addr) { ret_val = hw->phy.ops.acquire(hw); if (ret_val) return ret_val; ret_val = igc_write_phy_reg_mdic(hw, offset, data); if (ret_val) return ret_val; hw->phy.ops.release(hw); } else { ret_val = igc_write_xmdio_reg(hw, (u16)offset, dev_addr, data); } return ret_val; } /** * 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) { s32 ret_val; u8 dev_addr = (offset & GPY_MMD_MASK) >> GPY_MMD_SHIFT; DEBUGFUNC("igc_read_phy_reg_gpy"); offset = offset & GPY_REG_MASK; if (!dev_addr) { ret_val = hw->phy.ops.acquire(hw); if (ret_val) return ret_val; ret_val = igc_read_phy_reg_mdic(hw, offset, data); if (ret_val) return ret_val; hw->phy.ops.release(hw); } else { ret_val = igc_read_xmdio_reg(hw, (u16)offset, dev_addr, data); } return ret_val; } /** * __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) { s32 ret_val; DEBUGFUNC("__igc_access_xmdio_reg"); ret_val = hw->phy.ops.write_reg(hw, IGC_MMDAC, dev_addr); if (ret_val) return ret_val; ret_val = hw->phy.ops.write_reg(hw, IGC_MMDAAD, address); if (ret_val) return ret_val; ret_val = hw->phy.ops.write_reg(hw, IGC_MMDAC, IGC_MMDAC_FUNC_DATA | dev_addr); if (ret_val) return ret_val; if (read) ret_val = hw->phy.ops.read_reg(hw, IGC_MMDAAD, data); else ret_val = hw->phy.ops.write_reg(hw, IGC_MMDAAD, *data); if (ret_val) return ret_val; /* Recalibrate the device back to 0 */ ret_val = hw->phy.ops.write_reg(hw, IGC_MMDAC, 0); if (ret_val) return ret_val; return ret_val; } /** * 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 **/ s32 igc_read_xmdio_reg(struct igc_hw *hw, u16 addr, u8 dev_addr, u16 *data) { DEBUGFUNC("igc_read_xmdio_reg"); return __igc_access_xmdio_reg(hw, addr, dev_addr, data, true); } /** * 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 **/ s32 igc_write_xmdio_reg(struct igc_hw *hw, u16 addr, u8 dev_addr, u16 data) { DEBUGFUNC("igc_write_xmdio_reg"); return __igc_access_xmdio_reg(hw, addr, dev_addr, &data, false); }