linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: Raise SDA for each received bit, if necessary
@ 2016-04-27 18:11 Thomas Zimmermann
  2016-05-12  9:05 ` Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Zimmermann @ 2016-04-27 18:11 UTC (permalink / raw)
  To: wsa; +Cc: linux-i2c, linux-kernel, Thomas Zimmermann

Some I2C adapters don't raise SDA by themselves when sending a bit. This
behavior can be seen with the DDC channel of SiS 300 graphics cards.

This patch adds the flag |set_sdahi| to |struct i2c_algo_bit_data|. With
the flags set to true, the I2C bit algo will raise SDA before reading each
bit from the bus. With the flag set to false, the bit algo will keep its
current behavior of raising SDA only once before receiving a full byte.

The flag also ensures that |acknak| is always called with SDA raised.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
---
 drivers/i2c/algos/i2c-algo-bit.c | 2 ++
 include/linux/i2c-algo-bit.h     | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index 9d233bb..aa8cf33 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -224,6 +224,8 @@ static int i2c_inb(struct i2c_adapter *i2c_adap)
 			indata |= 0x01;
 		setscl(adap, 0);
 		udelay(i == 7 ? adap->udelay / 2 : adap->udelay);
+		if (adap->set_sdahi)
+			sdahi(adap);
 	}
 	/* assert: scl is low */
 	return indata;
diff --git a/include/linux/i2c-algo-bit.h b/include/linux/i2c-algo-bit.h
index 63904ba..e9f0a59 100644
--- a/include/linux/i2c-algo-bit.h
+++ b/include/linux/i2c-algo-bit.h
@@ -46,6 +46,11 @@ struct i2c_algo_bit_data {
 				   minimum 5 us for standard-mode I2C and SMBus,
 				   maximum 50 us for SMBus */
 	int timeout;		/* in jiffies */
+
+	/* Some adapters do not raise SDA by themselves when sending. Set
+	 * this flag to raise SDA before reading each bit.
+	 */
+	bool set_sdahi;
 };
 
 int i2c_bit_add_bus(struct i2c_adapter *);
-- 
2.1.4

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

end of thread, other threads:[~2016-05-13 16:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-27 18:11 [PATCH] i2c: Raise SDA for each received bit, if necessary Thomas Zimmermann
2016-05-12  9:05 ` Wolfram Sang
2016-05-12 16:19   ` Thomas Zimmermann
2016-05-13 10:33     ` Wolfram Sang
2016-05-13 16:06       ` Thomas Zimmermann

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