All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: bcm2835: Avoid clock stretching timeouts
@ 2018-02-23 21:42 ` Stefan Wahren
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Wahren @ 2018-02-23 21:42 UTC (permalink / raw)
  To: Wolfram Sang, Eric Anholt
  Cc: Noralf Trønnes, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

From: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>

The CLKT register contains at poweron 0x40, which at our typical 100kHz
bus rate means .64ms. But there is no specified limit to how long devices
should be able to stretch the clocks, so just disable the timeout. We
still have a timeout wrapping the entire transfer.

Signed-off-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
---
Hi,
just like "i2c: bcm2835: Set up the rising/falling edge delays" this is a
outstanding bugfix. Unfortunately i only have I2C slaves, which doesn't
stretch the clock. So test feedback is very welcome.


 drivers/i2c/busses/i2c-bcm2835.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 44deae7..ccd2565 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -28,6 +28,11 @@
 #define BCM2835_I2C_FIFO	0x10
 #define BCM2835_I2C_DIV		0x14
 #define BCM2835_I2C_DEL		0x18
+/*
+ * 16-bit field for the number of SCL cycles to wait after rising SCL
+ * before deciding the slave is not responding.  0 disables the
+ * timeout detection.
+ */
 #define BCM2835_I2C_CLKT	0x1c
 
 #define BCM2835_I2C_C_READ	BIT(0)
@@ -386,6 +391,12 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
 	adap->dev.of_node = pdev->dev.of_node;
 	adap->quirks = &bcm2835_i2c_quirks;
 
+	/*
+	 * Disable the hardware clock stretching timeout.  SMBUS
+	 * specifies a limit for how long the device can stretch the
+	 * clock, but core I2C doesn't.
+	 */
+	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_CLKT, 0);
 	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0);
 
 	ret = i2c_add_adapter(adap);
-- 
2.7.4

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

* [PATCH] i2c: bcm2835: Avoid clock stretching timeouts
@ 2018-02-23 21:42 ` Stefan Wahren
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Wahren @ 2018-02-23 21:42 UTC (permalink / raw)
  To: linux-arm-kernel

From: Eric Anholt <eric@anholt.net>

The CLKT register contains at poweron 0x40, which at our typical 100kHz
bus rate means .64ms. But there is no specified limit to how long devices
should be able to stretch the clocks, so just disable the timeout. We
still have a timeout wrapping the entire transfer.

Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
Hi,
just like "i2c: bcm2835: Set up the rising/falling edge delays" this is a
outstanding bugfix. Unfortunately i only have I2C slaves, which doesn't
stretch the clock. So test feedback is very welcome.


 drivers/i2c/busses/i2c-bcm2835.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 44deae7..ccd2565 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -28,6 +28,11 @@
 #define BCM2835_I2C_FIFO	0x10
 #define BCM2835_I2C_DIV		0x14
 #define BCM2835_I2C_DEL		0x18
+/*
+ * 16-bit field for the number of SCL cycles to wait after rising SCL
+ * before deciding the slave is not responding.  0 disables the
+ * timeout detection.
+ */
 #define BCM2835_I2C_CLKT	0x1c
 
 #define BCM2835_I2C_C_READ	BIT(0)
@@ -386,6 +391,12 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
 	adap->dev.of_node = pdev->dev.of_node;
 	adap->quirks = &bcm2835_i2c_quirks;
 
+	/*
+	 * Disable the hardware clock stretching timeout.  SMBUS
+	 * specifies a limit for how long the device can stretch the
+	 * clock, but core I2C doesn't.
+	 */
+	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_CLKT, 0);
 	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0);
 
 	ret = i2c_add_adapter(adap);
-- 
2.7.4

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

* Re: [PATCH] i2c: bcm2835: Avoid clock stretching timeouts
  2018-02-23 21:42 ` Stefan Wahren
@ 2018-02-26 23:33   ` Eric Anholt
  -1 siblings, 0 replies; 6+ messages in thread
From: Eric Anholt @ 2018-02-26 23:33 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Stefan Wahren, Noralf Trønnes, linux-i2c, linux-arm-kernel,
	linux-rpi-kernel


