[PATCH] i2c: Raise SDA for each received bit, if necessary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux