[U-Boot-Users] MPC8xx I2C

Ben Warren biggerbadderben at gmail.com
Wed Jan 30 17:33:56 CET 2008


Hi,

I'm trying to rationalize some very common I2C code and came across the 
following:

Every controller except cpu/mpc8xx implements functions like this:

---

uchar i2c_reg_read(uchar i2c_addr, uchar reg)
{
	uchar buf;

	i2c_read(i2c_addr, reg, 1, &buf, 1);
	return buf;
}

void i2c_reg_write(uchar i2c_addr, uchar reg, uchar val)
{
	i2c_write(i2c_addr, reg, 1, &val, 1);
}


---

cpu/mpc8xx, however, adds i2c_init() calls:

---

uchar i2c_reg_read(uchar i2c_addr, uchar reg)
{
	uchar buf;

	i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE);
	i2c_read(i2c_addr, reg, 1, &buf, 1);
	return (buf);
}

void i2c_reg_write(uchar i2c_addr, uchar reg, uchar val)
{
	i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE);
	i2c_write(i2c_addr, reg, 1, &val, 1);
}

---

Can somebody lend historical perspective as to why these i2c_init() 
calls are needed?

thanks,
Ben




More information about the U-Boot mailing list