28 #include <linux/if_ether.h>
80 mask = 0x01 << (count - 1);
95 igb_raise_eec_clk(hw, &eecd);
96 igb_lower_eec_clk(hw, &eecd);
127 for (i = 0; i <
count; i++) {
129 igb_raise_eec_clk(hw, &eecd);
137 igb_lower_eec_clk(hw, &eecd);
151 static s32 igb_poll_eerd_eewr_done(
struct e1000_hw *hw,
int ee_reg)
153 u32 attempts = 100000;
157 for (i = 0; i < attempts; i++) {
203 hw_dbg(
"Could not acquire NVM grant\n");
216 static void igb_standby_nvm(
struct e1000_hw *hw)
240 static void e1000_stop_nvm(
struct e1000_hw *hw)
248 igb_lower_eec_clk(hw, &eecd);
275 static s32 igb_ready_nvm_eeprom(
struct e1000_hw *hw)
300 hw->
nvm.opcode_bits);
301 spi_stat_reg = (
u8)igb_shift_in_eec_bits(hw, 8);
311 hw_dbg(
"SPI NVM Status error\n");
344 hw_dbg(
"nvm parameter(s) out of bounds\n");
349 ret_val = nvm->
ops.acquire(hw);
353 ret_val = igb_ready_nvm_eeprom(hw);
363 igb_shift_out_eec_bits(hw, read_opcode, nvm->
opcode_bits);
371 for (i = 0; i < words; i++) {
372 word_in = igb_shift_in_eec_bits(hw, 16);
373 data[
i] = (word_in >> 8) | (word_in << 8);
377 nvm->
ops.release(hw);
404 hw_dbg(
"nvm parameter(s) out of bounds\n");
409 for (i = 0; i < words; i++) {
450 hw_dbg(
"nvm parameter(s) out of bounds\n");
455 ret_val = hw->
nvm.ops.acquire(hw);
461 while (widx < words) {
464 ret_val = igb_ready_nvm_eeprom(hw);
484 igb_shift_out_eec_bits(hw, write_opcode, nvm->
opcode_bits);
485 igb_shift_out_eec_bits(hw, (
u16)((offset + widx) * 2),
489 while (widx < words) {
490 u16 word_out = data[widx];
491 word_out = (word_out >> 8) | (word_out << 8);
492 igb_shift_out_eec_bits(hw, word_out, 16);
495 if ((((offset + widx) * 2) % nvm->
page_size) == 0) {
504 hw->
nvm.ops.release(hw);
527 if (part_num ==
NULL) {
528 hw_dbg(
"PBA string buffer was null\n");
535 hw_dbg(
"NVM Read Error\n");
541 hw_dbg(
"NVM Read Error\n");
551 hw_dbg(
"NVM PBA number is not stored as string\n");
554 if (part_num_size < 11) {
555 hw_dbg(
"PBA string buffer too small\n");
560 part_num[0] = (nvm_data >> 12) & 0xF;
561 part_num[1] = (nvm_data >> 8) & 0xF;
562 part_num[2] = (nvm_data >> 4) & 0xF;
563 part_num[3] = nvm_data & 0xF;
564 part_num[4] = (pointer >> 12) & 0xF;
565 part_num[5] = (pointer >> 8) & 0xF;
568 part_num[8] = (pointer >> 4) & 0xF;
569 part_num[9] = pointer & 0xF;
575 for (offset = 0; offset < 10; offset++) {
576 if (part_num[offset] < 0xA)
578 else if (part_num[offset] < 0x10)
579 part_num[
offset] +=
'A' - 0xA;
585 ret_val = hw->
nvm.ops.read(hw, pointer, 1, &length);
587 hw_dbg(
"NVM Read Error\n");
591 if (length == 0xFFFF || length == 0) {
592 hw_dbg(
"NVM PBA number section invalid length\n");
597 if (part_num_size < (((
u32)length * 2) - 1)) {
598 hw_dbg(
"PBA string buffer too small\n");
607 for (offset = 0; offset <
length; offset++) {
608 ret_val = hw->
nvm.ops.read(hw, pointer + offset, 1, &nvm_data);
610 hw_dbg(
"NVM Read Error\n");
613 part_num[offset * 2] = (
u8)(nvm_data >> 8);
614 part_num[(offset * 2) + 1] = (
u8)(nvm_data & 0xFF);
616 part_num[offset * 2] =
'\0';
640 hw->
mac.perm_addr[i] = (
u8)(rar_low >> (i*8));
643 hw->
mac.perm_addr[i+4] = (
u8)(rar_high >> (i*8));
646 hw->
mac.addr[i] = hw->
mac.perm_addr[i];
665 ret_val = hw->
nvm.ops.read(hw, i, 1, &nvm_data);
667 hw_dbg(
"NVM Read Error\n");
674 hw_dbg(
"NVM Checksum Invalid\n");
698 ret_val = hw->
nvm.ops.read(hw, i, 1, &nvm_data);
700 hw_dbg(
"NVM Read Error while updating checksum.\n");
706 ret_val = hw->
nvm.ops.write(hw, NVM_CHECKSUM_REG, 1, &checksum);
708 hw_dbg(
"NVM Write Error while updating checksum.\n");