e1000e_nvm.c File Reference

#include "e1000e.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static void e1000e_stop_nvm (struct e1000_hw *hw)
 e1000e_stop_nvm - Terminate EEPROM command : pointer to the HW structure
static void e1000e_reload_nvm (struct e1000_hw *hw)
 e1000e_reload_nvm - Reloads EEPROM : pointer to the HW structure
void e1000e_init_nvm_ops_generic (struct e1000_hw *hw)
 e1000e_init_nvm_ops_generic - Initialize NVM function pointers : pointer to the HW structure
static void e1000e_raise_eec_clk (struct e1000_hw *hw, u32 *eecd)
 e1000e_raise_eec_clk - Raise EEPROM clock : pointer to the HW structure : pointer to the EEPROM
static void e1000e_lower_eec_clk (struct e1000_hw *hw, u32 *eecd)
 e1000e_lower_eec_clk - Lower EEPROM clock : pointer to the HW structure : pointer to the EEPROM
static void e1000e_shift_out_eec_bits (struct e1000_hw *hw, u16 data, u16 count)
 e1000e_shift_out_eec_bits - Shift data bits our to the EEPROM : pointer to the HW structure : data to send to the EEPROM : number of bits to shift out
static u16 e1000e_shift_in_eec_bits (struct e1000_hw *hw, u16 count)
 e1000e_shift_in_eec_bits - Shift data bits in from the EEPROM : pointer to the HW structure : number of bits to shift in
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_acquire_nvm (struct e1000_hw *hw)
 e1000e_acquire_nvm - Generic request for access to EEPROM : pointer to the HW structure
static void e1000e_standby_nvm (struct e1000_hw *hw)
 e1000e_standby_nvm - Return EEPROM to standby state : 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
static s32 e1000e_ready_nvm_eeprom (struct e1000_hw *hw)
 e1000e_ready_nvm_eeprom - Prepares EEPROM for read/write : pointer to the HW structure
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_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_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_mac_addr_generic (struct e1000_hw *hw)
 e1000e_read_mac_addr_generic - Read device MAC address : pointer to the HW structure
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_update_nvm_checksum_generic (struct e1000_hw *hw)
 e1000e_update_nvm_checksum_generic - Update EEPROM checksum : pointer to the HW structure


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static void e1000e_stop_nvm ( struct e1000_hw hw  )  [static]

e1000e_stop_nvm - Terminate EEPROM command : pointer to the HW structure

Terminates the current command by inverting the EEPROM's chip select pin.

Definition at line 252 of file e1000e_nvm.c.

References E1000_EECD_CS, e1000_nvm_eeprom_spi, e1000e_lower_eec_clk(), er32, e1000_hw::nvm, e1000_nvm_info::type, and u32.

Referenced by e1000e_release_nvm().

00253 {
00254         u32 eecd;
00255 
00256         eecd = er32(EECD);
00257         if (hw->nvm.type == e1000_nvm_eeprom_spi) {
00258                 /* Pull CS high */
00259                 eecd |= E1000_EECD_CS;
00260                 e1000e_lower_eec_clk(hw, &eecd);
00261         }
00262 }

static void e1000e_reload_nvm ( struct e1000_hw hw  )  [static]

e1000e_reload_nvm - Reloads EEPROM : pointer to the HW structure

Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the extended control register.

Definition at line 586 of file e1000e_nvm.c.

References E1000_CTRL_EXT_EE_RST, e1e_flush, er32, ew32, u32, and udelay().

Referenced by e1000e_init_nvm_ops_generic().

00587 {
00588         u32 ctrl_ext;
00589 
00590         udelay(10);
00591         ctrl_ext = er32(CTRL_EXT);
00592         ctrl_ext |= E1000_CTRL_EXT_EE_RST;
00593         ew32(CTRL_EXT, ctrl_ext);
00594         e1e_flush();
00595 }

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 }

static void e1000e_raise_eec_clk ( struct e1000_hw hw,
u32 eecd 
) [static]

e1000e_raise_eec_clk - Raise EEPROM clock : pointer to the HW structure : pointer to the EEPROM

Enable/Raise the EEPROM clock bit.

Definition at line 56 of file e1000e_nvm.c.

References e1000_nvm_info::delay_usec, E1000_EECD_SK, e1e_flush, ew32, e1000_hw::nvm, and udelay().

Referenced by e1000e_shift_in_eec_bits(), and e1000e_shift_out_eec_bits().

00057 {
00058         *eecd = *eecd | E1000_EECD_SK;
00059         ew32(EECD, *eecd);
00060         e1e_flush();
00061         udelay(hw->nvm.delay_usec);
00062 }

