Skip to content

Commit fa4d305

Browse files
ceggers-arriwsakernel
authored andcommitted
i2c: imx: Fix reset of I2SR_IAL flag
According to the "VFxxx Controller Reference Manual" (and the comment block starting at line 97), Vybrid requires writing a one for clearing an interrupt flag. Syncing the method for clearing I2SR_IIF in i2c_imx_isr(). Signed-off-by: Christian Eggers <[email protected]> Fixes: 4b77502 ("i2c: imx: add struct to hold more configurable quirks") Reviewed-by: Uwe Kleine-König <[email protected]> Cc: [email protected] Signed-off-by: Wolfram Sang <[email protected]>
1 parent 549738f commit fa4d305

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

drivers/i2c/busses/i2c-imx.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,19 @@ static void i2c_imx_dma_free(struct imx_i2c_struct *i2c_imx)
412412
dma->chan_using = NULL;
413413
}
414414

415+
static void i2c_imx_clear_irq(struct imx_i2c_struct *i2c_imx, unsigned int bits)
416+
{
417+
unsigned int temp;
418+
419+
/*
420+
* i2sr_clr_opcode is the value to clear all interrupts. Here we want to
421+
* clear only <bits>, so we write ~i2sr_clr_opcode with just <bits>
422+
* toggled. This is required because i.MX needs W1C and Vybrid uses W0C.
423+
*/
424+
temp = ~i2c_imx->hwdata->i2sr_clr_opcode ^ bits;
425+
imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR);
426+
}
427+
415428
static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy, bool atomic)
416429
{
417430
unsigned long orig_jiffies = jiffies;
@@ -424,8 +437,7 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy, bool a
424437

425438
/* check for arbitration lost */
426439
if (temp & I2SR_IAL) {
427-
temp &= ~I2SR_IAL;
428-
imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR);
440+
i2c_imx_clear_irq(i2c_imx, I2SR_IAL);
429441
return -EAGAIN;
430442
}
431443

@@ -623,9 +635,7 @@ static irqreturn_t i2c_imx_isr(int irq, void *dev_id)
623635
if (temp & I2SR_IIF) {
624636
/* save status register */
625637
i2c_imx->i2csr = temp;
626-
temp &= ~I2SR_IIF;
627-
temp |= (i2c_imx->hwdata->i2sr_clr_opcode & I2SR_IIF);
628-
imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR);
638+
i2c_imx_clear_irq(i2c_imx, I2SR_IIF);
629639
wake_up(&i2c_imx->queue);
630640
return IRQ_HANDLED;
631641
}

0 commit comments

Comments
 (0)