dt-binding: Add custom property for MAX7357
Subsystems (3)
PATCH 2/2 i2c: muxes: Enable features on MAX7357
In reply to Naresh SolankiFrom: Patrick Rudolph <[email protected]>
Detect that max7357 is being used and run custom init sequence.
By default MAX7357 disconnects all channels on a bus lock-up and
signals this condition to the bus master using an interrupt.
Disable the interrupt as it's not useful within the kernel and it might conflict with the reset functionality that shares the same pin.
Use the introduced 'maxim,bus-lockup-fix' property to enable faulty channel isolation and flush-out sequence generation.
--- drivers/i2c/muxes/i2c-mux-pca954x.c | 56 ++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-)
drivers/i2c/muxes/i2c-mux-pca954x.c +55 -1
@@ -57,6 +57,21 @@#define PCA954X_IRQ_OFFSET 4 +/* +* MAX7357 exposes 7 registers on POR which allow to configure additional +* features. The configuration register holds the following settings: +*/ +#define MAX7357_CONF_INT_ENABLE BIT(0) +#define MAX7357_CONF_FLUSH_OUT BIT(1) +#define MAX7357_CONF_RELEASE_INT BIT(2) +#define MAX7357_CONF_LOCK_UP_CLEAR BIT(3) +#define MAX7357_CONF_DISCON_SINGLE_CHAN BIT(4) +#define MAX7357_CONF_BUS_LOCKUP_DETECT_DIS BIT(5) +#define MAX7357_CONF_ENABLE_BASIC_MODE BIT(6) +#define MAX7357_CONF_PRECONNECT_TEST BIT(7) + +#define MAX7357_POR_DEFAULT_CONF BIT(0) +enum pca_type { max_7356, max_7357,
@@ -477,6 +492,41 @@ static int pca954x_init(struct i2c_client *client, struct pca954x *data)return ret; } +static int max7357_init (struct i2c_client *client,struct pca954x *data) +{ +struct i2c_adapter *adap = client->adapter; +u8 conf =MAX7357_POR_DEFAULT_CONF ; +int ret; + +if (!i2c_check_functionality (adap,I2C_FUNC_SMBUS_WRITE_BYTE_DATA )) +return pca954x_init (client, data); + +if (data->idle_state >=0 ) + data->last_chan =pca954x_regval (data, data->idle_state); +else + data->last_chan =0 ;/* Disconnect multiplexer */ + +/* +* The interrupt signals downstream channels that are stuck, but +* there's nothing to do and it prevents using the shared pin as reset. +*/ + conf &=MAX7357_CONF_INT_ENABLE ; + +/* +* On bus lock-up isolate the failing channel and try to clear the +* fault by sending the flush-out sequence. +*/ +if (device_property_read_bool (&client->dev,"maxim,bus-lockup-fix" )) + conf |=MAX7357_CONF_DISCON_SINGLE_CHAN | +MAX7357_CONF_FLUSH_OUT ; + + ret =i2c_smbus_write_byte_data (client, data->last_chan, conf); +if (ret <0 ) + data->last_chan =0 ; + +return ret; +} +/* * I2C init/probing/exit functions */
@@ -560,7 +610,11 @@ static int pca954x_probe(struct i2c_client *client)* initializes the mux to a channel * or disconnected state. */ - ret =pca954x_init (client, data); +if ((dev->of_node &&of_device_is_compatible (dev->of_node,"maxim,max7357" )) || + id->driver_data == max_7357) + ret =max7357_init (client, data); +else + ret =pca954x_init (client, data);if (ret <0 ) {dev_warn (dev,"probe failed\n" ); ret = -ENODEV ;
Signature · 1 line
2.41.0
Quoted 6 lines · Naresh Solanki
From: Patrick Rudolph <[email protected]>
Add a custom property "maxim,bus-lockup-fix" to enable proprietary features on MAX7357. The driver configures MAX7357 to isolate the failing channel and trigger a flush-out sequence for bus lock-up resolution.
Please use subject prefixes matching the subsystem. You can get them for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching.
It is "dt-bindings" not binding and several other fields are needed.
Also "add custom property" is quite generic. When you add next custom property you are going to have two commits with the same subject. Just make it descriptive - "Add foobar for MAX7357"
Quoted 12 lines
Signed-off-by Patrick Rudolph <[email protected]>Signed-off-by Naresh Solanki <[email protected]>--- .../devicetree/bindings/i2c/i2c-mux-pca954x.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+)Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +0
-0
Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml properties: · line 77
Quoted 7 lines
Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +4
-0@@ -71,6 +71,11 @@ properties: description: A voltage regulator supplying power to the chip. On PCA9846 the regulator supplies power to VDD2 (core logic) and optionally to VDD1. + maxim,bus-lockup-fix: + type: boolean + description: Isolates only the stuck channel and generates a flush-out sequence + to attempt to clear the bus lock-up.
Why wouldn't you want it to be enabled all the time? Why should it be configurable per-board?
Best regards,
Krzysztof
PATCH 1/2 dt-binding: Add custom property for MAX7357
From: Patrick Rudolph <[email protected]>
Add a custom property "maxim,bus-lockup-fix" to enable proprietary features on MAX7357. The driver configures MAX7357 to isolate the failing channel and trigger a flush-out sequence for bus lock-up resolution.
--- .../devicetree/bindings/i2c/i2c-mux-pca954x.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +15 -0
@@ -71,6 +71,11 @@ properties: description: A voltage regulator supplying power to the chip. On PCA9846 the regulator supplies power to VDD2 (core logic) and optionally to VDD1. + maxim,bus-lockup-fix: + type: boolean + description: Isolates only the stuck channel and generates a flush-out sequence + to attempt to clear the bus lock-up. + required: - compatible - reg
@@ -95,6 +100,16 @@ allOf: "#interrupt-cells": false interrupt-controller: false + - if: + not: + properties: + compatible: + contains: + const: maxim,max7357 + then: + properties: + maxim,bus-lockup-fix: false + unevaluatedProperties: false examples:
base-commit: f9ea75e087b81081f33e34c4e1ba8b4abe841d9f
Signature · 1 line
2.41.0
Hi
Quoted 4 lines · Krzysztof Kozlowski
Quoted 2 lines · Naresh Solanki
From: Patrick Rudolph <[email protected]>
Quoted 8 lines
Quoted 4 lines
Add a custom property "maxim,bus-lockup-fix" to enable proprietary features on MAX7357. The driver configures MAX7357 to isolate the failing channel and trigger a flush-out sequence for bus lock-up resolution.
Please use subject prefixes matching the subsystem. You can get them for example with
git log --oneline -- DIRECTORY_OR_FILEon the directory your patch is touching.
Ack
Quoted 2 lines
It is "dt-bindings" not binding and several other fields are needed.
Ack
Quoted 4 lines
Also "add custom property" is quite generic. When you add next custom property you are going to have two commits with the same subject. Just make it descriptive - "Add foobar for MAX7357"
Missed Properties in this Patch Series, Will Be Addressed in V2. So in that case I guess the below title should be fine?
dt-bindings: i2c: Add custom properties for MAX7357/MAX7358
Quoted 18 lines
Quoted 18 lines
Signed-off-by Patrick Rudolph <[email protected]>Signed-off-by Naresh Solanki <[email protected]>--- .../devicetree/bindings/i2c/i2c-mux-pca954x.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+)Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +0
-0@@ -71,6 +71,11 @@ properties: description: A voltage regulator supplying power to the chip. On PCA9846 the regulator supplies power to VDD2 (core logic) and optionally to VDD1.
Quoted 7 lines
Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml properties: · line 77
Quoted 4 lines
Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +4
-0+ maxim,bus-lockup-fix: + type: boolean + description: Isolates only the stuck channel and generates a flush-out sequence + to attempt to clear the bus lock-up.Why wouldn't you want it to be enabled all the time? Why should it be configurable per-board?
The chip doesn't enable these features by default & it is left to discretion of board designer to enable the same.
Regards,
Naresh
Quoted 4 lines
Best regards,
Krzysztof
Quoted 19 lines · Naresh Solanki
Hi
Quoted 4 lines · Krzysztof Kozlowski
Quoted 2 lines · Naresh Solanki
From: Patrick Rudolph <[email protected]>
Quoted 8 lines
Quoted 4 lines
Add a custom property "maxim,bus-lockup-fix" to enable proprietary features on MAX7357. The driver configures MAX7357 to isolate the failing channel and trigger a flush-out sequence for bus lock-up resolution.
Please use subject prefixes matching the subsystem. You can get them for example with
git log --oneline -- DIRECTORY_OR_FILEon the directory your patch is touching.Ack
Quoted 2 lines
It is "dt-bindings" not binding and several other fields are needed.
Quoted 8 lines
Ack
Quoted 4 lines
Also "add custom property" is quite generic. When you add next custom property you are going to have two commits with the same subject. Just make it descriptive - "Add foobar for MAX7357"
Missed Properties in this Patch Series, Will Be Addressed in V2. So in that case I guess the below title should be fine?
dt-bindings: i2c: Add custom properties for MAX7357/MAX7358
No, because you do not solve that part of my feedback:
Quoted 2 lines
Quoted 2 lines
Also "add custom property" is quite generic. When you add next custom property you are going to have two commits with the same subject.
I said, everything will be now "add custom properties", right?
The prefix is dt-bindings: i2c: pca954x:
Quoted 26 lines
Quoted 19 lines
Quoted 19 lines
Signed-off-by Patrick Rudolph <[email protected]>Signed-off-by Naresh Solanki <[email protected]>--- .../devicetree/bindings/i2c/i2c-mux-pca954x.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+)Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +0
-0@@ -71,6 +71,11 @@ properties: description: A voltage regulator supplying power to the chip. On PCA9846 the regulator supplies power to VDD2 (core logic) and optionally to VDD1.Quoted 7 lines
Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml properties: · line 77
Quoted 4 lines
Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +4
-0+ maxim,bus-lockup-fix: + type: boolean + description: Isolates only the stuck channel and generates a flush-out sequence + to attempt to clear the bus lock-up.Why wouldn't you want it to be enabled all the time? Why should it be configurable per-board?
Quoted 2 lines
The chip doesn't enable these features by default & it is left to discretion of board designer to enable the same.
That does not explain anything. Enable them by default in such case or come with some argument.
Best regards,
Krzysztof
Andi Shyti
maintainerRe: [PATCH 2/2] i2c: muxes: Enable features on MAX7357
In reply to Naresh SolankiHi Naresh,
Quoted 6 lines · Naresh Solanki
From: Patrick Rudolph <[email protected]>
Detect that max7357 is being used and run custom init sequence.
By default MAX7357 disconnects all channels on a bus lock-up and
signals this condition to the bus master using an interrupt.
please replace this tab with a space.
Quoted 23 lines
Disable the interrupt as it's not useful within the kernel and it might conflict with the reset functionality that shares the same pin.
Use the introduced 'maxim,bus-lockup-fix' property to enable faulty channel isolation and flush-out sequence generation.
Signed-off-by Patrick Rudolph <[email protected]>Signed-off-by Naresh Solanki <[email protected]>--- drivers/i2c/muxes/i2c-mux-pca954x.c | 56 ++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-)drivers/i2c/muxes/i2c-mux-pca954x.c +2
-0@@ -57,6 +57,21 @@#define PCA954X_IRQ_OFFSET 4 +/* +* MAX7357 exposes 7 registers on POR which allow to configure additional
drivers/i2c/muxes/i2c-mux-pca954x.c line 71
Quoted 10 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +10
-0+* features. The configuration register holds the following settings: +*/ +#define MAX7357_CONF_INT_ENABLE BIT(0) +#define MAX7357_CONF_FLUSH_OUT BIT(1) +#define MAX7357_CONF_RELEASE_INT BIT(2) +#define MAX7357_CONF_LOCK_UP_CLEAR BIT(3) +#define MAX7357_CONF_DISCON_SINGLE_CHAN BIT(4) +#define MAX7357_CONF_BUS_LOCKUP_DETECT_DIS BIT(5) +#define MAX7357_CONF_ENABLE_BASIC_MODE BIT(6) +#define MAX7357_CONF_PRECONNECT_TEST BIT(7)
Not all these defines are are used, can we remove those that we don't need?
drivers/i2c/muxes/i2c-mux-pca954x.c line 73
Quoted 1 line
drivers/i2c/muxes/i2c-mux-pca954x.c +1
-0+#define MAX7357_POR_DEFAULT_CONF BIT(0)
I think:
#define MAX7357_POR_DEFAULT_CONF MAX7357_CONF_INT_ENABLE
has a better meaning... but overall, do we need it?
Quoted 25 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +18
-0+enum pca_type { max_7356, max_7357,@@ -477,6 +492,41 @@ static int pca954x_init(struct i2c_client *client, struct pca954x *data)return ret; } +static int max7357_init (struct i2c_client *client,struct pca954x *data) +{ +struct i2c_adapter *adap = client->adapter; +u8 conf =MAX7357_POR_DEFAULT_CONF ; +int ret; + +if (!i2c_check_functionality (adap,I2C_FUNC_SMBUS_WRITE_BYTE_DATA )) +return pca954x_init (client, data); + +if (data->idle_state >=0 ) + data->last_chan =pca954x_regval (data, data->idle_state); +else + data->last_chan =0 ;/* Disconnect multiplexer */ + +/* +* The interrupt signals downstream channels that are stuck, but +* there's nothing to do and it prevents using the shared pin as reset.
drivers/i2c/muxes/i2c-mux-pca954x.c static int pca954x_init(struct i2c_client *client, struct pca954x *data) · line 521
Quoted 10 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +10
-0+*/ + conf &=MAX7357_CONF_INT_ENABLE ; + +/* +* On bus lock-up isolate the failing channel and try to clear the +* fault by sending the flush-out sequence. +*/ +if (device_property_read_bool (&client->dev,"maxim,bus-lockup-fix" )) + conf |=MAX7357_CONF_DISCON_SINGLE_CHAN | +MAX7357_CONF_FLUSH_OUT ;
this function is identical to pca954x_init() except for the conf.
If you:
u8 conf = 0;
...
if (i2c_check_functionality(adap, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) {
conf &= MAX7357_CONF_INT_ENABLE;
if (device_property_read_bool(&client->dev,
"maxim,bus-lockup-fix"))
conf |= MAX7357_CONF_DISCON_SINGLE_CHAN |
MAX7357_CONF_FLUSH_OUT;
}
ret = i2c_smbus_write_byte_data(client, data->last_chan, conf);
...You basically should obtain the same thing, I guess and we make things easier.
Quoted 10 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +6
-0+ ret =i2c_smbus_write_byte_data (client, data->last_chan, conf); +if (ret <0 ) + data->last_chan =0 ; +return ret; +} +/* * I2C init/probing/exit functions */
drivers/i2c/muxes/i2c-mux-pca954x.c static int pca954x_probe(struct i2c_client *client) · line 615
Quoted 7 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +3
-1@@ -560,7 +610,11 @@ static int pca954x_probe(struct i2c_client *client)* initializes the mux to a channel * or disconnected state. */ - ret =pca954x_init (client, data); +if ((dev->of_node &&of_device_is_compatible (dev->of_node,"maxim,max7357" )) || + id->driver_data == max_7357) + ret =max7357_init (client, data);
what happens if this is true and in max7357_init(); the i2c functionality check fails?
Which of the two if's is redundant? Should they be merged?
Andi
Quoted 8 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +2
-0+else + ret =pca954x_init (client, data);if (ret <0 ) {dev_warn (dev,"probe failed\n" ); ret = -ENODEV ;Signature · 1 line
2.41.0
Re: [PATCH 2/2] i2c: muxes: Enable features on MAX7357
Hi Andy,
Quoted 4 lines · Andi Shyti
Hi Naresh,
On Wed, Aug 30, 2023 at 01:57:43PM +0200, Naresh Solanki wrote:
Quoted 8 lines
Quoted 6 lines
From: Patrick Rudolph <[email protected]>
Detect that max7357 is being used and run custom init sequence.
By default MAX7357 disconnects all channels on a bus lock-up and
signals this condition to the bus master using an interrupt.please replace this tab with a space.
Ack
Quoted 22 lines
Quoted 22 lines
Disable the interrupt as it's not useful within the kernel and it might conflict with the reset functionality that shares the same pin.
Use the introduced 'maxim,bus-lockup-fix' property to enable faulty channel isolation and flush-out sequence generation.
Signed-off-by Patrick Rudolph <[email protected]>Signed-off-by Naresh Solanki <[email protected]>--- drivers/i2c/muxes/i2c-mux-pca954x.c | 56 ++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-)drivers/i2c/muxes/i2c-mux-pca954x.c +0
-0@@ -57,6 +57,21 @@#define PCA954X_IRQ_OFFSET 4
Quoted 15 lines
drivers/i2c/muxes/i2c-mux-pca954x.c line 71
Quoted 12 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +12
-0+/* +* MAX7357 exposes 7 registers on POR which allow to configure additional +* features. The configuration register holds the following settings: +*/ +#define MAX7357_CONF_INT_ENABLE BIT(0) +#define MAX7357_CONF_FLUSH_OUT BIT(1) +#define MAX7357_CONF_RELEASE_INT BIT(2) +#define MAX7357_CONF_LOCK_UP_CLEAR BIT(3) +#define MAX7357_CONF_DISCON_SINGLE_CHAN BIT(4) +#define MAX7357_CONF_BUS_LOCKUP_DETECT_DIS BIT(5) +#define MAX7357_CONF_ENABLE_BASIC_MODE BIT(6) +#define MAX7357_CONF_PRECONNECT_TEST BIT(7)Not all these defines are are used, can we remove those that we don't need?
Ack. Will keep the ones that are used.
Quoted 8 lines
drivers/i2c/muxes/i2c-mux-pca954x.c line 73
Quoted 2 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +1
-0+#define MAX7357_POR_DEFAULT_CONF BIT(0)I think:
#define MAX7357_POR_DEFAULT_CONF MAX7357_CONF_INT_ENABLEhas a better meaning... but overall, do we need it?
Ack. Will keep the ones that are in use.
Quoted 59 lines
Quoted 26 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +18
-0+enum pca_type { max_7356, max_7357,@@ -477,6 +492,41 @@ static int pca954x_init(struct i2c_client *client, struct pca954x *data)return ret; } +static int max7357_init (struct i2c_client *client,struct pca954x *data) +{ +struct i2c_adapter *adap = client->adapter; +u8 conf =MAX7357_POR_DEFAULT_CONF ; +int ret; + +if (!i2c_check_functionality (adap,I2C_FUNC_SMBUS_WRITE_BYTE_DATA )) +return pca954x_init (client, data); + +if (data->idle_state >=0 ) + data->last_chan =pca954x_regval (data, data->idle_state); +else + data->last_chan =0 ;/* Disconnect multiplexer */ + +/* +* The interrupt signals downstream channels that are stuck, but +* there's nothing to do and it prevents using the shared pin as reset. drivers/i2c/muxes/i2c-mux-pca954x.c static int pca954x_init(struct i2c_client *client, struct pca954x *data) · line 521
Quoted 10 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +10
-0+*/ + conf &=MAX7357_CONF_INT_ENABLE ; + +/* +* On bus lock-up isolate the failing channel and try to clear the +* fault by sending the flush-out sequence. +*/ +if (device_property_read_bool (&client->dev,"maxim,bus-lockup-fix" )) + conf |=MAX7357_CONF_DISCON_SINGLE_CHAN | +MAX7357_CONF_FLUSH_OUT ;this function is identical to
pca954x_init()except for the conf.If you:
u8 conf = 0; ... if (i2c_check_functionality(adap, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { conf &= MAX7357_CONF_INT_ENABLE; if (device_property_read_bool(&client->dev, "maxim,bus-lockup-fix")) conf |= MAX7357_CONF_DISCON_SINGLE_CHAN | MAX7357_CONF_FLUSH_OUT; } ret = i2c_smbus_write_byte_data(client, data->last_chan, conf); ...
Quoted 2 lines
You basically should obtain the same thing, I guess and we make things easier.
Ack. Will do the changes as suggested.
Also based on feedback from Krzysztof, it was suggested that the dt property might
not be needed & the settings can be configured/enabled by default. So will remove
the DT property check ?
Ref: https://lore.kernel.org/lkml/[email protected]/#t
Regards,
Naresh
Quoted 35 lines
Quoted 12 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +6
-0+ ret =i2c_smbus_write_byte_data (client, data->last_chan, conf); +if (ret <0 ) + data->last_chan =0 ; +return ret; +} +/* * I2C init/probing/exit functions */ drivers/i2c/muxes/i2c-mux-pca954x.c static int pca954x_probe(struct i2c_client *client) · line 615
Quoted 7 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +3
-1@@ -560,7 +610,11 @@ static int pca954x_probe(struct i2c_client *client)* initializes the mux to a channel * or disconnected state. */ - ret =pca954x_init (client, data); +if ((dev->of_node &&of_device_is_compatible (dev->of_node,"maxim,max7357" )) || + id->driver_data == max_7357) + ret =max7357_init (client, data);what happens if this is true and in
max7357_init(); the i2c functionality check fails?Which of the two if's is redundant? Should they be merged?
Andi
Quoted 8 lines
drivers/i2c/muxes/i2c-mux-pca954x.c +2
-1+else + ret =pca954x_init (client, data);if (ret <0 ) {dev_warn (dev,"probe failed\n" ); ret = -ENODEV ; --2.41.0