e1000_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 e1000_init_nvm_ops_generic (struct e1000_hw *hw)
 e1000_init_nvm_ops_generic - Initialize NVM function pointers : pointer to the HW structure
s32 e1000_null_read_nvm (struct e1000_hw *hw, u16 a, u16 b, u16 *c)
void e1000_null_nvm_generic (struct e1000_hw *hw)
s32 e1000_null_led_default (struct e1000_hw *hw, u16 *data)
s32 e1000_null_write_nvm (struct e1000_hw *hw, u16 a, u16 b, u16 *c)
s32 e1000_acquire_nvm_generic (struct e1000_hw *hw)
 e1000_acquire_nvm_generic - Generic request for access to EEPROM : pointer to the HW structure
s32 e1000_poll_eerd_eewr_done (struct e1000_hw *hw, int ee_reg)
 e1000_poll_eerd_eewr_done - Poll for EEPROM read/write completion : pointer to the HW structure : EEPROM flag for polling
s32 e1000_read_mac_addr_generic (struct e1000_hw *hw)
 e1000_read_mac_addr_generic - Read device MAC address : pointer to the HW structure
s32 e1000_read_pba_num_generic (struct e1000_hw *hw, u32 *pba_num)
 e1000_read_pba_num_generic - Read device part number : pointer to the HW structure : pointer to device part number
