2022-11-03 13:46:03

by Cosmin Tanislav

[permalink] [raw]
Subject: [PATCH v4 00/13] Support more parts in LTC2983

Add support for the following parts:
* LTC2984
* LTC2986
* LTM2985

The LTC2984 is a variant of the LTC2983 with EEPROM.
The LTC2986 is a variant of the LTC2983 with only 10 channels,
EEPROM and support for active analog temperature sensors.
The LTM2985 is software-compatible with the LTC2986.

Also, make bulk write buffer DMA-safe.
Besides that, refine the binding.

V1 -> V2:
* add Fixes tag
* add patch that fixes the regmap_bulk_write() call with stack allocated
buffer
* add patch that refines the binding in preperation for adding new
parts support to it
* do not use stack allocated buffer for writing the EEPROM key

V2 -> V3:
* drop minItems if equal to maxItems
* drop adi,single-ended conditions because of recent dtschema
restrictions (even though they're valid in jsonschema and the last
dtschema tag)
* drop "allocate iio channels once" patch since it's been picked as a fix

V3 -> V4:
* add pipe for 'adi,mux-delay-config-us' description
* add pipe for 'adi,rtd-curve' description
* keep newlines after descriptions
* move 'adi,current-rotate' to conditional
* put 'adi,custom-steinhart' in the original place
* keep 'minItems' for 'adi,custom-steinhart'
* override 'enum' to forbid auto-range in 'adi,excitation-current-nanoamp'
when using custom thermistors
* split refine patch into multiple patches
- use generic node name in example
- describe broken mux delay property
- refine descriptions
- change default excitation for custom thermistors
- require 4 wire rtd for current rotate
- require custom sensor tables
- describe matrix items
- remove qutations from phandle ref
- use hex for sensor address
- add default values

Cosmin Tanislav (13):
iio: temperature: ltc2983: make bulk write buffer DMA-safe
dt-bindings: iio: temperature: ltc2983: add default values
dt-bindings: iio: temperature: ltc2983: use hex for sensor address
dt-bindings: iio: temperature: ltc2983: remove qutations from phandle
ref
dt-bindings: iio: temperature: ltc2983: describe matrix items
dt-bindings: iio: temperature: ltc2983: require custom sensor tables
dt-bindings: iio: temperature: ltc2983: require 4 wire rtd for current
rotate
dt-bindings: iio: temperature: ltc2983: change default excitation for
custom thermistors
dt-bindings: iio: temperature: ltc2983: refine descriptions
dt-bindings: iio: temperature: ltc2983: describe broken mux delay
property
dt-bindings: iio: temperature: ltc2983: use generic node name in
example
dt-bindings: iio: temperature: ltc2983: support more parts
iio: temperature: ltc2983: support more parts

.../bindings/iio/temperature/adi,ltc2983.yaml | 335 +++++++++++-------
drivers/iio/temperature/ltc2983.c | 193 +++++++++-
2 files changed, 389 insertions(+), 139 deletions(-)

--
2.38.1



2022-11-03 13:47:51

by Cosmin Tanislav

[permalink] [raw]
Subject: [PATCH v4 06/13] dt-bindings: iio: temperature: ltc2983: require custom sensor tables

From: Cosmin Tanislav <[email protected]>

The driver will error out when a custom sensor type is used but a
custom sensor table is not provided. Require it in the binding too.

Signed-off-by: Cosmin Tanislav <[email protected]>
---
.../bindings/iio/temperature/adi,ltc2983.yaml | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml b/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
index 4f26b337c957..bbac5f5cfbb3 100644
--- a/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
+++ b/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
@@ -130,6 +130,15 @@ patternProperties:
- description: Voltage point in nV, signed.
- description: Temperature point in uK.

+ allOf:
+ - if:
+ properties:
+ adi,sensor-type:
+ const: 9
+ then:
+ required:
+ - adi,custom-thermocouple
+
"^diode@":
type: object
description:
@@ -263,6 +272,15 @@ patternProperties:
dependencies:
adi,current-rotate: [ "adi,rsense-share" ]

+ allOf:
+ - if:
+ properties:
+ adi,sensor-type:
+ const: 18
+ then:
+ required:
+ - adi,custom-rtd
+
"^thermistor@":
type: object
description:
@@ -349,6 +367,22 @@ patternProperties:
dependencies:
adi,current-rotate: [ "adi,rsense-share" ]

