示例#1
0
int early_i2c_read (u8 dev, uint addr, int alen, u8 * data, int length)
{
	int i = 0;
	u8 *a = (u8 *) & addr;

	/* wait while i2c bus is busy */
	if (i2c_wait4bus () < 0)
		goto exit;

	/* transmite the slave_addr+read/write phase */
	if (i2c_write_addr (dev, I2C_WRITE, 0) == 0)
		goto exit;

	/* select the i2c slave internal regs phase */
	/* because u32 -> u8, and big endian, so if alen is 1, write a[3] */
	if (__i2c_write (&a[4 - alen], alen) != alen)
		goto exit;
	/* dummy read phase */
	if (i2c_write_addr (dev, I2C_READ, 1) == 0)
		goto exit;

	/* transmite data phase */
	i = __i2c_read (data, length);

exit:
	writel (M83xx_CCR_MEN, I2CCCR);

	return !(i == length);
}
示例#2
0
int
i2c_write (u8 dev, uint addr, int alen, u8 *data, int length)
{
	int i = 0;
	u8 *a = (u8*)&addr;

	if (i2c_wait4bus () < 0)
		goto exit;

	if (i2c_write_addr (dev, I2C_WRITE, 0) == 0)
		goto exit;

	if (__i2c_write (&a[4 - alen], alen) != alen)
		goto exit;

	i = __i2c_write (data, length);

 exit:
	writeb(I2C_CR_MEN, &I2C->cr);
	return !(i == length);
}