All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: bcm2835: Set up the rising/falling edge delays
@ 2018-02-08 13:54 Boris Brezillon
       [not found] ` <20180208135405.25446-1-boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Boris Brezillon @ 2018-02-08 13:54 UTC (permalink / raw)
  To: Florian Fainelli, Ray Jui, Scott Branden,
	bcm-kernel-feedback-list, Stephen Warren, Lee Jones, Eric Anholt,
	linux-rpi-kernel, Wolfram Sang, linux-i2c
  Cc: Boris Brezillon, Gerd Hoffmann

From: Eric Anholt <eric@anholt.net>

We were leaving them in the power on state (or the state the firmware
had set up for some client, if we were taking over from them).  The
boot state was 30 core clocks, when we actually want to sample some
time after (to make sure that the new input bit has actually arrived).

Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
---
Hello,

I'm reviving this patch that has been posted a while ago by Gerd.
It fixes EDID retrieval on some (broken?) HDMI displays, but I'm pretty
sure it will fix other I2C setup.

Note that I also tested the change with a regular I2C device and it
worked just fine.

Regards,

Boris

Changes in v2:
- rebase on 4.15
---
 drivers/i2c/busses/i2c-bcm2835.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index cd07a69e2e93..44deae78913e 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -50,6 +50,9 @@
 #define BCM2835_I2C_S_CLKT	BIT(9)
 #define BCM2835_I2C_S_LEN	BIT(10) /* Fake bit for SW error reporting */
 
+#define BCM2835_I2C_FEDL_SHIFT	16
+#define BCM2835_I2C_REDL_SHIFT	0
+
 #define BCM2835_I2C_CDIV_MIN	0x0002
 #define BCM2835_I2C_CDIV_MAX	0xFFFE
 
@@ -81,7 +84,7 @@ static inline u32 bcm2835_i2c_readl(struct bcm2835_i2c_dev *i2c_dev, u32 reg)
 
 static int bcm2835_i2c_set_divider(struct bcm2835_i2c_dev *i2c_dev)
 {
-	u32 divider;
+	u32 divider, redl, fedl;
 
 	divider = DIV_ROUND_UP(clk_get_rate(i2c_dev->clk),
 			       i2c_dev->bus_clk_rate);
@@ -100,6 +103,22 @@ static int bcm2835_i2c_set_divider(struct bcm2835_i2c_dev *i2c_dev)
 
 	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DIV, divider);
 
+	/*
+	 * Number of core clocks to wait after falling edge before
+	 * outputting the next data bit.  Note that both FEDL and REDL
+	 * can't be greater than CDIV/2.
+	 */
+	fedl = max(divider / 16, 1u);
+
+	/*
+	 * Number of core clocks to wait after rising edge before
+	 * sampling the next incoming data bit.
+	 */
+	redl = max(divider / 4, 1u);
+
+	bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_DEL,
+			   (fedl << BCM2835_I2C_FEDL_SHIFT) |
+			   (redl << BCM2835_I2C_REDL_SHIFT));
 	return 0;
 }
 
-- 
2.14.1

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

* Re: [PATCH] i2c: bcm2835: Set up the rising/falling edge delays
       [not found] ` <20180208135405.25446-1-boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>
@ 2018-02-21  8:42   ` Wolfram Sang
  2018-02-21 22:03     ` Eric Anholt
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2018-02-21  8:42 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Scott Branden, Ray Jui, Lee Jones,
	bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA


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

On Thu, Feb 08, 2018 at 02:54:05PM +0100, Boris Brezillon wrote:
> From: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
> 
> We were leaving them in the power on state (or the state the firmware
> had set up for some client, if we were taking over from them).  The
> boot state was 30 core clocks, when we actually want to sample some
> time after (to make sure that the new input bit has actually arrived).
> 
> Signed-off-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
> Signed-off-by: Boris Brezillon <boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>
> Cc: Gerd Hoffmann <kraxel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> Hello,
> 
> I'm reviving this patch that has been posted a while ago by Gerd.
> It fixes EDID retrieval on some (broken?) HDMI displays, but I'm pretty
> sure it will fix other I2C setup.
> 
> Note that I also tested the change with a regular I2C device and it
> worked just fine.

Applied to for-current, thanks!

Could you provide a Fixes tag if you think this should go to stable?


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

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

_______________________________________________
linux-rpi-kernel mailing list
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

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

* Re: [PATCH] i2c: bcm2835: Set up the rising/falling edge delays
  2018-02-21  8:42   ` Wolfram Sang
@ 2018-02-21 22:03     ` Eric Anholt
       [not found]       ` <87h8qayp8v.fsf-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Anholt @ 2018-02-21 22:03 UTC (permalink / raw)
  To: Wolfram Sang, Boris Brezillon
  Cc: Scott Branden, Ray Jui, Lee Jones,
	bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA


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

Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org> writes:

> [ Unknown signature status ]
> On Thu, Feb 08, 2018 at 02:54:05PM +0100, Boris Brezillon wrote:
>> From: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
>> 
>> We were leaving them in the power on state (or the state the firmware
>> had set up for some client, if we were taking over from them).  The
>> boot state was 30 core clocks, when we actually want to sample some
>> time after (to make sure that the new input bit has actually arrived).
>> 
>> Signed-off-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
>> Signed-off-by: Boris Brezillon <boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>
>> Cc: Gerd Hoffmann <kraxel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> ---
>> Hello,
>> 
>> I'm reviving this patch that has been posted a while ago by Gerd.
>> It fixes EDID retrieval on some (broken?) HDMI displays, but I'm pretty
>> sure it will fix other I2C setup.
>> 
>> Note that I also tested the change with a regular I2C device and it
>> worked just fine.
>
> Applied to for-current, thanks!
>
> Could you provide a Fixes tag if you think this should go to stable?

It would be a fix back to the start of the driver, but should apply
cleanly back to:

Fixes: 9446f62e8e18 ("i2c: bcm2835: Add support for dynamic clock")

and over a year ago seems like plenty of backport.

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

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

_______________________________________________
linux-rpi-kernel mailing list
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

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

* Re: [PATCH] i2c: bcm2835: Set up the rising/falling edge delays
       [not found]       ` <87h8qayp8v.fsf-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
@ 2018-02-22 11:21         ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2018-02-22 11:21 UTC (permalink / raw)
  To: Eric Anholt
  Cc: Scott Branden, Ray Jui, Lee Jones, Boris Brezillon,
	bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA


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


> > Could you provide a Fixes tag if you think this should go to stable?
> 
> It would be a fix back to the start of the driver, but should apply
> cleanly back to:
> 
> Fixes: 9446f62e8e18 ("i2c: bcm2835: Add support for dynamic clock")
> 
> and over a year ago seems like plenty of backport.

Thanks for the input. I simply added stable now, so people can apply it as
long as it fits. I didn't use the above Fixes because it did not really
introduce the issue.


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

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

_______________________________________________
linux-rpi-kernel mailing list
linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

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

end of thread, other threads:[~2018-02-22 11:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-08 13:54 [PATCH] i2c: bcm2835: Set up the rising/falling edge delays Boris Brezillon
     [not found] ` <20180208135405.25446-1-boris.brezillon-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org>
2018-02-21  8:42   ` Wolfram Sang
2018-02-21 22:03     ` Eric Anholt
     [not found]       ` <87h8qayp8v.fsf-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2018-02-22 11:21         ` 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.