e1000e_nvm.h File Reference

Go to the source code of this file.

Defines

#define E1000_STM_OPCODE   0xDB00

Functions

 FILE_LICENCE (GPL2_OR_LATER)
void e1000e_init_nvm_ops_generic (struct e1000_hw *hw)
 e1000e_init_nvm_ops_generic - Initialize NVM function pointers : pointer to the HW structure
s32 e1000e_acquire_nvm (struct e1000_hw *hw)
 e1000e_acquire_nvm - Generic request for access to EEPROM : pointer to the HW structure
s32 e1000e_poll_eerd_eewr_done (struct e1000_hw *hw, int ee_reg)
 e1000e_poll_eerd_eewr_done - Poll for EEPROM read/write completion : pointer to the HW structure : EEPROM flag for polling
s32 e1000e_read_mac_addr_generic (struct e1000_hw *hw)
 e1000e_read_mac_addr_generic - Read device MAC address : pointer to the HW structure
s32 e1000e_read_pba_num (struct e1000_hw *hw, u32 *pba_num)
 e1000e_read_pba_num - Read device part number : pointer to the HW structure : pointer to device part number
s32 e1000e_read_nvm_eerd (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 e1000e_read_nvm_eerd - Reads EEPROM using EERD register : pointer to the HW structure : offset of word in the EEPROM to read : number of words to read : word read from the EEPROM
s32 e1000e_valid_led_default (struct e1000_hw *hw, u16 *data)
 e1000e_valid_led_default - Verify a valid default LED config : pointer to the HW structure : pointer to the NVM (EEPROM)
s32 e1000e_validate_nvm_checksum_generic (struct e1000_hw *hw)
 e1000e_validate_nvm_checksum_generic - Validate EEPROM checksum : pointer to the HW structure
s32 e1000e_write_nvm_eewr (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
s32 e1000e_write_nvm_spi (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 e1000e_write_nvm_spi - Write to EEPROM using SPI : pointer to the HW structure : offset within the EEPROM to be written to : number of words to write : 16 bit word(s) to be written to the EEPROM
s32 e1000e_update_nvm_checksum_generic (struct e1000_hw *hw)
 e1000e_update_nvm_checksum_generic - Update EEPROM checksum : pointer to the HW structure
void e1000e_release_nvm (struct e1000_hw *hw)
 e1000e_release_nvm - Release exclusive access to EEPROM : pointer to the HW structure


Define Documentation

#define E1000_STM_OPCODE   0xDB00

Definition at line 51 of file e1000e_nvm.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

void e1000e_init_nvm_ops_generic ( struct e1000_hw hw  ) 

e1000e_init_nvm_ops_generic - Initialize NVM function pointers : pointer to the HW structure

Setups up the function pointers to no-op functions

Definition at line 42 of file e1000e_nvm.c.

References e1000e_reload_nvm(), e1000_hw::nvm, e1000_nvm_info::ops, and e1000_nvm_operations::reload.

Referenced by e1000e_init_function_pointers_80003es2lan(), e1000e_init_function_pointers_82571(), and e1000e_init_function_pointers_ich8lan().

00043 {
00044         struct e1000_nvm_info *nvm = &hw->nvm;
00045         /* Initialize function pointers */
00046         nvm->ops.reload = e1000e_reload_nvm;
00047 }

s32 e1000e_acquire_nvm ( struct e1000_hw hw  ) 

e1000e_acquire_nvm - Generic request for access to EEPROM : pointer to the HW structure

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 -E1000_ERR_NVM (-1).

Definition at line 196 of file e1000e_nvm.c.

References E1000_EECD_GNT, E1000_EECD_REQ, E1000_ERR_NVM, E1000_NVM_GRANT_ATTEMPTS, E1000_SUCCESS, e_dbg, er32, ew32, timeout(), u32, and udelay().

00197 {
00198         u32 eecd = er32(EECD);
00199         s32 timeout = E1000_NVM_GRANT_ATTEMPTS;
00200         s32 ret_val = E1000_SUCCESS;
00201 
00202         ew32(EECD, eecd | E1000_EECD_REQ);
00203         eecd = er32(EECD);
00204         while (timeout) {
00205                 if (eecd & E1000_EECD_GNT)
00206                         break;
00207                 udelay(5);
00208                 eecd = er32(EECD);
00209                 timeout--;
00210         }
00211 
00212         if (!timeout) {
00213                 eecd &= ~E1000_EECD_REQ;
00214                 ew32(EECD, eecd);
00215                 e_dbg("Could not acquire NVM grant\n");
00216                 ret_val = -E1000_ERR_NVM;
00217         }
00218 
00219         return ret_val;
00220 }

s32 e1000e_poll_eerd_eewr_done ( struct e1000_hw hw,
int  ee_reg 
)

e1000e_poll_eerd_eewr_done - Poll for EEPROM read/write completion : pointer to the HW structure : EEPROM flag for polling

Polls the EEPROM status bit for either read or write completion based upon the value of 'ee_reg'.

Definition at line 165 of file e1000e_nvm.c.

References E1000_ERR_NVM, E1000_NVM_POLL_READ, E1000_NVM_RW_REG_DONE, E1000_SUCCESS, er32, u32, and udelay().

00166 {
00167         u32 attempts = 100000;
00168         u32 i, reg = 0;
00169         s32 ret_val = -E1000_ERR_NVM;
00170 
00171         for (i = 0; i < attempts; i++) {
00172                 if (ee_reg == E1000_NVM_POLL_READ)
00173                         reg = er32(EERD);
00174                 else
00175                         reg = er32(EEWR);
00176 
00177                 if (reg & E1000_NVM_RW_REG_DONE) {
00178                         ret_val = E1000_SUCCESS;
00179                         break;
00180                 }
00181 
00182                 udelay(5);
00183         }
00184 
00185         return ret_val;
00186 }

s32 e1000e_read_mac_addr_generic ( struct e1000_hw hw  ) 

e1000e_read_mac_addr_generic - Read device MAC address : pointer to the HW structure

Reads the device MAC address from the EEPROM and stores the value. Since devices with two ports use the same EEPROM, we increment the last bit in the MAC address for the second port.

Definition at line 495 of file e1000e_nvm.c.

References e1000_mac_info::addr, E1000_RAH_MAC_ADDR_LEN, E1000_RAL_MAC_ADDR_LEN, E1000_SUCCESS, er32, ETH_ADDR_LEN, e1000_hw::mac, e1000_mac_info::perm_addr, u16, u32, and u8.

Referenced by e1000e_init_mac_ops_generic(), e1000e_read_mac_addr(), e1000e_read_mac_addr_80003es2lan(), and e1000e_read_mac_addr_82571().

00496 {
00497         u32 rar_high;
00498         u32 rar_low;
00499         u16 i;
00500 
00501         rar_high = er32(RAH(0));
00502         rar_low = er32(RAL(0));
00503 
00504         for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++)
00505                 hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8));
00506 
00507         for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++)
00508                 hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8));
00509 
00510         for (i = 0; i < ETH_ADDR_LEN; i++)
00511                 hw->mac.addr[i] = hw->mac.perm_addr[i];
00512 
00513         return E1000_SUCCESS;
00514 }

