Skip to content

Commit

Permalink
drivers: i2c: xec: Handle additional I2C flags for read
Browse files Browse the repository at this point in the history
I2C restart flag is now handled during I2C reads

Signed-off-by: Jose Alberto Meza <[email protected]>
  • Loading branch information
albertofloyd authored and nashif committed Oct 11, 2019
1 parent 8ffff14 commit cb6097d
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions drivers/i2c/i2c_mchp_xec.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ static int i2c_xec_poll_write(struct device *dev, struct i2c_msg msg,

/* Send bytes */
for (int i = 0U; i < msg.len; i++) {

MCHP_I2C_SMB_DATA(ba) = msg.buf[i];
ret = wait_completion(ba);
if (ret) {
Expand All @@ -283,6 +282,7 @@ static int i2c_xec_poll_write(struct device *dev, struct i2c_msg msg,
}
}
}

return 0;
}

Expand All @@ -297,15 +297,17 @@ static int i2c_xec_poll_read(struct device *dev, struct i2c_msg msg,
u8_t byte, ctrl;
int ret;

/* Check clock and data lines */
if (check_lines(ba)) {
return -EBUSY;
}
if (!(msg.flags & I2C_MSG_RESTART)) {
/* Check clock and data lines */
if (check_lines(ba)) {
return -EBUSY;
}

/* Wait until bus is free */
ret = wait_bus_free(ba);
if (ret) {
return ret;
/* Wait until bus is free */
ret = wait_bus_free(ba);
if (ret) {
return ret;
}
}

/* Send slave address */
Expand Down Expand Up @@ -354,11 +356,6 @@ static int i2c_xec_poll_read(struct device *dev, struct i2c_msg msg,
msg.buf[i] = MCHP_I2C_SMB_DATA(ba);
}

/* Check clock and data lines */
if (check_lines(ba)) {
return -EBUSY;
}

return 0;
}

Expand Down

0 comments on commit cb6097d

Please sign in to comment.