From fd1cd4a26c0f752a3270b424df4d8a6841ae7baf 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 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index ebf727e1816b..09283ca1b275 100644 --- a/drivers/i2c/busses/i2c-rk3x.c +++ b/drivers/i2c/busses/i2c-rk3x.c @@ -77,6 +77,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 */ @@ -252,6 +255,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; @@ -1131,7 +1139,7 @@ static int rk3x_i2c_xfer_common(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); @@ -1148,6 +1156,7 @@ static int rk3x_i2c_xfer_common(struct i2c_adapter *adap, } } + rk3x_i2c_disable_irq(i2c); rk3x_i2c_disable(i2c); clk_disable(i2c->pclk);