devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Add MCP48XX bindings and driver support
@ 2023-04-05 14:01 Nicolas Frattaroli
  2023-04-05 14:01 ` [PATCH 1/4] dt-bindings: iio: dac: mcp4922: add vdd-supply property Nicolas Frattaroli
  2023-04-05 14:01 ` [PATCH 3/4] dt-bindings: iio: dac: add mcp4822 Nicolas Frattaroli
  0 siblings, 2 replies; 7+ messages in thread
From: Nicolas Frattaroli @ 2023-04-05 14:01 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Nicolas Frattaroli, Kory Maincent,
	Miquel Raynal, Nuno Sá, Michael Welling, linux-iio,
	devicetree, linux-kernel

This series aims to add support for the following DAC chips by Microchip:
 - MCP4801 (8 bit, 1 channel)
 - MCP4802 (8 bit, 2 channels)
 - MCP4811 (10 bit, 1 channel)
 - MCP4812 (10 bit, 2 channels)
 - MCP4821 (12 bit, 1 channel)
 - MCP4822 (12 bit, 2 channels)

The chips' interface is compatible with that of the MCP49XX ones, but they
come with an internal 2.048V voltage reference, meaning there is no need
for an external voltage reference (and no way to use one.)

The first patch rectifies an issue with the mcp4922 bindings where there
was no vdd-supply property modeled. Those chips do have a second supply
aside from vref, the vdd-supply, which powers the digital logic side of
things.

Patch number 2 uses the vdd regulator in the driver. This is just fairly
boring "enable it here, disable it here" type stuff.

Patch number 3 adds the bindings for the MCP48XX chips. We add the whole
family, not just the ones that have an analogous 4922 enum. There is a
need for a separate binding as making vref only required for some in the
mcp4922 binding would make it more complicated than it's worth.

Patch number 4 finally makes all the driver changes to support the
MCP48XX chips.

All changes have been tested on an MCP4821. I don't own the full line of
MCP48XX and MCP49XX chips, so couldn't exhaustively test everything for
all of them, but if Microchip feels like sending some over then I am more
than happy to receive them.

Kind regards,
Nicolas Frattaroli

Nicolas Frattaroli (4):
  dt-bindings: iio: dac: mcp4922: add vdd-supply property
  iio: dac: mcp4922: get and enable vdd regulator
  dt-bindings: iio: dac: add mcp4822
  iio: dac: mcp4922: add support for mcp48xx series chips

 .../bindings/iio/dac/microchip,mcp4822.yaml   |  49 +++++++
 .../bindings/iio/dac/microchip,mcp4922.yaml   |   4 +
 drivers/iio/dac/mcp4922.c                     | 130 ++++++++++++++----
 3 files changed, 154 insertions(+), 29 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/dac/microchip,mcp4822.yaml

-- 
2.40.0


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

* [PATCH 1/4] dt-bindings: iio: dac: mcp4922: add vdd-supply property
  2023-04-05 14:01 [PATCH 0/4] Add MCP48XX bindings and driver support Nicolas Frattaroli
@ 2023-04-05 14:01 ` Nicolas Frattaroli
  2023-04-09 20:52   ` Michael Welling
  2023-04-05 14:01 ` [PATCH 3/4] dt-bindings: iio: dac: add mcp4822 Nicolas Frattaroli
  1 sibling, 1 reply; 7+ messages in thread
From: Nicolas Frattaroli @ 2023-04-05 14:01 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Michael Welling
  Cc: Nicolas Frattaroli, linux-iio, devicetree, linux-kernel

These chips have a vdd supply input, which should be modelled in
the bindings as well. Vref is only the voltage reference supply for
the string DAC.

Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
---
 .../devicetree/bindings/iio/dac/microchip,mcp4922.yaml        | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/dac/microchip,mcp4922.yaml b/Documentation/devicetree/bindings/iio/dac/microchip,mcp4922.yaml
index 19374401e509..a3e80e90eeca 100644
--- a/Documentation/devicetree/bindings/iio/dac/microchip,mcp4922.yaml
+++ b/Documentation/devicetree/bindings/iio/dac/microchip,mcp4922.yaml
@@ -21,11 +21,14 @@ properties:
   reg:
     maxItems: 1
 
+  vdd-supply: true
+
   vref-supply: true
 
 required:
   - compatible
   - reg
+  - vdd-supply
   - vref-supply
 
 allOf:
@@ -42,6 +45,7 @@ examples:
         dac@0 {
             compatible = "microchip,mcp4912";
             reg = <0>;
+            vdd-supply = <&dac_reg>;
             vref-supply = <&dac_vref>;
         };
     };
-- 
2.40.0


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

* [PATCH 3/4] dt-bindings: iio: dac: add mcp4822
  2023-04-05 14:01 [PATCH 0/4] Add MCP48XX bindings and driver support Nicolas Frattaroli
  2023-04-05 14:01 ` [PATCH 1/4] dt-bindings: iio: dac: mcp4922: add vdd-supply property Nicolas Frattaroli
