Exemple #1
0
/* Write a block of data to the chip's buffer with padding if
 * neccessary, via the BAP. Synchronization/serialization is the
 * caller's problem. len must be even.
 *
 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
 */
int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_len, unsigned len,
		      u16 id, u16 offset)
{
	int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
	int err = 0;

	if (len < 0 || len % 2 || data_len > len)
		return -EINVAL;

	err = hermes_bap_seek(hw, bap, id, offset);
	if (err)
		goto out;

	/* Transfer all the complete words of data */
	hermes_write_words(hw, dreg, buf, data_len/2);
	/* If there is an odd byte left over pad and transfer it */
	if (data_len & 1) {
		u8 end[2];
		end[1] = 0;
		end[0] = ((unsigned char *)buf)[data_len - 1];
		hermes_write_words(hw, dreg, end, 1);
		data_len ++;
	}
	/* Now send zeros for the padding */
	if (data_len < len)
		hermes_clear_words(hw, dreg, (len - data_len) / 2);
	/* Complete */
 out:
	return err;
}
Exemple #2
0
int hermes_write_ltv(hermes_t *hw, int bap, u16 rid, 
		     u16 length, const void *value)
{
	int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
	int err = 0;
	unsigned count;

	if (length == 0)
		return -EINVAL;

	err = hermes_bap_seek(hw, bap, rid, 0);
	if (err)
		return err;

	hermes_write_reg(hw, dreg, length);
	hermes_write_reg(hw, dreg, rid);

	count = length - 1;

	hermes_write_words(hw, dreg, value, count);

	err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE, 
				rid, NULL);

	return err;
}
Exemple #3
0
int hermes_write_ltv(hermes_t *hw, int bap, u16 rid, 
		     u16 length, const void *value)
{
	int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
	int err = 0;
	hermes_response_t resp;
	int count;
	
	DEBUG(3, "write_ltv(): bap=%d rid=0x%04x length=%d (value=0x%04x)\n",
	      bap, rid, length, * ((u16 *)value));

	err = hermes_bap_seek(hw, bap, rid, 0);
	if (err)
		goto out;

	hermes_write_reg(hw, dreg, length);
	hermes_write_reg(hw, dreg, rid);

	count = length - 1;

	hermes_write_words(hw, dreg, value, count);

	err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE, 
				rid, &resp);

 out:
	return err;
}
Exemple #4
0
/* Write a block of data to the chip's buffer, via the
 * BAP. Synchronization/serialization is the caller's problem. len
 * must be even.
 *
 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
 */
int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, unsigned len,
		      u16 id, u16 offset)
{
	int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
	int err = 0;

	if ( (len < 0) || (len % 2) )
		return -EINVAL;

	err = hermes_bap_seek(hw, bap, id, offset);
	if (err)
		goto out;
	
	/* Actually do the transfer */
	hermes_write_words(hw, dreg, buf, len/2);

 out:	
	return err;
}