2024-03-06 11:10:17

by Ceclan, Dumitru

[permalink] [raw]
Subject: [PATCH v3 0/3] Add support for additional AD717x models

This patch series adds support for the Analog Devices AD7172-2, AD7175-8,
AD7177-2 ADCs within the AD7173 driver.

Datasheets:
https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-4.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/AD7175-8.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/AD7177-2.pdf

This series depends on patch series AD7173
https://lore.kernel.org/all/[email protected]/

V2->V3
dt-bindings: adc: ad7173: add support for additional models:
- Remove vref constraint for ad7172-4
- Add missing model that supports ref2
iio: adc: ad7173: improve chip id's defines
- Create patch
iio: adc: ad7173: add support for additional models:
- Add new attributes to *_device_info to describe model specific behaviour:
odr_start_value, has_int_ref, has_ref2
- Remove unnecessary space from *_id_table
- Move chip id define rename in a separate patch
- Order chip id's by value
V1->V2
dt-bindings: adc: ad7173: add support for additional models:
- Remove bindings descriptions update as already included in latest AD7173 bindings
- Remove default: false for adi,reference-select
iio: adc: ad7173: add support for additional models:
- Add period to commit message
- AD717X -> AD717x
- Fix typo
- Reformat supported devices list
- Reorder device ID's by value
- Use correct comment style
- Add missing space

Dumitru Ceclan (3):
dt-bindings: adc: ad7173: add support for additional models
iio: adc: ad7173: improve chip id's defines
iio: adc: ad7173: add support for additional models

.../bindings/iio/adc/adi,ad7173.yaml | 39 +++++++-
drivers/iio/adc/ad7173.c | 92 +++++++++++++++++--
2 files changed, 119 insertions(+), 12 deletions(-)

--
2.43.0



2024-03-06 11:10:45

by Ceclan, Dumitru

[permalink] [raw]
Subject: [PATCH v3 2/3] iio: adc: ad7173: improve chip id's defines

Rename to AD7172_2_ID to avoid confusion with _4 model.
Reorder id's by reg value.

Signed-off-by: Dumitru Ceclan <[email protected]>
---
drivers/iio/adc/ad7173.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c
index b42fbe28a325..59a55d2944a7 100644
--- a/drivers/iio/adc/ad7173.c
+++ b/drivers/iio/adc/ad7173.c
@@ -61,10 +61,10 @@
#define AD7173_AIN_TEMP_POS 17
#define AD7173_AIN_TEMP_NEG 18

-#define AD7172_ID 0x00d0
-#define AD7173_ID 0x30d0
+#define AD7172_2_ID 0x00d0
#define AD7175_ID 0x0cd0
#define AD7176_ID 0x0c90
+#define AD7173_ID 0x30d0
#define AD7173_ID_MASK GENMASK(15, 4)

