All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: sound: Convert Allwinner SPDIF binding to YAML
@ 2019-04-15 12:07 ` Maxime Ripard
  0 siblings, 0 replies; 16+ messages in thread
From: Maxime Ripard @ 2019-04-15 12:07 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Mark Rutland, devicetree, alsa-devel, Maxime Ripard,
	Chen-Yu Tsai, Rob Herring, Frank Rowand, linux-arm-kernel

The Allwinner SoCs feature an SPDIF controller across multiple SoC
generations.

However, earlier generations were a bit simpler than the subsequent ones,
and for example would always have RX and TX capabilities, and no reset
lines.

In order to express this, let's create two YAML schemas instead of the free
form text we had before.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt          | 42 +-----------------------------------
 3 files changed, 159 insertions(+), 42 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
 delete mode 100644 Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt

diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml
new file mode 100644
index 000000000000..f2e97f250519
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/allwinner,sun4i-a10-spdif.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner A10 S/PDIF Controller Device Tree Bindings
+
+maintainers:
+  - Chen-Yu Tsai <wens@csie.org>
+  - Liam Girdwood <lgirdwood@gmail.com>
+  - Mark Brown <broonie@kernel.org>
+  - Maxime Ripard <maxime.ripard@bootlin.com>
+
+properties:
+  "#sound-dai-cells":
+    const: 0
+
+  compatible:
+    const: allwinner,sun4i-a10-spdif
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Bus Clock
+      - description: Module Clock
+
+  clock-names:
+    items:
+      - const: apb
+      - const: spdif
+
+  dmas:
+    items:
+      - description: RX DMA Channel
+      - description: TX DMA Channel
+
+  dma-names:
+    items:
+      - const: rx
+      - const: tx
+
+required:
+  - "#sound-dai-cells"
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - dmas
+  - dma-names
+
+additionalProperties: false
+
+examples:
+  - |
+    spdif: spdif@1c21000 {
+        #sound-dai-cells = <0>;
+        compatible = "allwinner,sun4i-a10-spdif";
+        reg = <0x01c21000 0x40>;
+        interrupts = <13>;
+        clocks = <&apb0_gates 1>, <&spdif_clk>;
+        clock-names = "apb", "spdif";
+        dmas = <&dma 0 2>, <&dma 0 2>;
+        dma-names = "rx", "tx";
+    };
+
+...
diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
new file mode 100644
index 000000000000..7329d9fcf34c
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
@@ -0,0 +1,86 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/allwinner,sun6i-a31-spdif.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner A31 S/PDIF Controller Device Tree Bindings
+
+maintainers:
+  - Chen-Yu Tsai <wens@csie.org>
+  - Liam Girdwood <lgirdwood@gmail.com>
+  - Mark Brown <broonie@kernel.org>
+  - Maxime Ripard <maxime.ripard@bootlin.com>
+
+properties:
+  "#sound-dai-cells":
+    const: 0
+
+  compatible:
+    oneOf:
+      - const: allwinner,sun6i-a31-spdif
+      - const: allwinner,sun8i-h3-spdif
+      - items:
+          - const: allwinner,sun8i-a83t-spdif
+          - const: allwinner,sun8i-h3-spdif
+      - items:
+          - const: allwinner,sun50i-a64-spdif
+          - const: allwinner,sun8i-h3-spdif
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Bus Clock
+      - description: Module Clock
+
+  clock-names:
+    items:
+      - const: apb
+      - const: spdif
+
+  dmas:
+    items:
+      - description: RX DMA Channel
+      - description: TX DMA Channel
+
+  dma-names:
+    items:
+      - const: rx
+      - const: tx
+
+  resets:
+    maxItems: 1
+
+required:
+  - "#sound-dai-cells"
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - dmas
+  - dma-names
+  - resets
+
+additionalProperties: false
+
+examples:
+  - |
+    spdif: spdif@1c21000 {
+        #sound-dai-cells = <0>;
+        compatible = "allwinner,sun6i-a31-spdif";
+        reg = <0x01c21000 0x400>;
+        interrupts = <0 12 4>;
+        clocks = <&ccu 62>, <&ccu 99>;
+        clock-names = "apb", "spdif";
+        resets = <&ccu 43>;
+        dmas = <&dma 2>, <&dma 2>;
+        dma-names = "rx", "tx";
+    };
+
+...
diff --git a/Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt b/Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt
deleted file mode 100644
index 0c64a209c2e9..000000000000
--- a/Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-Allwinner Sony/Philips Digital Interface Format (S/PDIF) Controller
-
-The Allwinner S/PDIF audio block is a transceiver that allows the
-processor to receive and transmit digital audio via an coaxial cable or
-a fibre cable.
-For now only playback is supported.
-
-Required properties:
-
-  - compatible		: should be one of the following:
-    - "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC
-    - "allwinner,sun6i-a31-spdif": for the Allwinner A31 SoC
-    - "allwinner,sun8i-h3-spdif": for the Allwinner H3 SoC
-
-  - reg			: Offset and length of the register set for the device.
-
-  - interrupts		: Contains the spdif interrupt.
-
-  - dmas		: Generic dma devicetree binding as described in
-			  Documentation/devicetree/bindings/dma/dma.txt.
-
-  - dma-names		: Two dmas have to be defined, "tx" and "rx".
-
-  - clocks		: Contains an entry for each entry in clock-names.
-
-  - clock-names		: Includes the following entries:
-	"apb"		  clock for the spdif bus.
-	"spdif"		  clock for spdif controller.
-
-  - resets		: reset specifier for the ahb reset (A31 and newer only)
-
-Example:
-
-spdif: spdif@1c21000 {
-	compatible = "allwinner,sun4i-a10-spdif";
-	reg = <0x01c21000 0x40>;
-	interrupts = <13>;
-	clocks = <&apb0_gates 1>, <&spdif_clk>;
-	clock-names = "apb", "spdif";
-	dmas = <&dma 0 2>, <&dma 0 2>;
-	dma-names = "rx", "tx";
-};

base-commit: f9221a7a1014d8a047b277a73289678646ddc110
-- 
git-series 0.9.1

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

* [PATCH 1/2] dt-bindings: sound: Convert Allwinner SPDIF binding to YAML
@ 2019-04-15 12:07 ` Maxime Ripard
  0 siblings, 0 replies; 16+ messages in thread
