igb_nvm.h File Reference

Go to the source code of this file.

Defines

#define E1000_STM_OPCODE   0xDB00

Functions

 FILE_LICENCE (GPL2_ONLY)
void igb_init_nvm_ops_generic (struct e1000_hw *hw)
 igb_init_nvm_ops_generic - Initialize NVM function pointers : pointer to the HW structure
s32 igb_acquire_nvm_generic (struct e1000_hw *hw)
 igb_acquire_nvm_generic - Generic request for access to EEPROM : pointer to the HW structure
s32 igb_poll_eerd_eewr_done (struct e1000_hw *hw, int ee_reg)
 igb_poll_eerd_eewr_done - Poll for EEPROM read/write completion : pointer to the HW structure : EEPROM flag for polling
s32 igb_read_mac_addr_generic (struct e1000_hw *hw)
 igb_read_mac_addr_generic - Read device MAC address : pointer to the HW structure
s32 igb_read_pba_num_generic (struct e1000_hw *hw, u32 *pba_num)
 igb_read_pba_num_generic - Read device part number : pointer to the HW structure : pointer to device part number
s32 igb_read_nvm_eerd (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 igb_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 igb_valid_led_default_generic (struct e1000_hw *hw, u16 *data)
 igb_valid_led_default_generic - Verify a valid default LED config : pointer to the HW structure : pointer to the NVM (EEPROM)
s32 igb_validate_nvm_checksum_generic (struct e1000_hw *hw)
 igb_validate_nvm_checksum_generic - Validate EEPROM checksum : pointer to the HW structure
s32 igb_write_nvm_eewr (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
s32 igb_write_nvm_spi (struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 igb_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 igb_update_nvm_checksum_generic (struct e1000_hw *hw)
 igb_update_nvm_checksum_generic - Update EEPROM checksum : pointer to the HW structure
void igb_release_nvm_generic (struct e1000_hw *hw)
 igb_release_nvm_generic - Release exclusive access to EEPROM : pointer to the HW structure


Define Documentation

#define E1000_STM_OPCODE   0xDB00

Definition at line 50 of file igb_nvm.h.


Function Documentation

FILE_LICENCE ( GPL2_ONLY   ) 

void igb_init_nvm_ops_generic ( struct e1000_hw hw  ) 

igb_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 41 of file igb_nvm.c.

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

Referenced by igb_setup_init_funcs().

00042 {
00043         struct e1000_nvm_info *nvm = &hw->nvm;
00044         DEBUGFUNC("igb_init_nvm_ops_generic");
00045 
00046         /* Initialize function pointers */
00047         nvm->ops.reload = igb_reload_nvm_generic;
00048 }

s32 igb_acquire_nvm_generic ( struct e1000_hw hw  ) 

igb_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 204 of file igb_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 igb_acquire_nvm_82575().

00205 {
00206         u32 eecd = E1000_READ_REG(hw, E1000_EECD);
00207         s32 timeout = E1000_NVM_GRANT_ATTEMPTS;
00208         s32 ret_val = E1000_SUCCESS;
00209 
00210         DEBUGFUNC("igb_acquire_nvm_generic");
00211 
00212         E1000_WRITE_REG(hw, E1000_EECD, eecd | E1000_EECD_REQ);
00213         eecd = E1000_READ_REG(hw, E1000_EECD);
00214 
00215         while (timeout) {
00216                 if (eecd & E1000_EECD_GNT)
00217                         break;
00218                 usec_delay(5);
00219                 eecd = E1000_READ_REG(hw, E1000_EECD);
00220                 timeout--;
00221         }
00222 
00223         if (!timeout) {
00224                 eecd &= ~E1000_EECD_REQ;
00225                 E1000_WRITE_REG(hw, E1000_EECD, eecd);
00226                 DEBUGOUT("Could not acquire NVM grant\n");
00227                 ret_val = -E1000_ERR_NVM;
00228         }
00229 
00230         return ret_val;
00231 }

s32 igb_poll_eerd_eewr_done ( struct e1000_hw hw,
int  ee_reg 
)

igb_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 171 of file igb_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 igb_read_nvm_eerd().

00172 {
00173         u32 attempts = 100000;
00174         u32 i, reg = 0;
00175         s32 ret_val = -E1000_ERR_NVM;
00176 
00177         DEBUGFUNC("igb_poll_eerd_eewr_done");
00178 
00179         for (i = 0; i < attempts; i++) {
00180                 if (ee_reg == E1000_NVM_POLL_READ)
00181                         reg = E1000_READ_REG(hw, E1000_EERD);
00182                 else
00183                         reg = E1000_READ_REG(hw, E1000_EEWR);
00184 
00185                 if (reg & E1000_NVM_RW_REG_DONE) {
00186                         ret_val = E1000_SUCCESS;
00187                         break;
00188                 }
00189 
00190                 usec_delay(5);
00191         }
00192 
00193         return ret_val;
00194 }

s32 igb_read_mac_addr_generic ( struct e1000_hw hw  ) 

igb_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 520 of file igb_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 igb_init_mac_ops_generic(), igb_read_mac_addr(), and igb_read_mac_addr_82575().

00521 {
00522         u32 rar_high;
00523         u32 rar_low;
00524         u16 i;
00525 
00526         rar_high = E1000_READ_REG(hw, E1000_RAH(0));
00527         rar_low = E1000_READ_REG(hw, E1000_RAL(0));
00528 
00529         for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++)
00530                 hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8));
00531 
00532         for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++)
00533                 hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8));
00534 
00535         for (i = 0; i < ETH_ADDR_LEN; i++)
00536                 hw->mac.addr[i] = hw->mac.perm_addr[i];
00537 
00538         return E1000_SUCCESS;
00539 }