s32 e1000_read_nvm_spi (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 e1000_read_nvm_spi - Read EEPROM's using SPI : pointer to the HW structure : offset of word in the EEPROM to read : number of words to read : word read from the EEPROM
s32 e1000_read_nvm_microwire (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 e1000_read_nvm_microwire - Reads EEPROM's using microwire : pointer to the HW structure : offset of word in the EEPROM to read : number of words to read : word read from the EEPROM
s32 e1000_read_nvm_eerd (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 e1000_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 e1000_valid_led_default_generic (struct e1000_hw *hw, u16 *data)
 e1000_valid_led_default_generic - Verify a valid default LED config : pointer to the HW structure : pointer to the NVM (EEPROM)
s32 e1000_validate_nvm_checksum_generic (struct e1000_hw *hw)
 e1000_validate_nvm_checksum_generic - Validate EEPROM checksum : pointer to the HW structure
s32 e1000_write_nvm_eewr (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
s32 e1000_write_nvm_microwire (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 e1000_write_nvm_microwire - Writes EEPROM using microwire : 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 e1000_write_nvm_spi (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 e1000_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 e1000_update_nvm_checksum_generic (struct e1000_hw *hw)
 e1000_update_nvm_checksum_generic - Update EEPROM checksum : pointer to the HW structure
void e1000_stop_nvm (struct e1000_hw *hw)
 e1000_stop_nvm - Terminate EEPROM command : pointer to the HW structure
void e1000_release_nvm_generic (struct e1000_hw *hw)
 e1000_release_nvm_generic - Release exclusive access to EEPROM : pointer to the HW structure


Define Documentation

#define E1000_STM_OPCODE   0xDB00

Definition at line 61 of file e1000_nvm.h.

Referenced by e1000e_update_nvm_checksum_82571().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

void e1000_init_nvm_ops_generic ( struct e1000_hw hw  ) 

s32 e1000_null_read_nvm ( struct e1000_hw hw,
u16  a,
u16  b,
u16 c 
)

void e1000_null_nvm_generic ( struct e1000_hw hw  ) 

s32 e1000_null_led_default ( struct e1000_hw hw,
u16 data 
)

s32 e1000_null_write_nvm ( struct e1000_hw hw,
u16  a,
u16  b,
u16 c 
)

s32 e1000_acquire_nvm_generic ( struct e1000_hw hw  ) 

e1000_acquire_nvm_generic - 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 258 of file e1000_nvm.c.

References DEBUGFUNC, DEBUGOUT, E1000_EECD, E1000_EECD_GNT, E1000_EECD_REQ, E1000_ERR_NVM, E1000_NVM_GRANT_ATTEMPTS, E1000_READ_REG, E1000_SUCCESS, E1000_WRITE_REG, timeout(), u32, and usec_delay.

Referenced by e1000_init_nvm_params_82540(), and e1000_init_nvm_params_82541().

00259 {
00260         u32 eecd = E1000_READ_REG(hw, E1000_EECD);
00261         s32 timeout = E1000_NVM_GRANT_ATTEMPTS;
00262         s32 ret_val = E1000_SUCCESS;
00263 
00264         DEBUGFUNC("e1000_acquire_nvm_generic");
00265 
00266         E1000_WRITE_REG(hw, E1000_EECD, eecd | E1000_EECD_REQ);
00267         eecd = E1000_READ_REG(hw, E1000_EECD);
00268 
00269         while (timeout) {
00270                 if (eecd & E1000_EECD_GNT)
00271                         break;
00272                 usec_delay(5);
00273                 eecd = E1000_READ_REG(hw, E1000_EECD);
00274                 timeout--;
00275         }
00276 
00277         if (!timeout) {
00278                 eecd &= ~E1000_EECD_REQ;
00279                 E1000_WRITE_REG(hw, E1000_EECD, eecd);
00280                 DEBUGOUT("Could not acquire NVM grant\n");
00281                 ret_val = -E1000_ERR_NVM;
00282         }
00283 
00284         return ret_val;
00285 }

s32 e1000_poll_eerd_eewr_done ( struct e1000_hw hw,
int  ee_reg 
)

e1000_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 225 of file e1000_nvm.c.

References DEBUGFUNC, E1000_EERD, E1000_EEWR, E1000_ERR_NVM, E1000_NVM_POLL_READ, E1000_NVM_RW_REG_DONE, E1000_READ_REG, E1000_SUCCESS, u32, and usec_delay.

Referenced by e1000_read_nvm_eerd().

00226 {
00227         u32 attempts = 100000;
00228         u32 i, reg = 0;
00229         s32 ret_val = -E1000_ERR_NVM;
00230 
00231         DEBUGFUNC("e1000_poll_eerd_eewr_done");
00232 
00233         for (i = 0; i < attempts; i++) {
00234                 if (ee_reg == E1000_NVM_POLL_READ)
00235                         reg = E1000_READ_REG(hw, E1000_EERD);
00236                 else
00237                         reg = E1000_READ_REG(hw, E1000_EEWR);
00238 
00239                 if (reg & E1000_NVM_RW_REG_DONE) {
00240                         ret_val = E1000_SUCCESS;
00241                         break;
00242                 }
00243 
00244                 usec_delay(5);
00245         }
00246 
00247         return ret_val;
00248 }

s32 e1000_read_mac_addr_generic ( struct e1000_hw hw  ) 

e1000_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 817 of file e1000_nvm.c.

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

Referenced by e1000_init_mac_ops_generic(), and e1000_read_mac_addr().

00818 {
00819         u32 rar_high;
00820         u32 rar_low;
00821         u16 i;
00822 
00823         rar_high = E1000_READ_REG(hw, E1000_RAH(0));
00824         rar_low = E1000_READ_REG(hw, E1000_RAL(0));
00825 
00826         for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++)
00827                 hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8));
00828 
00829         for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++)
00830                 hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8));
00831 
00832         for (i = 0; i < ETH_ADDR_LEN; i++)
00833                 hw->mac.addr[i] = hw->mac.perm_addr[i];
00834 
00835         return E1000_SUCCESS;
00836 }

s32 e1000_read_pba_num_generic ( struct e1000_hw hw,
u32 pba_num 
)

e1000_read_pba_num_generic - 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 784 of file e1000_nvm.c.

References DEBUGFUNC, DEBUGOUT, e1000_hw::nvm, NVM_PBA_OFFSET_0, NVM_PBA_OFFSET_1, e1000_nvm_info::ops, e1000_nvm_operations::read, u16, and u32.

Referenced by e1000_read_pba_num().

00785 {
00786         s32  ret_val;
00787         u16 nvm_data;
00788 
00789         DEBUGFUNC("e1000_read_pba_num_generic");
00790 
00791         ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
00792         if (ret_val) {
00793                 DEBUGOUT("NVM Read Error\n");
00794                 goto out;
00795         }
00796         *pba_num = (u32)(nvm_data << 16);
00797 
00798         ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_1, 1, &nvm_data);
00799         if (ret_val) {
00800                 DEBUGOUT("NVM Read Error\n");
00801                 goto out;
00802         }
00803         *pba_num |= nvm_data;
00804 
00805 out:
00806         return ret_val;
00807 }

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

e1000_read_nvm_spi - Read EEPROM's using SPI : 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.

Definition at line 443 of file e1000_nvm.c.

References e1000_nvm_operations::acquire, e1000_nvm_info::address_bits, DEBUGFUNC, DEBUGOUT, E1000_ERR_NVM, e1000_ready_nvm_eeprom(), e1000_shift_in_eec_bits(), e1000_shift_out_eec_bits(), e1000_standby_nvm(), e1000_hw::nvm, NVM_A8_OPCODE_SPI, NVM_READ_OPCODE_SPI, e1000_nvm_info::opcode_bits, e1000_nvm_info::ops, e1000_nvm_operations::release, u16, u32, u8, and e1000_nvm_info::word_size.

Referenced by e1000_init_nvm_params_82541().

00444 {
00445         struct e1000_nvm_info *nvm = &hw->nvm;
00446         u32 i = 0;
00447         s32 ret_val;
00448         u16 word_in;
00449         u8 read_opcode = NVM_READ_OPCODE_SPI;
00450 
00451         DEBUGFUNC("e1000_read_nvm_spi");
00452 
00453         /*
00454          * A check for invalid values:  offset too large, too many words,
00455          * and not enough words.
00456          */
00457         if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
00458             (words == 0)) {
00459                 DEBUGOUT("nvm parameter(s) out of bounds\n");
00460                 ret_val = -E1000_ERR_NVM;
00461                 goto out;
00462         }
00463 
00464         ret_val = nvm->ops.acquire(hw);
00465         if (ret_val)
00466                 goto out;
00467 
00468         ret_val = e1000_ready_nvm_eeprom(hw);
00469         if (ret_val)
00470                 goto release;
00471 
00472         e1000_standby_nvm(hw);
00473 
00474         if ((nvm->address_bits == 8) && (offset >= 128))
00475                 read_opcode |= NVM_A8_OPCODE_SPI;
00476 
00477         /* Send the READ command (opcode + addr) */
00478         e1000_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits);
00479         e1000_shift_out_eec_bits(hw, (u16)(offset*2), nvm->address_bits);
00480 
00481         /*
00482          * Read the data.  SPI NVMs increment the address with each byte
00483          * read and will roll over if reading beyond the end.  This allows
00484          * us to read the whole NVM from any offset
00485          */
00486         for (i = 0; i < words; i++) {
00487                 word_in = e1000_shift_in_eec_bits(hw, 16);
00488                 data[i] = (word_in >> 8) | (word_in << 8);
00489         }
00490 
00491 release:
00492         nvm->ops.release(hw);
00493 
00494 out:
00495         return ret_val;
00496 }

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

e1000_read_nvm_microwire - Reads EEPROM's using microwire : 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.

Definition at line 507 of file e1000_nvm.c.

References e1000_nvm_operations::acquire, e1000_nvm_info::address_bits, DEBUGFUNC, DEBUGOUT, E1000_ERR_NVM, e1000_ready_nvm_eeprom(), e1000_shift_in_eec_bits(), e1000_shift_out_eec_bits(), e1000_standby_nvm(), e1000_hw::nvm, NVM_READ_OPCODE_MICROWIRE, e1000_nvm_info::opcode_bits, e1000_nvm_info::ops, e1000_nvm_operations::release, u16, u32, u8, and e1000_nvm_info::word_size.

Referenced by e1000_init_nvm_params_82540(), e1000_init_nvm_params_82541(), e1000_init_nvm_params_82542(), and e1000_init_nvm_params_82543().

