diff mbox series

[01/13] dt-bindings: iio: adc: microchip,mcp3201 yaml conversion.

Message ID 20200809111753.156236-2-jic23@kernel.org
State New
Headers show
Series dt-bindings: yaml conversions of some simple ADC bindings. | expand

Commit Message

Jonathan Cameron Aug. 9, 2020, 11:17 a.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Drops the deprecated compatibles without the vendor name.
Whilst the driver continues to support these for old dt blobs,
any dt bindings that are actuallly verified against this document should
be fixed to add the vendor name.

Enforces rule that spi-cpol == spi-cpha.  Is there a cleaner way to
do this?

Added the #io-channel-cells property to allow for consumers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Oskar Andero <oskar.andero@gmail.com>
---
 .../devicetree/bindings/iio/adc/mcp320x.txt   | 57 ------------
 .../bindings/iio/adc/microchip,mcp3201.yaml   | 93 +++++++++++++++++++
 2 files changed, 93 insertions(+), 57 deletions(-)

Comments

Rob Herring Aug. 18, 2020, 2:24 a.m. UTC | #1
On Sun, Aug 09, 2020 at 12:17:41PM +0100, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Drops the deprecated compatibles without the vendor name.
> Whilst the driver continues to support these for old dt blobs,
> any dt bindings that are actuallly verified against this document should
> be fixed to add the vendor name.
> 
> Enforces rule that spi-cpol == spi-cpha.  Is there a cleaner way to
> do this?

dependencies:
  spi-cpol: [ spi-cpha ]
  spi-cpha: [ spi-cpol ]

With that,

Reviewed-by: Rob Herring <robh@kernel.org>

> 
> Added the #io-channel-cells property to allow for consumers.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Oskar Andero <oskar.andero@gmail.com>
> ---
>  .../devicetree/bindings/iio/adc/mcp320x.txt   | 57 ------------
>  .../bindings/iio/adc/microchip,mcp3201.yaml   | 93 +++++++++++++++++++
>  2 files changed, 93 insertions(+), 57 deletions(-)
Jonathan Cameron Aug. 30, 2020, 1:25 p.m. UTC | #2
On Mon, 17 Aug 2020 20:24:51 -0600
Rob Herring <robh@kernel.org> wrote:

> On Sun, Aug 09, 2020 at 12:17:41PM +0100, Jonathan Cameron wrote:
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > Drops the deprecated compatibles without the vendor name.
> > Whilst the driver continues to support these for old dt blobs,
> > any dt bindings that are actuallly verified against this document should
> > be fixed to add the vendor name.
> > 
> > Enforces rule that spi-cpol == spi-cpha.  Is there a cleaner way to
> > do this?  
> 
> dependencies:
>   spi-cpol: [ spi-cpha ]
>   spi-cpha: [ spi-cpol ]

Great!

> 
> With that,
> 
> Reviewed-by: Rob Herring <robh@kernel.org>

Applied,

Thanks,

Jonathan

> 
> > 
> > Added the #io-channel-cells property to allow for consumers.
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Oskar Andero <oskar.andero@gmail.com>
> > ---
> >  .../devicetree/bindings/iio/adc/mcp320x.txt   | 57 ------------
> >  .../bindings/iio/adc/microchip,mcp3201.yaml   | 93 +++++++++++++++++++
> >  2 files changed, 93 insertions(+), 57 deletions(-)
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/iio/adc/mcp320x.txt b/Documentation/devicetree/bindings/iio/adc/mcp320x.txt
deleted file mode 100644
index 56373d643f76..000000000000
--- a/Documentation/devicetree/bindings/iio/adc/mcp320x.txt
+++ /dev/null
@@ -1,57 +0,0 @@ 
-* Microchip Analog to Digital Converter (ADC)
-
-The node for this driver must be a child node of a SPI controller, hence
-all mandatory properties described in
-
-        Documentation/devicetree/bindings/spi/spi-bus.txt
-
-must be specified.
-
-Required properties:
-	- compatible:  	Must be one of the following, depending on the
-			model:
-				"mcp3001" (DEPRECATED)
-				"mcp3002" (DEPRECATED)
-				"mcp3004" (DEPRECATED)
-				"mcp3008" (DEPRECATED)
-				"mcp3201" (DEPRECATED)
-				"mcp3202" (DEPRECATED)
-				"mcp3204" (DEPRECATED)
-				"mcp3208" (DEPRECATED)
-				"mcp3301" (DEPRECATED)
-
-				"microchip,mcp3001"
-				"microchip,mcp3002"
-				"microchip,mcp3004"
-				"microchip,mcp3008"
-				"microchip,mcp3201"
-				"microchip,mcp3202"
-				"microchip,mcp3204"
-				"microchip,mcp3208"
-				"microchip,mcp3301"
-				"microchip,mcp3550-50"
-				"microchip,mcp3550-60"
-				"microchip,mcp3551"
-				"microchip,mcp3553"
-
-			NOTE: The use of the compatibles with no vendor prefix
-			is deprecated and only listed because old DT use them.
-
-	- spi-cpha, spi-cpol (boolean):
-			Either SPI mode (0,0) or (1,1) must be used, so specify
-			none or both of spi-cpha, spi-cpol.  The MCP3550/1/3
-			is more efficient in mode (1,1) as only 3 instead of
-			4 bytes need to be read from the ADC, but not all SPI
-			masters support it.
-
-	- vref-supply:	Phandle to the external reference voltage supply.
-
-Examples:
-spi_controller {
-	mcp3x0x@0 {
-		compatible = "microchip,mcp3002";
-		reg = <0>;
-		spi-max-frequency = <1000000>;
-		vref-supply = <&vref_reg>;
-	};
-};
diff --git a/Documentation/devicetree/bindings/iio/adc/microchip,mcp3201.yaml b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3201.yaml
new file mode 100644
index 000000000000..38dfb856da62
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/microchip,mcp3201.yaml
@@ -0,0 +1,93 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/microchip,mcp3201.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microchip mcp3201 and similar ADCs
+
+maintainers:
+  - Oskar Andero <oskar.andero@gmail.com>
+
+description: |
+   Family of simple ADCs with an I2C inteface.
+
+properties:
+  compatible:
+    enum:
+      - microchip,mcp3001
+      - microchip,mcp3002
+      - microchip,mcp3004
+      - microchip,mcp3008
+      - microchip,mcp3201
+      - microchip,mcp3202
+      - microchip,mcp3204
+      - microchip,mcp3208
+      - microchip,mcp3301
+      - microchip,mcp3550-50
+      - microchip,mcp3550-60
+      - microchip,mcp3551
+      - microchip,mcp3553
+
+  reg:
+    maxItems: 1
+
+  spi-max-frequency: true
+  spi-cpha: true
+  spi-cpol: true
+
+  vref-supply:
+    description: External reference.
+
+  "#io-channel-cells":
+    const: 1
+
+allOf:
+  - if:
+      required:
+        - spi-cpha
+    then:
+      required:
+        - spi-cpol
+    else:
+      properties:
+        spi-cpol: false
+  - if:
+      required:
+        - spi-cpol
+    then:
+      required:
+        - spi-cpha
+    else:
+      properties:
+        spi-cpha: false
+
+required:
+  - compatible
+  - reg
+  - vref-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        adc@0 {
+            compatible = "microchip,mcp3002";
+            reg = <0>;
+            vref-supply = <&vref_reg>;
+            spi-cpha;
+            spi-cpol;
+            #io-channel-cells = <1>;
+        };
+        adc@1 {
+            compatible = "microchip,mcp3002";
+            reg = <1>;
+            vref-supply = <&vref_reg>;
+            spi-max-frequency = <1500000>;
+        };
+    };
+...