+ allOf:
+ - if:
+ properties:
+ adi,sensor-type:
+ const: 26
+ then:
+ required:
+ - adi,custom-steinhart
+ - if:
+ properties:
+ adi,sensor-type:
+ const: 27
+ then:
+ required:
+ - adi,custom-thermistor
+
"^adc@":
type: object
description: Represents a channel which is being used as a direct adc.
--
2.38.1


2022-11-03 13:59:22

by Cosmin Tanislav

[permalink] [raw]
Subject: [PATCH v4 04/13] dt-bindings: iio: temperature: ltc2983: remove qutations from phandle ref

From: Cosmin Tanislav <[email protected]>

Not needed, so why have them?

Signed-off-by: Cosmin Tanislav <[email protected]>
---
.../devicetree/bindings/iio/temperature/adi,ltc2983.yaml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml b/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
index 29f6fa5e2529..6b3a20448f78 100644
--- a/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
+++ b/Documentation/devicetree/bindings/iio/temperature/adi,ltc2983.yaml
@@ -112,7 +112,7 @@ patternProperties:
description:
Phandle which points to a sensor object responsible for measuring
the thermocouple cold junction temperature.
- $ref: "/schemas/types.yaml#/definitions/phandle"
+ $ref: /schemas/types.yaml#/definitions/phandle

adi,custom-thermocouple:
description:
@@ -204,7 +204,7 @@ patternProperties:
adi,rsense-handle:
description:
Phandle pointing to a rsense object associated with this RTD.
- $ref: "/schemas/types.yaml#/definitions/phandle"
+ $ref: /schemas/types.yaml#/definitions/phandle

adi,number-of-wires:
description:
@@ -288,7 +288,7 @@ patternProperties:
description:
Phandle pointing to a rsense object associated with this
thermistor.
- $ref: "/schemas/types.yaml#/definitions/phandle"
+ $ref: /schemas/types.yaml#/definitions/phandle

adi,single-ended:
description:
--
2.38.1


2022-11-03 14:00:09

by Cosmin Tanislav

[permalink] [raw]
Subject: [PATCH v4 01/13] iio: temperature: ltc2983: make bulk write buffer DMA-safe

From: Cosmin Tanislav <[email protected]>

regmap_bulk_write() does not guarantee implicit DMA-safety,
even though the current implementation duplicates the given
buffer. Do not rely on it.

Fixes: f110f3188e56 ("iio: temperature: Add support for LTC2983")
Signed-off-by: Cosmin Tanislav <[email protected]>
---
drivers/iio/temperature/ltc2983.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
index b652d2b39bcf..ca1bb5f48988 100644
--- a/drivers/iio/temperature/ltc2983.c
+++ b/drivers/iio/temperature/ltc2983.c
@@ -209,6 +209,7 @@ struct ltc2983_data {
* Holds the converted temperature
*/
__be32 temp __aligned(IIO_DMA_MINALIGN);
+ __be32 chan_val;
};

struct ltc2983_sensor {
@@ -313,19 +314,18 @@ static int __ltc2983_fault_handler(const struct ltc2983_data *st,
return 0;
}

-static int __ltc2983_chan_assign_common(const struct ltc2983_data *st,
+static int __ltc2983_chan_assign_common(struct ltc2983_data *st,
const struct ltc2983_sensor *sensor,
u32 chan_val)
{
u32 reg = LTC2983_CHAN_START_ADDR(sensor->chan);
- __be32 __chan_val;

chan_val |= LTC2983_CHAN_TYPE(sensor->type);
dev_dbg(&st->spi->dev, "Assign reg:0x%04X, val:0x%08X\n", reg,
chan_val);
- __chan_val = cpu_to_be32(chan_val);
- return regmap_bulk_write(st->regmap, reg, &__chan_val,
- sizeof(__chan_val));
+ st->chan_val = cpu_to_be32(chan_val);
+ return regmap_bulk_write(st->regmap, reg, &st->chan_val,
+ sizeof(st->chan_val));
}

static int __ltc2983_chan_custom_sensor_assign(struct ltc2983_data *st,
--
2.38.1


2022-11-06 17:52:31

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v4 00/13] Support more parts in LTC2983

On Thu, 3 Nov 2022 15:00:28 +0200
Cosmin Tanislav <[email protected]> wrote:

> Add support for the following parts:
> * LTC2984
> * LTC2986
> * LTM2985
>
> The LTC2984 is a variant of the LTC2983 with EEPROM.
> The LTC2986 is a variant of the LTC2983 with only 10 channels,
> EEPROM and support for active analog temperature sensors.
> The LTM2985 is software-compatible with the LTC2986.
>
> Also, make bulk write buffer DMA-safe.
> Besides that, refine the binding.
Replying at least partly so I can see I already looked at this...

Looks good to me. Will pick up once DT bindings maintainers are
happy.

Thanks,

Jonathan

>
> V1 -> V2:
> * add Fixes tag
> * add patch that fixes the regmap_bulk_write() call with stack allocated
> buffer
> * add patch that refines the binding in preperation for adding new
> parts support to it
> * do not use stack allocated buffer for writing the EEPROM key
>
> V2 -> V3:
> * drop minItems if equal to maxItems
> * drop adi,single-ended conditions because of recent dtschema
> restrictions (even though they're valid in jsonschema and the last
> dtschema tag)
> * drop "allocate iio channels once" patch since it's been picked as a fix
>
> V3 -> V4:
> * add pipe for 'adi,mux-delay-config-us' description
> * add pipe for 'adi,rtd-curve' description
> * keep newlines after descriptions
> * move 'adi,current-rotate' to conditional
> * put 'adi,custom-steinhart' in the original place
> * keep 'minItems' for 'adi,custom-steinhart'
> * override 'enum' to forbid auto-range in 'adi,excitation-current-nanoamp'
> when using custom thermistors
> * split refine patch into multiple patches
> - use generic node name in example
> - describe broken mux delay property
> - refine descriptions
> - change default excitation for custom thermistors
> - require 4 wire rtd for current rotate
> - require custom sensor tables
> - describe matrix items
> - remove qutations from phandle ref
> - use hex for sensor address
> - add default values
>
> Cosmin Tanislav (13):
> iio: temperature: ltc2983: make bulk write buffer DMA-safe
> dt-bindings: iio: temperature: ltc2983: add default values
> dt-bindings: iio: temperature: ltc2983: use hex for sensor address
> dt-bindings: iio: temperature: ltc2983: remove qutations from phandle
> ref
> dt-bindings: iio: temperature: ltc2983: describe matrix items
> dt-bindings: iio: temperature: ltc2983: require custom sensor tables
> dt-bindings: iio: temperature: ltc2983: require 4 wire rtd for current
> rotate
> dt-bindings: iio: temperature: ltc2983: change default excitation for
> custom thermistors
> dt-bindings: iio: temperature: ltc2983: refine descriptions
> dt-bindings: iio: temperature: ltc2983: describe broken mux delay
> property
> dt-bindings: iio: temperature: ltc2983: use generic node name in
> example
> dt-bindings: iio: temperature: ltc2983: support more parts
> iio: temperature: ltc2983: support more parts
>
> .../bindings/iio/temperature/adi,ltc2983.yaml | 335 +++++++++++-------
> drivers/iio/temperature/ltc2983.c | 193 +++++++++-
> 2 files changed, 389 insertions(+), 139 deletions(-)
>


2022-11-07 17:10:44

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v4 04/13] dt-bindings: iio: temperature: ltc2983: remove qutations from phandle ref


On Thu, 03 Nov 2022 15:00:32 +0200, Cosmin Tanislav wrote:
> From: Cosmin Tanislav <[email protected]>
>
> Not needed, so why have them?
>
> Signed-off-by: Cosmin Tanislav <[email protected]>
> ---
> .../devicetree/bindings/iio/temperature/adi,ltc2983.yaml | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>

Acked-by: Rob Herring <[email protected]>

2022-11-07 17:51:12

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v4 06/13] dt-bindings: iio: temperature: ltc2983: require custom sensor tables


