Skip to contentSkip to conversation

iio:adc:ltc2471: add match table for existing devices

PATCH In review Darius Berghe 2 participants 7 messages Jun 17, 2020 – Jun 27, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 iio:adc:ltc2471: add match table for existing devices

OF style match table is the proper way of matching device tree nodes with drivers and such table was missing, this commit adds it.

---
 drivers/iio/adc/ltc2471.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/iio/adc/ltc2471.c +8 -0
index 55fab612843a..0e5cdb43a943 100644
@@ -143,9 +143,17 @@ static const struct i2c_device_id ltc2471_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ltc2471_i2c_id);
 
+static const struct of_device_id ltc2471_of_match[] = {
+	{ .compatible = "adi,ltc2471" },
+	{ .compatible = "adi,ltc2473" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, ltc2471_of_match);
+
 static struct i2c_driver ltc2471_i2c_driver = {
 	.driver = {
 		.name = "ltc2471",
+		.of_match_table = of_match_ptr(ltc2471_of_match)
 	},
 	.probe    = ltc2471_i2c_probe,
 	.id_table = ltc2471_i2c_id,
Signature · 1 line
2.26.2
#1 lore raw

PATCH 2/3 iio:adc:ltc2471: add ltc2461/ltc2463 compatible strings

Add compatible strings for these devices in the existing ltc2471 driver.

The only difference between 2461/2463 and 2471/2473 is the output rate of fixed 60sps and selectible 208/833sps respectively.

The driver does not implement changing the sampling rate so the new devices are fully code comptible with this driver.

---
 drivers/iio/adc/ltc2471.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/iio/adc/ltc2471.c +11 -3
index 0e5cdb43a943..098765882bba 100644
@@ -1,7 +1,9 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Driver for Linear Technology LTC2471 and LTC2473 voltage monitors
+ * Driver for Linear Technology LTC2471, LTC2473, LTC2461 and LTC2463 voltage
+ * monitors.
  * The LTC2473 is identical to the 2471, but reports a differential signal.
+ * The LTC2463 is identical to the 2461, but reports a differential signal.
  *
  * Copyright (C) 2017 Topic Embedded Products
  * Author: Mike Looijmans <[email protected]>
@@ -17,6 +19,8 @@
 enum ltc2471_chips {
 	ltc2471,
 	ltc2473,
+	ltc2461,
+	ltc2463
 };
 
 struct ltc2471_data {
@@ -120,7 +124,7 @@ static int ltc2471_i2c_probe(struct i2c_client *client,
 	indio_dev->name = id->name;
 	indio_dev->info = &ltc2471_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
-	if (id->driver_data == ltc2473)
+	if (id->driver_data == ltc2473 || id->driver_data == ltc2463)
 		indio_dev->channels = ltc2473_channel;
 	else
 		indio_dev->channels = ltc2471_channel;
@@ -139,6 +143,8 @@ static int ltc2471_i2c_probe(struct i2c_client *client,
 static const struct i2c_device_id ltc2471_i2c_id[] = {
 	{ "ltc2471", ltc2471 },
 	{ "ltc2473", ltc2473 },
+	{ "ltc2461", ltc2461 },
+	{ "ltc2463", ltc2463 },
 	{}
 };
 MODULE_DEVICE_TABLE(i2c, ltc2471_i2c_id);
@@ -146,6 +152,8 @@ MODULE_DEVICE_TABLE(i2c, ltc2471_i2c_id);
 static const struct of_device_id ltc2471_of_match[] = {
 	{ .compatible = "adi,ltc2471" },
 	{ .compatible = "adi,ltc2473" },
+	{ .compatible = "adi,ltc2461" },
+	{ .compatible = "adi,ltc2463" },
 	{}
 };
 MODULE_DEVICE_TABLE(of, ltc2471_of_match);
@@ -161,6 +169,6 @@ static struct i2c_driver ltc2471_i2c_driver = {
 
 module_i2c_driver(ltc2471_i2c_driver);
 
-MODULE_DESCRIPTION("LTC2471/LTC2473 ADC driver");
+MODULE_DESCRIPTION("LTC2471/LTC2473/LTC2461/LTC2463 ADC driver");
 MODULE_AUTHOR("Topic Embedded Products");
 MODULE_LICENSE("GPL v2");
Signature · 1 line
2.26.2
#2 lore raw

PATCH 3/3 iio:adc:ltc2471: add dt binding yaml

In reply to Darius Berghe

Add dt binding documentation for ltc2471 driver. This covers all supported devices.

---
 .../bindings/iio/adc/adi,ltc2471.yaml         | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +52 -0
new file mode 100644
index 000000000000..0b84e14ec984
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2020 Analog Devices Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/bindings/iio/adc/adi,ltc2471.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices LTC2471 16-bit I2C Sigma-Delta ADC
+
+maintainers:
+  - Mike Looijmans <[email protected]>
+
+description: |
+  Analog Devices LTC2471 (single-ended) and LTC2473 (differential) 16-bit
+  I2C Sigma-Delta ADC with selectable 208/833sps output rate.
+  https://www.analog.com/media/en/technical-documentation/data-sheets/24713fb.pdf
+
+  Analog Devices LTC2461 (single-ended) and LTC2463 (differential) 16-bit
+  I2C Sigma-Delta ADC with 60sps output rate.
+  https://www.analog.com/media/en/technical-documentation/data-sheets/24613fa.pdf
+
+properties:
+  compatible:
+    enum:
+      - adi,ltc2471
+      - adi,ltc2473
+      - adi,ltc2461
+      - adi,ltc2463
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    i2c0 {
+      ltc2461@14 {
+        compatible = "ltc2461";
+        reg = <0x14>;
+      };
+    };
+  - |
+    i2c0 {
+      ltc2473@54 {
+        compatible = "ltc2473";
+        reg = <0x54>;
+      };
+    };
+
Signature · 1 line
2.26.2
maintainer
#3 lore raw

Re: [PATCH v1 3/3] iio:adc:ltc2471: add dt binding yaml

Quoted 4 lines · On Wed, 17 Jun 2020 16:35:23 +0300 Darius Berghe <[email protected]>…

Add dt binding documentation for ltc2471 driver. This covers all supported devices.

A few things inline but basically fine.

We should however also think about documenting power supplies. Even though the driver doesn't currently control the binding should be as complete as possible.

Jonathan

Quoted 21 lines
---
 .../bindings/iio/adc/adi,ltc2471.yaml         | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +10 -0
new file mode 100644
index 000000000000..0b84e14ec984
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2020 Analog Devices Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/bindings/iio/adc/adi,ltc2471.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices LTC2471 16-bit I2C Sigma-Delta ADC
+
+maintainers:

Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml line 20

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +10 -0
+  - Mike Looijmans <[email protected]>
+
+description: |
+  Analog Devices LTC2471 (single-ended) and LTC2473 (differential) 16-bit
+  I2C Sigma-Delta ADC with selectable 208/833sps output rate.
+  https://www.analog.com/media/en/technical-documentation/data-sheets/24713fb.pdf
+
+  Analog Devices LTC2461 (single-ended) and LTC2463 (differential) 16-bit
+  I2C Sigma-Delta ADC with 60sps output rate.
+  https://www.analog.com/media/en/technical-documentation/data-sheets/24613fa.pdf

Put these two blocks in numeric order. If we end up adding a bunch more devices it will be much more consistent if they are order.

Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml line 28

Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +8 -0
+
+properties:
+  compatible:
+    enum:
+      - adi,ltc2471
+      - adi,ltc2473
+      - adi,ltc2461
+      - adi,ltc2463

Put them in numeric order.

Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml line 40

Quoted 12 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +12 -0
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    i2c0 {
+      ltc2461@14 {

Should use a generic name
adc@14

Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml line 46

Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +6 -0
+        compatible = "ltc2461";
+        reg = <0x14>;
+      };
+    };
+  - |
+    i2c0 {

Not a lot of point in two examples given how similar they are. I'd just keep the one.

Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +6 -0
+      ltc2473@54 {
+        compatible = "ltc2473";
+        reg = <0x54>;
+      };
+    };
+
#4 lore raw

Re: [PATCH v1 3/3] iio:adc:ltc2471: add dt binding yaml

Quoted 8 lines · Jonathan Cameron

[External]

Quoted 3 lines · On Wed, 17 Jun 2020 16:35:23 +0300 Darius Berghe <[email protected]>…

Add dt binding documentation for ltc2471 driver. This covers all supported devices.

Quoted 9 lines
Quoted 1 line

A few things inline but basically fine.

We should however also think about documenting power supplies. Even though the driver doesn't currently control the binding should be as complete as possible.

Jonathan

Hi Jonathan,

And thanks for the review !

This chips have a fixed internal vref of 1.25V that is output on the REFOUT pin, there is no place for configuration here. Or perhaps did you mean the VCC (2.7V-5.5V) ? I'm not sure what the added value would be to add vref-supply and vcc-supply to yaml if they are not implemented. I find it confusing.

Quoted 26 lines
Quoted 26 lines
---
 .../bindings/iio/adc/adi,ltc2471.yaml         | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +15 -0
new file mode 100644
index 000000000000..0b84e14ec984
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2020 Analog Devices Inc.
+%YAML 1.2
+---
+$id: https://urldefense.com/v3/__http://devicetree.org/schemas/bindings/iio/adc/adi,ltc2471.yaml*__;Iw!!A3Ni8CS0y2Y!vUpDwSslcaNrc3db6AQ6x3gzYHbR_WxOtQyPinkeZCjgpiQ4elEbjMzDs1OGEYZou4E$ 
+$schema: https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!A3Ni8CS0y2Y!vUpDwSslcaNrc3db6AQ6x3gzYHbR_WxOtQyPinkeZCjgpiQ4elEbjMzDs1OG4cmRuW4$ 
+
+title: Analog Devices LTC2471 16-bit I2C Sigma-Delta ADC
+
+maintainers:
+  - Mike Looijmans <[email protected]>
+
+description: |
+  Analog Devices LTC2471 (single-ended) and LTC2473 (differential) 16-bit
+  I2C Sigma-Delta ADC with selectable 208/833sps output rate.
Quoted 9 lines

Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml line 20

Quoted 5 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +5 -0
+  https://www.analog.com/media/en/technical-documentation/data-sheets/24713fb.pdf
+
+  Analog Devices LTC2461 (single-ended) and LTC2463 (differential) 16-bit
+  I2C Sigma-Delta ADC with 60sps output rate.
+  https://www.analog.com/media/en/technical-documentation/data-sheets/24613fa.pdf

Put these two blocks in numeric order. If we end up adding a bunch more devices it will be much more consistent if they are order.

Ack, will do.

Quoted 11 lines

Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml line 28

Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +8 -0
+
+properties:
+  compatible:
+    enum:
+      - adi,ltc2471
+      - adi,ltc2473
+      - adi,ltc2461
+      - adi,ltc2463

Put them in numeric order.

Ack, will do.

Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +7 -0
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
Quoted 9 lines

Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml line 40

Quoted 5 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +5 -0
+
+examples:
+  - |
+    i2c0 {
+      ltc2461@14 {

Should use a generic name
adc@14

Ack, will do.

Quoted 10 lines

Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml line 46

Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +6 -0
+        compatible = "ltc2461";
+        reg = <0x14>;
+      };
+    };
+  - |
+    i2c0 {

Not a lot of point in two examples given how similar they are. I'd just keep the one.

Ack, will do.
I only chose to give two examples because the chip has 2 possible I2C slave addresses 0x14 and 0x54 depending on the AO pin value being low or high. But you're right, they're too simple and similar.

Best regards,
Darius

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +6 -0
+      ltc2473@54 {
+        compatible = "ltc2473";
+        reg = <0x54>;
+      };
+    };
+
maintainer
#5 lore raw

Re: [PATCH v1 3/3] iio:adc:ltc2471: add dt binding yaml

Quoted 18 lines · Darius
Quoted 8 lines · Jonathan Cameron

[External]

Quoted 3 lines · On Wed, 17 Jun 2020 16:35:23 +0300 Darius Berghe <[email protected]>…

Add dt binding documentation for ltc2471 driver. This covers all supported devices.

Quoted 9 lines
Quoted 1 line

A few things inline but basically fine.

We should however also think about documenting power supplies. Even though the driver doesn't currently control the binding should be as complete as possible.

Jonathan

Quoted 7 lines

Hi Jonathan,

And thanks for the review !

This chips have a fixed internal vref of 1.25V that is output on the REFOUT pin, there is no place for configuration here. Or perhaps did you mean the VCC (2.7V-5.5V) ?

Yes, VCC was what I was referring to.

Quoted 2 lines

I'm not sure what the added value would be to add vref-supply and vcc-supply to yaml if they are not implemented. I find it confusing.

Bindings are intended to describe the hardware rather than what we've implemented
support for in the driver. It's fairly likely that we will end up supporting
regulator control sooner or later (tends to happen if a driver is getting much use as someone will care about powering down the supplies when suspending etc).

So ideally we'd add support to the driver, but even if it's not there we can consider adding it to the binding docs. However, it's not (to my mind) vital.

Quoted 79 lines
Quoted 27 lines
Quoted 27 lines
---
 .../bindings/iio/adc/adi,ltc2471.yaml         | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +15 -0
new file mode 100644
index 000000000000..0b84e14ec984
@@ -0,0 +1,52 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright 2020 Analog Devices Inc.
+%YAML 1.2
+---
+$id: https://urldefense.com/v3/__http://devicetree.org/schemas/bindings/iio/adc/adi,ltc2471.yaml*__;Iw!!A3Ni8CS0y2Y!vUpDwSslcaNrc3db6AQ6x3gzYHbR_WxOtQyPinkeZCjgpiQ4elEbjMzDs1OGEYZou4E$ 
+$schema: https://urldefense.com/v3/__http://devicetree.org/meta-schemas/core.yaml*__;Iw!!A3Ni8CS0y2Y!vUpDwSslcaNrc3db6AQ6x3gzYHbR_WxOtQyPinkeZCjgpiQ4elEbjMzDs1OG4cmRuW4$ 
+
+title: Analog Devices LTC2471 16-bit I2C Sigma-Delta ADC
+
+maintainers:
+  - Mike Looijmans <[email protected]>
+
+description: |
+  Analog Devices LTC2471 (single-ended) and LTC2473 (differential) 16-bit
+  I2C Sigma-Delta ADC with selectable 208/833sps output rate.
Quoted 9 lines

Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml line 20

Quoted 5 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +5 -0
+  https://www.analog.com/media/en/technical-documentation/data-sheets/24713fb.pdf
+
+  Analog Devices LTC2461 (single-ended) and LTC2463 (differential) 16-bit
+  I2C Sigma-Delta ADC with 60sps output rate.
+  https://www.analog.com/media/en/technical-documentation/data-sheets/24613fa.pdf  

Put these two blocks in numeric order. If we end up adding a bunch more devices it will be much more consistent if they are order.

Ack, will do.

Quoted 11 lines

Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml line 28

Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +8 -0
+
+properties:
+  compatible:
+    enum:
+      - adi,ltc2471
+      - adi,ltc2473
+      - adi,ltc2461
+      - adi,ltc2463  

Put them in numeric order.

Ack, will do.

Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +7 -0
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
Quoted 9 lines

Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml line 40

Quoted 5 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +5 -0
+
+examples:
+  - |
+    i2c0 {
+      ltc2461@14 {  

Should use a generic name
adc@14

Ack, will do.

Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +6 -0
+        compatible = "ltc2461";
+        reg = <0x14>;
+      };
+    };
+  - |
+    i2c0 {  
Quoted 6 lines
Quoted 3 lines

Not a lot of point in two examples given how similar they are. I'd just keep the one.

Ack, will do.
I only chose to give two examples because the chip has 2 possible I2C slave addresses 0x14 and 0x54 depending on the AO pin value being low or high. But you're right, they're too simple and similar.

Agreed

Thanks,

Jonathan

Quoted 10 lines

Best regards,
Darius

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/adi,ltc2471.yaml new file +6 -0
+      ltc2473@54 {
+        compatible = "ltc2473";
+        reg = <0x54>;
+      };
+    };
+  
maintainer
#6 lore raw
In reply to Darius Berghe
Quoted 4 lines · On Wed, 17 Jun 2020 16:35:21 +0300 Darius Berghe <[email protected]>…

OF style match table is the proper way of matching device tree nodes with drivers and such table was missing, this commit adds it.

Hi Darius

A few minor things inline.

Thanks,

Jonathan

drivers/iio/adc/ltc2471.c static const struct i2c_device_id ltc2471_i2c_id[] = { · line 146

Quoted 13 lines
---
 drivers/iio/adc/ltc2471.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/iio/adc/ltc2471.c +1 -0
index 55fab612843a..0e5cdb43a943 100644
@@ -143,9 +143,17 @@ static const struct i2c_device_id ltc2471_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ltc2471_i2c_id);
 
+static const struct of_device_id ltc2471_of_match[] = {

Should include mod_device_table.h as we are using of_device_id which is defined in that header.

drivers/iio/adc/ltc2471.c static const struct i2c_device_id ltc2471_i2c_id[] = { · line 156

Quoted 10 lines
drivers/iio/adc/ltc2471.c +7 -0
+	{ .compatible = "adi,ltc2471" },
+	{ .compatible = "adi,ltc2473" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, ltc2471_of_match);
+
 static struct i2c_driver ltc2471_i2c_driver = {
 	.driver = {
 		.name = "ltc2471",
+		.of_match_table = of_match_ptr(ltc2471_of_match)

Drop the of_match_ptr protection. That prevents the use of this binding with ACPI (via the magic of PRP0001 which allows you to use DT bindings in an ACPI DSDT).

We are slowly working our way through all the drivers removing the use of this macro (and converting to generic binding handling where relevant). It'll take a while yet though before there are no instances of this to copy!

Quoted 3 lines
drivers/iio/adc/ltc2471.c +0 -0
 	},
 	.probe    = ltc2471_i2c_probe,
 	.id_table = ltc2471_i2c_id,