i2c/pca954x: Initialize the mux to disconnected state
PATCH 1/1 i2c/pca954x: Initialize the mux to disconnected state
Port of a Linux kernel commit cd823db8b1161ef0d756514d280715a576d65cc3
pca954x power-on default is channel 0 connected. If multiple pca954x muxes are connected to the same physical I2C bus, the parent bus will see channel 0 devices behind both muxes by default. This is bad.
Scenario:
-- pca954x @ 0x70 -- ch 0 (I2C-bus-101) -- EEPROM @ 0x50 |
I2C-bus-1 ---
|
-- pca954x @ 0x71 -- ch 0 (I2C-bus-111) -- EEPROM @ 0x50
1. Load I2C bus driver: creates I2C-bus-1
2. Load pca954x driver: creates virtual I2C-bus-101 and I2C-bus-111
3. Load eeprom driver
4. Try to read EEPROM @ 0x50 on I2C-bus-101. The transaction will also bleed onto I2C-bus-111 because pca954x @ 0x71 channel 0 is connected by default.
Fix: Initialize pca954x to disconnected state in pca954x_probe()
--- drivers/i2c/muxes/i2c-mux-pca954x.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/i2c/muxes/i2c-mux-pca954x.c +5 -4
@@ -195,10 +195,11 @@ static int pca954x_probe(struct device_d *dev)if (gpio_is_valid (gpio))gpio_direction_output (gpio,1 ); -/* Read the mux register at addr to verify -* that the mux is in fact present. -*/ -if (i2c_smbus_read_byte (client) <0 ) { +/* Write the mux register at addr to verify +* that the mux is in fact present. This also +* initializes the mux to disconnected state. +*/ +if (i2c_smbus_write_byte (client,0 ) <0 ) {dev_warn (&client->dev,"probe failed\n" ); goto exit_free; }
Signature · 7 lines
2.21.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 21 lines · Andrey Smirnov
Port of a Linux kernel commit
cd823db8b1161ef0d756514d280715a576d65cc3pca954x power-on default is channel 0 connected. If multiple pca954x muxes are connected to the same physical I2C bus, the parent bus will see channel 0 devices behind both muxes by default. This is bad.
Scenario:
-- pca954x @0x70-- ch 0 (I2C-bus-101) -- EEPROM @0x50|
I2C-bus-1 ---
|
-- pca954x @0x71-- ch 0 (I2C-bus-111) -- EEPROM @0x501. Load I2C bus driver: creates I2C-bus-1
2. Load pca954x driver: creates virtual I2C-bus-101 and I2C-bus-111
3. Load eeprom driver
4. Try to read EEPROM @0x50on I2C-bus-101. The transaction will also bleed onto I2C-bus-111 because pca954x @0x71channel 0 is connected by default.Fix: Initialize pca954x to disconnected state in
pca954x_probe()
Quoted 8 lines
Signed-off-by Petri Gynther <[email protected]>Signed-off-by Jean Delvare <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- drivers/i2c/muxes/i2c-mux-pca954x.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
Applied with whitespace cleanup, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox