diff mbox series

[2/2] i2c: imx-lpi2c: check only for enabled interrupt flags

Message ID 20230130153247.445027-2-alexander.stein@ew.tq-group.com
State New
Headers show
Series [1/2] i2c: imx-lpi2c: clean rx/tx buffers upon new message | expand

Commit Message

Alexander Stein Jan. 30, 2023, 3:32 p.m. UTC
When reading from I2C, the Tx watermark is set to 0. Unfortunately the
TDF (transmit data flag) is enabled when Tx FIFO entries is equal or less
than watermark. So it is set in every case, hence the reset default of 1.
This results in the MSR_RDF _and_ MSR_TDF flags to be set thus trying
to send Tx data on a read message.
Mask the IRQ status to filter for wanted flags only.

Fixes: a55fa9d0e42e ("i2c: imx-lpi2c: add low power i2c bus driver")
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
To be honest I'm wondering why this didn't occur to somebody else before.
The behaviour also matches the downstream kernel which does

> if (temp & MSR_RDF)
>	lpi2c_imx_read_rxfifo(lpi2c_imx);
> else if (temp & MSR_TDF)
>	lpi2c_imx_write_txfifo(lpi2c_imx);

avoiding handling both Rx and Tx events.

 drivers/i2c/busses/i2c-imx-lpi2c.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Wolfram Sang March 16, 2023, 7:36 p.m. UTC | #1
On Mon, Jan 30, 2023 at 04:32:47PM +0100, Alexander Stein wrote:
> When reading from I2C, the Tx watermark is set to 0. Unfortunately the
> TDF (transmit data flag) is enabled when Tx FIFO entries is equal or less
> than watermark. So it is set in every case, hence the reset default of 1.
> This results in the MSR_RDF _and_ MSR_TDF flags to be set thus trying
> to send Tx data on a read message.
> Mask the IRQ status to filter for wanted flags only.
> 
> Fixes: a55fa9d0e42e ("i2c: imx-lpi2c: add low power i2c bus driver")
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>

Applied to for-current, thanks!
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index c6d0225246e6..a49b14d52a98 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -505,10 +505,14 @@  static int lpi2c_imx_xfer(struct i2c_adapter *adapter,
 static irqreturn_t lpi2c_imx_isr(int irq, void *dev_id)
 {
 	struct lpi2c_imx_struct *lpi2c_imx = dev_id;
+	unsigned int enabled;
 	unsigned int temp;
 
+	enabled = readl(lpi2c_imx->base + LPI2C_MIER);
+
 	lpi2c_imx_intctrl(lpi2c_imx, 0);
 	temp = readl(lpi2c_imx->base + LPI2C_MSR);
+	temp &= enabled;
 
 	if (temp & MSR_RDF)
 		lpi2c_imx_read_rxfifo(lpi2c_imx);