i2c: rcar_iic: Read ICSR only once
authorMarek Vasut <marek.vasut@gmail.com>
Thu, 7 Mar 2019 02:41:08 +0000 (03:41 +0100)
committerHeiko Schocher <hs@denx.de>
Thu, 7 Mar 2019 05:20:09 +0000 (06:20 +0100)
Read ICSR only once to avoid missing interrupts. This happens on R8A7791
Porter during reset, when reading the PMIC register 0x13, which may fail
sometimes because of the missed DTE interrupt.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Heiko Schocher <hs@denx.de>
Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
drivers/i2c/rcar_iic.c

index e91fc86c1acc7b5f0f25ffd939f6f448dbe3034c..9d45f547d15313d24645df1ebf1800f68c8eb344 100644 (file)
@@ -58,12 +58,14 @@ static void sh_irq_dte(struct udevice *dev)
 static int sh_irq_dte_with_tack(struct udevice *dev)
 {
        struct rcar_iic_priv *priv = dev_get_priv(dev);
+       u8 icsr;
        int i;
 
        for (i = 0; i < IRQ_WAIT; i++) {
-               if (RCAR_IC_DTE & readb(priv->base + RCAR_IIC_ICSR))
+               icsr = readb(priv->base + RCAR_IIC_ICSR);
+               if (RCAR_IC_DTE & icsr)
                        break;
-               if (RCAR_IC_TACK & readb(priv->base + RCAR_IIC_ICSR))
+               if (RCAR_IC_TACK & icsr)
                        return -ETIMEDOUT;
                udelay(10);
        }