src/dpdk/drivers/net/e1000/base/e1000_82575.c
s32 e1000_write_i2c_byte_generic(struct e1000_hw *hw, u8 byte_offset,
				 u8 dev_addr, u8 data)
{
	s32 status = E1000_SUCCESS;
	u32 max_retry = 1;
	u32 retry = 0;
	u16 swfw_mask = 0;

	DEBUGFUNC("e1000_write_i2c_byte_generic");

	swfw_mask = E1000_SWFW_PHY0_SM;

	if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) != E1000_SUCCESS) {
		status = E1000_ERR_SWFW_SYNC;
		goto write_byte_out;
	}

	do {
		e1000_i2c_start(hw);

		status = e1000_clock_out_i2c_byte(hw, dev_addr);
		if (status != E1000_SUCCESS)
			goto fail;

		status = e1000_get_i2c_ack(hw);
		if (status != E1000_SUCCESS)
			goto fail;

		status = e1000_clock_out_i2c_byte(hw, byte_offset);
		if (status != E1000_SUCCESS)
			goto fail;

		status = e1000_get_i2c_ack(hw);
		if (status != E1000_SUCCESS)
			goto fail;

		status = e1000_clock_out_i2c_byte(hw, data);
		if (status != E1000_SUCCESS)
			goto fail;

		status = e1000_get_i2c_ack(hw);
		if (status != E1000_SUCCESS)
			goto fail;

		e1000_i2c_stop(hw);
		break;

fail:
		e1000_i2c_bus_clear(hw);
		retry++;
		if (retry < max_retry)
			DEBUGOUT("I2C byte write error - Retrying.\n");
		else
			DEBUGOUT("I2C byte write error.\n");
	} while (retry < max_retry);

	hw->mac.ops.release_swfw_sync(hw, swfw_mask);

write_byte_out:

	return status;
}
/**
 *  e1000_write_i2c_byte_generic - Writes 8 bit word over I2C
 *  @hw: pointer to hardware structure
 *  @byte_offset: byte offset to write
 *  @dev_addr: device address
 *  @data: value to write
 *
 *  Performs byte write operation over I2C interface at
 *  a specified device address.
 **/
Writes 8 bit word over I2C
@hw: pointer to hardware structure
@byte_offset: byte offset to write
@dev_addr: device address
@data: value to write

Performs byte write operation over I2C interface at
a specified device address.
Writes 8 bit word over I2C @hw : pointer to hardware structure @byte_offset : byte offset to write @dev_addr : device address @data : value to write Performs byte write operation over I2C interface at a specified device address .
s32 e1000_write_i2c_byte_generic(struct e1000_hw *hw, u8 byte_offset,
				 u8 dev_addr, u8 data)
{
	s32 status = E1000_SUCCESS;
	u32 max_retry = 1;
	u32 retry = 0;
	u16 swfw_mask = 0;
	DEBUGFUNC("e1000_write_i2c_byte_generic");
	swfw_mask = E1000_SWFW_PHY0_SM;
	if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) != E1000_SUCCESS) {
		status = E1000_ERR_SWFW_SYNC;
		goto write_byte_out;
	}
	do {
		e1000_i2c_start(hw);
		status = e1000_clock_out_i2c_byte(hw, dev_addr);
		if (status != E1000_SUCCESS)
			goto fail;
		status = e1000_get_i2c_ack(hw);
		if (status != E1000_SUCCESS)
			goto fail;
		status = e1000_clock_out_i2c_byte(hw, byte_offset);
		if (status != E1000_SUCCESS)
			goto fail;
		status = e1000_get_i2c_ack(hw);
		if (status != E1000_SUCCESS)
			goto fail;
		status = e1000_clock_out_i2c_byte(hw, data);
		if (status != E1000_SUCCESS)
			goto fail;
		status = e1000_get_i2c_ack(hw);
		if (status != E1000_SUCCESS)
			goto fail;
		e1000_i2c_stop(hw);
		break;
fail:
		e1000_i2c_bus_clear(hw);
		retry++;
		if (retry < max_retry)
			DEBUGOUT("I2C byte write error - Retrying.\n");
		else
			DEBUGOUT("I2C byte write error.\n");
	} while (retry < max_retry);
	hw->mac.ops.release_swfw_sync(hw, swfw_mask);
write_byte_out:
	return status;
}
s32 e1000_write_i2c_byte_generic ( struct e1000_hw * hw , u8 byte_offset , u8 dev_addr , u8 data ) { s32 status = E1000_SUCCESS ; u32 max_retry = 1 ; u32 retry = 0 ; u16 swfw_mask = 0 ; DEBUGFUNC ( " " ) ; swfw_mask = E1000_SWFW_PHY0_SM ; if ( hw -> mac . ops . acquire_swfw_sync ( hw , swfw_mask ) != E1000_SUCCESS ) { status = E1000_ERR_SWFW_SYNC ; goto write_byte_out ; } do { e1000_i2c_start ( hw ) ; status = e1000_clock_out_i2c_byte ( hw , dev_addr ) ; if ( status != E1000_SUCCESS ) goto fail ; status = e1000_get_i2c_ack ( hw ) ; if ( status != E1000_SUCCESS ) goto fail ; status = e1000_clock_out_i2c_byte ( hw , byte_offset ) ; if ( status != E1000_SUCCESS ) goto fail ; status = e1000_get_i2c_ack ( hw ) ; if ( status != E1000_SUCCESS ) goto fail ; status = e1000_clock_out_i2c_byte ( hw , data ) ; if ( status != E1000_SUCCESS ) goto fail ; status = e1000_get_i2c_ack ( hw ) ; if ( status != E1000_SUCCESS ) goto fail ; e1000_i2c_stop ( hw ) ; break ; fail : e1000_i2c_bus_clear ( hw ) ; retry ++ ; if ( retry < max_retry ) DEBUGOUT ( " \n " ) ; else DEBUGOUT ( " \n " ) ; } while ( retry < max_retry ) ; hw -> mac . ops . release_swfw_sync ( hw , swfw_mask ) ; write_byte_out : return status ; }
e1000_write_i2c_byte_generic - Writes 8 bit word over I2C
  @hw: pointer to hardware structure
  @byte_offset: byte offset to write
  @dev_addr: device address
  @data: value to write
e1000_write_i2c_byte_generic - Writes 8 bit word over I2C @hw : pointer to hardware structure @byte_offset : byte offset to write @dev_addr : device address @data : value to write