Skip to content

Commit cd823db

Browse files
Petri GyntherJean Delvare
authored andcommitted
i2c/pca954x: Initialize the mux to disconnected state
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() Signed-off-by: Petri Gynther <[email protected]> Signed-off-by: Jean Delvare <[email protected]> Cc: [email protected]
1 parent 9b640f2 commit cd823db

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/i2c/muxes/pca954x.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,11 @@ static int pca954x_probe(struct i2c_client *client,
201201

202202
i2c_set_clientdata(client, data);
203203

204-
/* Read the mux register at addr to verify
205-
* that the mux is in fact present.
204+
/* Write the mux register at addr to verify
205+
* that the mux is in fact present. This also
206+
* initializes the mux to disconnected state.
206207
*/
207-
if (i2c_smbus_read_byte(client) < 0) {
208+
if (i2c_smbus_write_byte(client, 0) < 0) {
208209
dev_warn(&client->dev, "probe failed\n");
209210
goto exit_free;
210211
}

0 commit comments

Comments
 (0)