linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] iio: dac: ad5686: add support for AD5338R
@ 2020-09-22 18:40 Michael Auchter
  2020-09-22 18:40 ` [PATCH v2 2/3] iio: dac: ad5686: add of_match_table Michael Auchter
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michael Auchter @ 2020-09-22 18:40 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Michael Hennerich
  Cc: Michael Auchter, linux-iio, linux-kernel, linux-pm

The AD5338R is a 10-bit DAC with 2 outputs and an internal 2.5V
reference (enabled by default). The register configuration is nearly
identical to the AD5696R DAC that's already supported by this driver,
with the channel selection bits being the only thing different.

Signed-off-by: Michael Auchter <michael.auchter@ni.com>
---
Changes since v1:
- Keep things sorted by product name
- Update Kconfig description to list supported converters

 drivers/iio/dac/Kconfig      |  7 ++++---
 drivers/iio/dac/ad5686.c     | 13 +++++++++++++
 drivers/iio/dac/ad5686.h     |  1 +
 drivers/iio/dac/ad5696-i2c.c |  1 +
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
index dae8d27e772d..6f6074a5d3db 100644
--- a/drivers/iio/dac/Kconfig
+++ b/drivers/iio/dac/Kconfig
@@ -141,9 +141,10 @@ config AD5696_I2C
 	depends on I2C
 	select AD5686
 	help
-	  Say yes here to build support for Analog Devices AD5671R, AD5675R,
-	  AD5694, AD5694R, AD5695R, AD5696, AD5696R Voltage Output Digital to
-	  Analog Converter.
+	  Say yes here to build support for Analog Devices AD5311R, AD5338R,
+	  AD5671R, AD5675R, AD5691R, AD5692R, AD5693, AD5693R, AD5694, AD5694R,
+	  AD5695R, AD5696, and AD5696R Digital to Analog converters.
+
 	  To compile this driver as a module, choose M here: the module will be
 	  called ad5696.
 
diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index 56cf9344d187..382b3eb7ec06 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -210,6 +210,12 @@ static struct iio_chan_spec name[] = {				\
 		AD5868_CHANNEL(0, 0, bits, _shift),		\
 }
 
+#define DECLARE_AD5338_CHANNELS(name, bits, _shift)		\
+static struct iio_chan_spec name[] = {				\
+		AD5868_CHANNEL(0, 1, bits, _shift),		\
+		AD5868_CHANNEL(1, 8, bits, _shift),		\
+}
+
 #define DECLARE_AD5686_CHANNELS(name, bits, _shift)		\
 static struct iio_chan_spec name[] = {				\
 		AD5868_CHANNEL(0, 1, bits, _shift),		\
@@ -252,6 +258,7 @@ static struct iio_chan_spec name[] = {				\
 
 DECLARE_AD5693_CHANNELS(ad5310r_channels, 10, 2);
 DECLARE_AD5693_CHANNELS(ad5311r_channels, 10, 6);
+DECLARE_AD5338_CHANNELS(ad5338r_channels, 10, 6);
 DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4);
 DECLARE_AD5679_CHANNELS(ad5674r_channels, 12, 4);
 DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0);
@@ -276,6 +283,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
 		.num_channels = 1,
 		.regmap_type = AD5693_REGMAP,
 	},
+	[ID_AD5338R] = {
+		.channels = ad5338r_channels,
+		.int_vref_mv = 2500,
+		.num_channels = 2,
+		.regmap_type = AD5686_REGMAP,
+	},
 	[ID_AD5671R] = {
 		.channels = ad5672_channels,
 		.int_vref_mv = 2500,
diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
index 52009b5eef88..c714afa40adf 100644
--- a/drivers/iio/dac/ad5686.h
+++ b/drivers/iio/dac/ad5686.h
@@ -52,6 +52,7 @@
 enum ad5686_supported_device_ids {
 	ID_AD5310R,
 	ID_AD5311R,
+	ID_AD5338R,
 	ID_AD5671R,
 	ID_AD5672R,
 	ID_AD5674R,
diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
index ccf794caef43..89e7b063b7bb 100644
--- a/drivers/iio/dac/ad5696-i2c.c
+++ b/drivers/iio/dac/ad5696-i2c.c
@@ -72,6 +72,7 @@ static int ad5686_i2c_remove(struct i2c_client *i2c)
 
 static const struct i2c_device_id ad5686_i2c_id[] = {
 	{"ad5311r", ID_AD5311R},
+	{"ad5338r", ID_AD5338R},
 	{"ad5671r", ID_AD5671R},
 	{"ad5675r", ID_AD5675R},
 	{"ad5691r", ID_AD5691R},
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/3] iio: dac: ad5686: add of_match_table
  2020-09-22 18:40 [PATCH v2 1/3] iio: dac: ad5686: add support for AD5338R Michael Auchter
@ 2020-09-22 18:40 ` Michael Auchter
  2020-09-22 18:40 ` [PATCH v2 3/3] dt-bindings: iio: dac: ad5686: add binding Michael Auchter
  2020-09-23 20:18 ` [PATCH v2 1/3] iio: dac: ad5686: add support for AD5338R Jonathan Cameron
  2 siblings, 0 replies; 5+ messages in thread
From: Michael Auchter @ 2020-09-22 18:40 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler
  Cc: Michael Auchter, linux-pm, linux-iio, linux-kernel

Add of_match_table to this driver, so devices can be probed based on
device tree contents.

Signed-off-by: Michael Auchter <michael.auchter@ni.com>
---
Changes since v1:
- Drop of_match_ptr() use

 drivers/iio/dac/ad5696-i2c.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
index 89e7b063b7bb..a39eda7c02d2 100644
--- a/drivers/iio/dac/ad5696-i2c.c
+++ b/drivers/iio/dac/ad5696-i2c.c
@@ -88,9 +88,28 @@ static const struct i2c_device_id ad5686_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, ad5686_i2c_id);
 
+static const struct of_device_id ad5686_of_match[] = {
+	{ .compatible = "adi,ad5311r" },
+	{ .compatible = "adi,ad5338r" },
+	{ .compatible = "adi,ad5671r" },
+	{ .compatible = "adi,ad5675r" },
+	{ .compatible = "adi,ad5691r" },
+	{ .compatible = "adi,ad5692r" },
+	{ .compatible = "adi,ad5693" },
+	{ .compatible = "adi,ad5693r" },
+	{ .compatible = "adi,ad5694" },
+	{ .compatible = "adi,ad5694r" },
+	{ .compatible = "adi,ad5695r" },
+	{ .compatible = "adi,ad5696" },
+	{ .compatible = "adi,ad5696r" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, ad5686_of_match);
+
 static struct i2c_driver ad5686_i2c_driver = {
 	.driver = {
 		.name = "ad5696",
+		.of_match_table = ad5686_of_match,
 	},
 	.probe = ad5686_i2c_probe,
 	.remove = ad5686_i2c_remove,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] dt-bindings: iio: dac: ad5686: add binding
  2020-09-22 18:40 [PATCH v2 1/3] iio: dac: ad5686: add support for AD5338R Michael Auchter
  2020-09-22 18:40 ` [PATCH v2 2/3] iio: dac: ad5686: add of_match_table Michael Auchter
@ 2020-09-22 18:40 ` Michael Auchter
  2020-09-23 20:15   ` Jonathan Cameron
  2020-09-23 20:18 ` [PATCH v2 1/3] iio: dac: ad5686: add support for AD5338R Jonathan Cameron
  2 siblings, 1 reply; 5+ messages in thread
From: Michael Auchter @ 2020-09-22 18:40 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Rob Herring, Michael Auchter
  Cc: linux-iio, devicetree, linux-kernel

Add a binding for AD5686

Signed-off-by: Michael Auchter <michael.auchter@ni.com>
---
Changes since v1:
- Keep supported device sorted
- fix adc -> dac type in schema path

 .../bindings/iio/dac/adi,ad5686.yaml          | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml

diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml
new file mode 100644
index 000000000000..9ce76d75f31b
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/dac/adi,ad5686.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices AD5686 and similar multi-channel DACs
+
+maintainers:
+  - Michael Auchter <michael.auchter@ni.com>
+
+description: |
+  Binding for Analog Devices AD5686 and similar multi-channel DACs
+
+properties:
+  compatible:
+    enum:
+      - adi,ad5311r
+      - adi,ad5338r
+      - adi,ad5671r
+      - adi,ad5675r
+      - adi,ad5691r
+      - adi,ad5692r
+      - adi,ad5693
+      - adi,ad5693r
+      - adi,ad5694
+      - adi,ad5694r
+      - adi,ad5695r
+      - adi,ad5696
+      - adi,ad5696r
+
+  reg:
+    maxItems: 1
+
+  vcc-supply:
+    description: |
+      The regulator supply for DAC reference voltage.
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      ad5686: dac@0 {
+        compatible = "adi,ad5686";
+        reg = <0>;
+        vcc-supply = <&dac_vref>;
+      };
+    };
+
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 3/3] dt-bindings: iio: dac: ad5686: add binding
  2020-09-22 18:40 ` [PATCH v2 3/3] dt-bindings: iio: dac: ad5686: add binding Michael Auchter
@ 2020-09-23 20:15   ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2020-09-23 20:15 UTC (permalink / raw)
  To: Michael Auchter
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, linux-iio, devicetree, linux-kernel

On Tue, 22 Sep 2020 13:40:12 -0500
Michael Auchter <michael.auchter@ni.com> wrote:

> Add a binding for AD5686
> 
> Signed-off-by: Michael Auchter <michael.auchter@ni.com>
Hi Michael,

Thanks for this.
A few comments inline.

Thanks,

Jonathan

> ---
> Changes since v1:
> - Keep supported device sorted
> - fix adc -> dac type in schema path
> 
>  .../bindings/iio/dac/adi,ad5686.yaml          | 61 +++++++++++++++++++
>  1 file changed, 61 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml
> 
> diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml
> new file mode 100644
> index 000000000000..9ce76d75f31b
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml
> @@ -0,0 +1,61 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/dac/adi,ad5686.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Analog Devices AD5686 and similar multi-channel DACs
> +
> +maintainers:
> +  - Michael Auchter <michael.auchter@ni.com>
> +
> +description: |
> +  Binding for Analog Devices AD5686 and similar multi-channel DACs
> +
> +properties:
> +  compatible:
> +    enum:
> +      - adi,ad5311r
> +      - adi,ad5338r
> +      - adi,ad5671r
> +      - adi,ad5675r
> +      - adi,ad5691r
> +      - adi,ad5692r
> +      - adi,ad5693
> +      - adi,ad5693r
> +      - adi,ad5694
> +      - adi,ad5694r
> +      - adi,ad5695r
> +      - adi,ad5696
> +      - adi,ad5696r
> +
> +  reg:
> +    maxItems: 1
> +
> +  vcc-supply:
> +    description: |
> +      The regulator supply for DAC reference voltage.
> +
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 0

Why address-cells and size-cells?  Properties we are giving
are for the dac, not the i2c bus.

> +
> +required:
> +  - compatible
> +  - reg


additionalProperties: false

> +
> +examples:
> +  - |
> +    i2c {
> +      #address-cells = <1>;
> +      #size-cells = <0>;
> +
> +      ad5686: dac@0 {
> +        compatible = "adi,ad5686";
> +        reg = <0>;
> +        vcc-supply = <&dac_vref>;
> +      };
> +    };
> +


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/3] iio: dac: ad5686: add support for AD5338R
  2020-09-22 18:40 [PATCH v2 1/3] iio: dac: ad5686: add support for AD5338R Michael Auchter
  2020-09-22 18:40 ` [PATCH v2 2/3] iio: dac: ad5686: add of_match_table Michael Auchter
  2020-09-22 18:40 ` [PATCH v2 3/3] dt-bindings: iio: dac: ad5686: add binding Michael Auchter
@ 2020-09-23 20:18 ` Jonathan Cameron
  2 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2020-09-23 20:18 UTC (permalink / raw)
  To: Michael Auchter
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Michael Hennerich, linux-iio, linux-kernel, linux-pm