s32 igb_read_pba_num_generic ( struct e1000_hw hw,
u32 pba_num 
)

igb_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 487 of file igb_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 igb_read_pba_num().

00488 {
00489         s32  ret_val;
00490         u16 nvm_data;
00491 
00492         DEBUGFUNC("igb_read_pba_num_generic");
00493 
00494         ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_0, 1, &nvm_data);
00495         if (ret_val) {
00496                 DEBUGOUT("NVM Read Error\n");
00497                 goto out;
00498         }
00499         *pba_num = (u32)(nvm_data << 16);
00500 
00501         ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_1, 1, &nvm_data);
00502         if (ret_val) {
00503                 DEBUGOUT("NVM Read Error\n");
00504                 goto out;
00505         }
00506         *pba_num |= nvm_data;
00507 
00508 out:
00509         return ret_val;
00510 }

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

igb_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 359 of file igb_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_READ_REG, E1000_SUCCESS, E1000_WRITE_REG, igb_poll_eerd_eewr_done(), e1000_hw::nvm, u32, and e1000_nvm_info::word_size.

Referenced by igb_init_nvm_params_82575().

00360 {
00361         struct e1000_nvm_info *nvm = &hw->nvm;
00362         u32 i, eerd = 0;
00363         s32 ret_val = E1000_SUCCESS;
00364 
00365         DEBUGFUNC("igb_read_nvm_eerd");
00366 
00367         /*
00368          * A check for invalid values:  offset too large, too many words,
00369          * too many words for the offset, and not enough words.
00370          */
00371         if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
00372             (words == 0)) {
00373                 DEBUGOUT("nvm parameter(s) out of bounds\n");
00374                 ret_val = -E1000_ERR_NVM;
00375                 goto out;
00376         }
00377 
00378         for (i = 0; i < words; i++) {
00379                 eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) +
00380                        E1000_NVM_RW_REG_START;
00381 
00382                 E1000_WRITE_REG(hw, E1000_EERD, eerd);
00383                 ret_val = igb_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ);
00384                 if (ret_val)
00385                         break;
00386 
00387                 data[i] = (E1000_READ_REG(hw, E1000_EERD) >>
00388                            E1000_NVM_RW_REG_DATA);
00389         }
00390 
00391 out:
00392         return ret_val;
00393 }

s32 igb_valid_led_default_generic ( struct e1000_hw hw,
u16 data 
)

igb_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 1546 of file igb_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.

01547 {
01548         s32 ret_val;
01549 
01550         DEBUGFUNC("igb_valid_led_default_generic");
01551 
01552         ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data);
01553         if (ret_val) {
01554                 DEBUGOUT("NVM Read Error\n");
01555                 goto out;
01556         }
01557 
01558         if (*data == ID_LED_RESERVED_0000 || *data == ID_LED_RESERVED_FFFF)
01559                 *data = ID_LED_DEFAULT;
01560 
01561 out:
01562         return ret_val;
01563 }

s32 igb_validate_nvm_checksum_generic ( struct e1000_hw hw  ) 

igb_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 548 of file igb_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 igb_init_nvm_params_82575().

00549 {
00550         s32 ret_val = E1000_SUCCESS;
00551         u16 checksum = 0;
00552         u16 i, nvm_data;
00553 
00554         DEBUGFUNC("igb_validate_nvm_checksum_generic");
00555 
00556         for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) {
00557                 ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
00558                 if (ret_val) {
00559                         DEBUGOUT("NVM Read Error\n");
00560                         goto out;
00561                 }
00562                 checksum += nvm_data;
00563         }
00564 
00565         if (checksum != (u16) NVM_SUM) {
00566                 DEBUGOUT("NVM Checksum Invalid\n");
00567                 ret_val = -E1000_ERR_NVM;
00568                 goto out;
00569         }
00570 
00571 out:
00572         return ret_val;
00573 }

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

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

