Skip to content

Commit fd01eec

Browse files
rayagondaWolfram Sang
authored andcommitted
i2c: iproc: Fix i2c master read more than 63 bytes
Use SMBUS_MASTER_DATA_READ.MASTER_RD_STATUS bit to check for RX FIFO empty condition because SMBUS_MASTER_FIFO_CONTROL.MASTER_RX_PKT_COUNT is not updated for read >= 64 bytes. This fixes the issue when trying to read from the I2C slave more than 63 bytes. Fixes: c24b8d5 ("i2c: iproc: Extend I2C read up to 255 bytes") Cc: stable@kernel.org Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com> Reviewed-by: Ray Jui <ray.jui@broadcom.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent 3a5ff11 commit fd01eec

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/i2c/busses/i2c-bcm-iproc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,18 @@ static bool bcm_iproc_i2c_slave_isr(struct bcm_iproc_i2c_dev *iproc_i2c,
392392
static void bcm_iproc_i2c_read_valid_bytes(struct bcm_iproc_i2c_dev *iproc_i2c)
393393
{
394394
struct i2c_msg *msg = iproc_i2c->msg;
395+
uint32_t val;
395396

396397
/* Read valid data from RX FIFO */
397398
while (iproc_i2c->rx_bytes < msg->len) {
398-
if (!((iproc_i2c_rd_reg(iproc_i2c, M_FIFO_CTRL_OFFSET) >> M_FIFO_RX_CNT_SHIFT)
399-
& M_FIFO_RX_CNT_MASK))
399+
val = iproc_i2c_rd_reg(iproc_i2c, M_RX_OFFSET);
400+
401+
/* rx fifo empty */
402+
if (!((val >> M_RX_STATUS_SHIFT) & M_RX_STATUS_MASK))
400403
break;
401404

402405
msg->buf[iproc_i2c->rx_bytes] =
403-
(iproc_i2c_rd_reg(iproc_i2c, M_RX_OFFSET) >>
404-
M_RX_DATA_SHIFT) & M_RX_DATA_MASK;
406+
(val >> M_RX_DATA_SHIFT) & M_RX_DATA_MASK;
405407
iproc_i2c->rx_bytes++;
406408
}
407409
}

0 commit comments

Comments
 (0)