i2c: rcar: slave: only send STOP event when we have been addressed
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Mon, 29 Jun 2020 15:38:07 +0000 (17:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 09:02:10 +0000 (11:02 +0200)
[ Upstream commit 314139f9f0abdba61ed9a8463bbcb0bf900ac5a2 ]

When the SSR interrupt is activated, it will detect every STOP condition
on the bus, not only the ones after we have been addressed. So, enable
this interrupt only after we have been addressed, and disable it
otherwise.

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/i2c/busses/i2c-rcar.c

index 93b8069041bb124c94e35ab0afd9cc6a99bc9666..4231673435e7bbb42537f239e429626b9fb0d6e3 100644 (file)
@@ -527,13 +527,14 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv)
                        rcar_i2c_write(priv, ICSIER, SDR | SSR | SAR);
                }
 
-               rcar_i2c_write(priv, ICSSR, ~SAR & 0xff);
+               /* Clear SSR, too, because of old STOPs to other clients than us */
+               rcar_i2c_write(priv, ICSSR, ~(SAR | SSR) & 0xff);
        }
 
        /* master sent stop */
        if (ssr_filtered & SSR) {
                i2c_slave_event(priv->slave, I2C_SLAVE_STOP, &value);
-               rcar_i2c_write(priv, ICSIER, SAR | SSR);
+               rcar_i2c_write(priv, ICSIER, SAR);
                rcar_i2c_write(priv, ICSSR, ~SSR & 0xff);
        }
 
@@ -762,7 +763,7 @@ static int rcar_reg_slave(struct i2c_client *slave)
        priv->slave = slave;
        rcar_i2c_write(priv, ICSAR, slave->addr);
        rcar_i2c_write(priv, ICSSR, 0);
-       rcar_i2c_write(priv, ICSIER, SAR | SSR);
+       rcar_i2c_write(priv, ICSIER, SAR);
        rcar_i2c_write(priv, ICSCR, SIE | SDBS);
 
        return 0;