Skip to content

Commit 2a01046

Browse files
wangbaolin719Wolfram Sang
authored andcommitted
i2c: sprd: Fix the i2c count issue
We found the I2C controller count register is unreliable sometimes, that will cause I2C to lose data. Thus we can read the data count from 'i2c_dev->count' instead of the I2C controller count register. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent da33aa0 commit 2a01046

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/i2c/busses/i2c-sprd.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,12 @@ static irqreturn_t sprd_i2c_isr_thread(int irq, void *dev_id)
368368
struct sprd_i2c *i2c_dev = dev_id;
369369
struct i2c_msg *msg = i2c_dev->msg;
370370
bool ack = !(readl(i2c_dev->base + I2C_STATUS) & I2C_RX_ACK);
371-
u32 i2c_count = readl(i2c_dev->base + I2C_COUNT);
372371
u32 i2c_tran;
373372

374373
if (msg->flags & I2C_M_RD)
375374
i2c_tran = i2c_dev->count >= I2C_FIFO_FULL_THLD;
376375
else
377-
i2c_tran = i2c_count;
376+
i2c_tran = i2c_dev->count;
378377

379378
/*
380379
* If we got one ACK from slave when writing data, and we did not
@@ -412,14 +411,13 @@ static irqreturn_t sprd_i2c_isr(int irq, void *dev_id)
412411
{
413412
struct sprd_i2c *i2c_dev = dev_id;
414413
struct i2c_msg *msg = i2c_dev->msg;
415-
u32 i2c_count = readl(i2c_dev->base + I2C_COUNT);
416414
bool ack = !(readl(i2c_dev->base + I2C_STATUS) & I2C_RX_ACK);
417415
u32 i2c_tran;
418416

419417
if (msg->flags & I2C_M_RD)
420418
i2c_tran = i2c_dev->count >= I2C_FIFO_FULL_THLD;
421419
else
422-
i2c_tran = i2c_count;
420+
i2c_tran = i2c_dev->count;
423421

424422
/*
425423
* If we did not get one ACK from slave when writing data, then we

0 commit comments

Comments
 (0)