00509 {
00510         struct e1000_nvm_info *nvm = &hw->nvm;
00511         u32 i = 0;
00512         s32 ret_val;
00513         u8 read_opcode = NVM_READ_OPCODE_MICROWIRE;
00514 
00515         DEBUGFUNC("e1000_read_nvm_microwire");
00516 
00517         /*
00518          * A check for invalid values:  offset too large, too many words,
00519          * and not enough words.
00520          */
00521         if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
00522             (words == 0)) {
00523                 DEBUGOUT("nvm parameter(s) out of bounds\n");
00524                 ret_val = -E1000_ERR_NVM;
00525                 goto out;
00526         }
00527 
00528         ret_val = nvm->ops.acquire(hw);
00529         if (ret_val)
00530                 goto out;
00531 
00532         ret_val = e1000_ready_nvm_eeprom(hw);
00533         if (ret_val)
00534                 goto release;
00535 
00536         for (i = 0; i < words; i++) {
00537                 /* Send the READ command (opcode + addr) */
00538                 e1000_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits);
00539                 e1000_shift_out_eec_bits(hw, (u16)(offset + i),
00540                                         nvm->address_bits);
00541 
00542                 /*
00543                  * Read the data.  For microwire, each word requires the
00544                  * overhead of setup and tear-down.
00545                  */
00546                 data[i] = e1000_shift_in_eec_bits(hw, 16);
00547                 e1000_standby_nvm(hw);
00548         }
00549 
00550 release:
00551         nvm->ops.release(hw);
00552 
00553 out:
00554         return ret_val;
00555 }

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

e1000_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 566 of file e1000_nvm.c.

References DEBUGFUNC, DEBUGOUT, E1000_EERD, E1000_ERR_NVM, E1000_NVM_POLL_READ, E1000_NVM_RW_ADDR_SHIFT, E1000_NVM_RW_REG_DATA, E1000_NVM_RW_REG_START, e1000_poll_eerd_eewr_done(), E1000_READ_REG, E1000_SUCCESS, E1000_WRITE_REG, e1000_hw::nvm, u32, and e1000_nvm_info::word_size.

00567 {
00568         struct e1000_nvm_info *nvm = &hw->nvm;
00569         u32 i, eerd = 0;
00570         s32 ret_val = E1000_SUCCESS;
00571 
00572         DEBUGFUNC("e1000_read_nvm_eerd");
00573 
00574         /*
00575          * A check for invalid values:  offset too large, too many words,
00576          * too many words for the offset, and not enough words.
00577          */
00578         if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
00579             (words == 0)) {
00580                 DEBUGOUT("nvm parameter(s) out of bounds\n");
00581                 ret_val = -E1000_ERR_NVM;
00582                 goto out;
00583         }
00584 
00585         for (i = 0; i < words; i++) {
00586                 eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) +
00587                        E1000_NVM_RW_REG_START;
00588 
00589                 E1000_WRITE_REG(hw, E1000_EERD, eerd);
00590                 ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ);
00591                 if (ret_val)
00592                         break;
00593 
00594                 data[i] = (E1000_READ_REG(hw, E1000_EERD) >>
00595                            E1000_NVM_RW_REG_DATA);
00596         }
00597 
00598 out:
00599         return ret_val;
00600 }

s32 e1000_valid_led_default_generic ( struct e1000_hw hw,
u16 data 
)

e1000_valid_led_default_generic - 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 1775 of file e1000_mac.c.

References DEBUGFUNC, DEBUGOUT, ID_LED_DEFAULT, ID_LED_RESERVED_0000, ID_LED_RESERVED_FFFF, e1000_hw::nvm, NVM_ID_LED_SETTINGS, e1000_nvm_info::ops, and e1000_nvm_operations::read.

Referenced by e1000_init_nvm_params_82540(), e1000_init_nvm_params_82541(), and e1000_init_nvm_params_82543().

01776 {
01777         s32 ret_val;
01778 
01779         DEBUGFUNC("e1000_valid_led_default_generic");
01780 
01781         ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
01782         if (ret_val) {
01783                 DEBUGOUT("NVM Read Error\n");
01784                 goto out;
01785         }
01786 
01787         if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
01788                 *data = ID_LED_DEFAULT;
01789 
01790 out:
01791         return ret_val;
01792 }

s32 e1000_validate_nvm_checksum_generic ( struct e1000_hw hw  ) 

e1000_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 845 of file e1000_nvm.c.

References DEBUGFUNC, DEBUGOUT, E1000_ERR_NVM, E1000_SUCCESS, e1000_hw::nvm, NVM_CHECKSUM_REG, NVM_SUM, e1000_nvm_info::ops, e1000_nvm_operations::read, and u16.

Referenced by e1000_init_nvm_params_82540(), e1000_init_nvm_params_82541(), e1000_init_nvm_params_82542(), and e1000_init_nvm_params_82543().

00846 {
00847         s32 ret_val = E1000_SUCCESS;
00848         u16 checksum = 0;
00849         u16 i, nvm_data;
00850 
00851         DEBUGFUNC("e1000_validate_nvm_checksum_generic");
00852 
00853         for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
00854                 ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
00855                 if (ret_val) {
00856                         DEBUGOUT("NVM Read Error\n");
00857                         goto out;
00858                 }
00859                 checksum += nvm_data;
00860         }
00861 
00862         if (checksum != (u16) NVM_SUM) {
00863                 DEBUGOUT("NVM Checksum Invalid\n");
00864                 ret_val = -E1000_ERR_NVM;
00865                 goto out;
00866         }
00867 
00868 out:
00869         return ret_val;
00870 }

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

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

e1000_write_nvm_microwire - Writes EEPROM using microwire : 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 microwire interface.

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

Definition at line 698 of file e1000_nvm.c.

References e1000_nvm_operations::acquire, e1000_nvm_info::address_bits, DEBUGFUNC, DEBUGOUT, E1000_EECD, E1000_EECD_DO, E1000_ERR_NVM, E1000_READ_REG, e1000_ready_nvm_eeprom(), e1000_shift_out_eec_bits(), e1000_standby_nvm(), e1000_hw::nvm, NVM_EWDS_OPCODE_MICROWIRE, NVM_EWEN_OPCODE_MICROWIRE, NVM_WRITE_OPCODE_MICROWIRE, e1000_nvm_info::opcode_bits, e1000_nvm_info::ops, e1000_nvm_operations::release, u16, u32, usec_delay, and e1000_nvm_info::word_size.

Referenced by e1000_init_nvm_params_82540(), e1000_init_nvm_params_82541(), e1000_init_nvm_params_82542(), and e1000_init_nvm_params_82543().

