linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] i2c: algo-pca: Add 0x78 as SCL stuck low status
@ 2020-07-01 22:39 Chris Packham
  2020-07-02 10:04 ` Andy Shevchenko
  2020-07-04  6:03 ` Wolfram Sang
  0 siblings, 2 replies; 3+ messages in thread
From: Chris Packham @ 2020-07-01 22:39 UTC (permalink / raw)
  To: wsa, andriy.shevchenko
  Cc: Mark Tomlinson, 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.

Based on looking through the PCA9564 and PCA9665 datasheets this should
be safe for both chips. The PCA9564 should not return 0x78 for any valid
state and the PCA9665 should not return 0x90.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
Changes in v2:
- Note which status corresponds to which chip
- Move patch commentary to commit message

 drivers/i2c/algos/i2c-algo-pca.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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


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

* Re: [PATCH v2] i2c: algo-pca: Add 0x78 as SCL stuck low status
  2020-07-01 22:39 [PATCH v2] i2c: algo-pca: Add 0x78 as SCL stuck low status Chris Packham
@ 2020-07-02 10:04 ` Andy Shevchenko
  2020-07-04  6:03 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-07-02 10:04 UTC (permalink / raw)
  To: Chris Packham; +Cc: wsa, Mark Tomlinson, linux-i2c, linux-kernel

On Thu, Jul 02, 2020 at 10:39:11AM +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.
> 
> Based on looking through the PCA9564 and PCA9665 datasheets this should
> be safe for both chips. The PCA9564 should not return 0x78 for any valid
> state and the PCA9665 should not return 0x90.

For me as well looks better this way.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> Changes in v2:
> - Note which status corresponds to which chip
> - Move patch commentary to commit message
> 
>  drivers/i2c/algos/i2c-algo-pca.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
> index 7f10312d1b88..388978775be0 100644
> --- a/drivers/i2c/algos/i2c-algo-pca.c
> +++ b/drivers/i2c/algos/i2c-algo-pca.c
> @@ -314,7 +314,8 @@ static int pca_xfer(struct i2c_adapter *i2c_adap,
>  			DEB2("BUS ERROR - SDA Stuck low\n");
>  			pca_reset(adap);
>  			goto out;
> -		case 0x90: /* Bus error - SCL stuck low */
> +		case 0x78: /* Bus error - SCL stuck low (PCA9665) */
> +		case 0x90: /* Bus error - SCL stuck low (PCA9564) */
>  			DEB2("BUS ERROR - SCL Stuck low\n");
>  			pca_reset(adap);
>  			goto out;
> -- 
> 2.27.0
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2] i2c: algo-pca: Add 0x78 as SCL stuck low status
  2020-07-01 22:39 [PATCH v2] i2c: algo-pca: Add 0x78 as SCL stuck low status Chris Packham
  2020-07-02 10:04 ` Andy Shevchenko
@ 2020-07-04  6:03 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2020-07-04  6:03 UTC (permalink / raw)
  To: Chris Packham; +Cc: andriy.shevchenko, Mark Tomlinson, linux-i2c, linux-kernel

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

On Thu, Jul 02, 2020 at 10:39:11AM +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.
> 
> Based on looking through the PCA9564 and PCA9665 datasheets this should
> be safe for both chips. The PCA9564 should not return 0x78 for any valid
> state and the PCA9665 should not return 0x90.
> 
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

Applied to for-current, 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-04  6:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01 22:39 [PATCH v2] i2c: algo-pca: Add 0x78 as SCL stuck low status Chris Packham
2020-07-02 10:04 ` Andy Shevchenko
2020-07-04  6:03 ` 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).