linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: algo-pca: Add 0x78 as SCL stuck low status
@ 2020-06-21 22:57 Chris Packham
  2020-06-23 19:34 ` Wolfram Sang
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Packham @ 2020-06-21 22:57 UTC (permalink / raw)
  To: wsa, andriy.shevchenko; +Cc: linux-i2c, linux-kernel, Chris Packham

The PCA9665 datasheet says that I2CSTA = 78h indicates that SCL is stuck
low, this differs to the PCA9564 which uses 90h for this indication.
Treat either 0x78 or 0x90 as an indication that the SCL line is stuck.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
Based on looking through the PCA9564 and PCA9665 datasheets this should be
safe. The PCA9564 should not return 0x78 for any valid state and the PCA9665
should not return 0x90.

 drivers/i2c/algos/i2c-algo-pca.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index 7f10312d1b88..e3017329cea8 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -314,6 +314,7 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
 			DEB2("BUS ERROR - SDA Stuck low\n");
 			pca_reset(adap);
 			goto out;
+		case 0x78: /* Bus error - SCL stuck low */
 		case 0x90: /* Bus error - SCL stuck low */
 			DEB2("BUS ERROR - SCL Stuck low\n");
 			pca_reset(adap);
-- 
2.27.0


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

* Re: [PATCH] i2c: algo-pca: Add 0x78 as SCL stuck low status
  2020-06-21 22:57 [PATCH] i2c: algo-pca: Add 0x78 as SCL stuck low status Chris Packham
@ 2020-06-23 19:34 ` Wolfram Sang
       [not found]   ` <c5bd59ec-aa1f-dd8e-fdbf-5cc2aad0b5a7@alliedtelesis.co.nz>
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfram Sang @ 2020-06-23 19:34 UTC (permalink / raw)
  To: Chris Packham; +Cc: andriy.shevchenko, linux-i2c, linux-kernel

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

Hi Chris,

thanks for the patch!

On Mon, Jun 22, 2020 at 10:57:05AM +1200, Chris Packham wrote:
> The PCA9665 datasheet says that I2CSTA = 78h indicates that SCL is stuck
> low, this differs to the PCA9564 which uses 90h for this indication.
> Treat either 0x78 or 0x90 as an indication that the SCL line is stuck.
> 
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> Based on looking through the PCA9564 and PCA9665 datasheets this should be
> safe. The PCA9564 should not return 0x78 for any valid state and the PCA9665
> should not return 0x90.

On the other hand, we know which type was detected, so we could check
for the correct type?

Kind regards,

   Wolfram


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

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

* Re: [PATCH] i2c: algo-pca: Add 0x78 as SCL stuck low status
       [not found]     ` <62bb6093-5f8b-8b81-805b-41624cfd83b5@alliedtelesis.co.nz>
@ 2020-07-01 22:29       ` Wolfram Sang
  0 siblings, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2020-07-01 22:29 UTC (permalink / raw)
  To: Chris Packham; +Cc: andriy.shevchenko, linux-i2c, linux-kernel

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


> Any conclusion on this? I'm still suggesting that just treating 0x78
> and 0x90 as SCL stuck for either chip is the cleanest solution. I
> think I could do something with a fall-through that repeats the check
> with an if which wouldn't be too ugly.

I tried as well and also came up with code which was not very readable
while trying to be clever.

So, I agree. Let's keep things simple and take your original approach.
Can you resend the patch and update the comments to reflect which code
is for which version? And include the other paragraph in your commit
message?

Thanks!


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

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

end of thread, other threads:[~2020-07-01 22:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-21 22:57 [PATCH] i2c: algo-pca: Add 0x78 as SCL stuck low status Chris Packham
2020-06-23 19:34 ` Wolfram Sang
     [not found]   ` <c5bd59ec-aa1f-dd8e-fdbf-5cc2aad0b5a7@alliedtelesis.co.nz>
     [not found]     ` <62bb6093-5f8b-8b81-805b-41624cfd83b5@alliedtelesis.co.nz>
2020-07-01 22:29       ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).