@ 2023-04-05 14:01 ` Nicolas Frattaroli
  2023-04-05 14:10   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 7+ messages in thread
From: Nicolas Frattaroli @ 2023-04-05 14:01 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Nicolas Frattaroli
  Cc: linux-iio, devicetree, linux-kernel

The MCP4801, MCP4802, MCP4811, MCP4812, MCP4821, and MCP4822 are
SPI digital-to-analog converters by Microchip, which have an
internal voltage reference, in contrast to the MCP49xx series
of DACs which use an external voltage reference.

Thus, these need a separate binding, as to not overcomplicate
the mcp4922 binding.

Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
---
 .../bindings/iio/dac/microchip,mcp4822.yaml   | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/dac/microchip,mcp4822.yaml

diff --git a/Documentation/devicetree/bindings/iio/dac/microchip,mcp4822.yaml b/Documentation/devicetree/bindings/iio/dac/microchip,mcp4822.yaml
new file mode 100644
index 000000000000..c6eaf0079add
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/dac/microchip,mcp4822.yaml
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/dac/microchip,mcp4822.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip MCP4801, MCP4802, MCP4811, MCP4812, MCP4821 and MCP4822 SPI DACs
+
+maintainers:
+  - Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
+
+properties:
+  compatible:
+    enum:
+      - microchip,mcp4801
+      - microchip,mcp4802
+      - microchip,mcp4811
+      - microchip,mcp4812
+      - microchip,mcp4821
+      - microchip,mcp4822
+
+  reg:
+    maxItems: 1
+
+  vdd-supply: true
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+
+allOf:
+  - $ref: /schemas/spi/spi-peripheral-props.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        dac@0 {
+            compatible = "microchip,mcp4821";
+            reg = <0>;
+            vdd-supply = <&dac_reg>;
+        };
+    };
+...
-- 
2.40.0


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

* Re: [PATCH 3/4] dt-bindings: iio: dac: add mcp4822
  2023-04-05 14:01 ` [PATCH 3/4] dt-bindings: iio: dac: add mcp4822 Nicolas Frattaroli
@ 2023-04-05 14:10   ` Krzysztof Kozlowski
  2023-04-05 14:17     ` Nicolas Frattaroli
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-04-05 14:10 UTC (permalink / raw)
  To: Nicolas Frattaroli, Jonathan Cameron, Lars-Peter Clausen,
	Rob Herring, Krzysztof Kozlowski
  Cc: linux-iio, devicetree, linux-kernel

On 05/04/2023 16:01, Nicolas Frattaroli wrote:
> The MCP4801, MCP4802, MCP4811, MCP4812, MCP4821, and MCP4822 are
> SPI digital-to-analog converters by Microchip, which have an
> internal voltage reference, in contrast to the MCP49xx series
> of DACs which use an external voltage reference.
> 
> Thus, these need a separate binding, as to not overcomplicate
> the mcp4922 binding.

The difference is just one property which is very easy to handle - one
allOf:if:then: with
    vref-supply: false

Are there any other differences?

Best regards,
Krzysztof


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

* Re: [PATCH 3/4] dt-bindings: iio: dac: add mcp4822
  2023-04-05 14:10   ` Krzysztof Kozlowski
@ 2023-04-05 14:17     ` Nicolas Frattaroli
  2023-04-06 18:58       ` Krzysztof Kozlowski
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Frattaroli @ 2023-04-05 14:17 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Krzysztof Kozlowski
  Cc: linux-iio, devicetree, linux-kernel

On Mittwoch, 5. April 2023 16:10:10 CEST Krzysztof Kozlowski wrote:
> On 05/04/2023 16:01, Nicolas Frattaroli wrote:
> > The MCP4801, MCP4802, MCP4811, MCP4812, MCP4821, and MCP4822 are
> > SPI digital-to-analog converters by Microchip, which have an
> > internal voltage reference, in contrast to the MCP49xx series
> > of DACs which use an external voltage reference.
> > 
> > Thus, these need a separate binding, as to not overcomplicate
> > the mcp4922 binding.
> 
> The difference is just one property which is very easy to handle - one
> allOf:if:then: with
>     vref-supply: false
> 
> Are there any other differences?
> 
> Best regards,
> Krzysztof
> 
> 

In place of the external vref input, the MCP48XX series chips also
have a "SHDN" input, which is an active-low pin to disable the whole
chip and put it in a low power state. Future users of the bindings
may want to model this as being tied to some GPIO, though I haven't
done it here since I don't care about this feature.

Kind regards,
Nicolas Frattaroli



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

* Re: [PATCH 3/4] dt-bindings: iio: dac: add mcp4822
  2023-04-05 14:17     ` Nicolas Frattaroli