From: Maxime Ripard @ 2019-04-15 12:07 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Mark Rutland, devicetree, alsa-devel, Maxime Ripard,
	Chen-Yu Tsai, Rob Herring, Frank Rowand, linux-arm-kernel

The Allwinner SoCs feature an SPDIF controller across multiple SoC
generations.

However, earlier generations were a bit simpler than the subsequent ones,
and for example would always have RX and TX capabilities, and no reset
lines.

In order to express this, let's create two YAML schemas instead of the free
form text we had before.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt          | 42 +-----------------------------------
 3 files changed, 159 insertions(+), 42 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
 delete mode 100644 Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt

diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml
new file mode 100644
index 000000000000..f2e97f250519
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-spdif.yaml
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/allwinner,sun4i-a10-spdif.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner A10 S/PDIF Controller Device Tree Bindings
+
+maintainers:
+  - Chen-Yu Tsai <wens@csie.org>
+  - Liam Girdwood <lgirdwood@gmail.com>
+  - Mark Brown <broonie@kernel.org>
+  - Maxime Ripard <maxime.ripard@bootlin.com>
+
+properties:
+  "#sound-dai-cells":
+    const: 0
+
+  compatible:
+    const: allwinner,sun4i-a10-spdif
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Bus Clock
+      - description: Module Clock
+
+  clock-names:
+    items:
+      - const: apb
+      - const: spdif
+
+  dmas:
+    items:
+      - description: RX DMA Channel
+      - description: TX DMA Channel
+
+  dma-names:
+    items:
+      - const: rx
+      - const: tx
+
+required:
+  - "#sound-dai-cells"
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - dmas
+  - dma-names
+
+additionalProperties: false
+
+examples:
+  - |
+    spdif: spdif@1c21000 {
+        #sound-dai-cells = <0>;
+        compatible = "allwinner,sun4i-a10-spdif";
+        reg = <0x01c21000 0x40>;
+        interrupts = <13>;
+        clocks = <&apb0_gates 1>, <&spdif_clk>;
+        clock-names = "apb", "spdif";
+        dmas = <&dma 0 2>, <&dma 0 2>;
+        dma-names = "rx", "tx";
+    };
+
+...
diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
new file mode 100644
index 000000000000..7329d9fcf34c
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
@@ -0,0 +1,86 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/allwinner,sun6i-a31-spdif.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Allwinner A31 S/PDIF Controller Device Tree Bindings
+
+maintainers:
+  - Chen-Yu Tsai <wens@csie.org>
+  - Liam Girdwood <lgirdwood@gmail.com>
+  - Mark Brown <broonie@kernel.org>
+  - Maxime Ripard <maxime.ripard@bootlin.com>
+
+properties:
+  "#sound-dai-cells":
+    const: 0
+
+  compatible:
+    oneOf:
+      - const: allwinner,sun6i-a31-spdif
+      - const: allwinner,sun8i-h3-spdif
+      - items:
+          - const: allwinner,sun8i-a83t-spdif
+          - const: allwinner,sun8i-h3-spdif
+      - items:
+          - const: allwinner,sun50i-a64-spdif
+          - const: allwinner,sun8i-h3-spdif
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Bus Clock
+      - description: Module Clock
+
+  clock-names:
+    items:
+      - const: apb
+      - const: spdif
+
+  dmas:
+    items:
+      - description: RX DMA Channel
+      - description: TX DMA Channel
+
+  dma-names:
+    items:
+      - const: rx
+      - const: tx
+
+  resets:
+    maxItems: 1
+
+required:
+  - "#sound-dai-cells"
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - dmas
+  - dma-names
+  - resets
+
+additionalProperties: false
+
+examples:
+  - |
+    spdif: spdif@1c21000 {
+        #sound-dai-cells = <0>;
+        compatible = "allwinner,sun6i-a31-spdif";
+        reg = <0x01c21000 0x400>;
+        interrupts = <0 12 4>;
+        clocks = <&ccu 62>, <&ccu 99>;
+        clock-names = "apb", "spdif";
+        resets = <&ccu 43>;
+        dmas = <&dma 2>, <&dma 2>;
+        dma-names = "rx", "tx";
+    };
+
+...
diff --git a/Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt b/Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt
deleted file mode 100644
index 0c64a209c2e9..000000000000
--- a/Documentation/devicetree/bindings/sound/sunxi,sun4i-spdif.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-Allwinner Sony/Philips Digital Interface Format (S/PDIF) Controller
-
-The Allwinner S/PDIF audio block is a transceiver that allows the
-processor to receive and transmit digital audio via an coaxial cable or
-a fibre cable.
-For now only playback is supported.
-
-Required properties:
-
-  - compatible		: should be one of the following:
-    - "allwinner,sun4i-a10-spdif": for the Allwinner A10 SoC
-    - "allwinner,sun6i-a31-spdif": for the Allwinner A31 SoC
-    - "allwinner,sun8i-h3-spdif": for the Allwinner H3 SoC
-
-  - reg			: Offset and length of the register set for the device.
-
-  - interrupts		: Contains the spdif interrupt.
-
-  - dmas		: Generic dma devicetree binding as described in
-			  Documentation/devicetree/bindings/dma/dma.txt.
-
-  - dma-names		: Two dmas have to be defined, "tx" and "rx".
-
-  - clocks		: Contains an entry for each entry in clock-names.
-
-  - clock-names		: Includes the following entries:
-	"apb"		  clock for the spdif bus.
-	"spdif"		  clock for spdif controller.
-
-  - resets		: reset specifier for the ahb reset (A31 and newer only)
-
-Example:
-
-spdif: spdif@1c21000 {
-	compatible = "allwinner,sun4i-a10-spdif";
-	reg = <0x01c21000 0x40>;
-	interrupts = <13>;
-	clocks = <&apb0_gates 1>, <&spdif_clk>;
-	clock-names = "apb", "spdif";
-	dmas = <&dma 0 2>, <&dma 0 2>;
-	dma-names = "rx", "tx";
-};

base-commit: f9221a7a1014d8a047b277a73289678646ddc110
-- 
git-series 0.9.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/2] dt-bindings: sound: sun6i-spdif: Document that the RX channel can be missing
  2019-04-15 12:07 ` Maxime Ripard
@ 2019-04-15 12:07   ` Maxime Ripard
  -1 siblings, 0 replies; 16+ messages in thread
From: Maxime Ripard @ 2019-04-15 12:07 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Mark Rutland, devicetree, alsa-devel, Maxime Ripard,
	Chen-Yu Tsai, Rob Herring, Frank Rowand, linux-arm-kernel

Not all controllers using the A31 SPDIF binding actually have some RX
capabilities, and therefore on some controllers we don't have the option to
set an RX DMA channel.

This was already done in the DTSI, but the binding itself was never
updated.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
index 7329d9fcf34c..800f794fafe0 100644
--- a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
+++ b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
@@ -44,14 +44,24 @@ properties:
       - const: spdif
 
   dmas:
+    minItems: 1
+    maxItems: 2
     items:
       - description: RX DMA Channel
       - description: TX DMA Channel
+    description:
+      Some controllers cannot receive but can only transmit data. In
+      such a case, the RX DMA channel is to be omitted.
 
   dma-names:
-    items:
-      - const: rx
-      - const: tx
+    minItems: 1
+    maxItems: 2
+    enum:
+      - rx
+      - tx
+    description:
+      Some controllers cannot receive but can only transmit data. In
+      such a case, the RX name is to be omitted.
 
   resets:
     maxItems: 1
-- 
git-series 0.9.1

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

* [PATCH 2/2] dt-bindings: sound: sun6i-spdif: Document that the RX channel can be missing
@ 2019-04-15 12:07   ` Maxime Ripard
  0 siblings, 0 replies; 16+ messages in thread
From: Maxime Ripard @ 2019-04-15 12:07 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood
  Cc: Mark Rutland, devicetree, alsa-devel, Maxime Ripard,
	Chen-Yu Tsai, Rob Herring, Frank Rowand, linux-arm-kernel

Not all controllers using the A31 SPDIF binding actually have some RX
capabilities, and therefore on some controllers we don't have the option to
set an RX DMA channel.

This was already done in the DTSI, but the binding itself was never
updated.

Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
index 7329d9fcf34c..800f794fafe0 100644
--- a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
+++ b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
@@ -44,14 +44,24 @@ properties:
       - const: spdif
 
   dmas:
+    minItems: 1
+    maxItems: 2
     items:
       - description: RX DMA Channel
       - description: TX DMA Channel
+    description:
+      Some controllers cannot receive but can only transmit data. In
+      such a case, the RX DMA channel is to be omitted.
 
   dma-names:
-    items:
-      - const: rx
-      - const: tx
+    minItems: 1
+    maxItems: 2
+    enum:
+      - rx
+      - tx
+    description:
+      Some controllers cannot receive but can only transmit data. In
+      such a case, the RX name is to be omitted.
 
   resets:
     maxItems: 1
-- 
git-series 0.9.1

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] dt-bindings: sound: sun6i-spdif: Document that the RX channel can be missing
  2019-04-15 12:07   ` Maxime Ripard
