Skip to contentSkip to conversation

ASoC: dt-bindings: Centralize the 'sound-dai' definition

PATCH In review Rob Herring 4 participants 6 messages Jan 26, 2022 – Jan 28, 2022

Subsystems (7)
lore
Share & tools
lore

Rob Herring

author maintainer
#0 lore raw

PATCH 1/1 ASoC: dt-bindings: Centralize the 'sound-dai' definition

'sound-dai' is a common property, but has duplicate type definitions. Create a new common definition to define the type and then update all the other occurrences to just define how many entries there are just like other phandle+arg properties.

The constraints on the number of entries is based on the examples and could be wrong.

Cc Krzysztof Kozlowski <[email protected]>

---
Please ack, this depends on commit abf0fee97313 ("dt-bindings: Improve phandle-array schemas") in my tree.

---
 .../bindings/sound/amlogic,gx-sound-card.yaml |  4 ++--
 .../bindings/sound/google,sc7180-trogdor.yaml |  6 ++++--
 .../bindings/sound/imx-audio-card.yaml        |  7 +++++--
 .../bindings/sound/qcom,sm8250.yaml           | 10 +++++++---
 .../bindings/sound/samsung,aries-wm8994.yaml  |  5 +----
 .../bindings/sound/samsung,midas-audio.yaml   |  2 --
 .../bindings/sound/samsung,odroid.yaml        |  9 +++------
 .../devicetree/bindings/sound/sound-dai.yaml  | 20 +++++++++++++++++++
 8 files changed, 42 insertions(+), 21 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/sound-dai.yaml
Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml +2 -2
index 2e35aeaa8781..8b5be4b92f35 100644
@@ -57,7 +57,7 @@ patternProperties:
           rate
 
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
+        maxItems: 1
         description: phandle of the CPU DAI
 
     patternProperties:
@@ -71,7 +71,7 @@ patternProperties:
 
         properties:
           sound-dai:
-            $ref: /schemas/types.yaml#/definitions/phandle-array
+            maxItems: 1
             description: phandle of the codec DAI
 
         required:
Documentation/devicetree/bindings/sound/google,sc7180-trogdor.yaml +4 -2
index 837e3faa63a9..233caa0ade87 100644
@@ -62,13 +62,15 @@ patternProperties:
         description: Holds subnode which indicates cpu dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            maxItems: 1
 
       codec:
         description: Holds subnode which indicates codec dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            maxItems: 1
 
     required:
       - link-name
Documentation/devicetree/bindings/sound/imx-audio-card.yaml +5 -2
index d1816dd061cf..bb3a435722c7 100644
@@ -59,13 +59,16 @@ patternProperties:
         description: Holds subnode which indicates cpu dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            maxItems: 1
 
       codec:
         description: Holds subnode which indicates codec dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            minItems: 1
+            maxItems: 2
 
       fsl,mclk-equal-bclk:
         description: Indicates mclk can be equal to bclk, especially for sai interface
Documentation/devicetree/bindings/sound/qcom,sm8250.yaml +7 -3
index 4bfda04b4608..4ecd4080bb96 100644
@@ -69,19 +69,23 @@ patternProperties:
         description: Holds subnode which indicates cpu dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            maxItems: 1
 
       platform:
         description: Holds subnode which indicates platform dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            maxItems: 1
 
       codec:
         description: Holds subnode which indicates codec dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            minItems: 1
+            maxItems: 4
 
     required:
       - link-name
Documentation/devicetree/bindings/sound/samsung,aries-wm8994.yaml +1 -4
index eb487ed3ca3b..4ffa275b3c49 100644
@@ -27,9 +27,6 @@ properties:
       sound-dai:
         minItems: 2
         maxItems: 2
-        items:
-          maxItems: 1
-        $ref: /schemas/types.yaml#/definitions/phandle-array
         description: |
           phandles to the I2S controller and bluetooth codec,
           in that order
@@ -38,7 +35,7 @@ properties:
     type: object
     properties:
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
+        maxItems: 1
         description: phandle to the WM8994 CODEC
 
   samsung,audio-routing:
Documentation/devicetree/bindings/sound/samsung,midas-audio.yaml +0 -2
index 095775c598fa..ec50bcb4af5f 100644
@@ -21,7 +21,6 @@ properties:
     type: object
     properties:
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
         maxItems: 1
         description: phandle to the I2S controller
     required:
@@ -31,7 +30,6 @@ properties:
     type: object
     properties:
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
         maxItems: 1
         description: phandle to the WM1811 CODEC
     required:
Documentation/devicetree/bindings/sound/samsung,odroid.yaml +3 -6
index e8122bc87362..db2513f3e168 100644
@@ -37,18 +37,15 @@ properties:
     type: object
     properties:
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
         description: phandles to the I2S controllers
 
   codec:
     type: object
     properties:
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
-        description: |
-          List of phandles to the CODEC nodes,
-          first entry must be corresponding to the MAX98090 CODEC and
-          the second entry must be the phandle of the HDMI IP block node.
+        items:
+          - description: phandle of the MAX98090 CODEC
+          - description: phandle of the HDMI IP block node
 
   samsung,audio-routing:
     $ref: /schemas/types.yaml#/definitions/non-unique-string-array
Documentation/devicetree/bindings/sound/sound-dai.yaml new file +20 -0
new file mode 100644
index 000000000000..61c6f7abc4e7
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/sound-dai.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Digital Audio Interface consumer Device Tree Bindings
+
+maintainers:
+  - Rob Herring <[email protected]>
+
+select: true
+
+properties:
+  sound-dai:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    description: A phandle plus args to digital audio interface provider(s)
+
+additionalProperties: true
+...
Signature · 1 line
2.32.0
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Rob Herring

'sound-dai' is a common property, but has duplicate type definitions. Create a new common definition to define the type and then update all the other occurrences to just define how many entries there are just like other phandle+arg properties.

The constraints on the number of entries is based on the examples and could be wrong.

Cc Krzysztof Kozlowski <[email protected]>

---
Please ack, this depends on commit abf0fee97313 ("dt-bindings: Improve phandle-array schemas") in my tree.

Quoted 12 lines
---
 .../bindings/sound/amlogic,gx-sound-card.yaml |  4 ++--
 .../bindings/sound/google,sc7180-trogdor.yaml |  6 ++++--
 .../bindings/sound/imx-audio-card.yaml        |  7 +++++--
 .../bindings/sound/qcom,sm8250.yaml           | 10 +++++++---
 .../bindings/sound/samsung,aries-wm8994.yaml  |  5 +----
 .../bindings/sound/samsung,midas-audio.yaml   |  2 --
 .../bindings/sound/samsung,odroid.yaml        |  9 +++------
 .../devicetree/bindings/sound/sound-dai.yaml  | 20 +++++++++++++++++++
 8 files changed, 42 insertions(+), 21 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/sound-dai.yaml

Best regards,
Krzysztof

maintainer
#2 lore raw
In reply to Rob Herring
Quoted 39 lines · Rob Herring

'sound-dai' is a common property, but has duplicate type definitions. Create a new common definition to define the type and then update all the other occurrences to just define how many entries there are just like other phandle+arg properties.

The constraints on the number of entries is based on the examples and could be wrong.

Cc Krzysztof Kozlowski <[email protected]>

---
Please ack, this depends on commit abf0fee97313 ("dt-bindings: Improve phandle-array schemas") in my tree.

---
 .../bindings/sound/amlogic,gx-sound-card.yaml |  4 ++--
 .../bindings/sound/google,sc7180-trogdor.yaml |  6 ++++--
 .../bindings/sound/imx-audio-card.yaml        |  7 +++++--
 .../bindings/sound/qcom,sm8250.yaml           | 10 +++++++---
 .../bindings/sound/samsung,aries-wm8994.yaml  |  5 +----
 .../bindings/sound/samsung,midas-audio.yaml   |  2 --
 .../bindings/sound/samsung,odroid.yaml        |  9 +++------
 .../devicetree/bindings/sound/sound-dai.yaml  | 20 +++++++++++++++++++
 8 files changed, 42 insertions(+), 21 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/sound-dai.yaml
Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml +1 -1
index 2e35aeaa8781..8b5be4b92f35 100644
@@ -57,7 +57,7 @@ patternProperties:
           rate
 
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
+        maxItems: 1
         description: phandle of the CPU DAI
 
     patternProperties:

Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml patternProperties: · line 74

Quoted 5 lines
Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml +1 -1
@@ -71,7 +71,7 @@ patternProperties:
 
         properties:
           sound-dai:
-            $ref: /schemas/types.yaml#/definitions/phandle-array
+            maxItems: 1

No min or max here. Links may have more than one codec.

Ex:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts#n158

Quoted 174 lines
Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml +0 -0
             description: phandle of the codec DAI
 
         required:
Documentation/devicetree/bindings/sound/google,sc7180-trogdor.yaml +4 -2
index 837e3faa63a9..233caa0ade87 100644
@@ -62,13 +62,15 @@ patternProperties:
         description: Holds subnode which indicates cpu dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            maxItems: 1
 
       codec:
         description: Holds subnode which indicates codec dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            maxItems: 1
 
     required:
       - link-name
Documentation/devicetree/bindings/sound/imx-audio-card.yaml +5 -2
index d1816dd061cf..bb3a435722c7 100644
@@ -59,13 +59,16 @@ patternProperties:
         description: Holds subnode which indicates cpu dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            maxItems: 1
 
       codec:
         description: Holds subnode which indicates codec dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            minItems: 1
+            maxItems: 2
 
       fsl,mclk-equal-bclk:
         description: Indicates mclk can be equal to bclk, especially for sai interface
Documentation/devicetree/bindings/sound/qcom,sm8250.yaml +7 -3
index 4bfda04b4608..4ecd4080bb96 100644
@@ -69,19 +69,23 @@ patternProperties:
         description: Holds subnode which indicates cpu dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            maxItems: 1
 
       platform:
         description: Holds subnode which indicates platform dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            maxItems: 1
 
       codec:
         description: Holds subnode which indicates codec dai.
         type: object
         properties:
-          sound-dai: true
+          sound-dai:
+            minItems: 1
+            maxItems: 4
 
     required:
       - link-name
Documentation/devicetree/bindings/sound/samsung,aries-wm8994.yaml +1 -4
index eb487ed3ca3b..4ffa275b3c49 100644
@@ -27,9 +27,6 @@ properties:
       sound-dai:
         minItems: 2
         maxItems: 2
-        items:
-          maxItems: 1
-        $ref: /schemas/types.yaml#/definitions/phandle-array
         description: |
           phandles to the I2S controller and bluetooth codec,
           in that order
@@ -38,7 +35,7 @@ properties:
     type: object
     properties:
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
+        maxItems: 1
         description: phandle to the WM8994 CODEC
 
   samsung,audio-routing:
Documentation/devicetree/bindings/sound/samsung,midas-audio.yaml +0 -2
index 095775c598fa..ec50bcb4af5f 100644
@@ -21,7 +21,6 @@ properties:
     type: object
     properties:
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
         maxItems: 1
         description: phandle to the I2S controller
     required:
@@ -31,7 +30,6 @@ properties:
     type: object
     properties:
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
         maxItems: 1
         description: phandle to the WM1811 CODEC
     required:
Documentation/devicetree/bindings/sound/samsung,odroid.yaml +3 -6
index e8122bc87362..db2513f3e168 100644
@@ -37,18 +37,15 @@ properties:
     type: object
     properties:
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
         description: phandles to the I2S controllers
 
   codec:
     type: object
     properties:
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
-        description: |
-          List of phandles to the CODEC nodes,
-          first entry must be corresponding to the MAX98090 CODEC and
-          the second entry must be the phandle of the HDMI IP block node.
+        items:
+          - description: phandle of the MAX98090 CODEC
+          - description: phandle of the HDMI IP block node
 
   samsung,audio-routing:
     $ref: /schemas/types.yaml#/definitions/non-unique-string-array
Documentation/devicetree/bindings/sound/sound-dai.yaml new file +20 -0
new file mode 100644
index 000000000000..61c6f7abc4e7
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/sound-dai.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Digital Audio Interface consumer Device Tree Bindings
+
+maintainers:
+  - Rob Herring <[email protected]>
+
+select: true
+
+properties:
+  sound-dai:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    description: A phandle plus args to digital audio interface provider(s)
+
+additionalProperties: true
+...
author maintainer
#3 lore raw
Quoted 51 lines · Jerome Brunet
Quoted 39 lines · Rob Herring

'sound-dai' is a common property, but has duplicate type definitions. Create a new common definition to define the type and then update all the other occurrences to just define how many entries there are just like other phandle+arg properties.