00700 {
00701         struct e1000_nvm_info *nvm = &hw->nvm;
00702         s32  ret_val;
00703         u32 eecd;
00704         u16 words_written = 0;
00705         u16 widx = 0;
00706 
00707         DEBUGFUNC("e1000_write_nvm_microwire");
00708 
00709         /*
00710          * A check for invalid values:  offset too large, too many words,
00711          * and not enough words.
00712          */
00713         if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
00714             (words == 0)) {
00715                 DEBUGOUT("nvm parameter(s) out of bounds\n");
00716                 ret_val = -E1000_ERR_NVM;
00717                 goto out;
00718         }
00719 
00720         ret_val = nvm->ops.acquire(hw);
00721         if (ret_val)
00722                 goto out;
00723 
00724         ret_val = e1000_ready_nvm_eeprom(hw);
00725         if (ret_val)
00726                 goto release;
00727 
00728         e1000_shift_out_eec_bits(hw, NVM_EWEN_OPCODE_MICROWIRE,
00729                                  (u16)(nvm->opcode_bits + 2));
00730 
00731         e1000_shift_out_eec_bits(hw, 0, (u16)(nvm->address_bits - 2));
00732 
00733         e1000_standby_nvm(hw);
00734 
00735         while (words_written < words) {
00736                 e1000_shift_out_eec_bits(hw, NVM_WRITE_OPCODE_MICROWIRE,
00737                                          nvm->opcode_bits);
00738 
00739                 e1000_shift_out_eec_bits(hw, (u16)(offset + words_written),
00740                                          nvm->address_bits);
00741 
00742                 e1000_shift_out_eec_bits(hw, data[words_written], 16);
00743 
00744                 e1000_standby_nvm(hw);
00745 
00746                 for (widx = 0; widx < 200; widx++) {
00747                         eecd = E1000_READ_REG(hw, E1000_EECD);
00748                         if (eecd & E1000_EECD_DO)
00749                                 break;
00750                         usec_delay(50);
00751                 }
00752 
00753                 if (widx == 200) {
00754                         DEBUGOUT("NVM Write did not complete\n");
00755                         ret_val = -E1000_ERR_NVM;
00756                         goto release;
00757                 }
00758 
00759                 e1000_standby_nvm(hw);
00760 
00761                 words_written++;
00762         }
00763 
00764         e1000_shift_out_eec_bits(hw, NVM_EWDS_OPCODE_MICROWIRE,
00765                                  (u16)(nvm->opcode_bits + 2));
00766 
00767         e1000_shift_out_eec_bits(hw, 0, (u16)(nvm->address_bits - 2));
00768 
00769 release:
00770         nvm->ops.release(hw);
00771 
00772 out:
00773         return ret_val;
00774 }

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

e1000_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 e1000_update_nvm_checksum is not called after this function , the EEPROM will most likely contain an invalid checksum.

Definition at line 614 of file e1000_nvm.c.

References e1000_nvm_operations::acquire, e1000_nvm_info::address_bits, DEBUGFUNC, DEBUGOUT, E1000_ERR_NVM, e1000_ready_nvm_eeprom(), e1000_shift_out_eec_bits(), e1000_standby_nvm(), msec_delay, 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 e1000_init_nvm_params_82541().

00615 {
00616         struct e1000_nvm_info *nvm = &hw->nvm;
00617         s32 ret_val;
00618         u16 widx = 0;
00619 
00620         DEBUGFUNC("e1000_write_nvm_spi");
00621 
00622         /*
00623          * A check for invalid values:  offset too large, too many words,
00624          * and not enough words.
00625          */
00626         if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
00627             (words == 0)) {
00628                 DEBUGOUT("nvm parameter(s) out of bounds\n");
00629                 ret_val = -E1000_ERR_NVM;
00630                 goto out;
00631         }
00632 
00633         ret_val = nvm->ops.acquire(hw);
00634         if (ret_val)
00635                 goto out;
00636 
00637         while (widx < words) {
00638                 u8 write_opcode = NVM_WRITE_OPCODE_SPI;
00639 
00640                 ret_val = e1000_ready_nvm_eeprom(hw);
00641                 if (ret_val)
00642                         goto release;
00643 
00644                 e1000_standby_nvm(hw);
00645 
00646                 /* Send the WRITE ENABLE command (8 bit opcode) */
00647                 e1000_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI,
00648                                          nvm->opcode_bits);
00649 
00650                 e1000_standby_nvm(hw);
00651 
00652                 /*
00653                  * Some SPI eeproms use the 8th address bit embedded in the
00654                  * opcode
00655                  */
00656                 if ((nvm->address_bits == 8) && (offset >= 128))
00657                         write_opcode |= NVM_A8_OPCODE_SPI;
00658 
00659                 /* Send the Write command (8-bit opcode + addr) */
00660                 e1000_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits);
00661                 e1000_shift_out_eec_bits(hw, (u16)((offset + widx) * 2),
00662                                          nvm->address_bits);
00663 
00664                 /* Loop to allow for up to whole page write of eeprom */
00665                 while (widx < words) {
00666                         u16 word_out = data[widx];
00667                         word_out = (word_out >> 8) | (word_out << 8);
00668                         e1000_shift_out_eec_bits(hw, word_out, 16);
00669                         widx++;
00670 
00671                         if ((((offset + widx) * 2) % nvm->page_size) == 0) {
00672                                 e1000_standby_nvm(hw);
00673                                 break;
00674                         }
00675                 }
00676         }
00677 
00678         msec_delay(10);
00679 release:
00680         nvm->ops.release(hw);
00681 
00682 out:
00683         return ret_val;
00684 }

