Skip to content

Commit df7cbce

Browse files
PatrickRudolphAndi Shyti
authored andcommitted
i2c: muxes: pca954x: Enable features on MAX7357
Enable additional features based on DT settings and unconditionally release the shared interrupt pin after 1.6 seconds and allow to use it as reset. These features aren't enabled by default and it's up to board designer to validate for proper functioning and detection of devices in secondary bus as sometimes it can cause secondary bus being disabled. Signed-off-by: Patrick Rudolph <[email protected]> Signed-off-by: Naresh Solanki <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Signed-off-by: Andi Shyti <[email protected]>
1 parent 5731cb4 commit df7cbce

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

drivers/i2c/muxes/i2c-mux-pca954x.c

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@
5757

5858
#define PCA954X_IRQ_OFFSET 4
5959

60+
/*
61+
* MAX7357's configuration register is writeable after POR, but
62+
* can be locked by setting the basic mode bit. MAX7358 configuration
63+
* register is locked by default and needs to be unlocked first.
64+
* The configuration register holds the following settings:
65+
*/
66+
#define MAX7357_CONF_INT_ENABLE BIT(0)
67+
#define MAX7357_CONF_FLUSH_OUT BIT(1)
68+
#define MAX7357_CONF_RELEASE_INT BIT(2)
69+
#define MAX7357_CONF_DISCON_SINGLE_CHAN BIT(4)
70+
#define MAX7357_CONF_PRECONNECT_TEST BIT(7)
71+
72+
#define MAX7357_POR_DEFAULT_CONF MAX7357_CONF_INT_ENABLE
73+
6074
enum pca_type {
6175
max_7356,
6276
max_7357,
@@ -470,7 +484,34 @@ static int pca954x_init(struct i2c_client *client, struct pca954x *data)
470484
else
471485
data->last_chan = 0; /* Disconnect multiplexer */
472486

473-
ret = i2c_smbus_write_byte(client, data->last_chan);
487+
if (device_is_compatible(&client->dev, "maxim,max7357")) {
488+
if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) {
489+
u8 conf = MAX7357_POR_DEFAULT_CONF;
490+
/*
491+
* The interrupt signal is shared with the reset pin. Release the
492+
* interrupt after 1.6 seconds to allow using the pin as reset.
493+
*/
494+
conf |= MAX7357_CONF_RELEASE_INT;
495+
496+
if (device_property_read_bool(&client->dev, "maxim,isolate-stuck-channel"))
497+
conf |= MAX7357_CONF_DISCON_SINGLE_CHAN;
498+
if (device_property_read_bool(&client->dev,
499+
"maxim,send-flush-out-sequence"))
500+
conf |= MAX7357_CONF_FLUSH_OUT;
501+
if (device_property_read_bool(&client->dev,
502+
"maxim,preconnection-wiggle-test-enable"))
503+
conf |= MAX7357_CONF_PRECONNECT_TEST;
504+
505+
ret = i2c_smbus_write_byte_data(client, data->last_chan, conf);
506+
} else {
507+
dev_warn(&client->dev, "Write byte data not supported."
508+
"Cannot enable enhanced mode features\n");
509+
ret = i2c_smbus_write_byte(client, data->last_chan);
510+
}
511+
} else {
512+
ret = i2c_smbus_write_byte(client, data->last_chan);
513+
}
514+
474515
if (ret < 0)
475516
data->last_chan = 0;
476517

0 commit comments

Comments
 (0)