aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/808-i2c-0013-LF-98-i2c-imx-fix-the-judgement-of-slave-mode-in-isr.patch
blob: cd404efcc0d4e6caa463ddb43fba307b0b492f42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 85048a8a0df324df94f9585c1e01d0a4419de4dc Mon Sep 17 00:00:00 2001
From: Clark Wang <xiaoning.wang@nxp.com>
Date: Wed, 27 Nov 2019 14:23:55 +0800
Subject: [PATCH] LF-98 i2c: imx: fix the judgement of slave mode in isr

The I2CR[MSTA] will be modified by software or hardware even in master
mode. The judgment of slave mode by reading CR register is unreliable.
Change to use i2c_imx->slave registered status to judge i2c mode.

Acked-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
---
 drivers/i2c/busses/i2c-imx.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -1482,23 +1482,20 @@ static const struct i2c_algorithm i2c_im
 static irqreturn_t i2c_imx_isr(int irq, void *dev_id)
 {
 	struct imx_i2c_struct *i2c_imx = dev_id;
-	unsigned int status, ctl;
-	irqreturn_t irq_status = IRQ_NONE;
+	unsigned int status;
 
 	status = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR);
-	ctl = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
 
 	if (status & I2SR_IIF) {
 		i2c_imx_clr_if_bit(status, i2c_imx);
-		if (ctl & I2CR_MSTA)
-			irq_status = i2c_imx_master_isr(i2c_imx);
 #if IS_ENABLED(CONFIG_I2C_SLAVE)
-		else
-			irq_status = i2c_imx_slave_isr(i2c_imx);
+		if (i2c_imx->slave)
+			return i2c_imx_slave_isr(i2c_imx);
 #endif
+		return i2c_imx_master_isr(i2c_imx);
 	}
 
-	return irq_status;
+	return IRQ_NONE;
 }
 
 static int i2c_imx_probe(struct platform_device *pdev)