@ 2023-04-06 18:58       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2023-04-06 18:58 UTC (permalink / raw)
  To: Nicolas Frattaroli, Jonathan Cameron, Lars-Peter Clausen,
	Rob Herring, Krzysztof Kozlowski
  Cc: linux-iio, devicetree, linux-kernel

On 05/04/2023 16:17, Nicolas Frattaroli wrote:
> On Mittwoch, 5. April 2023 16:10:10 CEST Krzysztof Kozlowski wrote:
>> On 05/04/2023 16:01, Nicolas Frattaroli wrote:
>>> The MCP4801, MCP4802, MCP4811, MCP4812, MCP4821, and MCP4822 are
>>> SPI digital-to-analog converters by Microchip, which have an
>>> internal voltage reference, in contrast to the MCP49xx series
>>> of DACs which use an external voltage reference.
>>>
>>> Thus, these need a separate binding, as to not overcomplicate
>>> the mcp4922 binding.
>>
>> The difference is just one property which is very easy to handle - one
>> allOf:if:then: with
>>     vref-supply: false
>>
>> Are there any other differences?
>>
>> Best regards,
>> Krzysztof
>>
>>
> 
> In place of the external vref input, the MCP48XX series chips also
> have a "SHDN" input, which is an active-low pin to disable the whole
> chip and put it in a low power state. Future users of the bindings
> may want to model this as being tied to some GPIO, though I haven't
> done it here since I don't care about this feature.

OK to keep them separate, but then you should add here powerdown-gpios.
Bindings should be complete.

Best regards,
Krzysztof


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

* Re: [PATCH 1/4] dt-bindings: iio: dac: mcp4922: add vdd-supply property
  2023-04-05 14:01 ` [PATCH 1/4] dt-bindings: iio: dac: mcp4922: add vdd-supply property Nicolas Frattaroli
@ 2023-04-09 20:52   ` Michael Welling
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Welling @ 2023-04-09 20:52 UTC (permalink / raw)
  To: Nicolas Frattaroli
  Cc: Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, linux-iio, devicetree, linux-kernel

On Wed, Apr 05, 2023 at 04:01:11PM +0200, Nicolas Frattaroli wrote:
> These chips have a vdd supply input, which should be modelled in
> the bindings as well. Vref is only the voltage reference supply for
> the string DAC.
> 
> Signed-off-by: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>

Acked-by: Michael Welling <mwelling@ieee.org>

> ---
>  .../devicetree/bindings/iio/dac/microchip,mcp4922.yaml        | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/iio/dac/microchip,mcp4922.yaml b/Documentation/devicetree/bindings/iio/dac/microchip,mcp4922.yaml
> index 19374401e509..a3e80e90eeca 100644
> --- a/Documentation/devicetree/bindings/iio/dac/microchip,mcp4922.yaml
> +++ b/Documentation/devicetree/bindings/iio/dac/microchip,mcp4922.yaml
> @@ -21,11 +21,14 @@ properties:
>    reg:
>      maxItems: 1
>  
> +  vdd-supply: true
> +
>    vref-supply: true
>  
>  required:
>    - compatible
>    - reg
> +  - vdd-supply
>    - vref-supply
>  
>  allOf:
> @@ -42,6 +45,7 @@ examples:
>          dac@0 {
>              compatible = "microchip,mcp4912";
>              reg = <0>;
> +            vdd-supply = <&dac_reg>;
>              vref-supply = <&dac_vref>;
>          };
>      };
> -- 
> 2.40.0
> 

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

end of thread, other threads:[~2023-04-09 20:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-05 14:01 [PATCH 0/4] Add MCP48XX bindings and driver support Nicolas Frattaroli
2023-04-05 14:01 ` [PATCH 1/4] dt-bindings: iio: dac: mcp4922: add vdd-supply property Nicolas Frattaroli
2023-04-09 20:52   ` Michael Welling
2023-04-05 14:01 ` [PATCH 3/4] dt-bindings: iio: dac: add mcp4822 Nicolas Frattaroli
2023-04-05 14:10   ` Krzysztof Kozlowski
2023-04-05 14:17     ` Nicolas Frattaroli
2023-04-06 18:58       ` Krzysztof Kozlowski

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