diff options
author | David Wu <david.wu@rock-chips.com> | 2018-10-18 20:26:05 +0800 |
---|---|---|
committer | Tao Huang <huangtao@rock-chips.com> | 2018-10-22 11:11:08 +0800 |
commit | d5635ca05b11659179776c208b4fb12349b1285d (patch) | |
tree | 3669482f109234836568c958597a8a098b1d2831 | |
parent | 9861dcac9c529e9bc6bc998d94737305d16dd703 (diff) |
i2c: rk3x: Disable irq after i2c transfer finished
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 <david.wu@rock-chips.com>
-rw-r--r-- | drivers/i2c/busses/i2c-rk3x.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c index 2fc598588703..d0490b1b21ce 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 */ @@ -245,6 +248,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; @@ -1107,7 +1115,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); @@ -1124,6 +1132,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); |