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

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>
---
 drivers/iio/dac/ad5686.c     | 13 +++++++++++++
 drivers/iio/dac/ad5686.h     |  1 +
 drivers/iio/dac/ad5696-i2c.c |  1 +
 3 files changed, 15 insertions(+)

diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index e06b29c565b9..bbcac0e44837 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_AD5338R_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),		\
@@ -262,6 +268,7 @@ DECLARE_AD5686_CHANNELS(ad5686_channels, 16, 0);
 DECLARE_AD5693_CHANNELS(ad5693_channels, 16, 0);
 DECLARE_AD5693_CHANNELS(ad5692r_channels, 14, 2);
 DECLARE_AD5693_CHANNELS(ad5691r_channels, 12, 4);
+DECLARE_AD5338R_CHANNELS(ad5338r_channels, 10, 6);
 
 static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
 	[ID_AD5310R] = {
@@ -413,6 +420,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
 		.num_channels = 4,
 		.regmap_type = AD5686_REGMAP,
 	},
+	[ID_AD5338R] = {
+		.channels = ad5338r_channels,
+		.int_vref_mv = 2500,
+		.num_channels = 2,
+		.regmap_type = AD5686_REGMAP,
+	},
 };
 
 int ad5686_probe(struct device *dev,
diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
index 70a779939ddb..02eb196fcf0f 100644
--- a/drivers/iio/dac/ad5686.h
+++ b/drivers/iio/dac/ad5686.h
@@ -77,6 +77,7 @@ enum ad5686_supported_device_ids {
 	ID_AD5695R,
 	ID_AD5696,
 	ID_AD5696R,
+	ID_AD5338R,
 };
 
 enum ad5686_regmap_type {
diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
index ccf794caef43..f100a5fe4219 100644
--- a/drivers/iio/dac/ad5696-i2c.c
+++ b/drivers/iio/dac/ad5696-i2c.c
@@ -83,6 +83,7 @@ static const struct i2c_device_id ad5686_i2c_id[] = {
 	{"ad5695r", ID_AD5695R},
 	{"ad5696", ID_AD5696},
 	{"ad5696r", ID_AD5696R},
+	{"ad5338r", ID_AD5338R},
 	{}
 };
 MODULE_DEVICE_TABLE(i2c, ad5686_i2c_id);
-- 
2.24.1


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

* [PATCH 2/3] iio: dac: ad5686: add of_match_table
  2020-03-18 15:34 [PATCH 1/3] iio: dac: ad5686: add support for AD5338R Michael Auchter
@ 2020-03-18 15:34 ` Michael Auchter
  2020-03-18 17:33   ` Lars-Peter Clausen
  2020-03-22  0:33   ` Andy Shevchenko
  2020-03-18 15:34 ` [PATCH 3/3] dt-bindings: iio: dac: ad5686: add binding Michael Auchter
  2020-03-18 17:30 ` [PATCH 1/3] iio: dac: ad5686: add support for AD5338R Lars-Peter Clausen
  2 siblings, 2 replies; 7+ messages in thread
From: Michael Auchter @ 2020-03-18 15:34 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Stefan Popa,
	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>
---
 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 f100a5fe4219..26818bccffa2 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,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" },
+	{ .compatible = "adi,ad5338r" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, ad5686_of_match);
+
 static struct i2c_driver ad5686_i2c_driver = {
 	.driver = {
 		.name = "ad5696",
+		.of_match_table = of_match_ptr(ad5686_of_match),
 	},
 	.probe = ad5686_i2c_probe,
 	.remove = ad5686_i2c_remove,
-- 
2.24.1


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

* [PATCH 3/3] dt-bindings: iio: dac: ad5686: add binding
  2020-03-18 15:34 [PATCH 1/3] iio: dac: ad5686: add support for AD5338R Michael Auchter
  2020-03-18 15:34 ` [PATCH 2/3] iio: dac: ad5686: add of_match_table Michael Auchter
@ 2020-03-18 15:34 ` Michael Auchter
  2020-03-19 17:12   ` Rob Herring
  2020-03-18 17:30 ` [PATCH 1/3] iio: dac: ad5686: add support for AD5338R Lars-Peter Clausen
  2 siblings, 1 reply; 7+ messages in thread
From: Michael Auchter @ 2020-03-18 15:34 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Rob Herring, Mark Rutland
  Cc: Michael Auchter, linux-iio, devicetree, linux-kernel

Add a binding for AD5686

Signed-off-by: Michael Auchter <michael.auchter@ni.com>
---
 .../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..4bd379720e99
--- /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/adc/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,ad5671r
+      - adi,ad5675r
+      - adi,ad5691r
+      - adi,ad5692r
+      - adi,ad5693
+      - adi,ad5693r
+      - adi,ad5694
+      - adi,ad5694r
+      - adi,ad5695r
+      - adi,ad5696
+      - adi,ad5696r
+      - adi,ad5338r
+
+  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.24.1


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

* Re: [PATCH 1/3] iio: dac: ad5686: add support for AD5338R
  2020-03-18 15:34 [PATCH 1/3] iio: dac: ad5686: add support for AD5338R Michael Auchter
  2020-03-18 15:34 ` [PATCH 2/3] iio: dac: ad5686: add of_match_table Michael Auchter
  2020-03-18 15:34 ` [PATCH 3/3] dt-bindings: iio: dac: ad5686: add binding Michael Auchter
@ 2020-03-18 17:30 ` Lars-Peter Clausen
  2 siblings, 0 replies; 7+ messages in thread
From: Lars-Peter Clausen @ 2020-03-18 17:30 UTC (permalink / raw)
  To: Michael Auchter, Michael Hennerich, Stefan Popa,
	Jonathan Cameron, Hartmut Knaack, Peter Meerwald-Stadler
  Cc: linux-pm, linux-iio, linux-kernel

On 3/18/20 4:34 PM, Michael Auchter 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>

Patch looks good, thanks. I just have one wish, which is to keep 
everything sorted by device ID. This will improve the longterm 
maintainability of the driver. AD5338R should be after AD5311R.

Also consider updating the Kconfig entry.

> ---
>   drivers/iio/dac/ad5686.c     | 13 +++++++++++++
>   drivers/iio/dac/ad5686.h     |  1 +
>   drivers/iio/dac/ad5696-i2c.c |  1 +
>   3 files changed, 15 insertions(+)
> 
> diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
> index e06b29c565b9..bbcac0e44837 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_AD5338R_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),		\
> @@ -262,6 +268,7 @@ DECLARE_AD5686_CHANNELS(ad5686_channels, 16, 0);
>   DECLARE_AD5693_CHANNELS(ad5693_channels, 16, 0);
>   DECLARE_AD5693_CHANNELS(ad5692r_channels, 14, 2);
>   DECLARE_AD5693_CHANNELS(ad5691r_channels, 12, 4);
> +DECLARE_AD5338R_CHANNELS(ad5338r_channels, 10, 6); >
>   static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
>   	[ID_AD5310R] = {
> @@ -413,6 +420,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = {
>   		.num_channels = 4,
>   		.regmap_type = AD5686_REGMAP,
>   	},
> +	[ID_AD5338R] = {
> +		.channels = ad5338r_channels,
> +		.int_vref_mv = 2500,
> +		.num_channels = 2,
> +		.regmap_type = AD5686_REGMAP,
> +	}, >   };
>   
>   int ad5686_probe(struct device *dev,
> diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
> index 70a779939ddb..02eb196fcf0f 100644
> --- a/drivers/iio/dac/ad5686.h
> +++ b/drivers/iio/dac/ad5686.h
> @@ -77,6 +77,7 @@ enum ad5686_supported_device_ids {
>   	ID_AD5695R,
>   	ID_AD5696,
>   	ID_AD5696R,
> +	ID_AD5338R,
>   };
>   
>   enum ad5686_regmap_type {
> diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
> index ccf794caef43..f100a5fe4219 100644
> --- a/drivers/iio/dac/ad5696-i2c.c
> +++ b/drivers/iio/dac/ad5696-i2c.c
> @@ -83,6 +83,7 @@ static const struct i2c_device_id ad5686_i2c_id[] = {
>   	{"ad5695r", ID_AD5695R},
>   	{"ad5696", ID_AD5696},
>   	{"ad5696r", ID_AD5696R},
> +	{"ad5338r", ID_AD5338R},
>   	{}
>   };
>   MODULE_DEVICE_TABLE(i2c, ad5686_i2c_id);
> 


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

* Re: [PATCH 2/3] iio: dac: ad5686: add of_match_table
  2020-03-18 15:34 ` [PATCH 2/3] iio: dac: ad5686: add of_match_table Michael Auchter
@ 2020-03-18 17:33   ` Lars-Peter Clausen
  2020-03-22  0:33   ` Andy Shevchenko
  1 sibling, 0 replies; 7+ messages in thread
From: Lars-Peter Clausen @ 2020-03-18 17:33 UTC (permalink / raw)
  To: Michael Auchter, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler
  Cc: linux-pm, linux-iio, linux-kernel

On 3/18/20 4:34 PM, Michael Auchter wrote:
> 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>
> ---
>   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 f100a5fe4219..26818bccffa2 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,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" },
> +	{ .compatible = "adi,ad5338r" },

Same here, table should be ordered.

> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, ad5686_of_match);
> +
>   static struct i2c_driver ad5686_i2c_driver = {
>   	.driver = {
>   		.name = "ad5696",
> +		.of_match_table = of_match_ptr(ad5686_of_match),
>   	},
>   	.probe = ad5686_i2c_probe,
>   	.remove = ad5686_i2c_remove,
> 


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

* Re: [PATCH 3/3] dt-bindings: iio: dac: ad5686: add binding
  2020-03-18 15:34 ` [PATCH 3/3] dt-bindings: iio: dac: ad5686: add binding Michael Auchter
@ 2020-03-19 17:12   ` Rob Herring
  0 siblings, 0 replies; 7+ messages in thread
From: Rob Herring @ 2020-03-19 17:12 UTC (permalink / raw)
  To: Michael Auchter
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Mark Rutland, Michael Auchter, linux-iio,
	devicetree, linux-kernel

On Wed, 18 Mar 2020 10:34:34 -0500, Michael Auchter wrote:
> Add a binding for AD5686
> 
> Signed-off-by: Michael Auchter <michael.auchter@ni.com>
> ---
>  .../bindings/iio/dac/adi,ad5686.yaml          | 61 +++++++++++++++++++
>  1 file changed, 61 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml
> 

My bot found errors running 'make dt_binding_check' on your patch:

Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml: $id: relative path/filename doesn't match actual path or filename
	expected: http://devicetree.org/schemas/iio/dac/adi,ad5686.yaml#

See https://patchwork.ozlabs.org/patch/1257638
Please check and re-submit.

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

* Re: [PATCH 2/3] iio: dac: ad5686: add of_match_table
  2020-03-18 15:34 ` [PATCH 2/3] iio: dac: ad5686: add of_match_table Michael Auchter
  2020-03-18 17:33   ` Lars-Peter Clausen
@ 2020-03-22  0:33   ` Andy Shevchenko
  1 sibling, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2020-03-22  0:33 UTC (permalink / raw)
  To: Michael Auchter
  Cc: Lars-Peter Clausen, Michael Hennerich, Stefan Popa,
	Jonathan Cameron, Hartmut Knaack, Peter Meerwald-Stadler,
	Linux PM, linux-iio, Linux Kernel Mailing List

On Wed, Mar 18, 2020 at 5:56 PM Michael Auchter <michael.auchter@ni.com> wrote:
>
> Add of_match_table to this driver, so devices can be probed based on
> device tree contents.

> +               .of_match_table = of_match_ptr(ad5686_of_match),

There is no need to use of_match_ptr().
Didn't you get a compiler warning for !OF case?

-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2020-03-22  0:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18 15:34 [PATCH 1/3] iio: dac: ad5686: add support for AD5338R Michael Auchter
2020-03-18 15:34 ` [PATCH 2/3] iio: dac: ad5686: add of_match_table Michael Auchter
2020-03-18 17:33   ` Lars-Peter Clausen
2020-03-22  0:33   ` Andy Shevchenko
2020-03-18 15:34 ` [PATCH 3/3] dt-bindings: iio: dac: ad5686: add binding Michael Auchter
2020-03-19 17:12   ` Rob Herring
2020-03-18 17:30 ` [PATCH 1/3] iio: dac: ad5686: add support for AD5338R Lars-Peter Clausen

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).