src/dpdk/drivers/net/igc/base/igc_nvm.c
s32 igc_write_nvm_microwire(struct igc_hw *hw, u16 offset, u16 words,
			      u16 *data)
{
	struct igc_nvm_info *nvm = &hw->nvm;
	s32  ret_val;
	u32 eecd;
	u16 words_written = 0;
	u16 widx = 0;

	DEBUGFUNC("igc_write_nvm_microwire");

	/* A check for invalid values:  offset too large, too many words,
	 * and not enough words.
	 */
	if (offset >= nvm->word_size || words > (nvm->word_size - offset) ||
			words == 0) {
		DEBUGOUT("nvm parameter(s) out of bounds\n");
		return -IGC_ERR_NVM;
	}

	ret_val = nvm->ops.acquire(hw);
	if (ret_val)
		return ret_val;

	ret_val = igc_ready_nvm_eeprom(hw);
	if (ret_val)
		goto release;

	igc_shift_out_eec_bits(hw, NVM_EWEN_OPCODE_MICROWIRE,
				 (u16)(nvm->opcode_bits + 2));

	igc_shift_out_eec_bits(hw, 0, (u16)(nvm->address_bits - 2));

	igc_standby_nvm(hw);

	while (words_written < words) {
		igc_shift_out_eec_bits(hw, NVM_WRITE_OPCODE_MICROWIRE,
					 nvm->opcode_bits);

		igc_shift_out_eec_bits(hw, (u16)(offset + words_written),
					 nvm->address_bits);

		igc_shift_out_eec_bits(hw, data[words_written], 16);

		igc_standby_nvm(hw);

		for (widx = 0; widx < 200; widx++) {
			eecd = IGC_READ_REG(hw, IGC_EECD);
			if (eecd & IGC_EECD_DO)
				break;
			usec_delay(50);
		}

		if (widx == 200) {
			DEBUGOUT("NVM Write did not complete\n");
			ret_val = -IGC_ERR_NVM;
			goto release;
		}

		igc_standby_nvm(hw);

		words_written++;
	}

	igc_shift_out_eec_bits(hw, NVM_EWDS_OPCODE_MICROWIRE,
				 (u16)(nvm->opcode_bits + 2));

	igc_shift_out_eec_bits(hw, 0, (u16)(nvm->address_bits - 2));

release:
	nvm->ops.release(hw);

	return ret_val;
}
/**
 *  igc_write_nvm_microwire - Writes EEPROM using microwire
 *  @hw: pointer to the HW structure
 *  @offset: offset within the EEPROM to be written to
 *  @words: number of words to write
 *  @data: 16 bit word(s) to be written to the EEPROM
 *
 *  Writes data to EEPROM at offset using microwire interface.
 *
 *  If igc_update_nvm_checksum is not called after this function , the
 *  EEPROM will most likely contain an invalid checksum.
 **/
Writes EEPROM using microwire
@hw: pointer to the HW structure
@offset: offset within the EEPROM to be written to
@words: number of words to write
@data: 16 bit word(s) to be written to the EEPROM

Writes data to EEPROM at offset using microwire interface.