The constraints on the number of entries is based on the examples and could be wrong.

Cc Krzysztof Kozlowski <[email protected]>

---
Please ack, this depends on commit abf0fee97313 ("dt-bindings: Improve phandle-array schemas") in my tree.

---
 .../bindings/sound/amlogic,gx-sound-card.yaml |  4 ++--
 .../bindings/sound/google,sc7180-trogdor.yaml |  6 ++++--
 .../bindings/sound/imx-audio-card.yaml        |  7 +++++--
 .../bindings/sound/qcom,sm8250.yaml           | 10 +++++++---
 .../bindings/sound/samsung,aries-wm8994.yaml  |  5 +----
 .../bindings/sound/samsung,midas-audio.yaml   |  2 --
 .../bindings/sound/samsung,odroid.yaml        |  9 +++------
 .../devicetree/bindings/sound/sound-dai.yaml  | 20 +++++++++++++++++++
 8 files changed, 42 insertions(+), 21 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/sound-dai.yaml
Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml +1 -1
index 2e35aeaa8781..8b5be4b92f35 100644
@@ -57,7 +57,7 @@ patternProperties:
           rate
 
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
+        maxItems: 1
         description: phandle of the CPU DAI
 
     patternProperties:

Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml patternProperties: · line 74

Quoted 5 lines
Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml +1 -1
@@ -71,7 +71,7 @@ patternProperties:
 
         properties:
           sound-dai:
-            $ref: /schemas/types.yaml#/definitions/phandle-array
+            maxItems: 1

No min or max here. Links may have more than one codec.

Quoted 2 lines

Ex:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts#n158

What do you mean? Every 'sound-dai' there only has 1 phande+args. Each codec is a child node.

Rob

maintainer Acked-by
#4 lore raw
Quoted 52 lines · Rob Herring
Quoted 51 lines · Jerome Brunet
Quoted 39 lines · Rob Herring

'sound-dai' is a common property, but has duplicate type definitions. Create a new common definition to define the type and then update all the other occurrences to just define how many entries there are just like other phandle+arg properties.

The constraints on the number of entries is based on the examples and could be wrong.

Cc Krzysztof Kozlowski <[email protected]>

---
Please ack, this depends on commit abf0fee97313 ("dt-bindings: Improve phandle-array schemas") in my tree.

---
 .../bindings/sound/amlogic,gx-sound-card.yaml |  4 ++--
 .../bindings/sound/google,sc7180-trogdor.yaml |  6 ++++--
 .../bindings/sound/imx-audio-card.yaml        |  7 +++++--
 .../bindings/sound/qcom,sm8250.yaml           | 10 +++++++---
 .../bindings/sound/samsung,aries-wm8994.yaml  |  5 +----
 .../bindings/sound/samsung,midas-audio.yaml   |  2 --
 .../bindings/sound/samsung,odroid.yaml        |  9 +++------
 .../devicetree/bindings/sound/sound-dai.yaml  | 20 +++++++++++++++++++
 8 files changed, 42 insertions(+), 21 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/sound-dai.yaml
Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml +1 -1
index 2e35aeaa8781..8b5be4b92f35 100644
@@ -57,7 +57,7 @@ patternProperties:
           rate
 
       sound-dai:
-        $ref: /schemas/types.yaml#/definitions/phandle-array
+        maxItems: 1
         description: phandle of the CPU DAI
 
     patternProperties:

Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml patternProperties: · line 74

Quoted 5 lines
Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml +1 -1
@@ -71,7 +71,7 @@ patternProperties:
 
         properties:
           sound-dai:
-            $ref: /schemas/types.yaml#/definitions/phandle-array
+            maxItems: 1

No min or max here. Links may have more than one codec.

Quoted 5 lines
Quoted 2 lines

Ex:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts#n158

What do you mean? Every 'sound-dai' there only has 1 phande+args. Each codec is a child node.

Yes it is a child - sorry I misunderstood.
I thought the MaxItems: 1 would limit the number of codecs

For the amlogic part:

Quoted 2 lines

Rob

maintainer Acked-by on v1 1/1
#5 lore raw
In reply to Rob Herring
Quoted 4 lines · Rob Herring

'sound-dai' is a common property, but has duplicate type definitions. Create a new common definition to define the type and then update all the other occurrences to just define how many entries there are just like other phandle+arg properties.