set_i2c_bus_speed(base, i2c_clk, speed);
writeb(slaveadd << 1, &base->adr);/* write slave address */
writeb(0x0, &base->sr); /* clear status register */
- writeb(I2C_CR_MEN, &base->cr); /* start I2C controller */
+ /* start I2C controller */
+ writeb(I2C_CR_MEN | I2C_CR_MIEN, &base->cr);
timeval = get_ticks();
while (readb(&base->sr) & I2C_SR_MBB) {
static int i2c_write_addr(const struct fsl_i2c_base *base, u8 dev,
u8 dir, int rsta)
{
- writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_MTX
+ writeb(I2C_CR_MEN | I2C_CR_MIEN | I2C_CR_MSTA | I2C_CR_MTX
| (rsta ? I2C_CR_RSTA : 0),
&base->cr);
{
int i;
- writeb(I2C_CR_MEN | I2C_CR_MSTA | ((length == 1) ? I2C_CR_TXAK : 0),
+ writeb(I2C_CR_MEN | I2C_CR_MIEN |
+ I2C_CR_MSTA | ((length == 1) ? I2C_CR_TXAK : 0),
&base->cr);
/* dummy read */
/* Generate ack on last next to last byte */
if (i == length - 2)
- writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_TXAK,
- &base->cr);
+ writeb(I2C_CR_MEN | I2C_CR_MIEN | I2C_CR_MSTA |
+ I2C_CR_TXAK, &base->cr);
/* Do not generate stop on last byte */
if (i == length - 1)
- writeb(I2C_CR_MEN | I2C_CR_MSTA | I2C_CR_MTX,
- &base->cr);
+ writeb(I2C_CR_MEN | I2C_CR_MIEN | I2C_CR_MSTA |
+ I2C_CR_MTX, &base->cr);
data[i] = readb(&base->dr);
}