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

	bool nack = true;

	DEBUGFUNC("e1000_read_i2c_byte_generic");

	swfw_mask = E1000_SWFW_PHY0_SM;

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

		e1000_i2c_start(hw);

		/* Device Address and write indication */
		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;

		e1000_i2c_start(hw);

		/* Device Address and read indication */
		status = e1000_clock_out_i2c_byte(hw, (dev_addr | 0x1));
		if (status != E1000_SUCCESS)
			goto fail;

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

		e1000_clock_in_i2c_byte(hw, data);

		status = e1000_clock_out_i2c_bit(hw, nack);
		if (status != E1000_SUCCESS)
			goto fail;

		e1000_i2c_stop(hw);
		break;

fail:
		hw->mac.ops.release_swfw_sync(hw, swfw_mask);
		msec_delay(100);
		e1000_i2c_bus_clear(hw);
		retry++;
		if (retry < max_retry)
			DEBUGOUT("I2C byte read error - Retrying.\n");
		else
			DEBUGOUT("I2C byte read error.\n");

	} while (retry < max_retry);

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

read_byte_out:

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

Performs byte read operation over I2C interface at
a specified device address.
Reads 8 bit word over I2C @hw : pointer to hardware structure @byte_offset : byte offset to read @dev_addr : device address @data : value read Performs byte read operation over I2C interface at a specified device address .
s32 e1000_read_i2c_byte_generic(struct e1000_hw *hw, u8 byte_offset,
				u8 dev_addr, u8 *data)
{
	s32 status = E1000_SUCCESS;
	u32 max_retry = 10;
	u32 retry = 1;
	u16 swfw_mask = 0;
	bool nack = true;
	DEBUGFUNC("e1000_read_i2c_byte_generic");
	swfw_mask = E1000_SWFW_PHY0_SM;
	do {
		if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask)
		    != E1000_SUCCESS) {
			status = E1000_ERR_SWFW_SYNC;
			goto read_byte_out;
		}
		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;
		e1000_i2c_start(hw);
		status = e1000_clock_out_i2c_byte(hw, (dev_addr | 0x1));
		if (status != E1000_SUCCESS)
			goto fail;
		status = e1000_get_i2c_ack(hw);
		if (status != E1000_SUCCESS)
			goto fail;
		e1000_clock_in_i2c_byte(hw, data);
		status = e1000_clock_out_i2c_bit(hw, nack);
		if (status != E1000_SUCCESS)
			goto fail;
		e1000_i2c_stop(hw);
		break;
fail:
		hw->mac.ops.release_swfw_sync(hw, swfw_mask);
		msec_delay(100);
		e1000_i2c_bus_clear(hw);
		retry++;
		if (retry < max_retry)
			DEBUGOUT("I2C byte read error - Retrying.\n");
		else
			DEBUGOUT("I2C byte read error.\n");
	} while (retry < max_retry);
	hw->mac.ops.release_swfw_sync(hw, swfw_mask);
read_byte_out:
	return status;
}
s32 e1000_read_i2c_byte_generic ( struct e1000_hw * hw , u8 byte_offset , u8 dev_addr , u8 * data ) { s32 status = E1000_SUCCESS ; u32 max_retry = 10 ; u32 retry = 1 ; u16 swfw_mask = 0 ; bool nack = true ; DEBUGFUNC ( " " ) ; swfw_mask = E1000_SWFW_PHY0_SM ; do { if ( hw -> mac . ops . acquire_swfw_sync ( hw , swfw_mask ) != E1000_SUCCESS ) { status = E1000_ERR_SWFW_SYNC ; goto read_byte_out ; } 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 ; e1000_i2c_start ( hw ) ; status = e1000_clock_out_i2c_byte ( hw , ( dev_addr | 0x1 ) ) ; if ( status != E1000_SUCCESS ) goto fail ; status = e1000_get_i2c_ack ( hw ) ; if ( status != E1000_SUCCESS ) goto fail ; e1000_clock_in_i2c_byte ( hw , data ) ; status = e1000_clock_out_i2c_bit ( hw , nack ) ; if ( status != E1000_SUCCESS ) goto fail ; e1000_i2c_stop ( hw ) ; break ; fail : hw -> mac . ops . release_swfw_sync ( hw , swfw_mask ) ; msec_delay ( 100 ) ; 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 ) ; read_byte_out : return status ; }
e1000_read_i2c_byte_generic - Reads 8 bit word over I2C
  @hw: pointer to hardware structure
  @byte_offset: byte offset to read
  @dev_addr: device address
  @data: value read
e1000_read_i2c_byte_generic - Reads 8 bit word over I2C @hw : pointer to hardware structure @byte_offset : byte offset to read @dev_addr : device address @data : value read
/* Device Address and write indication */ /* Device Address and read indication */