s32 e1000e_read_pba_num ( struct e1000_hw hw,
u32 pba_num 
)

e1000e_read_pba_num - Read device part number : pointer to the HW structure : pointer to device part number

Reads the product board assembly (PBA) number from the EEPROM and stores the value in pba_num.

Definition at line 464 of file e1000e_nvm.c.

References e1000e_read_nvm(), e_dbg, NVM_PBA_OFFSET_0, NVM_PBA_OFFSET_1, u16, and u32.

00465 {
00466         s32  ret_val;
00467         u16 nvm_data;
00468 
00469         ret_val = e1000e_read_nvm(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
00470         if (ret_val) {
00471                 e_dbg("NVM Read Error\n");
00472                 goto out;
00473         }
00474         *pba_num = (u32)(nvm_data << 16);
00475 
00476         ret_val = e1000e_read_nvm(hw, NVM_PBA_OFFSET_1, 1, &nvm_data);
00477         if (ret_val) {
00478                 e_dbg("NVM Read Error\n");
00479                 goto out;
00480         }
00481         *pba_num |= nvm_data;
00482 
00483 out:
00484         return ret_val;
00485 }

s32 e1000e_read_nvm_eerd ( struct e1000_hw hw,
u16  offset,
u16  words,
u16 data 
)

e1000e_read_nvm_eerd - Reads EEPROM using EERD register : pointer to the HW structure : offset of word in the EEPROM to read : number of words to read : word read from the EEPROM

Reads a 16 bit word from the EEPROM using the EERD register.

Definition at line 340 of file e1000e_nvm.c.

References E1000_ERR_NVM, E1000_NVM_POLL_READ, E1000_NVM_RW_ADDR_SHIFT, E1000_NVM_RW_REG_DATA, E1000_NVM_RW_REG_START, E1000_SUCCESS, e1000e_poll_eerd_eewr_done(), e_dbg, er32, ew32, e1000_hw::nvm, u32, and e1000_nvm_info::word_size.

00341 {
00342         struct e1000_nvm_info *nvm = &hw->nvm;
00343         u32 i, eerd = 0;
00344         s32 ret_val = E1000_SUCCESS;
00345 
00346         /*
00347          * A check for invalid values:  offset too large, too many words,
00348          * too many words for the offset, and not enough words.
00349          */
00350         if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
00351             (words == 0)) {
00352                 e_dbg("nvm parameter(s) out of bounds\n");
00353                 ret_val = -E1000_ERR_NVM;
00354                 goto out;
00355         }
00356 
00357         for (i = 0; i < words; i++) {
00358                 eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) +
00359                        E1000_NVM_RW_REG_START;
00360 
00361                 ew32(EERD, eerd);
00362                 ret_val = e1000e_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ);
00363                 if (ret_val)
00364                         break;
00365 
00366                 data[i] = (er32(EERD) >>
00367                            E1000_NVM_RW_REG_DATA);
00368         }
00369 
00370 out:
00371         return ret_val;
00372 }