On Thu, 03 Nov 2022 15:00:34 +0200, Cosmin Tanislav wrote:
> From: Cosmin Tanislav <[email protected]>
>
> The driver will error out when a custom sensor type is used but a
> custom sensor table is not provided. Require it in the binding too.
>
> Signed-off-by: Cosmin Tanislav <[email protected]>
> ---
> .../bindings/iio/temperature/adi,ltc2983.yaml | 34 +++++++++++++++++++
> 1 file changed, 34 insertions(+)
>

Reviewed-by: Rob Herring <[email protected]>

2022-11-12 16:06:15

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v4 00/13] Support more parts in LTC2983

On Sun, 6 Nov 2022 17:14:58 +0000
Jonathan Cameron <[email protected]> wrote:

> On Thu, 3 Nov 2022 15:00:28 +0200
> Cosmin Tanislav <[email protected]> wrote:
>
> > Add support for the following parts:
> > * LTC2984
> > * LTC2986
> > * LTM2985
> >
> > The LTC2984 is a variant of the LTC2983 with EEPROM.
> > The LTC2986 is a variant of the LTC2983 with only 10 channels,
> > EEPROM and support for active analog temperature sensors.
> > The LTM2985 is software-compatible with the LTC2986.
> >
> > Also, make bulk write buffer DMA-safe.
> > Besides that, refine the binding.
> Replying at least partly so I can see I already looked at this...
>
> Looks good to me. Will pick up once DT bindings maintainers are
> happy.

Series applied to the togreg branch of iio.git and initially pushed out
as testing. I tweaked patch 11 as requested whilst applying.

Thanks,

Jonathan
>
> Thanks,
>
> Jonathan
>
> >
> > V1 -> V2:
> > * add Fixes tag
> > * add patch that fixes the regmap_bulk_write() call with stack allocated
> > buffer
> > * add patch that refines the binding in preperation for adding new
> > parts support to it
> > * do not use stack allocated buffer for writing the EEPROM key
> >
> > V2 -> V3:
> > * drop minItems if equal to maxItems
> > * drop adi,single-ended conditions because of recent dtschema
> > restrictions (even though they're valid in jsonschema and the last
> > dtschema tag)
> > * drop "allocate iio channels once" patch since it's been picked as a fix
> >
> > V3 -> V4:
> > * add pipe for 'adi,mux-delay-config-us' description
> > * add pipe for 'adi,rtd-curve' description
> > * keep newlines after descriptions
> > * move 'adi,current-rotate' to conditional
> > * put 'adi,custom-steinhart' in the original place
> > * keep 'minItems' for 'adi,custom-steinhart'
> > * override 'enum' to forbid auto-range in 'adi,excitation-current-nanoamp'
> > when using custom thermistors
> > * split refine patch into multiple patches
> > - use generic node name in example
> > - describe broken mux delay property
> > - refine descriptions
> > - change default excitation for custom thermistors
> > - require 4 wire rtd for current rotate
> > - require custom sensor tables
> > - describe matrix items
> > - remove qutations from phandle ref
> > - use hex for sensor address
> > - add default values
> >
> > Cosmin Tanislav (13):
> > iio: temperature: ltc2983: make bulk write buffer DMA-safe
> > dt-bindings: iio: temperature: ltc2983: add default values
> > dt-bindings: iio: temperature: ltc2983: use hex for sensor address
> > dt-bindings: iio: temperature: ltc2983: remove qutations from phandle
> > ref
> > dt-bindings: iio: temperature: ltc2983: describe matrix items
> > dt-bindings: iio: temperature: ltc2983: require custom sensor tables
> > dt-bindings: iio: temperature: ltc2983: require 4 wire rtd for current
> > rotate
> > dt-bindings: iio: temperature: ltc2983: change default excitation for
> > custom thermistors
> > dt-bindings: iio: temperature: ltc2983: refine descriptions
> > dt-bindings: iio: temperature: ltc2983: describe broken mux delay
> > property
> > dt-bindings: iio: temperature: ltc2983: use generic node name in
> > example
> > dt-bindings: iio: temperature: ltc2983: support more parts
> > iio: temperature: ltc2983: support more parts
> >
> > .../bindings/iio/temperature/adi,ltc2983.yaml | 335 +++++++++++-------
> > drivers/iio/temperature/ltc2983.c | 193 +++++++++-
> > 2 files changed, 389 insertions(+), 139 deletions(-)
> >
>