38 static void e1000_raise_eec_clk(
struct e1000_hw *
hw,
u32 *eecd)
53 static void e1000_lower_eec_clk(
struct e1000_hw *
hw,
u32 *eecd)
77 mask = 0x01 << (count - 1);
92 e1000_raise_eec_clk(hw, &eecd);
93 e1000_lower_eec_clk(hw, &eecd);
113 static u16 e1000_shift_in_eec_bits(
struct e1000_hw *hw,
u16 count)
124 for (i = 0; i <
count; i++) {
126 e1000_raise_eec_clk(hw, &eecd);
134 e1000_lower_eec_clk(hw, &eecd);
150 u32 attempts = 100000;
153 for (i = 0; i < attempts; i++) {
195 e_dbg(
"Could not acquire NVM grant\n");
208 static void e1000_standby_nvm(
struct e1000_hw *hw)
232 static void e1000_stop_nvm(
struct e1000_hw *hw)
240 e1000_lower_eec_clk(hw, &eecd);
267 static s32 e1000_ready_nvm_eeprom(
struct e1000_hw *hw)
290 hw->
nvm.opcode_bits);
291 spi_stat_reg = (
u8)e1000_shift_in_eec_bits(hw, 8);
296 e1000_standby_nvm(hw);
301 e_dbg(
"SPI NVM Status error\n");
330 e_dbg(
"nvm parameter(s) out of bounds\n");
334 for (i = 0; i < words; i++) {
373 e_dbg(
"nvm parameter(s) out of bounds\n");
377 ret_val = nvm->
ops.acquire(hw);
381 while (widx < words) {
384 ret_val = e1000_ready_nvm_eeprom(hw);
388 e1000_standby_nvm(hw);
394 e1000_standby_nvm(hw);
404 e1000_shift_out_eec_bits(hw, write_opcode, nvm->
opcode_bits);
405 e1000_shift_out_eec_bits(hw, (
u16)((offset + widx) * 2),
409 while (widx < words) {
410 u16 word_out = data[widx];
411 word_out = (word_out >> 8) | (word_out << 8);
412 e1000_shift_out_eec_bits(hw, word_out, 16);
415 if ((((offset + widx) * 2) % nvm->
page_size) == 0) {
416 e1000_standby_nvm(hw);
424 nvm->
ops.release(hw);
447 if (pba_num ==
NULL) {
448 e_dbg(
"PBA string buffer was null\n");
454 e_dbg(
"NVM Read Error\n");
460 e_dbg(
"NVM Read Error\n");
470 e_dbg(
"NVM PBA number is not stored as string\n");
473 if (pba_num_size < 11) {
474 e_dbg(
"PBA string buffer too small\n");
479 pba_num[0] = (nvm_data >> 12) & 0xF;
480 pba_num[1] = (nvm_data >> 8) & 0xF;
481 pba_num[2] = (nvm_data >> 4) & 0xF;
482 pba_num[3] = nvm_data & 0xF;
483 pba_num[4] = (pba_ptr >> 12) & 0xF;
484 pba_num[5] = (pba_ptr >> 8) & 0xF;
487 pba_num[8] = (pba_ptr >> 4) & 0xF;
488 pba_num[9] = pba_ptr & 0xF;
494 for (offset = 0; offset < 10; offset++) {
495 if (pba_num[offset] < 0xA)
497 else if (pba_num[offset] < 0x10)
498 pba_num[
offset] +=
'A' - 0xA;
504 ret_val = e1000_read_nvm(hw, pba_ptr, 1, &length);
506 e_dbg(
"NVM Read Error\n");
510 if (length == 0xFFFF || length == 0) {
511 e_dbg(
"NVM PBA number section invalid length\n");
515 if (pba_num_size < (((
u32)length * 2) - 1)) {
516 e_dbg(
"PBA string buffer too small\n");
524 for (offset = 0; offset <
length; offset++) {
525 ret_val = e1000_read_nvm(hw, pba_ptr + offset, 1, &nvm_data);
527 e_dbg(
"NVM Read Error\n");
530 pba_num[offset * 2] = (
u8)(nvm_data >> 8);
531 pba_num[(offset * 2) + 1] = (
u8)(nvm_data & 0xFF);
533 pba_num[offset * 2] =
'\0';
552 rar_high =
er32(RAH(0));
556 hw->
mac.perm_addr[i] = (
u8)(rar_low >> (i * 8));
559 hw->
mac.perm_addr[i + 4] = (
u8)(rar_high >> (i * 8));
562 hw->
mac.addr[i] = hw->
mac.perm_addr[i];
581 ret_val = e1000_read_nvm(hw, i, 1, &nvm_data);
583 e_dbg(
"NVM Read Error\n");
590 e_dbg(
"NVM Checksum Invalid\n");
612 ret_val = e1000_read_nvm(hw, i, 1, &nvm_data);
614 e_dbg(
"NVM Read Error while updating checksum.\n");
620 ret_val = e1000_write_nvm(hw, NVM_CHECKSUM_REG, 1, &checksum);
622 e_dbg(
"NVM Write Error while updating checksum.\n");
639 ctrl_ext =
er32(CTRL_EXT);
641 ew32(CTRL_EXT, ctrl_ext);