igb_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 407 of file igb_nvm.c.

References e1000_nvm_operations::acquire, e1000_nvm_info::address_bits, DEBUGFUNC, DEBUGOUT, E1000_ERR_NVM, igb_ready_nvm_eeprom(), igb_shift_out_eec_bits(), igb_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 igb_init_nvm_params_82575().

00408 {
00409         struct e1000_nvm_info *nvm = &hw->nvm;
00410         s32 ret_val;
00411         u16 widx = 0;
00412 
00413         DEBUGFUNC("igb_write_nvm_spi");
00414 
00415         /*
00416          * A check for invalid values:  offset too large, too many words,
00417          * and not enough words.
00418          */
00419         if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
00420             (words == 0)) {
00421                 DEBUGOUT("nvm parameter(s) out of bounds\n");
00422                 ret_val = -E1000_ERR_NVM;
00423                 goto out;
00424         }
00425 
00426         ret_val = nvm->ops.acquire(hw);
00427         if (ret_val)
00428                 goto out;
00429 
00430         while (widx < words) {
00431                 u8 write_opcode = NVM_WRITE_OPCODE_SPI;
00432 
00433                 ret_val = igb_ready_nvm_eeprom(hw);
00434                 if (ret_val)
00435                         goto release;
00436 
00437                 igb_standby_nvm(hw);
00438 
00439                 /* Send the WRITE ENABLE command (8 bit opcode) */
00440                 igb_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI,
00441                                          nvm->opcode_bits);
00442 
00443                 igb_standby_nvm(hw);
00444 
00445                 /*
00446                  * Some SPI eeproms use the 8th address bit embedded in the
00447                  * opcode
00448                  */
00449                 if ((nvm->address_bits == 8) && (offset >= 128))
00450                         write_opcode |= NVM_A8_OPCODE_SPI;
00451 
00452                 /* Send the Write command (8-bit opcode + addr) */
00453                 igb_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits);
00454                 igb_shift_out_eec_bits(hw, (u16)((offset + widx) * 2),
00455                                          nvm->address_bits);
00456 
00457                 /* Loop to allow for up to whole page write of eeprom */
00458                 while (widx < words) {
00459                         u16 word_out = data[widx];
00460                         word_out = (word_out >> 8) | (word_out << 8);
00461                         igb_shift_out_eec_bits(hw, word_out, 16);
00462                         widx++;
00463 
00464                         if ((((offset + widx) * 2) % nvm->page_size) == 0) {
00465                                 igb_standby_nvm(hw);
00466                                 break;
00467                         }
00468                 }
00469         }
00470 
00471         msec_delay(10);
00472 release:
00473         nvm->ops.release(hw);
00474 
00475 out:
00476         return ret_val;
00477 }

s32 igb_update_nvm_checksum_generic ( struct e1000_hw hw  ) 

igb_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 583 of file igb_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 igb_init_nvm_params_82575().

00584 {
00585         s32  ret_val;
00586         u16 checksum = 0;
00587         u16 i, nvm_data;
00588 
00589         DEBUGFUNC("igb_update_nvm_checksum");
00590 
00591         for (i = 0; i < NVM_CHECKSUM_REG; i++) {
00592                 ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data);
00593                 if (ret_val) {
00594                         DEBUGOUT("NVM Read Error while updating checksum.\n");
00595                         goto out;
00596                 }
00597                 checksum += nvm_data;
00598         }
00599         checksum = (u16) NVM_SUM - checksum;
00600         ret_val = hw->nvm.ops.write(hw, NVM_CHECKSUM_REG, 1, &checksum);
00601         if (ret_val) {
00602                 DEBUGOUT("NVM Write Error while updating checksum.\n");
00603         }
00604 out:
00605         return ret_val;
00606 }

void igb_release_nvm_generic ( struct e1000_hw hw  ) 

igb_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 285 of file igb_nvm.c.

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

Referenced by igb_release_nvm_82575().

00286 {
00287         u32 eecd;
00288 
00289         DEBUGFUNC("igb_release_nvm_generic");
00290 
00291         igb_stop_nvm(hw);
00292 
00293         eecd = E1000_READ_REG(hw, E1000_EECD);
00294         eecd &= ~E1000_EECD_REQ;
00295         E1000_WRITE_REG(hw, E1000_EECD, eecd);
00296 }


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