@ 2019-04-16  1:36     ` Rob Herring
  -1 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2019-04-16  1:36 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood, Rob Herring,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
>
> Not all controllers using the A31 SPDIF binding actually have some RX
> capabilities, and therefore on some controllers we don't have the option to
> set an RX DMA channel.
>
> This was already done in the DTSI, but the binding itself was never
> updated.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> ---
>  Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> index 7329d9fcf34c..800f794fafe0 100644
> --- a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> +++ b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> @@ -44,14 +44,24 @@ properties:
>        - const: spdif
>
>    dmas:
> +    minItems: 1
> +    maxItems: 2
>      items:
>        - description: RX DMA Channel
>        - description: TX DMA Channel
> +    description:
> +      Some controllers cannot receive but can only transmit data. In
> +      such a case, the RX DMA channel is to be omitted.

Really, the schema is saying rx is optional, but it doesn't really
matter here as the schema for each item is just 'description'.

>    dma-names:
> -    items:
> -      - const: rx
> -      - const: tx
> +    minItems: 1
> +    maxItems: 2
> +    enum:
> +      - rx
> +      - tx
> +    description:
> +      Some controllers cannot receive but can only transmit data. In
> +      such a case, the RX name is to be omitted.

Here it matters though. This would allow just 'tx', '"tx", "tx"', or
either order.

You need something like this:

oneOf:
  -  items:
       - const: rx
       - const: tx
  - const: tx

Ideally, we'd always put the required entry first and avoid this
problem. Not always possible if the first entry gets removed in later
h/w.

Rob

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

* Re: [PATCH 2/2] dt-bindings: sound: sun6i-spdif: Document that the RX channel can be missing
@ 2019-04-16  1:36     ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2019-04-16  1:36 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood, Rob Herring,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
>
> Not all controllers using the A31 SPDIF binding actually have some RX
> capabilities, and therefore on some controllers we don't have the option to
> set an RX DMA channel.
>
> This was already done in the DTSI, but the binding itself was never
> updated.
>
> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> ---
>  Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> index 7329d9fcf34c..800f794fafe0 100644
> --- a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> +++ b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> @@ -44,14 +44,24 @@ properties:
>        - const: spdif
>
>    dmas:
> +    minItems: 1
> +    maxItems: 2
>      items:
>        - description: RX DMA Channel
>        - description: TX DMA Channel
> +    description:
> +      Some controllers cannot receive but can only transmit data. In
> +      such a case, the RX DMA channel is to be omitted.

Really, the schema is saying rx is optional, but it doesn't really
matter here as the schema for each item is just 'description'.

>    dma-names:
> -    items:
> -      - const: rx
> -      - const: tx
> +    minItems: 1
> +    maxItems: 2
> +    enum:
> +      - rx
> +      - tx
> +    description:
> +      Some controllers cannot receive but can only transmit data. In
> +      such a case, the RX name is to be omitted.

Here it matters though. This would allow just 'tx', '"tx", "tx"', or
either order.

You need something like this:

oneOf:
  -  items:
       - const: rx
       - const: tx
  - const: tx

Ideally, we'd always put the required entry first and avoid this
problem. Not always possible if the first entry gets removed in later
h/w.

Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] dt-bindings: sound: sun6i-spdif: Document that the RX channel can be missing
  2019-04-16  1:36     ` Rob Herring
  (?)
@ 2019-04-16  7:19     ` Maxime Ripard
  2019-04-16 21:50         ` Rob Herring
  -1 siblings, 1 reply; 16+ messages in thread
From: Maxime Ripard @ 2019-04-16  7:19 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE


[-- Attachment #1.1: Type: text/plain, Size: 3188 bytes --]

Hi Rob,

On Mon, Apr 15, 2019 at 08:36:28PM -0500, Rob Herring wrote:
> On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> >
> > Not all controllers using the A31 SPDIF binding actually have some RX
> > capabilities, and therefore on some controllers we don't have the option to
> > set an RX DMA channel.
> >
> > This was already done in the DTSI, but the binding itself was never
> > updated.
> >
> > Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> > ---
> >  Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml | 16 +++++++++++++---
> >  1 file changed, 13 insertions(+), 3 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > index 7329d9fcf34c..800f794fafe0 100644
> > --- a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > +++ b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > @@ -44,14 +44,24 @@ properties:
> >        - const: spdif
> >
> >    dmas:
> > +    minItems: 1
> > +    maxItems: 2
> >      items:
> >        - description: RX DMA Channel
> >        - description: TX DMA Channel
> > +    description:
> > +      Some controllers cannot receive but can only transmit data. In
> > +      such a case, the RX DMA channel is to be omitted.
>
> Really, the schema is saying rx is optional, but it doesn't really
> matter here as the schema for each item is just 'description'.

What should I do here then?

Remove the global description and leave only the one under items?

Also, it won't necessarily match the dma-names (since rx might be
there or not), does it matter or is it obvious enough that we don't
care?

> >    dma-names:
> > -    items:
> > -      - const: rx
> > -      - const: tx
> > +    minItems: 1
> > +    maxItems: 2
> > +    enum:
> > +      - rx
> > +      - tx
> > +    description:
> > +      Some controllers cannot receive but can only transmit data. In
> > +      such a case, the RX name is to be omitted.
>
> Here it matters though. This would allow just 'tx', '"tx", "tx"', or
> either order.
>
> You need something like this:
>
> oneOf:
>   -  items:
>        - const: rx
>        - const: tx
>   - const: tx

Ok.

> Ideally, we'd always put the required entry first and avoid this
> problem. Not always possible if the first entry gets removed in later
> h/w.

One of the question I was wondering myself when I wrote those schemas
is how are we supposed to deal with lists that need to have a
particular set of values, but without any particular order?

rx and tx here is a good example of that. We need both (let's leave
the "missing RX" case aside for a minute), but since we reference them
by name, '"rx", "tx"' is strictly equivalent to '"tx", "rx"'. Yet,
items cares about the order, so the latter would fail to validate with
that schemas.

Should we do something like:

oneOf:
  - items:
    - const: rx
    - const: tx
  - items:
    - const: tx
    - const: rx

or is there a smarter way?

Thanks!
Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] dt-bindings: sound: Convert Allwinner SPDIF binding to YAML
  2019-04-15 12:07 ` Maxime Ripard
@ 2019-04-16 21:36   ` Rob Herring
  -1 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2019-04-16 21:36 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood, Rob Herring,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
>
> The Allwinner SoCs feature an SPDIF controller across multiple SoC
> generations.
>
> However, earlier generations were a bit simpler than the subsequent ones,
> and for example would always have RX and TX capabilities, and no reset
> lines.
>
> In order to express this, let's create two YAML schemas instead of the free
> form text we had before.

The only difference is 'reset' is required in one? Perhaps better to
just not make 'reset' required til we figure out how to handle a
conditional like this. Seems like we discussed this and I probably
said to split things? I guess it's a judgement call depending on how
different things are.

Possibly, we could handle this case like this:

allOf:
  - $ref: allwinner,sun4i-a10-spdif.yaml

properties:
  resets:
    maxItems: 1

required:
  - resets


Plus we'd need the 'allwinner,sun6i-a31-spdif' and other compatibles
in both files. Note that you can't use 'additionalProperties: false'
in either file in this case.

I don't really love this solution though.

Rob

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

* Re: [PATCH 1/2] dt-bindings: sound: Convert Allwinner SPDIF binding to YAML
@ 2019-04-16 21:36   ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2019-04-16 21:36 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood, Rob Herring,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
>
> The Allwinner SoCs feature an SPDIF controller across multiple SoC
> generations.
>
> However, earlier generations were a bit simpler than the subsequent ones,
> and for example would always have RX and TX capabilities, and no reset
> lines.
>
> In order to express this, let's create two YAML schemas instead of the free
> form text we had before.

The only difference is 'reset' is required in one? Perhaps better to
just not make 'reset' required til we figure out how to handle a
conditional like this. Seems like we discussed this and I probably
said to split things? I guess it's a judgement call depending on how
different things are.

Possibly, we could handle this case like this:

allOf:
  - $ref: allwinner,sun4i-a10-spdif.yaml

properties:
  resets:
    maxItems: 1

required:
  - resets


Plus we'd need the 'allwinner,sun6i-a31-spdif' and other compatibles
in both files. Note that you can't use 'additionalProperties: false'
in either file in this case.

I don't really love this solution though.

Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] dt-bindings: sound: sun6i-spdif: Document that the RX channel can be missing
  2019-04-16  7:19     ` Maxime Ripard
@ 2019-04-16 21:50         ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2019-04-16 21:50 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Tue, Apr 16, 2019 at 2:19 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
>
> Hi Rob,
>
> On Mon, Apr 15, 2019 at 08:36:28PM -0500, Rob Herring wrote:
> > On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> > >
> > > Not all controllers using the A31 SPDIF binding actually have some RX
> > > capabilities, and therefore on some controllers we don't have the option to
> > > set an RX DMA channel.
> > >
> > > This was already done in the DTSI, but the binding itself was never
> > > updated.
> > >
> > > Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> > > ---
> > >  Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml | 16 +++++++++++++---
> > >  1 file changed, 13 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > > index 7329d9fcf34c..800f794fafe0 100644
> > > --- a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > > +++ b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > > @@ -44,14 +44,24 @@ properties:
> > >        - const: spdif
> > >
> > >    dmas:
> > > +    minItems: 1
> > > +    maxItems: 2
> > >      items:
> > >        - description: RX DMA Channel
> > >        - description: TX DMA Channel
> > > +    description:
> > > +      Some controllers cannot receive but can only transmit data. In
> > > +      such a case, the RX DMA channel is to be omitted.
> >
> > Really, the schema is saying rx is optional, but it doesn't really
> > matter here as the schema for each item is just 'description'.
>
> What should I do here then?
>
> Remove the global description and leave only the one under items?

I think the opposite. Just drop 'items' and leave 'description'.

> Also, it won't necessarily match the dma-names (since rx might be
> there or not), does it matter or is it obvious enough that we don't
> care?
>
> > >    dma-names:
> > > -    items:
> > > -      - const: rx
> > > -      - const: tx
> > > +    minItems: 1
> > > +    maxItems: 2
> > > +    enum:
> > > +      - rx
> > > +      - tx
> > > +    description:
> > > +      Some controllers cannot receive but can only transmit data. In
> > > +      such a case, the RX name is to be omitted.
> >
> > Here it matters though. This would allow just 'tx', '"tx", "tx"', or
> > either order.
> >
> > You need something like this:
> >
> > oneOf:
> >   -  items:
> >        - const: rx
> >        - const: tx
> >   - const: tx
>
> Ok.
>
> > Ideally, we'd always put the required entry first and avoid this
> > problem. Not always possible if the first entry gets removed in later
> > h/w.
>
> One of the question I was wondering myself when I wrote those schemas
> is how are we supposed to deal with lists that need to have a
> particular set of values, but without any particular order?

'items' can be a list or dictionary. When it's a dictionary, the
schema for 'items' is applied to each item. For example:

items:
  enum: [ rx, tx ]
  uniqueItems: true

'uniqueItems' prevents the case of 'rx, rx' or 'tx, tx'.

> rx and tx here is a good example of that. We need both (let's leave
> the "missing RX" case aside for a minute), but since we reference them
> by name, '"rx", "tx"' is strictly equivalent to '"tx", "rx"'. Yet,
> items cares about the order, so the latter would fail to validate with
> that schemas.

Even when we reference things by name, the order should be defined
still. Using names allows for skipping entries.

If you have a mixture, I'd prefer to see dts files cleaned-up.

Rob

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

* Re: [PATCH 2/2] dt-bindings: sound: sun6i-spdif: Document that the RX channel can be missing
@ 2019-04-16 21:50         ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2019-04-16 21:50 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Tue, Apr 16, 2019 at 2:19 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
>
> Hi Rob,
>
> On Mon, Apr 15, 2019 at 08:36:28PM -0500, Rob Herring wrote:
> > On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> > >
> > > Not all controllers using the A31 SPDIF binding actually have some RX
> > > capabilities, and therefore on some controllers we don't have the option to
> > > set an RX DMA channel.
> > >
> > > This was already done in the DTSI, but the binding itself was never
> > > updated.
> > >
> > > Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> > > ---
> > >  Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml | 16 +++++++++++++---
> > >  1 file changed, 13 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > > index 7329d9fcf34c..800f794fafe0 100644
> > > --- a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > > +++ b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > > @@ -44,14 +44,24 @@ properties:
> > >        - const: spdif
> > >
> > >    dmas:
> > > +    minItems: 1
> > > +    maxItems: 2
> > >      items:
> > >        - description: RX DMA Channel
> > >        - description: TX DMA Channel
> > > +    description:
> > > +      Some controllers cannot receive but can only transmit data. In
> > > +      such a case, the RX DMA channel is to be omitted.
> >
> > Really, the schema is saying rx is optional, but it doesn't really
> > matter here as the schema for each item is just 'description'.
>
> What should I do here then?
>
> Remove the global description and leave only the one under items?

I think the opposite. Just drop 'items' and leave 'description'.

> Also, it won't necessarily match the dma-names (since rx might be
> there or not), does it matter or is it obvious enough that we don't
> care?
>
> > >    dma-names:
> > > -    items:
> > > -      - const: rx
> > > -      - const: tx
> > > +    minItems: 1
> > > +    maxItems: 2
> > > +    enum:
> > > +      - rx
> > > +      - tx
> > > +    description:
> > > +      Some controllers cannot receive but can only transmit data. In
> > > +      such a case, the RX name is to be omitted.
> >
> > Here it matters though. This would allow just 'tx', '"tx", "tx"', or
> > either order.
> >
> > You need something like this:
> >
> > oneOf:
> >   -  items:
> >        - const: rx
> >        - const: tx
> >   - const: tx
>
> Ok.
>
> > Ideally, we'd always put the required entry first and avoid this
> > problem. Not always possible if the first entry gets removed in later
> > h/w.
>
> One of the question I was wondering myself when I wrote those schemas
> is how are we supposed to deal with lists that need to have a
> particular set of values, but without any particular order?

'items' can be a list or dictionary. When it's a dictionary, the
schema for 'items' is applied to each item. For example:

items:
  enum: [ rx, tx ]
  uniqueItems: true

'uniqueItems' prevents the case of 'rx, rx' or 'tx, tx'.

> rx and tx here is a good example of that. We need both (let's leave
> the "missing RX" case aside for a minute), but since we reference them
> by name, '"rx", "tx"' is strictly equivalent to '"tx", "rx"'. Yet,
> items cares about the order, so the latter would fail to validate with
> that schemas.

Even when we reference things by name, the order should be defined
still. Using names allows for skipping entries.

If you have a mixture, I'd prefer to see dts files cleaned-up.

Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] dt-bindings: sound: Convert Allwinner SPDIF binding to YAML
  2019-04-16 21:36   ` Rob Herring
  (?)
@ 2019-04-17  6:43   ` Maxime Ripard
  2019-04-17 16:04       ` Rob Herring
  -1 siblings, 1 reply; 16+ messages in thread
From: Maxime Ripard @ 2019-04-17  6:43 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE


[-- Attachment #1.1: Type: text/plain, Size: 1863 bytes --]

Hi Rob,

On Tue, Apr 16, 2019 at 04:36:18PM -0500, Rob Herring wrote:
> On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> >
> > The Allwinner SoCs feature an SPDIF controller across multiple SoC
> > generations.
> >
> > However, earlier generations were a bit simpler than the subsequent ones,
> > and for example would always have RX and TX capabilities, and no reset
> > lines.
> >
> > In order to express this, let's create two YAML schemas instead of the free
> > form text we had before.
>
> The only difference is 'reset' is required in one? Perhaps better to
> just not make 'reset' required til we figure out how to handle a
> conditional like this. Seems like we discussed this and I probably
> said to split things?

We indeed discussed this, and this was one of the solutions to support
this. I wanted to get the discussion started as of how exactly we want
to support this kind of construct.

I looked it up a bit, and it looks like json schema 7 introduces
conditionals that would allow us to deal with this nicely.

https://json-schema.org/understanding-json-schema/reference/conditionals.html

Is that something we can switch to while we have not a lot of schemas,
or would that require some significant work?

> I guess it's a judgement call depending on how different things are.
>
> Possibly, we could handle this case like this:
>
> allOf:
>   - $ref: allwinner,sun4i-a10-spdif.yaml
>
> properties:
>   resets:
>     maxItems: 1
>
> required:
>   - resets
>
>
> Plus we'd need the 'allwinner,sun6i-a31-spdif' and other compatibles
> in both files. Note that you can't use 'additionalProperties: false'
> in either file in this case.
>
> I don't really love this solution though.

Yeah, I'm not a big fan of it either.

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] dt-bindings: sound: Convert Allwinner SPDIF binding to YAML
  2019-04-17  6:43   ` Maxime Ripard
@ 2019-04-17 16:04       ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2019-04-17 16:04 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Wed, Apr 17, 2019 at 1:43 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
>
> Hi Rob,
>
> On Tue, Apr 16, 2019 at 04:36:18PM -0500, Rob Herring wrote:
> > On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> > >
> > > The Allwinner SoCs feature an SPDIF controller across multiple SoC
> > > generations.
> > >
> > > However, earlier generations were a bit simpler than the subsequent ones,
> > > and for example would always have RX and TX capabilities, and no reset
> > > lines.
> > >
> > > In order to express this, let's create two YAML schemas instead of the free
> > > form text we had before.
> >
> > The only difference is 'reset' is required in one? Perhaps better to
> > just not make 'reset' required til we figure out how to handle a
> > conditional like this. Seems like we discussed this and I probably
> > said to split things?
>
> We indeed discussed this, and this was one of the solutions to support
> this. I wanted to get the discussion started as of how exactly we want
> to support this kind of construct.
>
> I looked it up a bit, and it looks like json schema 7 introduces
> conditionals that would allow us to deal with this nicely.
>
> https://json-schema.org/understanding-json-schema/reference/conditionals.html
>
> Is that something we can switch to while we have not a lot of schemas,
> or would that require some significant work?

We need check if the json-schema library supports this yet. I think it
should as there was an issue for it which is closed now.

We'll then need to update the meta-schema and maybe the schema fixups
to handle this case. We should have a test case in the library too.
Test cases are important given that if you get schemas wrong, the
result is silence.

Rob

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

* Re: [PATCH 1/2] dt-bindings: sound: Convert Allwinner SPDIF binding to YAML
@ 2019-04-17 16:04       ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2019-04-17 16:04 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Wed, Apr 17, 2019 at 1:43 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
>
> Hi Rob,
>
> On Tue, Apr 16, 2019 at 04:36:18PM -0500, Rob Herring wrote:
> > On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> > >
> > > The Allwinner SoCs feature an SPDIF controller across multiple SoC
> > > generations.
> > >
> > > However, earlier generations were a bit simpler than the subsequent ones,
> > > and for example would always have RX and TX capabilities, and no reset
> > > lines.
> > >
> > > In order to express this, let's create two YAML schemas instead of the free
> > > form text we had before.
> >
> > The only difference is 'reset' is required in one? Perhaps better to
> > just not make 'reset' required til we figure out how to handle a
> > conditional like this. Seems like we discussed this and I probably
> > said to split things?
>
> We indeed discussed this, and this was one of the solutions to support
> this. I wanted to get the discussion started as of how exactly we want
> to support this kind of construct.
>
> I looked it up a bit, and it looks like json schema 7 introduces
> conditionals that would allow us to deal with this nicely.
>
> https://json-schema.org/understanding-json-schema/reference/conditionals.html
>
> Is that something we can switch to while we have not a lot of schemas,
> or would that require some significant work?

We need check if the json-schema library supports this yet. I think it
should as there was an issue for it which is closed now.

We'll then need to update the meta-schema and maybe the schema fixups
to handle this case. We should have a test case in the library too.
Test cases are important given that if you get schemas wrong, the
result is silence.

Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] dt-bindings: sound: Convert Allwinner SPDIF binding to YAML
  2019-04-17 16:04       ` Rob Herring
  (?)