s32 e1000e_valid_led_default ( struct e1000_hw hw,
u16 data 
)

e1000e_valid_led_default - Verify a valid default LED config : pointer to the HW structure : pointer to the NVM (EEPROM)

Read the EEPROM for the current default LED configuration. If the LED configuration is not valid, set to a valid LED configuration.

Definition at line 1492 of file e1000e_mac.c.

References e1000e_read_nvm(), e_dbg, ID_LED_DEFAULT, ID_LED_RESERVED_0000, ID_LED_RESERVED_FFFF, and NVM_ID_LED_SETTINGS.

01493 {
01494         s32 ret_val;
01495 
01496         ret_val = e1000e_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data);
01497         if (ret_val) {
01498                 e_dbg("NVM Read Error\n");
01499                 goto out;
01500         }
01501 
01502         if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
01503                 *data = ID_LED_DEFAULT;
01504 
01505 out:
01506         return ret_val;
01507 }

s32 e1000e_validate_nvm_checksum_generic ( struct e1000_hw hw  ) 

e1000e_validate_nvm_checksum_generic - Validate EEPROM checksum : 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.

Definition at line 523 of file e1000e_nvm.c.

References E1000_ERR_NVM, E1000_SUCCESS, e1000e_read_nvm(), e_dbg, NVM_CHECKSUM_REG, NVM_SUM, and u16.

00524 {
00525         s32 ret_val = E1000_SUCCESS;
00526         u16 checksum = 0;
00527         u16 i, nvm_data;
00528 
00529         for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
00530                 ret_val = e1000e_read_nvm(hw, i, 1, &nvm_data);
00531                 if (ret_val) {
00532                         e_dbg("NVM Read Error\n");
00533                         goto out;
00534                 }
00535                 checksum += nvm_data;
00536         }
00537 
00538         if (checksum != (u16) NVM_SUM) {
00539                 e_dbg("NVM Checksum Invalid\n");
00540                 ret_val = -E1000_ERR_NVM;
00541                 goto out;
00542         }
00543 
00544 out:
00545         return ret_val;
00546 }

s32 e1000e_write_nvm_eewr ( struct e1000_hw hw,
u16  offset,
u16  words,
u16 data 
)

s32 e1000e_write_nvm_spi ( struct e1000_hw hw,
u16  offset,
u16  words,
u16 data 
)

e1000e_write_nvm_spi - Write to EEPROM using SPI : pointer to the HW structure : offset within the EEPROM to be written to : number of words to write : 16 bit word(s) to be written to the EEPROM

Writes data to EEPROM at offset using SPI interface.

If e1000e_update_nvm_checksum is not called after this function , the EEPROM will most likely contain an invalid checksum.

Definition at line 386 of file e1000e_nvm.c.

References e1000_nvm_operations::acquire, e1000_nvm_info::address_bits, E1000_ERR_NVM, e1000e_ready_nvm_eeprom(), e1000e_shift_out_eec_bits(), e1000e_standby_nvm(), e_dbg, msleep, e1000_hw::nvm, NVM_A8_OPCODE_SPI, NVM_WREN_OPCODE_SPI, NVM_WRITE_OPCODE_SPI, e1000_nvm_info::opcode_bits, e1000_nvm_info::ops, e1000_nvm_info::page_size, e1000_nvm_operations::release, u16, u8, and e1000_nvm_info::word_size.

