1# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/sound/renesas,rsnd.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: Renesas R-Car Sound Driver Device Tree Bindings
8
9maintainers:
10  - Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
11
12properties:
13
14  compatible:
15    oneOf:
16      # for Gen1 SoC
17      - items:
18          - enum:
19              - renesas,rcar_sound-r8a7778   # R-Car M1A
20              - renesas,rcar_sound-r8a7779   # R-Car H1
21          - enum:
22              - renesas,rcar_sound-gen1
23      # for Gen2 SoC
24      - items:
25          - enum:
26              - renesas,rcar_sound-r8a7742   # RZ/G1H
27              - renesas,rcar_sound-r8a7743   # RZ/G1M
28              - renesas,rcar_sound-r8a7744   # RZ/G1N
29              - renesas,rcar_sound-r8a7745   # RZ/G1E
30              - renesas,rcar_sound-r8a77470  # RZ/G1C
31              - renesas,rcar_sound-r8a7790   # R-Car H2
32              - renesas,rcar_sound-r8a7791   # R-Car M2-W
33              - renesas,rcar_sound-r8a7793   # R-Car M2-N
34              - renesas,rcar_sound-r8a7794   # R-Car E2
35          - enum:
36              - renesas,rcar_sound-gen2
37      # for Gen3 SoC
38      - items:
39          - enum:
40              - renesas,rcar_sound-r8a774a1  # RZ/G2M
41              - renesas,rcar_sound-r8a774b1  # RZ/G2N
42              - renesas,rcar_sound-r8a774c0  # RZ/G2E
43              - renesas,rcar_sound-r8a774e1  # RZ/G2H
44              - renesas,rcar_sound-r8a7795   # R-Car H3
45              - renesas,rcar_sound-r8a7796   # R-Car M3-W
46              - renesas,rcar_sound-r8a77961  # R-Car M3-W+
47              - renesas,rcar_sound-r8a77965  # R-Car M3-N
48              - renesas,rcar_sound-r8a77990  # R-Car E3
49              - renesas,rcar_sound-r8a77995  # R-Car D3
50          - enum:
51              - renesas,rcar_sound-gen3
52      # for Generic
53      - items:
54          - enum:
55              - renesas,rcar_sound-gen1
56              - renesas,rcar_sound-gen2
57              - renesas,rcar_sound-gen3
58
59  reg:
60    minItems: 1
61    maxItems: 5
62
63  reg-names:
64    minItems: 1
65    maxItems: 5
66
67  "#sound-dai-cells":
68    description: |
69      it must be 0 if your system is using single DAI
70      it must be 1 if your system is using multi  DAIs
71    enum: [0, 1]
72
73  "#clock-cells":
74    description: |
75      it must be 0 if your system has audio_clkout
76      it must be 1 if your system has audio_clkout0/1/2/3
77    enum: [0, 1]
78
79  clock-frequency:
80    description: for audio_clkout0/1/2/3
81
82  clkout-lr-asynchronous:
83    description: audio_clkoutn is asynchronizes with lr-clock.
84    $ref: /schemas/types.yaml#/definitions/flag
85
86  power-domains: true
87
88  resets:
89    minItems: 1
90    maxItems: 11
91
92  reset-names:
93    minItems: 1
94    maxItems: 11
95
96  clocks:
97    description: References to SSI/SRC/MIX/CTU/DVC/AUDIO_CLK clocks.
98    minItems: 1
99    maxItems: 31
100
101  clock-names:
102    description: List of necessary clock names.
103    minItems: 1
104    maxItems: 31
105    items:
106      oneOf:
107        - const: ssi-all
108        - pattern: '^ssi\.[0-9]$'
109        - pattern: '^src\.[0-9]$'
110        - pattern: '^mix\.[0-1]$'
111        - pattern: '^ctu\.[0-1]$'
112        - pattern: '^dvc\.[0-1]$'
113        - pattern: '^clk_(a|b|c|i)$'
114
115  ports:
116    $ref: /schemas/graph.yaml#/properties/ports
117    patternProperties:
118      port(@[0-9a-f]+)?:
119        $ref: audio-graph-port.yaml#
120        unevaluatedProperties: false
121
122  port:
123    $ref: audio-graph-port.yaml#
124    unevaluatedProperties: false
125
126# use patternProperties to avoid naming "xxx,yyy" issue
127patternProperties:
128  "^rcar_sound,dvc$":
129    description: DVC subnode.
130    type: object
131    patternProperties:
132      "^dvc-[0-1]$":
133        type: object
134        properties:
135          dmas:
136            maxItems: 1
137          dma-names:
138            const: "tx"
139        required:
140          - dmas
141          - dma-names
142    additionalProperties: false
143
144  "^rcar_sound,mix$":
145    description: MIX subnode.
146    type: object
147    patternProperties:
148      "^mix-[0-1]$":
149        type: object
150        # no properties
151    additionalProperties: false
152
153  "^rcar_sound,ctu$":
154    description: CTU subnode.
155    type: object
156    patternProperties:
157      "^ctu-[0-7]$":
158        type: object
159        # no properties
160    additionalProperties: false
161
162  "^rcar_sound,src$":
163    description: SRC subnode.
164    type: object
165    patternProperties:
166      "^src-[0-9]$":
167        type: object
168        properties:
169          interrupts:
170            maxItems: 1
171          dmas:
172            maxItems: 2
173          dma-names:
174            allOf:
175              - items:
176                  enum:
177                    - tx
178                    - rx
179        required:
180          - interrupts
181          - dmas
182          - dma-names
183    additionalProperties: false
184
185  "^rcar_sound,ssiu$":
186    description: SSIU subnode.
187    type: object
188    patternProperties:
189      "^ssiu-[0-9]+$":
190        type: object
191        properties:
192          dmas:
193            maxItems: 2
194          dma-names:
195            allOf:
196              - items:
197                  enum:
198                    - tx
199                    - rx
200        required:
201          - dmas
202          - dma-names
203    additionalProperties: false
204
205  "^rcar_sound,ssi$":
206    description: SSI subnode.
207    type: object
208    patternProperties:
209      "^ssi-[0-9]$":
210        type: object
211        properties:
212          interrupts:
213            maxItems: 1
214          dmas:
215            minItems: 2
216            maxItems: 4
217          dma-names:
218            allOf:
219              - items:
220                  enum:
221                    - tx
222                    - rx
223                    - txu # if no ssiu node
224                    - rxu # if no ssiu node
225
226          shared-pin:
227            description: shared clock pin
228            $ref: /schemas/types.yaml#/definitions/flag
229          pio-transfer:
230            description: PIO transfer mode
231            $ref: /schemas/types.yaml#/definitions/flag
232          no-busif:
233            description: BUSIF is not used when [mem -> SSI] via DMA case
234            $ref: /schemas/types.yaml#/definitions/flag
235        required:
236          - interrupts
237          - dmas
238          - dma-names
239    additionalProperties: false
240
241  # For DAI base
242  "^rcar_sound,dai$":
243    description: DAI subnode.
244    type: object
245    patternProperties:
246      "^dai([0-9]+)?$":
247        type: object
248        properties:
249          playback:
250            $ref: /schemas/types.yaml#/definitions/phandle-array
251          capture:
252            $ref: /schemas/types.yaml#/definitions/phandle-array
253        anyOf:
254          - required:
255              - playback
256          - required:
257              - capture
258    additionalProperties: false
259
260required:
261  - compatible
262  - reg
263  - reg-names
264  - clocks
265  - clock-names
266  - "#sound-dai-cells"
267
268allOf:
269  - if:
270      properties:
271        compatible:
272          contains:
273            const: renesas,rcar_sound-gen1
274    then:
275      properties:
276        reg:
277          maxItems: 3
278        reg-names:
279          maxItems: 3
280          items:
281            enum:
282              - scu
283              - ssi
284              - adg
285    else:
286      properties:
287        reg:
288          maxItems: 5
289        reg-names:
290          maxItems: 5
291          items:
292            enum:
293              - scu
294              - adg
295              - ssiu
296              - ssi
297              - audmapp
298
299additionalProperties: false
300
301examples:
302  - |
303    rcar_sound: sound@ec500000 {
304        #sound-dai-cells = <1>;
305        compatible = "renesas,rcar_sound-r8a7790", "renesas,rcar_sound-gen2";
306        reg = <0xec500000 0x1000>, /* SCU  */
307              <0xec5a0000 0x100>,  /* ADG  */
308              <0xec540000 0x1000>, /* SSIU */
309              <0xec541000 0x1280>, /* SSI  */
310              <0xec740000 0x200>;  /* Audio DMAC peri peri*/
311        reg-names = "scu", "adg", "ssiu", "ssi", "audmapp";
312
313        clocks = <&mstp10_clks 1005>,                      /* SSI-ALL    */
314                 <&mstp10_clks 1006>, <&mstp10_clks 1007>, /* SSI9, SSI8 */
315                 <&mstp10_clks 1008>, <&mstp10_clks 1009>, /* SSI7, SSI6 */
316                 <&mstp10_clks 1010>, <&mstp10_clks 1011>, /* SSI5, SSI4 */
317                 <&mstp10_clks 1012>, <&mstp10_clks 1013>, /* SSI3, SSI2 */
318                 <&mstp10_clks 1014>, <&mstp10_clks 1015>, /* SSI1, SSI0 */
319                 <&mstp10_clks 1022>, <&mstp10_clks 1023>, /* SRC9, SRC8 */
320                 <&mstp10_clks 1024>, <&mstp10_clks 1025>, /* SRC7, SRC6 */
321                 <&mstp10_clks 1026>, <&mstp10_clks 1027>, /* SRC5, SRC4 */
322                 <&mstp10_clks 1028>, <&mstp10_clks 1029>, /* SRC3, SRC2 */
323                 <&mstp10_clks 1030>, <&mstp10_clks 1031>, /* SRC1, SRC0 */
324                 <&mstp10_clks 1020>, <&mstp10_clks 1021>, /* MIX1, MIX0 */
325                 <&mstp10_clks 1020>, <&mstp10_clks 1021>, /* CTU1, CTU0 */
326                 <&mstp10_clks 1019>, <&mstp10_clks 1018>, /* DVC0, DVC1 */
327                 <&audio_clk_a>, <&audio_clk_b>,           /* CLKA, CLKB */
328                 <&audio_clk_c>, <&audio_clk_i>;           /* CLKC, CLKI */
329
330        clock-names = "ssi-all",
331                      "ssi.9", "ssi.8",
332                      "ssi.7", "ssi.6",
333                      "ssi.5", "ssi.4",
334                      "ssi.3", "ssi.2",
335                      "ssi.1", "ssi.0",
336                      "src.9", "src.8",
337                      "src.7", "src.6",
338                      "src.5", "src.4",
339                      "src.3", "src.2",
340                      "src.1", "src.0",
341                      "mix.1", "mix.0",
342                      "ctu.1", "ctu.0",
343                      "dvc.0", "dvc.1",
344                      "clk_a", "clk_b",
345                      "clk_c", "clk_i";
346
347        rcar_sound,dvc {
348               dvc0: dvc-0 {
349                    dmas = <&audma0 0xbc>;
350                    dma-names = "tx";
351               };
352               dvc1: dvc-1 {
353                    dmas = <&audma0 0xbe>;
354                    dma-names = "tx";
355               };
356        };
357
358        rcar_sound,mix {
359            mix0: mix-0 { };
360            mix1: mix-1 { };
361        };
362
363        rcar_sound,ctu {
364            ctu00: ctu-0 { };
365            ctu01: ctu-1 { };
366            ctu02: ctu-2 { };
367            ctu03: ctu-3 { };
368            ctu10: ctu-4 { };
369            ctu11: ctu-5 { };
370            ctu12: ctu-6 { };
371            ctu13: ctu-7 { };
372        };
373
374        rcar_sound,src {
375            src0: src-0 {
376                status = "disabled";
377            };
378            src1: src-1 {
379                interrupts = <0 353 0>;
380                dmas = <&audma0 0x87>, <&audma1 0x9c>;
381                dma-names = "rx", "tx";
382            };
383            /* skip after src-2 */
384        };
385
386        rcar_sound,ssiu {
387            ssiu00: ssiu-0 {
388                dmas = <&audma0 0x15>, <&audma1 0x16>;
389                dma-names = "rx", "tx";
390            };
391            ssiu01: ssiu-1 {
392                dmas = <&audma0 0x35>, <&audma1 0x36>;
393                dma-names = "rx", "tx";
394            };
395            /* skip after ssiu-2 */
396        };
397
398        rcar_sound,ssi {
399            ssi0: ssi-0 {
400                interrupts = <0 370 1>;
401                dmas = <&audma0 0x01>, <&audma1 0x02>;
402                dma-names = "rx", "tx";
403            };
404            ssi1: ssi-1 {
405                interrupts = <0 371 1>;
406                dmas = <&audma0 0x03>, <&audma1 0x04>;
407                dma-names = "rx", "tx";
408            };
409            /* skip other ssi-2 */
410        };
411
412        /* DAI base */
413        rcar_sound,dai {
414            dai0 {
415                playback = <&ssi5>, <&src5>;
416                capture  = <&ssi6>;
417            };
418            dai1 {
419                playback = <&ssi3>;
420            };
421            dai2 {
422                capture  = <&ssi4>;
423            };
424            dai3 {
425                playback = <&ssi7>;
426            };
427            dai4 {
428                capture  = <&ssi8>;
429            };
430        };
431
432        /* assume audio-graph */
433        port {
434            rsnd_endpoint: endpoint {
435                remote-endpoint = <&codec_endpoint>;
436
437                dai-format = "left_j";
438                bitclock-master = <&rsnd_endpoint0>;
439                frame-master = <&rsnd_endpoint0>;
440
441                playback = <&ssi0>, <&src0>, <&dvc0>;
442                capture  = <&ssi1>, <&src1>, <&dvc1>;
443            };
444        };
445    };
446
447
448    /* assume audio-graph */
449    codec {
450        port {
451            codec_endpoint: endpoint {
452                remote-endpoint = <&rsnd_endpoint>;
453            };
454        };
455    };
456