static void e1000e_lower_eec_clk ( struct e1000_hw hw,
u32 eecd 
) [static]

e1000e_lower_eec_clk - Lower EEPROM clock : pointer to the HW structure : pointer to the EEPROM

Clear/Lower the EEPROM clock bit.

Definition at line 71 of file e1000e_nvm.c.

References e1000_nvm_info::delay_usec, E1000_EECD_SK, e1e_flush, ew32, e1000_hw::nvm, and udelay().

Referenced by e1000e_shift_in_eec_bits(), e1000e_shift_out_eec_bits(), and e1000e_stop_nvm().

00072 {
00073         *eecd = *eecd & ~E1000_EECD_SK;
00074         ew32(EECD, *eecd);
00075         e1e_flush();
00076         udelay(hw->nvm.delay_usec);
00077 }

static void e1000e_shift_out_eec_bits ( struct e1000_hw hw,
u16  data,
u16  count 
) [static]

e1000e_shift_out_eec_bits - Shift data bits our to the EEPROM : pointer to the HW structure : data to send to the EEPROM : number of bits to shift out

We need to shift 'count' bits out to the EEPROM. So, the value in the "data" parameter will be shifted out to the EEPROM one bit at a time. In order to do this, "data" must be broken down into bits.

Definition at line 89 of file e1000e_nvm.c.

References e1000_nvm_info::delay_usec, E1000_EECD_DI, E1000_EECD_DO, e1000_nvm_eeprom_spi, e1000e_lower_eec_clk(), e1000e_raise_eec_clk(), e1e_flush, er32, ew32, e1000_hw::nvm, e1000_nvm_info::type, u32, and udelay().

Referenced by e1000e_ready_nvm_eeprom(), and e1000e_write_nvm_spi().

00090 {
00091         struct e1000_nvm_info *nvm = &hw->nvm;
00092         u32 eecd = er32(EECD);
00093         u32 mask;
00094 
00095         mask = 0x01 << (count - 1);
00096         if (nvm->type == e1000_nvm_eeprom_spi)
00097                 eecd |= E1000_EECD_DO;
00098 
00099         do {
00100                 eecd &= ~E1000_EECD_DI;
00101 
00102                 if (data & mask)
00103                         eecd |= E1000_EECD_DI;
00104 
00105                 ew32(EECD, eecd);
00106                 e1e_flush();
00107 
00108                 udelay(nvm->delay_usec);
00109 
00110                 e1000e_raise_eec_clk(hw, &eecd);
00111                 e1000e_lower_eec_clk(hw, &eecd);
00112 
00113                 mask >>= 1;
00114         } while (mask);
00115 
00116         eecd &= ~E1000_EECD_DI;
00117         ew32(EECD, eecd);
00118 }

static u16 e1000e_shift_in_eec_bits ( struct e1000_hw hw,
u16  count 
) [static]

e1000e_shift_in_eec_bits - Shift data bits in from the EEPROM : pointer to the HW structure : number of bits to shift in

In order to read a register from the EEPROM, we need to shift 'count' bits in from the EEPROM. Bits are "shifted in" by raising the clock input to the EEPROM (setting the SK bit), and then reading the value of the data out "DO" bit. During this "shifting in" process the data in "DI" bit should always be clear.

Definition at line 131 of file e1000e_nvm.c.

References E1000_EECD_DI, E1000_EECD_DO, e1000e_lower_eec_clk(), e1000e_raise_eec_clk(), er32, u16, and u32.

Referenced by e1000e_ready_nvm_eeprom().

00132 {
00133         u32 eecd;
00134         u32 i;
00135         u16 data;
00136 
00137         eecd = er32(EECD);
00138         eecd &= ~(E1000_EECD_DO | E1000_EECD_DI);
00139         data = 0;
00140 
00141         for (i = 0; i < count; i++) {
00142                 data <<= 1;
00143                 e1000e_raise_eec_clk(hw, &eecd);
00144 
00145                 eecd = er32(EECD);
00146 
00147                 eecd &= ~E1000_EECD_DI;
00148                 if (eecd & E1000_EECD_DO)
00149                         data |= 1;
00150 
00151                 e1000e_lower_eec_clk(hw, &eecd);
00152         }
00153 
00154         return data;
00155 }

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

Referenced by e1000e_read_nvm_eerd(), and e1000e_write_nvm_eewr_82571().

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_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().

Referenced by e1000e_acquire_nvm_80003es2lan(), and e1000e_acquire_nvm_82571().

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 }