00387 {
00388         struct e1000_nvm_info *nvm = &hw->nvm;
00389         s32 ret_val;
00390         u16 widx = 0;
00391 
00392         /*
00393          * A check for invalid values:  offset too large, too many words,
00394          * and not enough words.
00395          */
00396         if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
00397             (words == 0)) {
00398                 e_dbg("nvm parameter(s) out of bounds\n");
00399                 ret_val = -E1000_ERR_NVM;
00400                 goto out;
00401         }
00402 
00403         ret_val = nvm->ops.acquire(hw);
00404         if (ret_val)
00405                 goto out;
00406 
00407         while (widx < words) {
00408                 u8 write_opcode = NVM_WRITE_OPCODE_SPI;
00409 
00410                 ret_val = e1000e_ready_nvm_eeprom(hw);
00411                 if (ret_val)
00412                         goto release;
00413 
00414                 e1000e_standby_nvm(hw);
00415 
00416                 /* Send the WRITE ENABLE command (8 bit opcode) */
00417                 e1000e_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI,
00418                                          nvm->opcode_bits);
00419 
00420                 e1000e_standby_nvm(hw);
00421 
00422                 /*
00423                  * Some SPI eeproms use the 8th address bit embedded in the
00424                  * opcode
00425                  */
00426                 if ((nvm->address_bits == 8) && (offset >= 128))
00427                         write_opcode |= NVM_A8_OPCODE_SPI;
00428 
00429                 /* Send the Write command (8-bit opcode + addr) */
00430                 e1000e_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits);
00431                 e1000e_shift_out_eec_bits(hw, (u16)((offset + widx) * 2),
00432                                          nvm->address_bits);
00433 
00434                 /* Loop to allow for up to whole page write of eeprom */
00435                 while (widx < words) {
00436                         u16 word_out = data[widx];
00437                         word_out = (word_out >> 8) | (word_out << 8);
00438                         e1000e_shift_out_eec_bits(hw, word_out, 16);
00439                         widx++;
00440 
00441                         if ((((offset + widx) * 2) % nvm->page_size) == 0) {
00442                                 e1000e_standby_nvm(hw);
00443                                 break;
00444                         }
00445                 }
00446         }
00447 
00448         msleep(10);
00449 release:
00450         nvm->ops.release(hw);
00451 
00452 out:
00453         return ret_val;
00454 }

s32 e1000e_update_nvm_checksum_generic ( struct e1000_hw hw  ) 

e1000e_update_nvm_checksum_generic - Update EEPROM checksum : 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.

Definition at line 556 of file e1000e_nvm.c.

References e1000e_read_nvm(), e1000e_write_nvm(), e_dbg, NVM_CHECKSUM_REG, NVM_SUM, and u16.

00557 {
00558         s32  ret_val;
00559         u16 checksum = 0;
00560         u16 i, nvm_data;
00561 
00562         for (i = 0; i < NVM_CHECKSUM_REG; i++) {
00563                 ret_val = e1000e_read_nvm(hw, i, 1, &nvm_data);
00564                 if (ret_val) {
00565                         e_dbg("NVM Read Error while updating checksum.\n");
00566                         goto out;
00567                 }
00568                 checksum += nvm_data;
00569         }
00570         checksum = (u16) NVM_SUM - checksum;
00571         ret_val = e1000e_write_nvm(hw, NVM_CHECKSUM_REG, 1, &checksum);
00572         if (ret_val)
00573                 e_dbg("NVM Write Error while updating checksum.\n");
00574 
00575 out:
00576         return ret_val;
00577 }

void e1000e_release_nvm ( struct e1000_hw hw  ) 

e1000e_release_nvm - Release exclusive access to EEPROM : pointer to the HW structure

Stop any current commands to the EEPROM and clear the EEPROM request bit.

Definition at line 270 of file e1000e_nvm.c.

References E1000_EECD_REQ, e1000e_stop_nvm(), er32, ew32, and u32.

00271 {
00272         u32 eecd;
00273 
00274         e1000e_stop_nvm(hw);
00275 
00276         eecd = er32(EECD);
00277         eecd &= ~E1000_EECD_REQ;
00278         ew32(EECD, eecd);
00279 }


Generated on Tue Apr 6 20:01:30 2010 for gPXE by  doxygen 1.5.7.1