i2c: Raise SDA for each received bit, if necessary
PATCH 1/1 i2c: Raise SDA for each received bit, if necessary
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.
--- drivers/i2c/algos/i2c-algo-bit.c | 2 ++ include/linux/i2c-algo-bit.h | 5 +++++ 2 files changed, 7 insertions(+)
drivers/i2c/algos/i2c-algo-bit.c +2 -0
@@ -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;
include/linux/i2c-algo-bit.h +5 -0
@@ -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 *);
Signature · 1 line
2.1.4
Hi Thomas,
Quoted 2 lines · 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.
I think you mean 'clients' or 'devices' here, not adapters (masters), right? So, it seems you have a bus without a pull-up resistor (or a broken one?) but use now a push-pull design. This is against the I2C standard and for most circiuts quite dangerous as it can lead to shortcuts.
Do you have any hints that the bus is designed this way? In which driver do you want to use the new flag?
Thanks,
Wolfram
Hi
Am 12.05.2016 um 11:05 schrieb Wolfram Sang:
Quoted 8 lines
Hi Thomas,
Quoted 2 lines · 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.
I think you mean 'clients' or 'devices' here, not adapters (masters), right?
Yes, sorry.
Quoted 4 lines
So, it seems you have a bus without a pull-up resistor (or a broken one?) but use now a push-pull design. This is against the I2C standard and for most circiuts quite dangerous as it can lead to shortcuts.
I see.
Quoted 2 lines
Do you have any hints that the bus is designed this way? In which driver do you want to use the new flag?
I was playing with the DRM framework and an old SiS graphics card. I discovered this issue while trying to read the EDID from the monitor.
I have a few other SiS cards/models here and they all expose this behavior. So I guess it's intentional(==cheaper?), although the HW docs don't seem mention it explicitly.
Best regards
Thomas
Quoted 5 lines
Thanks,
Wolfram
Signature · 2 lines
GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08
Quoted 3 lines
I was playing with the DRM framework and an old SiS graphics card. I discovered this issue while trying to read the EDID from the monitor.
So, there is no upstream user yet?
Quoted 3 lines
I have a few other SiS cards/models here and they all expose this behavior. So I guess it's intentional(==cheaper?), although the HW docs don't seem mention it explicitly.
OK. Well. As this flag is potentially dangerous, I would prefer to not apply the patch unless there is an upstream user of this. If there is one, I'd be okay with applying it with the flag renamed to something like "dangerous_push_pull_bus" or similar with additional comments saying there is some (broken) HW which needs it but nobody should get the idea to design a bus like this.
Makes sense?
Regards,
Wolfram
Hi
Am 13.05.2016 um 12:33 schrieb Wolfram Sang:
Quoted 5 lines
Quoted 3 lines
I was playing with the DRM framework and an old SiS graphics card. I discovered this issue while trying to read the EDID from the monitor.
So, there is no upstream user yet?
No.
Quoted 4 lines
Quoted 3 lines
I have a few other SiS cards/models here and they all expose this behavior. So I guess it's intentional(==cheaper?), although the HW docs don't seem mention it explicitly.
Quoted 8 lines
OK. Well. As this flag is potentially dangerous, I would prefer to not apply the patch unless there is an upstream user of this. If there is one, I'd be okay with applying it with the flag renamed to something like "
dangerous_push_pull_bus" or similar with additional comments saying there is some (broken) HW which needs it but nobody should get the idea to design a bus like this.Makes sense?
Sure, thanks!
Best regards
Thomas
Quoted 4 lines
Regards,
Wolfram
Signature · 2 lines
GnuPG: http://tdz.users.sourceforge.net/tdz.asc Fingerprint: 16FF F599 82F8 E5AA 18C6 5220 D9DA D7D4 4EF1 DF08