FreeBSD/sys/dev/cxgbe/common/t4_hw.c
/**
 *	t4_i2c_wr - write I2C data to adapter
 *	@adap: the adapter
 *	@port: Port number if per-port device; <0 if not
 *	@devid: per-port device ID or absolute device ID
 *	@offset: byte offset into device I2C space
 *	@len: byte length of I2C space data
 *	@buf: buffer containing new I2C data
 *
 *	Write the I2C data to the indicated device and location.
 */


Write the I2C data to the indicated device and location.
Write the I2C data to the indicated device and location .
int t4_i2c_wr(struct adapter *adap, unsigned int mbox,
	      int port, unsigned int devid,
	      unsigned int offset, unsigned int len,
	      u8 *buf)
{
	u32 ldst_addrspace;
	struct fw_ldst_cmd ldst;
	if (port >= 4 ||
	    devid >= 256 ||
	    offset >= 256 ||
	    len > sizeof ldst.u.i2c.data)
		return -EINVAL;
	memset(&ldst, 0, sizeof ldst);
	ldst_addrspace = V_FW_LDST_CMD_ADDRSPACE(FW_LDST_ADDRSPC_I2C);
	ldst.op_to_addrspace =
		cpu_to_be32(V_FW_CMD_OP(FW_LDST_CMD) |
			    F_FW_CMD_REQUEST |
			    F_FW_CMD_WRITE |
			    ldst_addrspace);
	ldst.cycles_to_len16 = cpu_to_be32(FW_LEN16(ldst));
	ldst.u.i2c.pid = (port < 0 ? 0xff : port);
	ldst.u.i2c.did = devid;
	ldst.u.i2c.boffset = offset;
	ldst.u.i2c.blen = len;
	memcpy(ldst.u.i2c.data, buf, len);
	return t4_wr_mbox(adap, mbox, &ldst, sizeof ldst, &ldst);
}
int t4_i2c_wr ( struct adapter * adap , unsigned int mbox , int port , unsigned int devid , unsigned int offset , unsigned int len , u8 * buf ) { u32 ldst_addrspace ; struct fw_ldst_cmd ldst ; if ( port >= 4 || devid >= 256 || offset >= 256 || len > sizeof ldst . u . i2c . data ) return - EINVAL ; memset ( & ldst , 0 , sizeof ldst ) ; ldst_addrspace = V_FW_LDST_CMD_ADDRSPACE ( FW_LDST_ADDRSPC_I2C ) ; ldst . op_to_addrspace = cpu_to_be32 ( V_FW_CMD_OP ( FW_LDST_CMD ) | F_FW_CMD_REQUEST | F_FW_CMD_WRITE | ldst_addrspace ) ; ldst . cycles_to_len16 = cpu_to_be32 ( FW_LEN16 ( ldst ) ) ; ldst . u . i2c . pid = ( port < 0 ? 0xff : port ) ; ldst . u . i2c . did = devid ; ldst . u . i2c . boffset = offset ; ldst . u . i2c . blen = len ; memcpy ( ldst . u . i2c . data , buf , len ) ; return t4_wr_mbox ( adap , mbox , & ldst , sizeof ldst , & ldst ) ; }
t4_i2c_wr - write I2C data to adapter
      @adap: the adapter
      @port: Port number if per-port device; <0 if not
      @devid: per-port device ID or absolute device ID
      @offset: byte offset into device I2C space
      @len: byte length of I2C space data
      @buf: buffer containing new I2C data
t4_i2c_wr - write I2C data to adapter @adap : the adapter @port : Port number if per - port device ; <0 if not @devid : per - port device ID or absolute device ID @offset : byte offset into device I2C space @len : byte length of I2C space data @buf : buffer containing new I2C data