aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/i2c/busses/i2c-img-scb.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
index 3795fe130ef2..c92bcf7c204f 100644
--- a/drivers/i2c/busses/i2c-img-scb.c
+++ b/drivers/i2c/busses/i2c-img-scb.c
@@ -750,7 +750,9 @@ static unsigned int img_i2c_atomic(struct img_i2c *i2c,
750 next_cmd = CMD_RET_ACK; 750 next_cmd = CMD_RET_ACK;
751 break; 751 break;
752 case CMD_RET_ACK: 752 case CMD_RET_ACK:
753 if (i2c->line_status & LINESTAT_ACK_DET) { 753 if (i2c->line_status & LINESTAT_ACK_DET ||
754 (i2c->line_status & LINESTAT_NACK_DET &&
755 i2c->msg.flags & I2C_M_IGNORE_NAK)) {
754 if (i2c->msg.len == 0) { 756 if (i2c->msg.len == 0) {
755 next_cmd = CMD_GEN_STOP; 757 next_cmd = CMD_GEN_STOP;
756 } else if (i2c->msg.flags & I2C_M_RD) { 758 } else if (i2c->msg.flags & I2C_M_RD) {
@@ -1017,20 +1019,23 @@ static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
1017 return -EIO; 1019 return -EIO;
1018 1020
1019 for (i = 0; i < num; i++) { 1021 for (i = 0; i < num; i++) {
1020 if (likely(msgs[i].len))
1021 continue;
1022 /* 1022 /*
1023 * 0 byte reads are not possible because the slave could try 1023 * 0 byte reads are not possible because the slave could try
1024 * and pull the data line low, preventing a stop bit. 1024 * and pull the data line low, preventing a stop bit.
1025 */ 1025 */
1026 if (unlikely(msgs[i].flags & I2C_M_RD)) 1026 if (!msgs[i].len && msgs[i].flags & I2C_M_RD)
1027 return -EIO; 1027 return -EIO;
1028 /* 1028 /*
1029 * 0 byte writes are possible and used for probing, but we 1029 * 0 byte writes are possible and used for probing, but we
1030 * cannot do them in automatic mode, so use atomic mode 1030 * cannot do them in automatic mode, so use atomic mode
1031 * instead. 1031 * instead.
1032 *
1033 * Also, the I2C_M_IGNORE_NAK mode can only be implemented
1034 * in atomic mode.
1032 */ 1035 */
1033 atomic = true; 1036 if (!msgs[i].len ||
1037 (msgs[i].flags & I2C_M_IGNORE_NAK))
1038 atomic = true;
1034 } 1039 }
1035 1040
1036 ret = clk_prepare_enable(i2c->scb_clk); 1041 ret = clk_prepare_enable(i2c->scb_clk);