s32 e1000_update_nvm_checksum_generic ( struct e1000_hw hw  ) 

e1000_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 880 of file e1000_nvm.c.

References DEBUGFUNC, DEBUGOUT, e1000_hw::nvm, NVM_CHECKSUM_REG, NVM_SUM, e1000_nvm_info::ops, e1000_nvm_operations::read, u16, and e1000_nvm_operations::write.

Referenced by e1000_init_nvm_params_82540(), e1000_init_nvm_params_82541(), e1000_init_nvm_params_82542(), and e1000_init_nvm_params_82543().

00881 {
00882         s32  ret_val;
00883         u16 checksum = 0;
00884         u16 i, nvm_data;
00885 
00886         DEBUGFUNC("e1000_update_nvm_checksum");
00887 
00888         for (i = 0; i < NVM_CHECKSUM_REG; i++) {
00889                 ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
00890                 if (ret_val) {
00891                         DEBUGOUT("NVM Read Error while updating checksum.\n");
00892                         goto out;
00893                 }
00894                 checksum += nvm_data;
00895         }
00896         checksum = (u16) NVM_SUM - checksum;
00897         ret_val = hw->nvm.ops.write(hw, NVM_CHECKSUM_REG, 1, &checksum);
00898         if (ret_val)
00899                 DEBUGOUT("NVM Write Error while updating checksum.\n");
00900 
00901 out:
00902         return ret_val;
00903 }

void e1000_stop_nvm ( struct e1000_hw hw  ) 

e1000_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 335 of file e1000_nvm.c.

References DEBUGFUNC, E1000_EECD, E1000_EECD_CS, E1000_EECD_DI, e1000_lower_eec_clk(), e1000_nvm_eeprom_microwire, e1000_nvm_eeprom_spi, e1000_raise_eec_clk(), E1000_READ_REG, E1000_WRITE_REG, e1000_hw::nvm, e1000_nvm_info::type, and u32.

Referenced by e1000_init_nvm_params_82542(), and e1000_release_nvm_generic().

00336 {
00337         u32 eecd;
00338 
00339         DEBUGFUNC("e1000_stop_nvm");
00340 
00341         eecd = E1000_READ_REG(hw, E1000_EECD);
00342         if (hw->nvm.type == e1000_nvm_eeprom_spi) {
00343                 /* Pull CS high */
00344                 eecd |= E1000_EECD_CS;
00345                 e1000_lower_eec_clk(hw, &eecd);
00346         } else if (hw->nvm.type == e1000_nvm_eeprom_microwire) {
00347                 /* CS on Microwire is active-high */
00348                 eecd &= ~(E1000_EECD_CS | E1000_EECD_DI);
00349                 E1000_WRITE_REG(hw, E1000_EECD, eecd);
00350                 e1000_raise_eec_clk(hw, &eecd);
00351                 e1000_lower_eec_clk(hw, &eecd);
00352         }
00353 }

void e1000_release_nvm_generic ( struct e1000_hw hw  ) 

e1000_release_nvm_generic - 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 361 of file e1000_nvm.c.

References DEBUGFUNC, E1000_EECD, E1000_EECD_REQ, E1000_READ_REG, e1000_stop_nvm(), E1000_WRITE_REG, and u32.

Referenced by e1000_init_nvm_params_82540(), and e1000_init_nvm_params_82541().

00362 {
00363         u32 eecd;
00364 
00365         DEBUGFUNC("e1000_release_nvm_generic");
00366 
00367         e1000_stop_nvm(hw);
00368 
00369         eecd = E1000_READ_REG(hw, E1000_EECD);
00370         eecd &= ~E1000_EECD_REQ;
00371         E1000_WRITE_REG(hw, E1000_EECD, eecd);
00372 }


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