cd404efcc0d4e6caa463ddb43fba307b0b492f42
[openwrt/staging/mkresin.git] /
1 From 85048a8a0df324df94f9585c1e01d0a4419de4dc Mon Sep 17 00:00:00 2001
2 From: Clark Wang <xiaoning.wang@nxp.com>
3 Date: Wed, 27 Nov 2019 14:23:55 +0800
4 Subject: [PATCH] LF-98 i2c: imx: fix the judgement of slave mode in isr
5
6 The I2CR[MSTA] will be modified by software or hardware even in master
7 mode. The judgment of slave mode by reading CR register is unreliable.
8 Change to use i2c_imx->slave registered status to judge i2c mode.
9
10 Acked-by: Fugang Duan <fugang.duan@nxp.com>
11 Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
12 ---
13 drivers/i2c/busses/i2c-imx.c | 13 +++++--------
14 1 file changed, 5 insertions(+), 8 deletions(-)
15
16 --- a/drivers/i2c/busses/i2c-imx.c
17 +++ b/drivers/i2c/busses/i2c-imx.c
18 @@ -1482,23 +1482,20 @@ static const struct i2c_algorithm i2c_im
19 static irqreturn_t i2c_imx_isr(int irq, void *dev_id)
20 {
21 struct imx_i2c_struct *i2c_imx = dev_id;
22 - unsigned int status, ctl;
23 - irqreturn_t irq_status = IRQ_NONE;
24 + unsigned int status;
25
26 status = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR);
27 - ctl = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
28
29 if (status & I2SR_IIF) {
30 i2c_imx_clr_if_bit(status, i2c_imx);
31 - if (ctl & I2CR_MSTA)
32 - irq_status = i2c_imx_master_isr(i2c_imx);
33 #if IS_ENABLED(CONFIG_I2C_SLAVE)
34 - else
35 - irq_status = i2c_imx_slave_isr(i2c_imx);
36 + if (i2c_imx->slave)
37 + return i2c_imx_slave_isr(i2c_imx);
38 #endif
39 + return i2c_imx_master_isr(i2c_imx);
40 }
41
42 - return irq_status;
43 + return IRQ_NONE;
44 }
45
46 static int i2c_imx_probe(struct platform_device *pdev)