Commit c55ebe0e authored by Sifan Naeem's avatar Sifan Naeem Committed by Wolfram Sang

i2c: img-scb: support I2C_M_IGNORE_NAK

This commit adds support for the I2C_M_IGNORE_NAK protocol
modification.

Such behaviour can only be implemented in atomic mode. So, if a
transaction contains a message with such flag the drivers
switches to atomic mode. The implementation consists simply in
treating NAKs as ACKs.
Signed-off-by: default avatarSifan Naeem <sifan.naeem@imgtec.com>
Acked-by: default avatarJames Hogan <james.hogan@imgtec.com>
Reviewed-by: default avatarJames Hartley <james.hartley@imgtec.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 54177ccf
...@@ -750,7 +750,9 @@ static unsigned int img_i2c_atomic(struct img_i2c *i2c, ...@@ -750,7 +750,9 @@ static unsigned int img_i2c_atomic(struct img_i2c *i2c,
next_cmd = CMD_RET_ACK; next_cmd = CMD_RET_ACK;
break; break;
case CMD_RET_ACK: case CMD_RET_ACK:
if (i2c->line_status & LINESTAT_ACK_DET) { if (i2c->line_status & LINESTAT_ACK_DET ||
(i2c->line_status & LINESTAT_NACK_DET &&
i2c->msg.flags & I2C_M_IGNORE_NAK)) {
if (i2c->msg.len == 0) { if (i2c->msg.len == 0) {
next_cmd = CMD_GEN_STOP; next_cmd = CMD_GEN_STOP;
} else if (i2c->msg.flags & I2C_M_RD) { } else if (i2c->msg.flags & I2C_M_RD) {
...@@ -1017,19 +1019,22 @@ static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, ...@@ -1017,19 +1019,22 @@ static int img_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
return -EIO; return -EIO;
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
if (likely(msgs[i].len))
continue;
/* /*
* 0 byte reads are not possible because the slave could try * 0 byte reads are not possible because the slave could try
* and pull the data line low, preventing a stop bit. * and pull the data line low, preventing a stop bit.
*/ */
if (unlikely(msgs[i].flags & I2C_M_RD)) if (!msgs[i].len && msgs[i].flags & I2C_M_RD)
return -EIO; return -EIO;
/* /*
* 0 byte writes are possible and used for probing, but we * 0 byte writes are possible and used for probing, but we
* cannot do them in automatic mode, so use atomic mode * cannot do them in automatic mode, so use atomic mode
* instead. * instead.
*
* Also, the I2C_M_IGNORE_NAK mode can only be implemented
* in atomic mode.
*/ */
if (!msgs[i].len ||
(msgs[i].flags & I2C_M_IGNORE_NAK))
atomic = true; atomic = true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment