diff mbox series

i2c: algo-pca: Add 0x78 as SCL stuck low status

Message ID 20200621225705.21666-1-chris.packham@alliedtelesis.co.nz
State Superseded
Headers show
Series i2c: algo-pca: Add 0x78 as SCL stuck low status | expand

Commit Message

Chris Packham June 21, 2020, 10:57 p.m. UTC
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(+)

Comments

Wolfram Sang June 23, 2020, 7:34 p.m. UTC | #1
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
Wolfram Sang July 1, 2020, 10:29 p.m. UTC | #2
> 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!
diff mbox series

Patch

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