Skip to content

Commit f1e5bbe

Browse files
wangbaolin719gregkh
authored andcommitted
i2c: sprd: Fix the i2c count issue
[ Upstream commit 2a01046 ] 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> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 201dc13 commit f1e5bbe

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎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)