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>
This commit is contained in:
David Wu
2018-10-18 20:26:05 +08:00
committed by Tao Huang
parent 9861dcac9c
commit d5635ca05b

View File

@@ -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);