321
* igb_read_nvm_spi - Read EEPROM's using SPI
322
* @hw: pointer to the HW structure
323
* @offset: offset of word in the EEPROM to read
324
* @words: number of words to read
325
* @data: word read from the EEPROM
327
* Reads a 16 bit word from the EEPROM.
329
s32 igb_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
331
struct e1000_nvm_info *nvm = &hw->nvm;
335
u8 read_opcode = NVM_READ_OPCODE_SPI;
338
* A check for invalid values: offset too large, too many words,
339
* and not enough words.
341
if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) ||
343
hw_dbg("nvm parameter(s) out of bounds\n");
344
ret_val = -E1000_ERR_NVM;
348
ret_val = nvm->ops.acquire(hw);
352
ret_val = igb_ready_nvm_eeprom(hw);
358
if ((nvm->address_bits == 8) && (offset >= 128))
359
read_opcode |= NVM_A8_OPCODE_SPI;
361
/* Send the READ command (opcode + addr) */
362
igb_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits);
363
igb_shift_out_eec_bits(hw, (u16)(offset*2), nvm->address_bits);
366
* Read the data. SPI NVMs increment the address with each byte
367
* read and will roll over if reading beyond the end. This allows
368
* us to read the whole NVM from any offset
370
for (i = 0; i < words; i++) {
371
word_in = igb_shift_in_eec_bits(hw, 16);
372
data[i] = (word_in >> 8) | (word_in << 8);
376
nvm->ops.release(hw);
321
383
* igb_read_nvm_eerd - Reads EEPROM using EERD register
322
384
* @hw: pointer to the HW structure
323
385
* @offset: offset of word in the EEPROM to read