From 3a0964387beec2f12695fbdd0217e46c85eb3264 Mon Sep 17 00:00:00 2001 From: David Wu Date: Thu, 18 Oct 2018 20:26:05 +0800 Subject: [PATCH] i2c: rk3x: Disable irq after i2c transfer finished MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some case,log like this: [ 12.393926] rk3x-i2c ff150000.i2c: irq in STATE_IDLE, ipd = 0x51 [ 12.416592] rk3x-i2c ff150000.i2c: irq in STATE_IDLE, ipd = 0x51 The i2c clock is disabled, so the pending irq clean is not worked. Disable the interrupt after the i2c jobs were done, the error log would not happen. Change-Id: If04a2e2214d675410c67db0f131ee7ef635ddcb4 Signed-off-by: David Wu --- drivers/i2c/busses/i2c-rk3x.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 653e471ca9cb..f9e5bb038713 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c @@ -79,6 +79,9 @@ enum { #define REG_INT_NAKRCV BIT(6) /* NACK received */ #define REG_INT_ALL 0xff +/* Disable i2c all irqs */ +#define IEN_ALL_DISABLE 0 + /* Constants */ #define WAIT_TIMEOUT 1000 /* ms */ #define DEFAULT_SCL_RATE (100 * 1000) /* Hz */ @@ -246,6 +249,11 @@ static inline void rk3x_i2c_clean_ipd(struct rk3x_i2c *i2c) i2c_writel(i2c, REG_INT_ALL, REG_IPD); } +static inline void rk3x_i2c_disable_irq(struct rk3x_i2c *i2c) +{ + i2c_writel(i2c, IEN_ALL_DISABLE, REG_IEN); +} + static inline void rk3x_i2c_disable(struct rk3x_i2c *i2c) { u32 val = i2c_readl(i2c, REG_CON) & REG_CON_TUNING_MASK; @@ -1108,7 +1116,7 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap, i2c_readl(i2c, REG_IPD), i2c->state); /* Force a STOP condition without interrupt */ - i2c_writel(i2c, 0, REG_IEN); + rk3x_i2c_disable_irq(i2c); val = i2c_readl(i2c, REG_CON) & REG_CON_TUNING_MASK; val |= REG_CON_EN | REG_CON_STOP; i2c_writel(i2c, val, REG_CON); @@ -1125,6 +1133,10 @@ static int rk3x_i2c_xfer(struct i2c_adapter *adap, } } + /* Interrupt is disabled when i2c transfer is timeout */ + if (timeout != 0) + rk3x_i2c_disable_irq(i2c); + rk3x_i2c_disable(i2c); clk_disable(i2c->pclk);