[-- Attachment #1.1: Type: text/plain, Size: 826 bytes --]

Stefan Wahren <stefan.wahren@i2se.com> writes:

> From: Eric Anholt <eric@anholt.net>
>
> The CLKT register contains at poweron 0x40, which at our typical 100kHz
> bus rate means .64ms. But there is no specified limit to how long devices
> should be able to stretch the clocks, so just disable the timeout. We
> still have a timeout wrapping the entire transfer.
>
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
> Hi,
> just like "i2c: bcm2835: Set up the rising/falling edge delays" this is a
> outstanding bugfix. Unfortunately i only have I2C slaves, which doesn't
> stretch the clock. So test feedback is very welcome.

I also didn't have any particular devices that this fixed.  It was just
an issue that came up in a previous discussion of clock stretching.

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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] i2c: bcm2835: Avoid clock stretching timeouts
@ 2018-02-26 23:33   ` Eric Anholt
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Anholt @ 2018-02-26 23:33 UTC (permalink / raw)
  To: linux-arm-kernel

Stefan Wahren <stefan.wahren@i2se.com> writes:

> From: Eric Anholt <eric@anholt.net>
>
> The CLKT register contains at poweron 0x40, which at our typical 100kHz
> bus rate means .64ms. But there is no specified limit to how long devices
> should be able to stretch the clocks, so just disable the timeout. We
> still have a timeout wrapping the entire transfer.
>
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---
> Hi,
> just like "i2c: bcm2835: Set up the rising/falling edge delays" this is a
> outstanding bugfix. Unfortunately i only have I2C slaves, which doesn't
> stretch the clock. So test feedback is very welcome.

I also didn't have any particular devices that this fixed.  It was just
an issue that came up in a previous discussion of clock stretching.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180226/0b6ffd48/attachment.sig>

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

* Re: [PATCH] i2c: bcm2835: Avoid clock stretching timeouts
  2018-02-23 21:42 ` Stefan Wahren
@ 2022-02-07 15:08   ` Wolfram Sang
  -1 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2022-02-07 15:08 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Eric Anholt, Noralf Trønnes, linux-i2c, linux-rpi-kernel,
	linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 717 bytes --]

On Fri, Feb 23, 2018 at 10:42:31PM +0100, Stefan Wahren wrote:
> From: Eric Anholt <eric@anholt.net>
> 
> The CLKT register contains at poweron 0x40, which at our typical 100kHz
> bus rate means .64ms. But there is no specified limit to how long devices
> should be able to stretch the clocks, so just disable the timeout. We
> still have a timeout wrapping the entire transfer.
> 
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>

Okay, it has been years but the issue came up again [1] so finally
applied to for-current with stable added, thanks!

[1] http://patchwork.ozlabs.org/project/linux-i2c/patch/20220117102504.90585-1-iivanov@suse.de/


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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] i2c: bcm2835: Avoid clock stretching timeouts
@ 2022-02-07 15:08   ` Wolfram Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2022-02-07 15:08 UTC (permalink / raw)
  To: Stefan Wahren
  Cc: Eric Anholt, Noralf Trønnes, linux-i2c, linux-rpi-kernel,
	linux-arm-kernel

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

On Fri, Feb 23, 2018 at 10:42:31PM +0100, Stefan Wahren wrote:
> From: Eric Anholt <eric@anholt.net>
> 
> The CLKT register contains at poweron 0x40, which at our typical 100kHz
> bus rate means .64ms. But there is no specified limit to how long devices
> should be able to stretch the clocks, so just disable the timeout. We
> still have a timeout wrapping the entire transfer.
> 
> Signed-off-by: Eric Anholt <eric@anholt.net>
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>

Okay, it has been years but the issue came up again [1] so finally
applied to for-current with stable added, thanks!

[1] http://patchwork.ozlabs.org/project/linux-i2c/patch/20220117102504.90585-1-iivanov@suse.de/


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

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

end of thread, other threads:[~2022-02-07 15:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-23 21:42 [PATCH] i2c: bcm2835: Avoid clock stretching timeouts Stefan Wahren
2018-02-23 21:42 ` Stefan Wahren
2018-02-26 23:33 ` Eric Anholt
2018-02-26 23:33   ` Eric Anholt
2022-02-07 15:08 ` Wolfram Sang
2022-02-07 15:08   ` 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.