@ 2019-04-17 18:22       ` Maxime Ripard
  -1 siblings, 0 replies; 16+ messages in thread
From: Maxime Ripard @ 2019-04-17 18:22 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE


[-- Attachment #1.1: Type: text/plain, Size: 2527 bytes --]

Hi,

On Wed, Apr 17, 2019 at 11:04:22AM -0500, Rob Herring wrote:
> On Wed, Apr 17, 2019 at 1:43 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> > On Tue, Apr 16, 2019 at 04:36:18PM -0500, Rob Herring wrote:
> > > On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> > > >
> > > > The Allwinner SoCs feature an SPDIF controller across multiple SoC
> > > > generations.
> > > >
> > > > However, earlier generations were a bit simpler than the subsequent ones,
> > > > and for example would always have RX and TX capabilities, and no reset
> > > > lines.
> > > >
> > > > In order to express this, let's create two YAML schemas instead of the free
> > > > form text we had before.
> > >
> > > The only difference is 'reset' is required in one? Perhaps better to
> > > just not make 'reset' required til we figure out how to handle a
> > > conditional like this. Seems like we discussed this and I probably
> > > said to split things?
> >
> > We indeed discussed this, and this was one of the solutions to support
> > this. I wanted to get the discussion started as of how exactly we want
> > to support this kind of construct.
> >
> > I looked it up a bit, and it looks like json schema 7 introduces
> > conditionals that would allow us to deal with this nicely.
> >
> > https://json-schema.org/understanding-json-schema/reference/conditionals.html
> >
> > Is that something we can switch to while we have not a lot of schemas,
> > or would that require some significant work?
>
> We need check if the json-schema library supports this yet. I think it
> should as there was an issue for it which is closed now.

Apparently, it's supported since 3.0.0, that got released on the 24th
of february.

I mass converted the yaml-bindings code to use the draft 7, and the
tests are passing (and a dtbs_check run seems legit too). So that went
smoothly...

> We'll then need to update the meta-schema and maybe the schema fixups
> to handle this case.

... except that after adding if, then and else to the meta-schemas, a
schema using that construct doesn't do anything (well, anything more
than what it is doing without if / then / else).

Apart from the fact that it doesn't work as expected (yet), the syntax
is pretty elegant, so I guess we should go for that.

> We should have a test case in the library too.
> Test cases are important given that if you get schemas wrong, the
> result is silence.

ACK

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] dt-bindings: sound: sun6i-spdif: Document that the RX channel can be missing
  2019-04-16 21:50         ` Rob Herring
  (?)