On Tue, 22 Sep 2020 13:40:10 -0500
Michael Auchter <michael.auchter@ni.com> wrote:

> The AD5338R is a 10-bit DAC with 2 outputs and an internal 2.5V
> reference (enabled by default). The register configuration is nearly
> identical to the AD5696R DAC that's already supported by this driver,
> with the channel selection bits being the only thing different.
> 
> Signed-off-by: Michael Auchter <michael.auchter@ni.com>

Looks good to me - just the DT binding to tweak for v3 unless
anyone else comments.

Thanks,

Jonathan


> ---
> Changes since v1:
> - Keep things sorted by product name
> - Update Kconfig description to list supported converters
> 
>  drivers/iio/dac/Kconfig      |  7 ++++---
>  drivers/iio/dac/ad5686.c     | 13 +++++++++++++
>  drivers/iio/dac/ad5686.h     |  1 +
>  drivers/iio/dac/ad5696-i2c.c |  1 +
>  4 files changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
> index dae8d27e772d..6f6074a5d3db 100644
> --- a/drivers/iio/dac/Kconfig
> +++ b/drivers/iio/dac/Kconfig
> @@ -141,9 +141,10 @@ config AD5696_I2C
>  	depends on I2C
>  	select AD5686
>  	help
> -	  Say yes here to build support for Analog Devices AD5671R, AD5675R,
> -	  AD5694, AD5694R, AD5695R, AD5696, AD5696R Voltage Output Digital to
> -	  Analog Converter.
> +	  Say yes here to build support for Analog Devices AD5311R, AD5338R,
> +	  AD5671R, AD5675R, AD5691R, AD5692R, AD5693, AD5693R, AD5694, AD5694R,
> +	  AD5695R, AD5696, and AD5696R Digital to Analog converters.
> +
>  	  To compile this driver as a module, choose M here: the module will be
>  	  called ad5696.
>  
> diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
> index 56cf9344d187..382b3eb7ec06 100644
> --- a/drivers/iio/dac/ad5686.c
> +++ b/drivers/iio/dac/ad5686.c
> @@ -210,6 +210,12 @@ static struct iio_chan_spec name[] = {				\
>  		AD5868_CHANNEL(0, 0, bits, _shift),		\
>  }
>  
> +#define DECLARE_AD5338_CHANNELS(name, bits, _shift)		\
> +static struct iio_chan_spec name[] = {				\
> +		AD5868_CHANNEL(0, 1, bits, _shift),		\
> +		AD5868_CHANNEL(1, 8, bits, _shift),		\
> +}
> +
>  #define DECLARE_AD5686_CHANNELS(name, bits, _shift)		\
>  static struct iio_chan_spec name[] = {				\
>  		AD5868_CHANNEL(0, 1, bits, _shift),		\
> @@ -252,6 +258,7 @@ static struct iio_chan_spec name[] = {				\
>  
>  DECLARE_AD5693_CHANNELS(ad5310r_channels, 10, 2);
>  DECLARE_AD5693_CHANNELS(ad5311r_channels, 10, 6);
> +DECLARE_AD5338_CHANNELS(ad5338r_channels, 10, 6);
>  DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4);
>  DECLARE_AD5679_CHANNELS(ad5674r_channels, 12, 4);
>  DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0);
> @@ -276,6 +283,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
>  		.num_channels = 1,
>  		.regmap_type = AD5693_REGMAP,
>  	},
> +	[ID_AD5338R] = {
> +		.channels = ad5338r_channels,
> +		.int_vref_mv = 2500,
> +		.num_channels = 2,
> +		.regmap_type = AD5686_REGMAP,
> +	},
>  	[ID_AD5671R] = {
>  		.channels = ad5672_channels,
>  		.int_vref_mv = 2500,
> diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
> index 52009b5eef88..c714afa40adf 100644
> --- a/drivers/iio/dac/ad5686.h
> +++ b/drivers/iio/dac/ad5686.h
> @@ -52,6 +52,7 @@
>  enum ad5686_supported_device_ids {
>  	ID_AD5310R,
>  	ID_AD5311R,
> +	ID_AD5338R,
>  	ID_AD5671R,
>  	ID_AD5672R,
>  	ID_AD5674R,
> diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
> index ccf794caef43..89e7b063b7bb 100644
> --- a/drivers/iio/dac/ad5696-i2c.c
> +++ b/drivers/iio/dac/ad5696-i2c.c
> @@ -72,6 +72,7 @@ static int ad5686_i2c_remove(struct i2c_client *i2c)
>  
>  static const struct i2c_device_id ad5686_i2c_id[] = {
>  	{"ad5311r", ID_AD5311R},
> +	{"ad5338r", ID_AD5338R},
>  	{"ad5671r", ID_AD5671R},
>  	{"ad5675r", ID_AD5675R},
>  	{"ad5691r", ID_AD5691R},


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-23 20:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-22 18:40 [PATCH v2 1/3] iio: dac: ad5686: add support for AD5338R Michael Auchter
2020-09-22 18:40 ` [PATCH v2 2/3] iio: dac: ad5686: add of_match_table Michael Auchter
2020-09-22 18:40 ` [PATCH v2 3/3] dt-bindings: iio: dac: ad5686: add binding Michael Auchter
2020-09-23 20:15   ` Jonathan Cameron
2020-09-23 20:18 ` [PATCH v2 1/3] iio: dac: ad5686: add support for AD5338R Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).