If igc_update_nvm_checksum is not called after this function , the
EEPROM will most likely contain an invalid checksum.
Writes EEPROM using microwire @hw : pointer to the HW structure @offset : offset within the EEPROM to be written to @words : number of words to write @data : 16 bit word ( s ) to be written to the EEPROM Writes data to EEPROM at offset using microwire interface . If igc_update_nvm_checksum is not called after this function the EEPROM will most likely contain an invalid checksum .
s32 igc_write_nvm_microwire(struct igc_hw *hw, u16 offset, u16 words,
			      u16 *data)
{
	struct igc_nvm_info *nvm = &hw->nvm;
	s32  ret_val;
	u32 eecd;
	u16 words_written = 0;
	u16 widx = 0;
	DEBUGFUNC("igc_write_nvm_microwire");
	if (offset >= nvm->word_size || words > (nvm->word_size - offset) ||
			words == 0) {
		DEBUGOUT("nvm parameter(s) out of bounds\n");
		return -IGC_ERR_NVM;
	}
	ret_val = nvm->ops.acquire(hw);
	if (ret_val)
		return ret_val;
	ret_val = igc_ready_nvm_eeprom(hw);
	if (ret_val)
		goto release;
	igc_shift_out_eec_bits(hw, NVM_EWEN_OPCODE_MICROWIRE,
				 (u16)(nvm->opcode_bits + 2));
	igc_shift_out_eec_bits(hw, 0, (u16)(nvm->address_bits - 2));
	igc_standby_nvm(hw);
	while (words_written < words) {
		igc_shift_out_eec_bits(hw, NVM_WRITE_OPCODE_MICROWIRE,
					 nvm->opcode_bits);
		igc_shift_out_eec_bits(hw, (u16)(offset + words_written),
					 nvm->address_bits);
		igc_shift_out_eec_bits(hw, data[words_written], 16);
		igc_standby_nvm(hw);
		for (widx = 0; widx < 200; widx++) {
			eecd = IGC_READ_REG(hw, IGC_EECD);
			if (eecd & IGC_EECD_DO)
				break;
			usec_delay(50);
		}
		if (widx == 200) {
			DEBUGOUT("NVM Write did not complete\n");
			ret_val = -IGC_ERR_NVM;
			goto release;
		}
		igc_standby_nvm(hw);
		words_written++;
	}
	igc_shift_out_eec_bits(hw, NVM_EWDS_OPCODE_MICROWIRE,
				 (u16)(nvm->opcode_bits + 2));
	igc_shift_out_eec_bits(hw, 0, (u16)(nvm->address_bits - 2));
release:
	nvm->ops.release(hw);
	return ret_val;
}
s32 igc_write_nvm_microwire ( struct igc_hw * hw , u16 offset , u16 words , u16 * data ) { struct igc_nvm_info * nvm = & hw -> nvm ; s32 ret_val ; u32 eecd ; u16 words_written = 0 ; u16 widx = 0 ; DEBUGFUNC ( " " ) ; if ( offset >= nvm -> word_size || words > ( nvm -> word_size - offset ) || words == 0 ) { DEBUGOUT ( " \n " ) ; return - IGC_ERR_NVM ; } ret_val = nvm -> ops . acquire ( hw ) ; if ( ret_val ) return ret_val ; ret_val = igc_ready_nvm_eeprom ( hw ) ; if ( ret_val ) goto release ; igc_shift_out_eec_bits ( hw , NVM_EWEN_OPCODE_MICROWIRE , ( u16 ) ( nvm -> opcode_bits + 2 ) ) ; igc_shift_out_eec_bits ( hw , 0 , ( u16 ) ( nvm -> address_bits - 2 ) ) ; igc_standby_nvm ( hw ) ; while ( words_written < words ) { igc_shift_out_eec_bits ( hw , NVM_WRITE_OPCODE_MICROWIRE , nvm -> opcode_bits ) ; igc_shift_out_eec_bits ( hw , ( u16 ) ( offset + words_written ) , nvm -> address_bits ) ; igc_shift_out_eec_bits ( hw , data [ words_written ] , 16 ) ; igc_standby_nvm ( hw ) ; for ( widx = 0 ; widx < 200 ; widx ++ ) { eecd = IGC_READ_REG ( hw , IGC_EECD ) ; if ( eecd & IGC_EECD_DO ) break ; usec_delay ( 50 ) ; } if ( widx == 200 ) { DEBUGOUT ( " \n " ) ; ret_val = - IGC_ERR_NVM ; goto release ; } igc_standby_nvm ( hw ) ; words_written ++ ; } igc_shift_out_eec_bits ( hw , NVM_EWDS_OPCODE_MICROWIRE , ( u16 ) ( nvm -> opcode_bits + 2 ) ) ; igc_shift_out_eec_bits ( hw , 0 , ( u16 ) ( nvm -> address_bits - 2 ) ) ; release : nvm -> ops . release ( hw ) ; return ret_val ; }
igc_write_nvm_microwire - Writes EEPROM using microwire
  @hw: pointer to the HW structure
  @offset: offset within the EEPROM to be written to
  @words: number of words to write
  @data: 16 bit word(s) to be written to the EEPROM
igc_write_nvm_microwire - Writes EEPROM using microwire @hw : pointer to the HW structure @offset : offset within the EEPROM to be written to @words : number of words to write @data : 16 bit word ( s ) to be written to the EEPROM
/* A check for invalid values:  offset too large, too many words,
	 * and not enough words.
	 */