i2c: rcar: always clear ICSAR to avoid side effects
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Sat, 4 Jul 2020 13:38:29 +0000 (15:38 +0200)
committerWolfram Sang <wsa@kernel.org>
Thu, 23 Jul 2020 20:25:18 +0000 (22:25 +0200)
On R-Car Gen2, we get a timeout when reading from the address set in
ICSAR, even though the slave interface is disabled. Clearing it fixes
this situation. Note that Gen3 is not affected.

To reproduce: bind and undbind an I2C slave on some bus, run
'i2cdetect' on that bus.

Fixes: de20d1857dd6 ("i2c: rcar: add slave support")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/busses/i2c-rcar.c

index a45c4bf1ec014e84b314c042edc365294a6de027..2e3e1bb75013454867c1a1d1e32036c165db7652 100644 (file)
@@ -868,6 +868,7 @@ static int rcar_unreg_slave(struct i2c_client *slave)
        /* disable irqs and ensure none is running before clearing ptr */
        rcar_i2c_write(priv, ICSIER, 0);
        rcar_i2c_write(priv, ICSCR, 0);
+       rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */
 
        synchronize_irq(priv->irq);
        priv->slave = NULL;
@@ -969,6 +970,8 @@ static int rcar_i2c_probe(struct platform_device *pdev)
        if (ret < 0)
                goto out_pm_put;
 
+       rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */
+
        if (priv->devtype == I2C_RCAR_GEN3) {
                priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
                if (!IS_ERR(priv->rstc)) {