All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] i2c: rcar: slave: only send STOP event when we have been addressed
@ 2020-06-29 16:15 Wolfram Sang
  2020-07-26 12:30 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2020-06-29 16:15 UTC (permalink / raw)
  To: linux-i2c; +Cc: linux-renesas-soc, Wolfram Sang

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>
---

Change since v1: It is probably cleaner to clear the SSR flag before we
enable the SSR interrupt.

 drivers/i2c/busses/i2c-rcar.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index a45c4bf1ec01..51a3909f8688 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -572,6 +572,9 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv)
 
 	/* address detected */
 	if (ssr_filtered & SAR) {
+		/* Clear SSR, too, because of old STOPs to other clients than us */
+		rcar_i2c_write(priv, ICSSR, ~(SAR | SSR) & 0xff);
+
 		/* read or write request */
 		if (ssr_raw & STM) {
 			i2c_slave_event(priv->slave, I2C_SLAVE_READ_REQUESTED, &value);
@@ -582,14 +585,12 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv)
 			rcar_i2c_read(priv, ICRXTX);	/* dummy read */
 			rcar_i2c_write(priv, ICSIER, SDR | SSR | SAR);
 		}
-
-		rcar_i2c_write(priv, ICSSR, ~SAR & 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);
 	}
 
@@ -853,7 +854,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;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] i2c: rcar: slave: only send STOP event when we have been addressed
  2020-06-29 16:15 [PATCH v2] i2c: rcar: slave: only send STOP event when we have been addressed Wolfram Sang
@ 2020-07-26 12:30 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2020-07-26 12:30 UTC (permalink / raw)
  To: linux-i2c; +Cc: linux-renesas-soc

[-- Attachment #1: Type: text/plain, Size: 763 bytes --]

On Mon, Jun 29, 2020 at 06:15:06PM +0200, Wolfram Sang wrote:
> 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>
> ---
> 
> Change since v1: It is probably cleaner to clear the SSR flag before we
> enable the SSR interrupt.

I am going to apply v1 of this patch. The above is not cleaner. It is
cleaner to clear SAR only when we are done with everything to make sure
SCL is stretched long enough. Clearing SSR a tad later is still good
enough.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-26 12:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 16:15 [PATCH v2] i2c: rcar: slave: only send STOP event when we have been addressed Wolfram Sang
2020-07-26 12:30 ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.