#define AD7173_ADC_MODE_REF_EN BIT(15)
@@ -190,7 +190,7 @@ static const unsigned int ad7175_sinc5_data_rates[] = {
static const struct ad7173_device_info ad7173_device_info[] = {
[ID_AD7172_2] = {
.name = "ad7172-2",
- .id = AD7172_ID,
+ .id = AD7172_2_ID,
.num_inputs = 5,
.num_channels = 4,
.num_configs = 4,
--
2.43.0


2024-03-06 11:32:51

by Ceclan, Dumitru

[permalink] [raw]
Subject: [PATCH v3 1/3] dt-bindings: adc: ad7173: add support for additional models

Add support for: AD7172-2, AD7175-8, AD7177-2.
AD7172-4 does not feature an internal reference, check for external
reference presence.

Signed-off-by: Dumitru Ceclan <[email protected]>
---
.../bindings/iio/adc/adi,ad7173.yaml | 39 +++++++++++++++++--
1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
index 36f16a325bc5..ea6cfcd0aff4 100644
--- a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
@@ -21,17 +21,23 @@ description: |

Datasheets for supported chips:
https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-2.pdf
+ https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-4.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/AD7173-8.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/AD7175-2.pdf
+ https://www.analog.com/media/en/technical-documentation/data-sheets/AD7175-8.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/AD7176-2.pdf
+ https://www.analog.com/media/en/technical-documentation/data-sheets/AD7177-2.pdf

properties:
compatible:
enum:
- adi,ad7172-2
+ - adi,ad7172-4
- adi,ad7173-8
- adi,ad7175-2
+ - adi,ad7175-8
- adi,ad7176-2
+ - adi,ad7177-2

reg:
maxItems: 1
@@ -136,8 +142,10 @@ patternProperties:
refout-avss: REFOUT/AVSS (Internal reference)
avdd : AVDD /AVSS

- External reference ref2 only available on ad7173-8.
- If not specified, internal reference used.
+ External reference ref2 only available on ad7173-8 and ad7172-4.
+ Internal reference refout-avss not available on ad7172-4.
+
+ If not specified, internal reference used (if available).
$ref: /schemas/types.yaml#/definitions/string
enum:
- vref
@@ -157,12 +165,17 @@ required:
allOf:
- $ref: /schemas/spi/spi-peripheral-props.yaml#

+ # Only ad7172-4, ad7173-8 and ad7175-8 support vref2
+ # Other models have [0-3] channel registers
- if:
properties:
compatible:
not:
contains:
- const: adi,ad7173-8
+ enum:
+ - adi,ad7172-4
+ - adi,ad7173-8
+ - adi,ad7175-8
then:
properties:
vref2-supply: false
@@ -177,6 +190,26 @@ allOf:
reg:
maximum: 3

+ # Model ad7172-4 does not support internal reference
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: adi,ad7172-4
+ then:
+ patternProperties:
+ "^channel@[0-9a-f]$":
+ properties:
+ reg:
+ maximum: 7
+ adi,reference-select:
+ enum:
+ - vref
+ - vref2
+ - avdd
+ required:
+ - adi,reference-select
+
- if:
anyOf:
- required: [clock-names]
--
2.43.0


2024-03-06 11:33:18

by Ceclan, Dumitru

[permalink] [raw]
Subject: [PATCH v3 3/3] iio: adc: ad7173: add support for additional models

Add support for Analog Devices AD7172-2, AD7175-8, AD7177-2.

Signed-off-by: Dumitru Ceclan <[email protected]>
---
drivers/iio/adc/ad7173.c | 86 +++++++++++++++++++++++++++++++++++++---
1 file changed, 80 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/ad7173.c b/drivers/iio/adc/ad7173.c
index 59a55d2944a7..4ff6ce46b02c 100644
--- a/drivers/iio/adc/ad7173.c
+++ b/drivers/iio/adc/ad7173.c
@@ -1,6 +1,11 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * AD7172-2/AD7173-8/AD7175-2/AD7176-2 SPI ADC driver
+ * AD717x family SPI ADC driver
+ *
+ * Supported devices:
+ * AD7172-2/AD7172-4/AD7173-8/AD7175-2
+ * AD7175-8/AD7176-2/AD7177-2
+ *
* Copyright (C) 2015, 2024 Analog Devices, Inc.
*/

@@ -64,7 +69,11 @@
#define AD7172_2_ID 0x00d0
#define AD7175_ID 0x0cd0
#define AD7176_ID 0x0c90
+#define AD7175_2_ID 0x0cd0
+#define AD7172_4_ID 0x2050
#define AD7173_ID 0x30d0
+#define AD7175_8_ID 0x3cd0
+#define AD7177_ID 0x4fd0
#define AD7173_ID_MASK GENMASK(15, 4)

#define AD7173_ADC_MODE_REF_EN BIT(15)
@@ -110,20 +119,25 @@
#define AD7173_SETUP_REF_SEL_EXT_REF 0x0
#define AD7173_VOLTAGE_INT_REF_uV 2500000
#define AD7173_TEMP_SENSIIVITY_uV_per_C 477
+#define AD7177_ODR_START_VALUE 0x07

#define AD7173_FILTER_ODR0_MASK GENMASK(5, 0)
#define AD7173_MAX_CONFIGS 8

enum ad7173_ids {
ID_AD7172_2,
+ ID_AD7172_4,
ID_AD7173_8,
ID_AD7175_2,
+ ID_AD7175_8,
ID_AD7176_2,
+ ID_AD7177_2,
};

struct ad7173_device_info {
const unsigned int *sinc5_data_rates;
unsigned int num_sinc5_data_rates;
+ unsigned int odr_start_value;
unsigned int num_channels;
unsigned int num_configs;
unsigned int num_inputs;
@@ -131,6 +145,8 @@ struct ad7173_device_info {
unsigned int id;
char *name;
bool has_temp;
+ bool has_int_ref;
+ bool has_ref2;
u8 num_gpios;
};

@@ -196,6 +212,19 @@ static const struct ad7173_device_info ad7173_device_info[] = {
.num_configs = 4,
.num_gpios = 2,
.has_temp = true,
+ .has_int_ref = true,
+ .clock = 2 * HZ_PER_MHZ,
+ .sinc5_data_rates = ad7173_sinc5_data_rates,
+ .num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
+ },
+ [ID_AD7172_4] = {
+ .id = AD7172_4_ID,
+ .num_inputs = 9,
+ .num_channels = 8,
+ .num_configs = 8,
+ .num_gpios = 4,
+ .has_temp = false,
+ .has_ref2 = true,
.clock = 2 * HZ_PER_MHZ,
.sinc5_data_rates = ad7173_sinc5_data_rates,
.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
@@ -208,18 +237,34 @@ static const struct ad7173_device_info ad7173_device_info[] = {
.num_configs = 8,
.num_gpios = 4,
.has_temp = true,
+ .has_int_ref = true,
+ .has_ref2 = true,
.clock = 2 * HZ_PER_MHZ,
.sinc5_data_rates = ad7173_sinc5_data_rates,
.num_sinc5_data_rates = ARRAY_SIZE(ad7173_sinc5_data_rates),
},
[ID_AD7175_2] = {
.name = "ad7175-2",
- .id = AD7175_ID,
+ .id = AD7175_2_ID,
.num_inputs = 5,
.num_channels = 4,
.num_configs = 4,
.num_gpios = 2,
.has_temp = true,
+ .has_int_ref = true,
+ .clock = 16 * HZ_PER_MHZ,
+ .sinc5_data_rates = ad7175_sinc5_data_rates,
+ .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
+ },
+ [ID_AD7175_8] = {
+ .id = AD7175_8_ID,
+ .num_inputs = 17,
+ .num_channels = 16,
+ .num_configs = 8,
+ .num_gpios = 4,
+ .has_temp = true,
+ .has_int_ref = true,
+ .has_ref2 = true,
.clock = 16 * HZ_PER_MHZ,
.sinc5_data_rates = ad7175_sinc5_data_rates,
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
@@ -232,7 +277,21 @@ static const struct ad7173_device_info ad7173_device_info[] = {
.num_configs = 4,
.num_gpios = 2,
.has_temp = false,
+ .has_int_ref = true,
+ .clock = 16 * HZ_PER_MHZ,
+ .sinc5_data_rates = ad7175_sinc5_data_rates,
+ .num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
+ },
+ [ID_AD7177_2] = {
+ .id = AD7177_ID,
+ .num_inputs = 5,
+ .num_channels = 4,
+ .num_configs = 4,
+ .num_gpios = 2,
+ .has_temp = true,
+ .has_int_ref = true,
.clock = 16 * HZ_PER_MHZ,
+ .odr_start_value = AD7177_ODR_START_VALUE,
.sinc5_data_rates = ad7175_sinc5_data_rates,
.num_sinc5_data_rates = ARRAY_SIZE(ad7175_sinc5_data_rates),
},
@@ -656,7 +715,7 @@ static int ad7173_write_raw(struct iio_dev *indio_dev,
switch (info) {
case IIO_CHAN_INFO_SAMP_FREQ:
freq = val * MILLI + val2 / MILLI;
- for (i = 0; i < st->info->num_sinc5_data_rates - 1; i++)
+ for (i = st->info->odr_start_value; i < st->info->num_sinc5_data_rates - 1; i++)
if (freq >= st->info->sinc5_data_rates[i])
break;

@@ -908,11 +967,17 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
else
ref_sel = ret;

- if (ref_sel == AD7173_SETUP_REF_SEL_EXT_REF2 &&
- st->info->id != AD7173_ID) {
+ if (ref_sel == AD7173_SETUP_REF_SEL_INT_REF &&
+ !st->info->has_int_ref) {
+ fwnode_handle_put(child);
+ return dev_err_probe(dev, -EINVAL,
+ "Internal reference is not available on current model.\n");
+ }
+
+ if (ref_sel == AD7173_SETUP_REF_SEL_EXT_REF2 && !st->info->has_ref2) {
fwnode_handle_put(child);
return dev_err_probe(dev, -EINVAL,
- "External reference 2 is only available on ad7173-8\n");
+ "External reference 2 is not available on current model.\n");
}

ret = ad7173_get_ref_voltage_milli(st, ref_sel);
@@ -1080,21 +1145,30 @@ static int ad7173_probe(struct spi_device *spi)
static const struct of_device_id ad7173_of_match[] = {
{ .compatible = "adi,ad7172-2",
.data = &ad7173_device_info[ID_AD7172_2]},
+ { .compatible = "adi,ad7172-4",
+ .data = &ad7173_device_info[ID_AD7172_4]},
{ .compatible = "adi,ad7173-8",
.data = &ad7173_device_info[ID_AD7173_8]},
{ .compatible = "adi,ad7175-2",
.data = &ad7173_device_info[ID_AD7175_2]},
+ { .compatible = "adi,ad7175-8",
+ .data = &ad7173_device_info[ID_AD7175_8]},
{ .compatible = "adi,ad7176-2",
.data = &ad7173_device_info[ID_AD7176_2]},
+ { .compatible = "adi,ad7177-2",
+ .data = &ad7173_device_info[ID_AD7177_2]},
{ }
};
MODULE_DEVICE_TABLE(of, ad7173_of_match);

static const struct spi_device_id ad7173_id_table[] = {
{ "ad7172-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7172_2]},
+ { "ad7172-4", (kernel_ulong_t)&ad7173_device_info[ID_AD7172_4]},
{ "ad7173-8", (kernel_ulong_t)&ad7173_device_info[ID_AD7173_8]},
{ "ad7175-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7175_2]},
+ { "ad7175-8", (kernel_ulong_t)&ad7173_device_info[ID_AD7175_8]},
{ "ad7176-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7176_2]},
+ { "ad7177-2", (kernel_ulong_t)&ad7173_device_info[ID_AD7177_2]},
{ }
};
MODULE_DEVICE_TABLE(spi, ad7173_id_table);
--
2.43.0


2024-03-06 18:13:52

by Conor Dooley

[permalink] [raw]
Subject: Re: [PATCH v3 1/3] dt-bindings: adc: ad7173: add support for additional models

On Wed, Mar 06, 2024 at 01:09:54PM +0200, Dumitru Ceclan wrote:
> Add support for: AD7172-2, AD7175-8, AD7177-2.
> AD7172-4 does not feature an internal reference, check for external
> reference presence.
>
> Signed-off-by: Dumitru Ceclan <[email protected]>

Reviewed-by: Conor Dooley <[email protected]>

Cheers,
Conor.

> ---
> .../bindings/iio/adc/adi,ad7173.yaml | 39 +++++++++++++++++--
> 1 file changed, 36 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
> index 36f16a325bc5..ea6cfcd0aff4 100644
> --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
> @@ -21,17 +21,23 @@ description: |
>
> Datasheets for supported chips:
> https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-2.pdf
> + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-4.pdf
> https://www.analog.com/media/en/technical-documentation/data-sheets/AD7173-8.pdf
> https://www.analog.com/media/en/technical-documentation/data-sheets/AD7175-2.pdf
> + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7175-8.pdf
> https://www.analog.com/media/en/technical-documentation/data-sheets/AD7176-2.pdf
> + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7177-2.pdf
>
> properties:
> compatible:
> enum:
> - adi,ad7172-2
> + - adi,ad7172-4
> - adi,ad7173-8
> - adi,ad7175-2
> + - adi,ad7175-8
> - adi,ad7176-2
> + - adi,ad7177-2
>
> reg:
> maxItems: 1
> @@ -136,8 +142,10 @@ patternProperties:
> refout-avss: REFOUT/AVSS (Internal reference)
> avdd : AVDD /AVSS
>
> - External reference ref2 only available on ad7173-8.
> - If not specified, internal reference used.
> + External reference ref2 only available on ad7173-8 and ad7172-4.
> + Internal reference refout-avss not available on ad7172-4.
> +
> + If not specified, internal reference used (if available).
> $ref: /schemas/types.yaml#/definitions/string
> enum:
> - vref
> @@ -157,12 +165,17 @@ required:
> allOf:
> - $ref: /schemas/spi/spi-peripheral-props.yaml#
>
> + # Only ad7172-4, ad7173-8 and ad7175-8 support vref2
> + # Other models have [0-3] channel registers
> - if:
> properties:
> compatible:
> not:
> contains:
> - const: adi,ad7173-8
> + enum:
> + - adi,ad7172-4
> + - adi,ad7173-8
> + - adi,ad7175-8
> then:
> properties:
> vref2-supply: false
> @@ -177,6 +190,26 @@ allOf:
> reg:
> maximum: 3
>
> + # Model ad7172-4 does not support internal reference
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: adi,ad7172-4
> + then:
> + patternProperties:
> + "^channel@[0-9a-f]$":
> + properties:
> + reg:
> + maximum: 7
> + adi,reference-select:
> + enum:
> + - vref
> + - vref2
> + - avdd
> + required:
> + - adi,reference-select
> +
> - if:
> anyOf:
> - required: [clock-names]
> --
> 2.43.0
>


Attachments:
(No filename) (3.55 kB)
signature.asc (235.00 B)
Download all attachments

2024-03-10 15:07:17

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v3 0/3] Add support for additional AD717x models

On Wed, 6 Mar 2024 13:09:53 +0200
Dumitru Ceclan <[email protected]> wrote:

> This patch series adds support for the Analog Devices AD7172-2, AD7175-8,
> AD7177-2 ADCs within the AD7173 driver.
>
> Datasheets:
> https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-4.pdf
> https://www.analog.com/media/en/technical-documentation/data-sheets/AD7175-8.pdf
> https://www.analog.com/media/en/technical-documentation/data-sheets/AD7177-2.pdf
>
> This series depends on patch series AD7173
> https://lore.kernel.org/all/[email protected]/
Applied to the togreg-normal branch of iio.git and pushed out for 0-day to
take a look. This is 3.10 material now given timing.

Thanks,

Jonathan