Skip to content

Commit 4e36c0f

Browse files
Wolfram SangAndi Shyti
authored andcommitted
i2c: rcar: bring hardware to known state when probing
When probing, the hardware is not brought into a known state. This may be a problem when a hypervisor restarts Linux without resetting the hardware, leaving an old state running. Make sure the hardware gets initialized, especially interrupts should be cleared and disabled. Reported-by: Dirk Behme <[email protected]> Reported-by: Geert Uytterhoeven <[email protected]> Closes: https://lore.kernel.org/r/[email protected] Fixes: 6ccbe60 ("i2c: add Renesas R-Car I2C driver") Signed-off-by: Wolfram Sang <[email protected]> Signed-off-by: Andi Shyti <[email protected]>
1 parent 256abd8 commit 4e36c0f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/i2c/busses/i2c-rcar.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,14 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv)
257257
}
258258
}
259259

260+
static void rcar_i2c_reset_slave(struct rcar_i2c_priv *priv)
261+
{
262+
rcar_i2c_write(priv, ICSIER, 0);
263+
rcar_i2c_write(priv, ICSSR, 0);
264+
rcar_i2c_write(priv, ICSCR, SDBS);
265+
rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */
266+
}
267+
260268
static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
261269
{
262270
int ret;
@@ -1033,11 +1041,8 @@ static int rcar_unreg_slave(struct i2c_client *slave)
10331041

10341042
/* ensure no irq is running before clearing ptr */
10351043
disable_irq(priv->irq);
1036-
rcar_i2c_write(priv, ICSIER, 0);
1037-
rcar_i2c_write(priv, ICSSR, 0);
1044+
rcar_i2c_reset_slave(priv);
10381045
enable_irq(priv->irq);
1039-
rcar_i2c_write(priv, ICSCR, SDBS);
1040-
rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */
10411046

10421047
priv->slave = NULL;
10431048

@@ -1152,7 +1157,9 @@ static int rcar_i2c_probe(struct platform_device *pdev)
11521157
goto out_pm_disable;
11531158
}
11541159

1155-
rcar_i2c_write(priv, ICSAR, 0); /* Gen2: must be 0 if not using slave */
1160+
/* Bring hardware to known state */
1161+
rcar_i2c_init(priv);
1162+
rcar_i2c_reset_slave(priv);
11561163

11571164
if (priv->devtype < I2C_RCAR_GEN3) {
11581165
irqflags |= IRQF_NO_THREAD;

0 commit comments

Comments
 (0)