static void e1000e_standby_nvm ( struct e1000_hw hw  )  [static]

e1000e_standby_nvm - Return EEPROM to standby state : pointer to the HW structure

Return the EEPROM to a standby state.

Definition at line 228 of file e1000e_nvm.c.

References e1000_nvm_info::delay_usec, E1000_EECD_CS, e1000_nvm_eeprom_spi, e1e_flush, er32, ew32, e1000_hw::nvm, e1000_nvm_info::type, u32, and udelay().

Referenced by e1000e_ready_nvm_eeprom(), and e1000e_write_nvm_spi().

00229 {
00230         struct e1000_nvm_info *nvm = &hw->nvm;
00231         u32 eecd = er32(EECD);
00232 
00233         if (nvm->type == e1000_nvm_eeprom_spi) {
00234                 /* Toggle CS to flush commands */
00235                 eecd |= E1000_EECD_CS;
00236                 ew32(EECD, eecd);
00237                 e1e_flush();
00238                 udelay(nvm->delay_usec);
00239                 eecd &= ~E1000_EECD_CS;
00240                 ew32(EECD, eecd);
00241                 e1e_flush();
00242                 udelay(nvm->delay_usec);
00243         }
00244 }

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.

Referenced by e1000e_release_nvm_80003es2lan(), and e1000e_release_nvm_82571().

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 }

static s32 e1000e_ready_nvm_eeprom ( struct e1000_hw hw  )  [static]

e1000e_ready_nvm_eeprom - Prepares EEPROM for read/write : pointer to the HW structure

Setups the EEPROM for reading and writing.

Definition at line 287 of file e1000e_nvm.c.

References E1000_EECD_CS, E1000_EECD_SK, E1000_ERR_NVM, e1000_nvm_eeprom_spi, E1000_SUCCESS, e1000e_shift_in_eec_bits(), e1000e_shift_out_eec_bits(), e1000e_standby_nvm(), e_dbg, er32, ew32, e1000_hw::nvm, NVM_MAX_RETRY_SPI, NVM_RDSR_OPCODE_SPI, NVM_STATUS_RDY_SPI, e1000_nvm_info::opcode_bits, timeout(), e1000_nvm_info::type, u16, u32, u8, and udelay().

Referenced by e1000e_write_nvm_spi().

00288 {
00289         struct e1000_nvm_info *nvm = &hw->nvm;
00290         u32 eecd = er32(EECD);
00291         s32 ret_val = E1000_SUCCESS;
00292         u16 timeout = 0;
00293         u8 spi_stat_reg;
00294 
00295         if (nvm->type == e1000_nvm_eeprom_spi) {
00296                 /* Clear SK and CS */
00297                 eecd &= ~(E1000_EECD_CS | E1000_EECD_SK);
00298                 ew32(EECD, eecd);
00299                 udelay(1);
00300                 timeout = NVM_MAX_RETRY_SPI;
00301 
00302                 /*
00303                  * Read "Status Register" repeatedly until the LSB is cleared.
00304                  * The EEPROM will signal that the command has been completed
00305                  * by clearing bit 0 of the internal status register.  If it's
00306                  * not cleared within 'timeout', then error out.
00307                  */
00308                 while (timeout) {
00309                         e1000e_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI,
00310                                                  hw->nvm.opcode_bits);
00311                         spi_stat_reg = (u8)e1000e_shift_in_eec_bits(hw, 8);
00312                         if (!(spi_stat_reg & NVM_STATUS_RDY_SPI))
00313                                 break;
00314 
00315                         udelay(5);
00316                         e1000e_standby_nvm(hw);
00317                         timeout--;
00318                 }
00319 
00320                 if (!timeout) {
00321                         e_dbg("SPI NVM Status error\n");
00322                         ret_val = -E1000_ERR_NVM;
00323                         goto out;
00324                 }
00325         }
00326 
00327 out:
00328         return ret_val;
00329 }

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.

Referenced by e1000e_init_nvm_params_80003es2lan(), and e1000e_init_nvm_params_82571().

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_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.

Referenced by e1000e_write_nvm_80003es2lan(), and e1000e_write_nvm_82571().

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_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_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_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.

Referenced by e1000e_init_nvm_params_80003es2lan(), e1000e_validate_nvm_checksum_82571(), and e1000e_validate_nvm_checksum_ich8lan().

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_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.

Referenced by e1000e_init_nvm_params_80003es2lan(), e1000e_update_nvm_checksum_82571(), and e1000e_update_nvm_checksum_ich8lan().

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 }


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