233
245
size += NVM_WORD_SIZE_BASE_SHIFT;
235
/* EEPROM access above 16k is unsupported */
248
* Check for invalid size
250
if ((hw->mac.type == e1000_82576) && (size > 15)) {
251
printk("igb: The NVM size is not valid, "
252
"defaulting to 32K.\n");
238
255
nvm->word_size = 1 << size;
240
/* if 82576 then initialize mailbox parameters */
241
if (mac->type == e1000_82576)
256
if (nvm->word_size == (1 << 15))
257
nvm->page_size = 128;
259
/* NVM Function Pointers */
260
nvm->ops.acquire = igb_acquire_nvm_82575;
261
if (nvm->word_size < (1 << 15))
262
nvm->ops.read = igb_read_nvm_eerd;
264
nvm->ops.read = igb_read_nvm_spi;
266
nvm->ops.release = igb_release_nvm_82575;
267
switch (hw->mac.type) {
269
nvm->ops.validate = igb_validate_nvm_checksum_82580;
270
nvm->ops.update = igb_update_nvm_checksum_82580;
273
nvm->ops.validate = igb_validate_nvm_checksum_i350;
274
nvm->ops.update = igb_update_nvm_checksum_i350;
277
nvm->ops.validate = igb_validate_nvm_checksum;
278
nvm->ops.update = igb_update_nvm_checksum;
280
nvm->ops.write = igb_write_nvm_spi;
282
/* if part supports SR-IOV then initialize mailbox parameters */
242
286
igb_init_mbx_params_pf(hw);
244
292
/* setup PHY parameters */
245
293
if (phy->media_type != e1000_media_type_copper) {
1747
1795
return ret_val;
1799
* igb_validate_nvm_checksum_with_offset - Validate EEPROM
1801
* @hw: pointer to the HW structure
1802
* @offset: offset in words of the checksum protected region
1804
* Calculates the EEPROM checksum by reading/adding each word of the EEPROM
1805
* and then verifies that the sum of the EEPROM is equal to 0xBABA.
1807
s32 igb_validate_nvm_checksum_with_offset(struct e1000_hw *hw, u16 offset)
1813
for (i = offset; i < ((NVM_CHECKSUM_REG + offset) + 1); i++) {
1814
ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
1816
hw_dbg("NVM Read Error\n");
1819
checksum += nvm_data;
1822
if (checksum != (u16) NVM_SUM) {
1823
hw_dbg("NVM Checksum Invalid\n");
1824
ret_val = -E1000_ERR_NVM;
1833
* igb_update_nvm_checksum_with_offset - Update EEPROM
1835
* @hw: pointer to the HW structure
1836
* @offset: offset in words of the checksum protected region
1838
* Updates the EEPROM checksum by reading/adding each word of the EEPROM
1839
* up to the checksum. Then calculates the EEPROM checksum and writes the
1840
* value to the EEPROM.
1842
s32 igb_update_nvm_checksum_with_offset(struct e1000_hw *hw, u16 offset)
1848
for (i = offset; i < (NVM_CHECKSUM_REG + offset); i++) {
1849
ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
1851
hw_dbg("NVM Read Error while updating checksum.\n");
1854
checksum += nvm_data;
1856
checksum = (u16) NVM_SUM - checksum;
1857
ret_val = hw->nvm.ops.write(hw, (NVM_CHECKSUM_REG + offset), 1,
1860
hw_dbg("NVM Write Error while updating checksum.\n");
1867
* igb_validate_nvm_checksum_82580 - Validate EEPROM checksum
1868
* @hw: pointer to the HW structure
1870
* Calculates the EEPROM section checksum by reading/adding each word of
1871
* the EEPROM and then verifies that the sum of the EEPROM is
1874
static s32 igb_validate_nvm_checksum_82580(struct e1000_hw *hw)
1877
u16 eeprom_regions_count = 1;
1881
ret_val = hw->nvm.ops.read(hw, NVM_COMPATIBILITY_REG_3, 1, &nvm_data);
1883
hw_dbg("NVM Read Error\n");
1887
if (nvm_data & NVM_COMPATIBILITY_BIT_MASK) {
1888
/* if checksums compatibility bit is set validate checksums
1889
* for all 4 ports. */
1890
eeprom_regions_count = 4;
1893
for (j = 0; j < eeprom_regions_count; j++) {
1894
nvm_offset = NVM_82580_LAN_FUNC_OFFSET(j);
1895
ret_val = igb_validate_nvm_checksum_with_offset(hw,
1906
* igb_update_nvm_checksum_82580 - Update EEPROM checksum
1907
* @hw: pointer to the HW structure
1909
* Updates the EEPROM section checksums for all 4 ports by reading/adding
1910
* each word of the EEPROM up to the checksum. Then calculates the EEPROM
1911
* checksum and writes the value to the EEPROM.
1913
static s32 igb_update_nvm_checksum_82580(struct e1000_hw *hw)
1919
ret_val = hw->nvm.ops.read(hw, NVM_COMPATIBILITY_REG_3, 1, &nvm_data);
1921
hw_dbg("NVM Read Error while updating checksum"
1922
" compatibility bit.\n");
1926
if ((nvm_data & NVM_COMPATIBILITY_BIT_MASK) == 0) {
1927
/* set compatibility bit to validate checksums appropriately */
1928
nvm_data = nvm_data | NVM_COMPATIBILITY_BIT_MASK;
1929
ret_val = hw->nvm.ops.write(hw, NVM_COMPATIBILITY_REG_3, 1,
1932
hw_dbg("NVM Write Error while updating checksum"
1933
" compatibility bit.\n");
1938
for (j = 0; j < 4; j++) {
1939
nvm_offset = NVM_82580_LAN_FUNC_OFFSET(j);
1940
ret_val = igb_update_nvm_checksum_with_offset(hw, nvm_offset);
1950
* igb_validate_nvm_checksum_i350 - Validate EEPROM checksum
1951
* @hw: pointer to the HW structure
1953
* Calculates the EEPROM section checksum by reading/adding each word of
1954
* the EEPROM and then verifies that the sum of the EEPROM is
1957
static s32 igb_validate_nvm_checksum_i350(struct e1000_hw *hw)
1963
for (j = 0; j < 4; j++) {
1964
nvm_offset = NVM_82580_LAN_FUNC_OFFSET(j);
1965
ret_val = igb_validate_nvm_checksum_with_offset(hw,
1976
* igb_update_nvm_checksum_i350 - Update EEPROM checksum
1977
* @hw: pointer to the HW structure
1979
* Updates the EEPROM section checksums for all 4 ports by reading/adding
1980
* each word of the EEPROM up to the checksum. Then calculates the EEPROM
1981
* checksum and writes the value to the EEPROM.
1983
static s32 igb_update_nvm_checksum_i350(struct e1000_hw *hw)
1989
for (j = 0; j < 4; j++) {
1990
nvm_offset = NVM_82580_LAN_FUNC_OFFSET(j);
1991
ret_val = igb_update_nvm_checksum_with_offset(hw, nvm_offset);
2001
* igb_set_eee_i350 - Enable/disable EEE support
2002
* @hw: pointer to the HW structure
2004
* Enable/disable EEE based on setting in dev_spec structure.
2007
s32 igb_set_eee_i350(struct e1000_hw *hw)
2010
u32 ipcnfg, eeer, ctrl_ext;
2012
ctrl_ext = rd32(E1000_CTRL_EXT);
2013
if ((hw->mac.type != e1000_i350) ||
2014
(ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK))
2016
ipcnfg = rd32(E1000_IPCNFG);
2017
eeer = rd32(E1000_EEER);
2019
/* enable or disable per user setting */
2020
if (!(hw->dev_spec._82575.eee_disable)) {
2021
ipcnfg |= (E1000_IPCNFG_EEE_1G_AN |
2022
E1000_IPCNFG_EEE_100M_AN);
2023
eeer |= (E1000_EEER_TX_LPI_EN |
2024
E1000_EEER_RX_LPI_EN |
2028
ipcnfg &= ~(E1000_IPCNFG_EEE_1G_AN |
2029
E1000_IPCNFG_EEE_100M_AN);
2030
eeer &= ~(E1000_EEER_TX_LPI_EN |
2031
E1000_EEER_RX_LPI_EN |
2034
wr32(E1000_IPCNFG, ipcnfg);
2035
wr32(E1000_EEER, eeer);
1750
2041
static struct e1000_mac_operations e1000_mac_ops_82575 = {
1751
2042
.init_hw = igb_init_hw_82575,
1752
2043
.check_for_link = igb_check_for_link_82575,