Skip to contentSkip to conversation

MPC8xx I2C

U-Boot-Users Ben Warren 1 participant 1 message Jan 30, 2008

lore
Share & tools
lore

Ben Warren

author
#0 lore raw

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