@ 2019-04-17 18:24         ` Maxime Ripard
  -1 siblings, 0 replies; 16+ messages in thread
From: Maxime Ripard @ 2019-04-17 18:24 UTC (permalink / raw)
  To: Rob Herring
  Cc: Mark Rutland, devicetree, Linux-ALSA, Liam Girdwood,
	Chen-Yu Tsai, Mark Brown, Frank Rowand,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE


[-- Attachment #1.1: Type: text/plain, Size: 4211 bytes --]

On Tue, Apr 16, 2019 at 04:50:35PM -0500, Rob Herring wrote:
> On Tue, Apr 16, 2019 at 2:19 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> >
> > Hi Rob,
> >
> > On Mon, Apr 15, 2019 at 08:36:28PM -0500, Rob Herring wrote:
> > > On Mon, Apr 15, 2019 at 7:07 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote:
> > > >
> > > > Not all controllers using the A31 SPDIF binding actually have some RX
> > > > capabilities, and therefore on some controllers we don't have the option to
> > > > set an RX DMA channel.
> > > >
> > > > This was already done in the DTSI, but the binding itself was never
> > > > updated.
> > > >
> > > > Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> > > > ---
> > > >  Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml | 16 +++++++++++++---
> > > >  1 file changed, 13 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > > > index 7329d9fcf34c..800f794fafe0 100644
> > > > --- a/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > > > +++ b/Documentation/devicetree/bindings/sound/allwinner,sun6i-a31-spdif.yaml
> > > > @@ -44,14 +44,24 @@ properties:
> > > >        - const: spdif
> > > >
> > > >    dmas:
> > > > +    minItems: 1
> > > > +    maxItems: 2
> > > >      items:
> > > >        - description: RX DMA Channel
> > > >        - description: TX DMA Channel
> > > > +    description:
> > > > +      Some controllers cannot receive but can only transmit data. In
> > > > +      such a case, the RX DMA channel is to be omitted.
> > >
> > > Really, the schema is saying rx is optional, but it doesn't really
> > > matter here as the schema for each item is just 'description'.
> >
> > What should I do here then?
> >
> > Remove the global description and leave only the one under items?
>
> I think the opposite. Just drop 'items' and leave 'description'.
>
> > Also, it won't necessarily match the dma-names (since rx might be
> > there or not), does it matter or is it obvious enough that we don't
> > care?
> >
> > > >    dma-names:
> > > > -    items:
> > > > -      - const: rx
> > > > -      - const: tx
> > > > +    minItems: 1
> > > > +    maxItems: 2
> > > > +    enum:
> > > > +      - rx
> > > > +      - tx
> > > > +    description:
> > > > +      Some controllers cannot receive but can only transmit data. In
> > > > +      such a case, the RX name is to be omitted.
> > >
> > > Here it matters though. This would allow just 'tx', '"tx", "tx"', or
> > > either order.
> > >
> > > You need something like this:
> > >
> > > oneOf:
> > >   -  items:
> > >        - const: rx
> > >        - const: tx
> > >   - const: tx
> >
> > Ok.
> >
> > > Ideally, we'd always put the required entry first and avoid this
> > > problem. Not always possible if the first entry gets removed in later
> > > h/w.
> >
> > One of the question I was wondering myself when I wrote those schemas
> > is how are we supposed to deal with lists that need to have a
> > particular set of values, but without any particular order?
>
> 'items' can be a list or dictionary. When it's a dictionary, the
> schema for 'items' is applied to each item. For example:
>
> items:
>   enum: [ rx, tx ]
>   uniqueItems: true
>
> 'uniqueItems' prevents the case of 'rx, rx' or 'tx, tx'.

Oh, so that's how you use uniqueItems. I've been struggling with it to
cover the ALSA routing options that will have non-unique strings, but
string-array didn't let me. I'll test that.

> > rx and tx here is a good example of that. We need both (let's leave
> > the "missing RX" case aside for a minute), but since we reference them
> > by name, '"rx", "tx"' is strictly equivalent to '"tx", "rx"'. Yet,
> > items cares about the order, so the latter would fail to validate with
> > that schemas.
>
> Even when we reference things by name, the order should be defined
> still. Using names allows for skipping entries.
>
> If you have a mixture, I'd prefer to see dts files cleaned-up.

That works for me, thanks!
Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-04-17 18:24 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-15 12:07 [PATCH 1/2] dt-bindings: sound: Convert Allwinner SPDIF binding to YAML Maxime Ripard
2019-04-15 12:07 ` Maxime Ripard
2019-04-15 12:07 ` [PATCH 2/2] dt-bindings: sound: sun6i-spdif: Document that the RX channel can be missing Maxime Ripard
2019-04-15 12:07   ` Maxime Ripard
2019-04-16  1:36   ` Rob Herring
2019-04-16  1:36     ` Rob Herring
2019-04-16  7:19     ` Maxime Ripard
2019-04-16 21:50       ` Rob Herring
2019-04-16 21:50         ` Rob Herring
2019-04-17 18:24         ` Maxime Ripard
2019-04-16 21:36 ` [PATCH 1/2] dt-bindings: sound: Convert Allwinner SPDIF binding to YAML Rob Herring
2019-04-16 21:36   ` Rob Herring
2019-04-17  6:43   ` Maxime Ripard
2019-04-17 16:04     ` Rob Herring
2019-04-17 16:04       ` Rob Herring
2019-04-17 18:22       ` Maxime Ripard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.